MCP 学习项目⚡

by uoky5217

162 downloads
Not rated
GitHub

About

MCP 学习项目⚡ is a learning project based on the Model Context Protocol (MCP) that demonstrates how to implement an MCP Server. It includes a FastAPI-based API server simulating a Java backend with basic arithmetic operations (addition, subtraction, multiplication, division), and…

Details

Author
uoky5217
Downloads
162
Categories
Other

- Arithmetic toolset: add, subtract, multiply, divide
- SSE-based real‑time message transport
- Async HTTP client (HTTPX) support
- Strong type input validation
- Two transport implementations: stdio and SSE

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP 学习项目⚡
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

To use the stdio mode, first run python main.py in the api_server directory to start the API service, then configure the MCP server in Cline with the provided stdio transport configuration. For SSE mode, after starting the API service, run python remote_server.py in the mcp_server directory to start the MCP server, then configure Cline with the SSE transport URL (http://127.0.0.1:8001/sse). In both cases, test the MCP server inside the Cline plugin.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp \u5b66\u4e60\u9879\u76ee\u26a1": {
            "Mcp-Server-Study": {
                "command": "python",
                "args": [
                    "main.py"
                ]
            }
        }
    }
}

McpServers

{
    "Mcp-Server-Study": {
        "command": "python",
        "args": [
            "main.py"
        ]
    }
}

MCP 学习项目⚡

Python 3.10+
[架构: 微服务]()
[测试: Pytest]()

🌟 项目简介

本项目是一个基于MCP协议的学习项目,主要用于学习MCP Server如何实现。 api_server目录内是一个使用FastAPI库实现的一组API服务接口,用来模拟现有系统的java后端服务,本项目内只是实现了加减乘除四则运算。 tests目录下是一个针对api_server的单元测试程序,用来熟悉pytest功能。 mcp_server目录下是mcp的server内容,包含mcp的两种实现方式

第一种是stdio方式

主要就是本地调用,本地运行的方式,主要实现包含在server.py代码中。 使用方式可以使用cline插件进行调用,下面附上cline调用的cfg配置
{
  "mcpServers": {
    "math": {
      "timeout": 60,
      "command": "mcp",
      "args": [
        "run",
        "\mcp_server\server.py"
      ],
      "transportType": "stdio",
      "disabled": true
    }
  }
}

stdio运行方式

#进入api_server目录下
python main.py
#启动api 服务

#配置好cline的cfg后
#在cline中测试mcp server

第二种是sse方式

使用uvicon生成一个服务,使用cline插件的remote server方式进行配置连接。 主要功能包含在remote_server.py中,下面附上cline的cfg配置
{
  "mcpServers": {
    "calculate": {
      "autoApprove": [
        "calculate_sum",
        "calculate_subtract",
        "calculate_multiply",
        "calculate_divide"
      ],
      "disabled": false,
      "timeout": 60,
      "url": "http://127.0.0.1:8001/sse",
      "transportType": "sse"
    }
  }
}

sse运行方式

#进入api_server目录下
python main.py
#启动api 服务

#进入mcp_server目录下
python remote_server.py
#启动mcp server

#配置好cline的cfg后
#在cline中测试mcp server

🌟 系统架构

graph LR
    Client-->|SSE Streaming| MCP_Server["MCP Server (Port 8001)"]
    MCP_Server-->|HTTP RPC| API_Server["API Server (Port 8000)"]
    API_Server-.->|Call Function| FUNC[(计算函数)]
    
    subgraph 计算服务
        API_Server
    end

✨ 核心功能

- 🧮 四则运算工具集(加减乘除)
- 📡 基于SSE的实时消息传输
- ⚡ 异步HTTP客户端支持
- 🔒 强类型输入校验

🛠️ 技术栈

- 框架: Starlette
- 服务器: Uvicorn
- HTTP客户端: HTTPX
- 传输协议: MCP Server-Sent Transports

🚀 快速开始

前置要求

- Python 3.10+ - uv

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.