- MCP Client
created by
alessandrodorazio5 days ago
A sample code to use Model Context Protocol with Claude APIs
Information
MCP Client
This is a Model Context Protocol (MCP) client that allows you to interact with MCP servers, enabling Claude to use tools provided by these servers.
Prerequisites
- Python 3.11 or higher
- An Anthropic API key (set in
.env
file)
Setup
-
Clone this repository
-
Ensure you have the required dependencies installed:
pip install anthropic mcp python-dotenv
Or use uv:
uv pip install anthropic mcp python-dotenv
-
Set up your Anthropic API key in a
.env
file:ANTHROPIC_API_KEY=your_api_key_here
Usage
Run the client by providing the path to an MCP server script:
python client.py path/to/server_script.py
The client supports both Python and JavaScript MCP servers:
python client.py path/to/server_script.js
How It Works
- The client connects to the specified MCP server
- It retrieves available tools from the server
- When you enter a query, it's sent to Claude along with tool descriptions
- Claude decides which tools to use
- The client executes tool calls through the server
- Results are sent back to Claude for a final response
Features
- Interactive command-line interface
- Support for both Python and Node.js MCP servers
- Proper resource management and error handling
- Seamless integration with Claude's tool-use capabilities
Troubleshooting
- If you encounter connection issues, verify the server path and ensure the server is running
- The first response might take up to 30 seconds due to initialization
- For more detailed logs, check the server output
Resources
Recommended Clients
MCP_LLM使用大模型结合mcp协议
Python MCP Client
MCP CLI ClientEen lokale MCP host en client die met meerdere LLM's en meerdere MCP servers kan werken.
Cursor Apple Notes IndexerAn MCP app for Cursor that searches and indexes Apple Notes locally
健康管理系统
MCP ClientA very simple MCP demo, based off of Anthropics MCP examples, with the added bonus of an agency loop
Mcp_agent_streamlit_rag
Flask Webapplicatie met LLM-integratie en MCP-toolsFlask webapplicatie met LLM-integratie en MCP-tools voor het verwerken van prompts via verschillende AI-modellen en contextuele tools.
Mattermost MCP Client
research