| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A simple agent that connects Agent-to-Agent (A2A) protocol and Model Context Protocol (MCP) with ease, providing an intuitive and easy-to-use interface. Built with Google ADK (Agent Development Kit).
This agent serves as a bridge between A2A and MCP protocols:
User/Agent <--> A2A Protocol <--> A2A-MCP Connector <--> MCP Protocol <--> MCP Tools
The connector implements the Model Context Protocol (MCP) using JSON-RPC 2.0 for communicating with MCP tools.
All communication with MCP tools follows the JSON-RPC 2.0 specification:
Requests: All requests to MCP tools are properly formatted JSON-RPC 2.0 requests
{
"jsonrpc": "2.0",
"id": "unique-request-id",
"method": "execute",
"params": {
"text": "Your input text",
"additional_parameter": "value"
}
}Responses: All responses from MCP tools must follow JSON-RPC 2.0 format
{
"jsonrpc": "2.0",
"id": "unique-request-id",
"result": {
"answer": "Tool response",
"metadata": {
"tool_name": "example-tool",
"version": "1.0.0"
}
}
}Error Handling: JSON-RPC errors are properly handled
{
"jsonrpc": "2.0",
"id": "unique-request-id",
"error": {
"code": -32601,
"message": "Method not found",
"data": {
"details": "Additional error information"
}
}
}Navigate to the agent directory:
cd samples/python/agents/a2a_mcp_connectorCreate an environment file with your API key:
Option A: Google AI Studio API Key
echo "GOOGLE_API_KEY=your_api_key_here" > .envOption B: Google Cloud Vertex AI
echo "GOOGLE_GENAI_USE_VERTEXAI=TRUE" > .env
echo "GOOGLE_CLOUD_PROJECT=your_project_id" >> .env
echo "GOOGLE_CLOUD_LOCATION=your_location" >> .envNote: Ensure you've authenticated with gcloud using gcloud auth login first.
(Optional) Specify a custom path for the tool registry:
echo "MCP_REGISTRY_PATH=/path/to/my_registry.json" >> .envRun the agent:
# Basic run on default port 10004
uv run .
# On custom host/port
uv run . --host 0.0.0.0 --port 8080
# To suppress hardlink warnings
uv run . --link-mode=copyNote: If you see warnings about hardlinks, you can suppress them by using the --link-mode=copy flag or by setting the environment variable: $env:UV_LINK_MODE="copy" (Windows) or export UV_LINK_MODE=copy (Linux/macOS).
After starting the agent:
In a new terminal, start an A2A client to interact with the agent:
Option A: Command Line
cd samples/python/hosts/cli
uv run . --agent http://localhost:10004Option B: Demo Web UI
cd demo/ui
echo "GOOGLE_API_KEY=your_api_key_here" > .env
uv run main.pyThen navigate to the web UI (typically http://localhost:12000):
If you encounter any of these issues, here are solutions:
This is expected when accessing the agent via a browser with a GET request. The agent now shows a helpful landing page instead of an error.
The agent includes proper package structure for ADK compatibility:
These are just informational messages and won't affect functionality. Use --link-mode=copy to suppress them.
If you're experiencing issues with MCP tool communication:
If you encounter CORS or network errors:
You can use the included test scripts to verify your MCP tool's JSON-RPC implementation:
python test_jsonrpc.py http://your-mcp-tool-url.com --text "Test query"For more complex parameters:
python test_jsonrpc.py http://your-mcp-tool-url.com --params '{"query": "test", "options": {"limit": 5}}'python validate_mcp_jsonrpc.py http://your-mcp-tool-url.comThis script runs a series of tests to verify that your MCP tool correctly implements the JSON-RPC 2.0 protocol, including:
For development and testing, you can use the included mock MCP server:
# Start the mock server
python mock_mcp_server.py --port 8500
# In another terminal, test it
python test_jsonrpc.py http://localhost:8500 --text "Hello, world!"
# Register it with the A2A-MCP connector
# (after starting the A2A-MCP connector)A simplified end-to-end test script is provided for testing the full flow:
python test_e2e.pyThis script demonstrates:
Note: This is a simplified test that simulates some interactions.
Register a new MCP tool with ID "weather-tool" at URL "http://weather-api.example.com/mcp" for checking weather forecasts
List all registered MCP tools
Use the weather-tool to check the forecast for New York
Remove the weather-tool from the registry
To create an MCP-compatible tool that can be used with this connector, your service should:
The connector follows the JSON-RPC 2.0 specification:
Request Format:
{
"jsonrpc": "2.0",
"id": "request-123",
"method": "execute",
"params": {
"text": "User query or structured data"
// Or any other parameters your tool expects
}
}Successful Response Format:
{
"jsonrpc": "2.0",
"id": "request-123",
"result": {
"answer": "Tool response data",
"metadata": {
"tool_name": "example-tool",
"version": "1.0.0"
}
}
}Error Response Format:
{
"jsonrpc": "2.0",
"id": "request-123",
"error": {
"code": -32000,
"message": "Error description",
"data": {
"additional": "error details"
}
}
}The A2A-MCP connector uses the JSON-RPC 2.0 protocol for all MCP tool communication:
JSON-RPC Request Creation:
Response Handling:
Utilities:
Several testing tools are provided to help validate your MCP tools:
JSON-RPC Test Script (test_jsonrpc.py):
Mock MCP Server (mock_mcp_server.py):
End-to-End Test (test_e2e.py):
The A2A-MCP connector has been updated to fully support JSON-RPC 2.0 for MCP tool communication:
| Back | FazBrowse Home | New Git URL |