MCP协议客户端

一个简单的Python MCP客户端,用于管理SSE/HTTP连接、处理mcp-session-id会话并发送JSON-RPC请求。

  • by jasonnn-bc
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 jasonnn-bc/mcp-client

使用说明

mcp-client

A simple Python MCP client that uses the MCP protocol, manages SSE/HTTP connections, handles mcp-session-id sessions, and sends JSON-RPC requests.

🚀 Usage

To use the MCP client in your own projects:

  1. Copy the folder mcp_client into your project.
  2. Install the required packages listed in requirements.txt:
    pip install -r requirements.txt
    
  3. Initialize the MCPClient with the url of your remote MCP server :
     from mcp_client import MCPClient
     client = MCPClient(url="mon_serveur_mcp:8000/mcp")
     await client.connect()
    

🔧 Available Methods

  1. List available tools from the MCP server :
     tools = await client.list_tools()
    
  2. Call a remote tool :
     parameters = {"param_name": param_value}
     tools = await client.call_tool()
    
  3. 🛑 Closing the connection
     await client.close()
    

📌 Notes

  • This client is designed to be lightweight and easily embeddable in your Python projects.

  • It follows the MCP protocol for communication and tool invocation.