A modular Python client for connecting to MCP servers, integrating with Anthropic Claude, and exposing a FastAPI-based API for handling queries and tool calls.
-
MCP Client: Connects to an MCP server (Node or Python) over stdio, negotiates available tools and manages tool calls.
-
Claude AI Integration: Uses Anthropic Claude to generate natural language responses and decide when to invoke tools.
-
Tool Invocation: Handles multi-turn reasoning between Claude and external tools, returning structured responses (markdown, code, chart data).
-
FastAPI Server: Provides HTTP API endpoints for frontend integration.
-
.env support: Loads Anthropic API keys and other environment variables from a .env file.
-
CORS Support: Allows flexible frontend/backend development.
-
Python 3.10+
-
An MCP server — e.g., mcp-node or compatible Python or Node MCP server.
-
An Anthropic API Key (for Claude).
git clone https://github.com/Kiran1689/mcp-proxy-server
cd mcp-proxy-server
It's recommended to use a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv sync
Create a .env
file in the project root:
ANTHROPIC_API_KEY=your-anthropic-api-key-here
Follow your MCP server's instructions (e.g., NodeJS or Python). Example for Node:
cd /path/to/mcp-node
npm install
npm run start
uvicorn client_server:app --reload
By default, this will:
-
Connect to your MCP server
-
Expose endpoints at http://localhost:8000
API Endpoints
-
POST /query
— Send a user query, receives structured response from Claude (may invoke tools). -
GET /tools
— Lists available server tools. -
GET /server-name
— Returns server name identifier.
You can run the interactive CLI for experimenting directly:
python client.py
-
client.py
— Implements MCPClient: connects to the MCP server, interfaces with Claude, manages conversation state, processes tool calls, and structures responses. -
client_server.py
— Launches a FastAPI server, provides API endpoints, manages single MCPClient instance. -
pyproject.toml
— Python packaging and dependencies.
-
You can update the system prompt for Claude in
client.py
to control formatting, chart standards, or code output. -
Tool schemas are detected live from your MCP server.
-
Extend or replace tool invocation logic as needed.
-
Check
.env
is present and contains your Anthropic key. -
Ensure server path/config in
client.py
matches your MCP server. -
View server/console logs for debugging info on tool calls and Claude's responses.
MIT
Feel free to submit pull requests or questions.
Built with 💙 by Kiran