This directory contains examples using ANPCrawler to access AMAP agent services.
amap_crawler_example.py- Complete example showcasing all ANPCrawler featuressimple_amap_example.py- Simplified example for quick startREADME.md- This documentation file
# Option 1: Install via pip
pip install anp
# Option 2: Source installation (recommended for developers)
git clone https://github.com/agent-network-protocol/AgentConnect.git
cd AgentConnect
uv syncEnsure the following files exist:
docs/did_public/public-did-doc.jsondocs/did_public/public-private-key.pem
uv run python examples/python/anp_crawler_examples/simple_amap_example.pyuv run python examples/python/anp_crawler_examples/amap_crawler_example.py# Access URL and retrieve ad.json content
content_json, interfaces_list = await crawler.fetch_text(
"https://agent-connect.ai/agents/travel/mcp/agents/amap/ad.json"
)# Automatically parse interfaces and convert to OpenAI tool format
tools = crawler.list_available_tools()# Call discovered tools/methods
result = await crawler.execute_tool_call(tool_name, arguments)After running examples, you will see:
- Agent Description Document Content - Complete ad.json content
- Discovered Interfaces - JSON-RPC interfaces extracted from agent description
- Available Tool List - Names of callable tools
- Tool Call Results - Actual JSON-RPC call return results
FileNotFoundError: DID document file not found
Solution: Ensure the following files exist:
docs/did_public/public-did-doc.jsondocs/did_public/public-private-key.pem
Ensure your network can access the agent-connect.ai domain.
Check if DID document and private key files are correctly generated and matched.
# 1. Initialize crawler
crawler = ANPCrawler(
did_document_path="path/to/did.json",
private_key_path="path/to/private-key.pem"
)
# 2. Fetch agent description
content, interfaces = await crawler.fetch_text(url)
# 3. List tools
tools = crawler.list_available_tools()
# 4. Call tools
result = await crawler.execute_tool_call(tool_name, arguments)