MCP (模型上下文协议) 服务器模板生成器
mcpc 是一个命令行工具,用于生成 MCP (模型上下文协议) 服务器项目的框架。它帮助您快速设置一个结构良好的项目,并包含所有必要的文件和配置。
使用 Make:
# 一步构建并安装
make install
或者直接使用 Cargo:
# 从本地仓库安装
cargo install --path .
基本用法:
mcpc 项目名称 [选项]
选项:
-l, --language: 要使用的编程语言(py/python, ts/typescript,默认:typescript)-t, --tool: 要使用的包管理器工具:
示例:
# 使用 pnpm 创建名为 'weather-api' 的 TypeScript 项目
mcpc weather-api -l ts -t pnpm
# 使用 uv 创建名为 'mcp-server' 的 Python 项目
mcpc mcp-server -l py -t uv
项目名称/
├── .gitignore
├── .prettierignore
├── .prettierrc
├── package.json
├── README.md
├── tsconfig.json
├── build/
└── src/
└── index.ts
项目名称/
├── .gitignore
├── pyproject.toml
├── README.md
├── requirements.txt
├── server.py
└── .venv/
# 激活虚拟环境
source .venv/bin/activate # 在 Windows 上:.venv\Scripts\activate
# 安装依赖项(如果尚未安装)
uv pip install -r requirements.txt
# 不使用 Claude 测试服务器功能
python server.py --test
# 运行服务器以集成 Claude
python server.py
# 安装依赖项(如果尚未安装)
pnpm install # 或:yarn / npm install
# 构建项目
pnpm run build # 或:yarn build / npm run build
# 运行服务器
node build/index.js
要与桌面版 Claude 集成,请在 Claude 的配置文件中配置您的服务器:
{
"mcpServers": {
"weather": {
"command": "uv", // 或 "node" 对于 TypeScript
"args": [
"--directory",
"/ABSOLUTE/PATH/TO/PROJECT",
"run",
"server.py" // 或 "build/index.js" 对于 TypeScript
]
}
}
}
make # 构建项目(与 'make build' 相同)
make build # 以调试模式构建项目
make release # 以发布模式构建项目
make install # 以发布模式构建并安装
make run # 以调试模式运行项目
make run-release # 以发布模式运行项目
make test # 运行测试
make docs # 生成并打开文档
make clean # 清理构建工件
make fmt # 使用 rustfmt 格式化代码
make check # 检查编译错误
make clippy # 运行 Clippy 检查
git clone https://github.com/yourusername/mcpc.git
cd mcpc
make install
本项目采用 MIT 许可证 - 详情见 LICENSE 文件。 </中文翻译>