AgentConnect is an open-source SDK implementation of the Agent Network Protocol (ANP).
The goal of Agent Network Protocol (ANP) is to become the HTTP of the Intelligent Agent Internet Era, building an open, secure, and efficient collaborative network for billions of intelligent agents.
Agent identity authentication system based on DID-WBA (Decentralized Identifier - Web-Based Authentication):
- Identity Management: Create and manage agent DID documents
- Identity Verification: Provide end-to-end identity authentication and authorization
- Secure Communication: Ensure security and trustworthiness of inter-agent communication
Discovery and interaction tools for the agent network:
- Agent Discovery: Automatically discover and parse agent description documents
- Interface Parsing: Parse JSON-RPC interfaces and convert them to callable tools
- Protocol Interaction: Support communication with agents that comply with ANP protocol
- Direct JSON-RPC: Execute JSON-RPC requests directly without interface discovery
Plugin-based framework for building ANP agents with FastAPI:
- Plugin Architecture: FastAPI as main framework, FastANP as helper plugin
- Automatic OpenRPC: Generate OpenRPC documents from Python functions
- Context Injection: Automatic session and Request object injection
- DID WBA Authentication: Built-in authentication middleware with wildcard path exemption
- Flexible Routing: Full control over all routes including ad.json
- Session Management: Built-in session management based on DID
For complete documentation, see FastANP README
Secure payment authorization protocol for agent transactions:
- CartMandate: Shopping cart authorization with merchant signature
- PaymentMandate: Payment authorization with user signature
- ES256K Signing: Support for ECDSA secp256k1 signatures
- Hash Integrity: Cart and payment data integrity verification
- DID WBA Integration: Seamless integration with DID-based authentication
Specification Document: AP2 Protocol Specification
pip install agent-connect# 下载源码
git clone https://github.com/agent-network-protocol/AgentConnect.git
cd AgentConnect
# 使用UV配置环境
uv sync
# 运行示例
uv run python examples/python/did_wba_examples/create_did_document.pyLocation: examples/python/did_wba_examples/
-
Create DID Document (
create_did_document.py)
Demonstrate how to generate DID documents and key pairs for agents -
Authenticate and Verify (
authenticate_and_verify.py)
Demonstrate the complete DID-WBA authentication and verification process
# Create DID Document
uv run python examples/python/did_wba_examples/create_did_document.py
# Authentication Demonstration
uv run python examples/python/did_wba_examples/authenticate_and_verify.pyDetailed Documentation: DID-WBA Example
Location: examples/python/anp_crawler_examples/
-
Simple Example (
simple_amap_example.py)
Quick Start: Connect to AMAP service and call the map search interface -
Complete Example (
amap_crawler_example.py)
Complete Demonstration: Agent discovery, interface parsing, and tool calling
# Quick Experience
uv run python examples/python/anp_crawler_examples/simple_amap_example.py
# Complete Function Demonstration
uv run python examples/python/anp_crawler_examples/amap_crawler_example.pyDetailed Documentation: ANP Crawler Example
Location: examples/python/fastanp_examples/
-
Simple Agent (
simple_agent.py) Minimal FastANP setup with single interface method -
Hotel Booking Agent (
hotel_booking_agent.py) Complete example with multiple interfaces, Pydantic models, and session management
# Simple Agent
uv run python examples/python/fastanp_examples/simple_agent.py
# Hotel Booking Agent
uv run python examples/python/fastanp_examples/hotel_booking_agent.py# Test with Python client
uv run python examples/python/fastanp_examples/test_hotel_booking_client.py
# Or test manually with curl
# Get Agent Description
curl http://localhost:8000/ad.json | jq
# Call JSON-RPC method
curl -X POST http://localhost:8000/rpc \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "id": 1, "method": "search_rooms", "params": {"query": {"check_in_date": "2025-01-01", "check_out_date": "2025-01-05", "guest_count": 2, "room_type": "deluxe"}}}'Detailed Documentation: FastANP Examples
Location: examples/python/ap2_examples/
- Complete Flow (
ap2_complete_flow.py) Full demonstration of AP2 payment protocol including merchant and shopper agents
- Merchant Agent: Handles cart creation and payment verification
- Shopper Agent: Creates shopping cart and authorizes payment
- Mandate Verification: Both CartMandate and PaymentMandate verification
- Local IP Communication: Two agents communicate over local network
- ES256K Signatures: Uses ECDSA secp256k1 for all mandate signatures
# Run complete AP2 flow
uv run python examples/python/ap2_examples/ap2_complete_flow.py- Merchant agent starts on local IP
- Shopper sends
create_cart_mandaterequest - Merchant verifies DID WBA auth, creates and signs CartMandate
- Shopper verifies CartMandate signature
- Shopper creates and signs PaymentMandate
- Shopper sends PaymentMandate to merchant
- Merchant verifies PaymentMandate and confirms payment
For detailed protocol specification, see AP2 Protocol Documentation
Use the web interface to explore the agent network using natural language: ANP Network Explorer Tool
Command line tool to quickly generate DID documents:
uv run python tools/did_generater/generate_did_doc.py <did> [--agent-description-url URL]- Author:GaoWei Chang
- Email:chgaowei@gmail.com
- Website:https://agent-network-protocol.com/
- Discord:https://discord.gg/sFjBKTY7sB
- GitHub:https://github.com/agent-network-protocol/AgentNetworkProtocol
- WeChat:flow10240
This project is open-sourced under the MIT License. Detailed information please refer to LICENSE file.
Copyright (c) 2024 GaoWei Chang
