Cover image
Try Now
2025-04-14

3 years

Works with Finder

2

Github Watches

0

Github Forks

2

Github Stars

🚀 My MCP Server

A lightweight, self-hosted MCP (Model Context Protocol) server based on the official MCP specification.

🚀 What is this?

This project provides a quick transformation structure
to adapt your existing backend services into an MCP-compliant server with minimal changes.

You can expose your existing service methods as MCP tools effortlessly!

Only one requirement:
Make sure your services/ package contains all the business interfaces you want to expose as MCP tools.


🛠️ Features

  • Fast Transformation: Quickly adapt your current backend into an MCP server.
  • 🔍 Auto Discovery: Automatically scan and register service methods as MCP tools.
  • 📦 Fully MCP-Compatible: Seamless connection to MCP Inspector or any MCP-compliant client.
  • 🛠️ Minimal Invasive: No need to heavily modify your existing service logic.
  • 🚀 Plug-and-Play: Just organize your methods properly under the services/ directory.

📂 Project Structure

my_mcp_server/
├── app.py                     # FastAPI app, defines /sse and /rpc endpoints
├── config/                     # Configuration files
├── core/
│   ├── mcp_session.py          # MCP session logic
│   ├── mcp_session_manager.py  # Session management
│   ├── models/                 # Event, McpRequest, Tool models
│   └── utils/                  # Scanners and path finders
├── services/                   # Business services to expose as MCP tools
│   ├── math_tool.py            # Example tool: math operations
├── README.md                   # Project documentation
└── requirements.txt            # Python dependencies

📦 Quick Start

1. Install dependencies

pip install -r requirements.txt

2. Start the server

uvicorn app:app --host 0.0.0.0 --port 8000 --reload

3. Connect MCP Inspector

  • Open MCP Inspector
  • Set your MCP Server URL to: http://localhost:8000
  • Start interacting!

📚 How It Works

  1. When a client connects to /sse, the server:
    • Creates a new McpSession.
    • Scans all tools in services/ and registers them.
    • Immediately pushes an initialize event.
  2. When a client sends a request to /v1/mcp/events/send:
    • The server routes it to the correct session.
    • Dispatches initialize, tools/list, or tools/call accordingly.
  3. Tools are dynamically mapped to your service methods.

⚠️ Notes

  • All business logic you want to expose must be placed inside the services/ directory.
  • Each service method should be an async def coroutine.
  • Tool scanning supports simple class-based services.
  • Make sure method names are unique across all services to avoid conflicts.

📄 Example Service (services/math_tool.py)

class MathService:
    async def add(self, a: int, b: int) -> int:
        """Add two numbers."""
        return a + b

    async def subtract(self, a: int, b: int) -> int:
        """Subtract two numbers."""
        return a - b

Once placed under services/, they will be automatically scanned and registered as MCP tools!


📋 Todo (optional extensions)

  • Support nested sub-packages inside services/
  • Add Session idle timeout and auto cleanup
  • Add /health and /metrics endpoints
  • Add Dockerfile and CI/CD scripts

📜 License

This project is open-sourced under the MIT License.

相关推荐

  • av
  • Effortlessly run LLM backends, APIs, frontends, and services with one command.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的LLM资料总结(Agent框架、辅助编程、数据处理、模型训练、模型推理、o1 模型、MCP、小语言模型、视觉语言模型) | Summary of the world's best LLM resources.

  • 1Panel-dev
  • 🔥 1Panel provides an intuitive web interface and MCP Server to manage websites, files, containers, databases, and LLMs on a Linux server.

  • rulego
  • ⛓️RuleGo is a lightweight, high-performance, embedded, next-generation component orchestration rule engine framework for Go.

  • Byaidu
  • PDF scientific paper translation with preserved formats - 基于 AI 完整保留排版的 PDF 文档全文双语翻译,支持 Google/DeepL/Ollama/OpenAI 等服务,提供 CLI/GUI/MCP/Docker/Zotero

  • lasso-security
  • A plugin-based gateway that orchestrates other MCPs and allows developers to build upon it enterprise-grade agents.

  • hkr04
  • Lightweight C++ MCP (Model Context Protocol) SDK

  • sigoden
  • Easily create LLM tools and agents using plain Bash/JavaScript/Python functions.

  • RockChinQ
  • 😎简单易用、🧩丰富生态 - 大模型原生即时通信机器人平台 | 适配 QQ / 微信(企业微信、个人微信)/ 飞书 / 钉钉 / Discord / Telegram / Slack 等平台 | 支持 ChatGPT、DeepSeek、Dify、Claude、Gemini、xAI、PPIO、Ollama、LM Studio、阿里云百炼、火山方舟、SiliconFlow、Qwen、Moonshot、ChatGLM、SillyTraven、MCP 等 LLM 的机器人 / Agent | LLM-based instant messaging bots platform, supports Discord, Telegram, WeChat, Lark, DingTalk, QQ, Slack

  • modelscope
  • Start building LLM-empowered multi-agent applications in an easier way.

    Reviews

    2 (5)
    Avatar
    user_KYijBxlr
    2025-04-25

    I am absolutely thrilled with my_mcp by chengnanyimeng. This application has exceeded all my expectations with its user-friendly interface and seamless integration. It's clear that a lot of thought has gone into the design and functionality, making it an indispensable tool in my daily routine. Highly recommend it to anyone looking for a reliable and efficient solution.

    Avatar
    user_znOi4z6d
    2025-04-25

    My_MCP is incredibly useful for streamlining my workflow! The app, created by chengnanyimeng, is intuitive and user-friendly, making it easy to navigate from the start URL. The welcoming information is clear and helpful, setting you up for success right away. Highly recommend for anyone needing a robust MCP application.

    Avatar
    user_hSrxOBy9
    2025-04-25

    I've been using my_mcp by chengnanyimeng for a while now, and it has significantly improved my workflow. The intuitive interface and reliable performance make it a top choice for anyone looking for high-quality MCP applications. Additionally, the comprehensive welcome information ensures a smooth start, even for new users. Highly recommended!

    Avatar
    user_DmkJ6k5g
    2025-04-25

    I recently started using my_mcp by chengnanyimeng and I'm thoroughly impressed. The application is user-friendly and offers seamless functionality. The welcome information makes it easy to get started, and the initial URL provided clear direction right from the beginning. Highly recommend for anyone seeking efficient solutions!

    Avatar
    user_a2oWMBCx
    2025-04-25

    I have been using my_mcp by chengnanyimeng for a while now, and it has significantly streamlined my workflow. The application is intuitive and user-friendly, making complex processes manageable and efficient. I highly recommend it to anyone looking for a reliable solution in its category.