Modular and extensible Model Context Protocol server framework featuring automatic module discovery, declarative configuration, FastMCP integration, and seamless AI application expansion with robust security and detailed logging.
Unlock the full potential of MCP-BOS through LangDB's AI Gateway. Get enterprise-grade security, analytics, and seamless integration with zero configuration.
Free tier available • No credit card required
使用基于约定的自动模块发现机制,为Claude Desktop打造的灵活MCP服务器框架。通过简洁的模块接口和声明式配置,轻松扩展AI应用功能,无需修改核心代码。支持FastMCP标准,包含完整工具、资源和提示模板注册能力。
Python
FastMCP
Model Context Protocol
Claude Desktop
JSON
模块化设计
微内核架构
!img.png
MCP-BOS框架采用了现代化的模块化架构设计,主要设计理念包括:
整个框架以模块为中心,每个功能都被封装在独立的模块中,使功能扩展变得简单直观。模块之间相互独立,但又通过标准接口相互协作,形成一个完整的服务生态。
框架能够自动发现modules
目录下的模块,无需手动注册每个模块。这种"约定优于配置"的方式大幅降低了扩展成本。
通过config.json
文件进行全局和模块级别的配置,使框架具有很高的灵活性,可以根据不同需求启用或禁用特定模块。
框架分为核心层和模块层,核心层负责框架基础功能,模块层负责具体业务功能,这种分层设计使框架更加健壮和可维护。
mcp-bos/
├── config.json # 全局配置文件
├── main.py # 主入口文件
├── core/ # 核心系统
│ ├── __init__.py
│ ├── module_registry.py # 模块注册表
│ ├── module_loader.py # 模块加载器
│ ├── module_interface.py # 模块接口定义
│ ├── config_manager.py # 配置管理器
│ └── server.py # FastMCP服务器适配
├── modules/ # 功能模块目录
│ ├── __init__.py
│ ├── hello_world/ # Hello World示例模块
│ │ ├── __init__.py
│ │ └── hello.py
│ └── ... # 其他功能模块
├── utils/ # 工具函数
│ ├── __init__.py
│ └── helpers.py
└── README.md # 项目文档
config.json
文件是框架的核心配置,分为全局配置和模块配置两部分:
{ "global": { "server_name": "MCP-BOS", "debug": true, "log_level": "INFO", "transport": "stdio", "dependencies": ["mcp[cli]"] }, "modules": { "hello_world": { "enabled": true, "message": "Hello, {}!" }, "module_name": { "enabled": false, "param1": "value1" } } }
global: 全局配置部分
modules: 模块配置部分,每个模块有自己的配置节
git clone https://github.com/kinbos/mcp-bos.git cd mcp-bos
uv pip install mcp[cli]
编辑config.json
文件来配置服务器和模块:
有以下几种方式运行服务器:
python main.py
uv run main.py
# 使用mcp CLI集成到Claude Desktop mcp install main.py
# 使用mcp Inspector测试服务器 mcp inspect main.py
modules
目录下创建一个新的模块目录:mkdir modules/my_module
touch modules/my_module/__init__.py touch modules/my_module/my_module.py
# modules/my_module/my_module.py from core.module_interface import ModuleInterface class MyModule(ModuleInterface): def get_info(self): return { "name": "my_module", "version": "1.0.0", "description": "我的自定义模块", "author": "kinbos 严富坤", "email": "fookinbos@gmail.com", "website": "htttps://www.yanfukun.com" } def register(self, server): @server.tool() def my_tool(param: str) -> str: """自定义工具""" return f"处理参数: {param}" @server.resource("my://resource") def my_resource() -> str: """自定义资源""" return "资源内容"
# modules/my_module/__init__.py from modules.my_module.my_module import MyModule __all__ = ['MyModule']
{ "modules": { "my_module": { "enabled": true, "custom_param": "value" } } }
__init__.py
文件是否导出了模块类如果在Windows环境下遇到中文编码问题,确保设置了正确的环境变量:
"env": { "PYTHONIOENCODING": "utf-8" }
欢迎提交贡献,请遵循以下步骤:
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!