Skip to main content

MCP Client

Connect to AgentVisor's MCP (Model Context Protocol) transport from Claude Desktop, Cursor, or a custom Python client.

Difficulty: Intermediate

This is a client, not an agent — it demonstrates calling an already-running AgentVisor instance from outside the sandbox, exposing your registered agents as MCP tools. Pair it with any agent that has MCP transport enabled.

What This Demonstrates

  • Claude Desktop / Cursor integration: Configuring an MCP-compatible client to use AgentVisor agents as tools
  • Tool discovery: Listing available agents via tools/list
  • Tool invocation: Calling an agent via tools/call, with thread_id for conversation continuity
  • Streaming: Receiving incremental updates over SSE

Prerequisites

Start an agent with MCP transport enabled:

agentvisor template create langgraph/chatbot-agent
cd chatbot-agent
docker compose up -d
AGENTVISOR_API_MCP_ENABLED=true agentvisor serve .

Setup

In a separate directory:

agentvisor template create clients/mcp-client
cd mcp-client

Claude Desktop

  1. Locate your Claude Desktop config file:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. Copy the provided config, or merge its mcpServers entry into your existing config:
    cp claude-desktop-config.json ~/Library/Application\ Support/Claude/claude_desktop_config.json
  3. Restart Claude Desktop. You should see agentvisor listed under MCP servers, with each registered agent available as a tool.

Python Client

cd python-client
pip install -r requirements.txt

List available tools (agents):

python client.py --list-tools

Send a message:

python client.py --agent chatbot --message "Hello, how are you?"

Interactive chat session:

python client.py --agent chatbot --interactive

Streaming:

python client.py --agent chatbot --message "Tell me a story" --streaming

Conversation continuity (same thread):

python client.py --agent chatbot --message "My name is Alice"
# Use the thread_id from the response for the follow-up
python client.py --agent chatbot --message "What's my name?" --thread-id <thread-id>

Against a different AgentVisor instance:

python client.py --url http://agentvisor:8090/mcp --list-tools

Files

mcp-client/
├── claude-desktop-config.json # Claude Desktop MCP server configuration
└── python-client/
├── client.py # Python MCP client
└── requirements.txt

See Also

  • MCP Transport Guide — enabling the transport and the full JSON-RPC method reference
  • MCP Gateway — the inverse pattern: your agent calling external MCP servers
  • A2A Client — the same idea over the A2A transport
  • Chatbot Agent — a simple agent to test against