MCP 开发手册
1. 项目概述
本项目是一个 MCP (Model Context Protocol) 项目,核心是通过工具注册表管理各种工具实例。 BaseHandler 作为工具基类,所有具体工具需继承该类并实现必要方法。
2. 开发环境准备
确保已安装 Python 环境,项目依赖维护在 requirements.txt 中,可通过以下命令安装依赖:
3. 核心类说明
- ToolRegistry : 工具注册表,负责管理所有工具实例,提供注册、获取单个工具和获取所有工具描述的方法。
- BaseHandler : 工具基类,子类需实现 get_tool_description 和 run_tool 方法。子类初始化时会自动注册到 ToolRegistry 。
4. 开发新工具步骤
以下是开发新工具的示例,假设我们要创建一个名为 ExampleTool 的新工具。
4.1 创建新工具类文件
在 src/handles 目录下创建新文件,例如 example_tool.py 。
4.2 注册新工具
由于 BaseHandler 的 init_subclass 方法会自动注册工具,只需继承 BaseHandler 并设置 name 属性即可完成注册。
5. 打包 Docker 镜像
项目根目录下已存在 Dockerfile ,可使用以下命令构建 Docker 镜像:
运行 Docker 容器:
6. 依赖管理
项目依赖版本维护在 requirements.txt 中,添加新依赖时,请在文件中添加对应依赖及其版本,示例如下:
基础项目代码整理说明 src/handles/base.py 代码
该文件定义了项目的核心类,为开发新工具提供基础框架。按照上述开发手册,开发者可基于 BaseHandler 类快速开发新工具。
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A Python framework for developing and managing tool instances through a registry system, where developers can easily create new tools by inheriting from the BaseHandler class and implementing required methods.
Related MCP Servers
- -securityFlicense-qualityEnables external tool registration and execution through WebSocket-based communication, providing a unified interface for real-time tool management within SillyTavern.Last updated -4JavaScript
- -securityFlicense-qualityEnables AI models to dynamically create and execute their own custom tools through a meta-function architecture, supporting JavaScript, Python, and Shell runtimes with sandboxed security and human approval flows.Last updated -2JavaScript
- AsecurityAlicenseAqualityAn AI-powered automation tool development platform that provides modular architecture with tool hot-reloading, enterprise-grade integration capabilities, and real-time updates with zero-downtime deployment.Last updated -174TypeScriptMIT License
Fastn Serverofficial
-securityAlicense-qualityAn MCP server that enables dynamic tool registration and execution based on API definitions, providing seamless integration with services like Claude.ai and Cursor.ai.Last updated -7PythonMIT License