MCP服务器Cookie切割器模板
用于创建新MCP(模型上下文协议)服务器的cookie切割模板。此模板生成一个功能齐全的MCP服务器,具有多传输支持(stdio和流式HTTP)、高级日志记录、自动装饰器和基于web的管理UI。
特性
- 多运输支持:stdio和流式HTTP在单个实现中
- 自动装饰机:异常处理、日志记录、类型转换和并行化
- 统一日志记录系统:基于SQLite的日志记录,带有相关ID和可扩展目标
- Web管理UI:基于Streamlit的配置、日志和文档界面
- 示例工具:具有最佳实践的现成示例工具
- 完全兼容MCP检查器:易于测试和调试
- 适当的绝对进口:整个包装结构清洁
- DevFlow集成:内置JIRA工作流命令(计划工作、实施、安全审查、完成)
- 综合文档:README、开发指南和设置提示模板
先决条件
- Python 3.11或更高版本
python --version # Should be 3.11 or higher- uv(快速Python包安装程序)
# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh- 饼干模子
uv pip install cookiecutter创建新的MCP服务器
您可以直接从GitHub或此模板的本地副本创建新的MCP服务器。
选项1:直接从GitHub
cookiecutter gh:codingthefuturewithai/mcp-cookie-cutter选项2:从本地副本
- 克隆此模板:
git clone https://github.com/codingthefuturewithai/mcp-cookie-cutter- 使用本地模板创建项目:
cookiecutter path/to/mcp-cookie-cutter模板配置
您将被要求:
project_name:人类可读的名称(例如“我的MCP服务器”)__project_slug:Python包名(由project_name自动生成,例如“my_mcp_server”)description:项目简介author_name:你的名字email:您的电子邮件地址server_port:流式HTTP传输端口(默认值:3001)
生成的项目结构
my_mcp_server/ # Your project directory
├── .claude/ # Claude Code integration
│ ├── agents/ # Security scanner agent
│ └── commands/ # DevFlow workflow commands
│ └── devflow/ # JIRA-integrated development workflow
├── my_mcp_server/ # Python package directory
│ ├── __init__.py
│ ├── __main__.py
│ ├── client/ # Client implementations
│ │ ├── __init__.py
│ │ └── app.py # Test client for development
│ ├── server/ # Server implementation
│ │ ├── __init__.py
│ │ └── app.py # Multi-transport MCP server (stdio, streamable HTTP)
│ ├── tools/ # Tool implementations
│ │ ├── __init__.py
│ │ └── example_tools.py # Example tools with decorators
│ ├── decorators/ # Automatic tool decorators
│ │ ├── exception_handler.py
│ │ ├── tool_logger.py
│ │ ├── type_converter.py
│ │ └── parallelize.py
│ ├── log_system/ # Unified logging system
│ │ ├── correlation.py # Correlation ID tracking
│ │ ├── unified_logger.py # Main logging interface
│ │ └── destinations/ # Log destinations (SQLite, etc.)
│ ├── ui/ # Streamlit management UI
│ │ ├── app.py
│ │ ├── lib/ # UI components and utilities
│ │ └── pages/ # UI pages (Home, Config, Logs, Docs)
│ ├── config.py # Server configuration
│ └── logging_config.py # Logging setup
├── tests/ # Test suite
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── pyproject.toml # Project configuration and dependencies
├── README.md # Project documentation template
├── DEVELOPMENT.md # Development guide
├── DEVELOPER_GUIDE.md # Developer reference
└── SETUP_PROMPT.md # AI-assisted setup guide下一步
项目生成后:
- 查看文档模板
- 定制 README.md 为您的项目 - 审查 DEVELOPMENT.md 用于开发工作流程 - 检查 DEVELOPER_GUIDE.md 建筑细节 - 使用 SETUP_PROMPT.md 用于人工智能辅助设置
- 设置开发环境
- 安装依赖项: uv pip install -e . - 运行测试: pytest - 启动服务器: python -m your_project_name --transport stdio
- 探索交通工具
- 工作室: python -m your_project_name --transport stdio - 可流式传输的HTTP: python -m your_project_name --transport streamable-http --port 3001
- 使用MCP检查员进行测试
- 安装: npm install -g @modelcontextprotocol/inspector - 运行: mcp dev your_project_name/server/app.py
- 访问管理UI
- 启动UI: streamlit run your_project_name/ui/app.py - 查看日志、配置服务器、浏览文档
- 添加您自己的工具
- 添加功能 tools/example_tools.py - 装饰器是自动应用的 - 注册于 example_tools 或 parallel_example_tools 列表
- 使用DevFlow工作流 (可选)
- 连接到JIRA - 使用 /devflow:plan-work ISSUE-KEY 计划 - 使用 /devflow:implement ISSUE-KEY 实施 - 使用 /devflow:security-review ISSUE-KEY 扫描 - 使用 /devflow:complete ISSUE-KEY 创建PR
许可证
此模板在MIT许可证下获得许可-有关详细信息,请参阅许可证文件。
