MCP ExplorerExplorer

Mcpproject

@Cuiikon 10 months ago
3 MIT
FreeCommunity
AI Systems
# MCP Tool in Progress

Overview

What is Mcpproject

McpProject is a modular and extensible MCP (Model Control Protocol) client implementation designed to connect to large model APIs and multiple tool servers.

Use cases

Use cases include connecting to weather APIs, managing AI model interactions, and developing custom MCP services in different programming languages like Python, Java, and C.

How to use

To use McpProject, clone the repository, set up a virtual environment, install dependencies, configure the necessary environment variables in a .env file, and run the main application either via command line or an IDE like PyCharm.

Key features

Key features include support for connecting to multiple MCP servers, a modular design for easy extension, a unified tool calling interface, improved error handling and logging, and support for streaming output and inference process display.

Where to use

McpProject can be used in various fields such as AI model management, data processing, and integration of multiple APIs for enhanced functionality.

Content

结构说明:

  1. 配置管理 (config.py)

    • 负责从环境变量加载和验证配置
  2. MCP服务器类型连接器 (server_connector.py)

    • 负责连接和管理多个 MCP 服务器
    • 支持连接本地脚本和 NPX 包
  3. 模型客户端 (model_client.py)

    • 负责与大模型 API 交互
    • 处理流式响应、工具调用和结果处理
  4. 存放本地MCP服务(py) (mcpserver)

    • 存放本地python的mcp服务,可自行扩展开发
  5. MCP配置信息加载器 (mcp_config_loader.py)

    • 解析mcp_servers.json文件的配置信息
  6. MCP配置文件 (mcp_servers.json)

    • 功能和Cursor的MCP文件一致的配置文件
  7. 主应用 (main.py)

    • 整合上述所有模块
    • 提供命令行界面和交互式聊天

使用方法

环境配置:

  1. 拉取项目后 进到根目录下
# 创建虚拟环境
uv venv

# 激活虚拟环境
.venv/bin/activate

# 安装依赖
uv pip install -r requirements.txt
uv add dotenv 
  1. 根目录下复制 .env example 改名为.env 文件并设置必要的环境变量:
# 阿里百练的apikey
DASHSCOPE_API_KEY=your_dashscope_api_key 

# 阿里百练的地址
BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1

# 选择模型
MODEL=xxxx

添加MCP

基于JSON文件统一管理

复制 mcp_servers.json example 改名为mcp_servers.json 文件

  1. 新增的MCP服务如果是自己写的py,则参考weather_server.py,

  2. 如果是其他远程MCP则复制对应MCP的JSON,添加进mcp_servers.json(和cursor的配置一致)

{
  "mcpServers": {
    "YourMcpName": {
      "disabled": false,
      "command": "xxx",
      "args": [
        "xxx"
      ],
      "env": {}
    }
  }
}

运行 (1或者2都可以)

1、命令行

激活虚拟环境后

python src/main.py

2、PyCharm
也可PyCharm运行

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers