MCP Test Pipeline Example¶
This Proof-of-Concept (POC) demonstrates how AgentVault can interact with tool servers compliant with the Model Context Protocol (MCP), enabling agents to execute external tools like filesystem operations or code execution securely.
Overview¶
The core idea is to use a specialized MCP Tool Proxy Agent. This A2A-compliant agent acts as a bridge:
- It receives standard A2A
tasks/send
requests from an orchestrator (like the MCP Test Orchestrator). - The request payload specifies which MCP tool server to target (e.g., 'filesystem', 'code-runner') and the tool method to call (e.g.,
filesystem.readFile
,code.runPython
) along with its arguments. - The Proxy Agent translates the A2A request into a JSON-RPC 2.0 request suitable for the target MCP server.
- It sends the JSON-RPC request to the MCP server's
/rpc
endpoint via HTTP POST. - It receives the JSON-RPC response from the MCP server.
- It translates the MCP response (including success/failure and results/errors) back into an A2A artifact or message for the orchestrator.
This allows LangGraph orchestrators (or any A2A client) to leverage MCP tools without needing direct MCP communication capabilities themselves.
Workflow Diagram¶
This diagram shows the interaction flow where the orchestrator uses the MCP Tool Proxy Agent to communicate with the custom Filesystem and Code Runner MCP servers.
(Diagram showing the orchestrator calling the MCP Tool Proxy, which in turn calls the Filesystem MCP Server and the Code Runner MCP Server via JSON-RPC/HTTP.)
Workflow Steps¶
- Orchestrator (
mcp_test_orchestrator
) -> MCP Tool Proxy Agent (local-poc/mcp-tool-proxy
)- Input: A2A Task with
DataPart
containing:target_mcp_server_id="filesystem"
,tool_name="filesystem.readFile"
,arguments={"path": "/data/test_script.py"}
.
- Input: A2A Task with
- MCP Tool Proxy Agent -> Filesystem MCP Server (
custom-filesystem-mcp
)- Input: HTTP POST to
/rpc
with JSON-RPC payload (method="filesystem.readFile"
).
- Input: HTTP POST to
- Filesystem MCP Server -> MCP Tool Proxy Agent
- Output: HTTP Response with JSON-RPC payload containing file content.
- MCP Tool Proxy Agent -> Orchestrator
- Output: A2A Task Completion with file content.
- Orchestrator (
mcp_test_orchestrator
) -> MCP Tool Proxy Agent (local-poc/mcp-tool-proxy
)- Input: A2A Task with
DataPart
containing:target_mcp_server_id="code"
,tool_name="code.runPython"
,arguments={"code": "..."}
(code read from file).
- Input: A2A Task with
- MCP Tool Proxy Agent -> Code Runner MCP Server (
custom-code-runner-mcp
)- Input: HTTP POST to
/rpc
with JSON-RPC payload (method="code.runPython"
).
- Input: HTTP POST to
- Code Runner MCP Server -> MCP Tool Proxy Agent
- Output: HTTP Response with JSON-RPC payload containing script stdout/stderr.
- MCP Tool Proxy Agent -> Orchestrator
- Output: A2A Task Completion with script output.
Components¶
poc_agents/mcp_test_pipeline/
: Root directory for this POC.custom-filesystem-mcp/
: A Python/FastAPI implementation of an MCP server providingfilesystem.*
tools. Uses a shared Docker volume (/data
). Exposes/rpc
.custom-code-runner-mcp/
: A Python/FastAPI implementation of an MCP server providingcode.runPython
. Exposes/rpc
.mcp-tool-proxy-agent/
: The A2A agent built with theagentvault-server-sdk
that acts as the bridge. It reads target server URLs from its.env
file (mapped by logical IDs like "filesystem", "code").mcp_test_orchestrator/
: A LangGraph-based orchestrator that defines the read-then-execute workflow.mcp_shared_data/
: Contains example files (liketest_script.py
) mounted into the shared Docker volume (/data
) accessible by the filesystem server.docker-compose.mcp-test.yml
: Docker Compose file specifically to run this pipeline, including the custom Python MCP servers and the proxy agent.
Setup¶
- Prerequisites: Docker, Docker Compose, Python 3.10+, Poetry. Ensure the
agentvault_network
Docker network exists (docker network create agentvault_network
). The AgentVault Registry should also be running. - Environment Variables:
- Review/create
.env
files withinmcp-tool-proxy-agent/
andmcp_test_orchestrator/
. - The
mcp-tool-proxy-agent/.env
must contain theMCP_SERVER_MAP
variable correctly mapping logical server IDs to their internal Docker service URLs: - The orchestrator's
.env
needsAGENTVAULT_REGISTRY_URL
.
- Review/create
- Build & Run Docker Compose:
- Navigate to the
poc_agents/mcp_test_pipeline/
directory. - Run:
docker-compose -f docker-compose.mcp-test.yml build
- Run:
docker-compose -f docker-compose.mcp-test.yml up -d
- Navigate to the
Running the POC¶
The orchestrator runs automatically on startup, processing /data/test_script.py
.
- Monitor Logs:
- Expected Log Flow:
- Orchestrator starts, discovers proxy agent.
start_mcp_test
node runs.read_code_file_via_proxy
node runs, calls proxy, which calls filesystem server.execute_python_code_via_proxy
node runs, calls proxy, which calls code runner server.- Pipeline finishes, logs show stdout/stderr from the executed script.
Example Run (GIF)¶
This animation displays the log output as the orchestrator interacts with the MCP Tool Proxy Agent, which then communicates with the custom Filesystem and Code Runner MCP servers via JSON-RPC.
(Animation showing logs from the orchestrator, proxy agent, filesystem server, and code runner server during the test script execution)
Key Features Demonstrated¶
- Model Context Protocol (MCP): Interaction with MCP-compliant tool servers via JSON-RPC over HTTP.
- A2A-MCP Bridging: Using a proxy agent (
mcp-tool-proxy-agent
) to allow A2A orchestrators to leverage MCP tools. - Tool Execution: Secure execution of external tools (filesystem access, code running) via dedicated servers.
- Custom MCP Servers: Python/FastAPI implementations of MCP servers providing specific functionalities.
- Docker Networking & Volumes: Enabling communication and shared file access between services.
- LangGraph Orchestration: Managing the state and workflow involving proxied tool calls.