基于 Model Context Protocol (MCP) 构建的碳排放因子数据库搜索服务,支持 Streamable HTTP 和 stdio 双传输机制。
| 工具名称 | 描述 |
|---|---|
search_factors |
搜索碳排放因子(格式化可读输出) |
search_factors_json |
搜索碳排放因子(结构化 JSON 输出,适合计算) |
compare_factors |
多关键词碳排放因子对比(最多 5 个) |
| 提示模板 | 描述 |
|---|---|
factor_search |
引导 LLM 进行因子搜索 |
carbon_calculation |
引导 LLM 进行碳排放量计算 |
无需安装,直接运行:
# stdio 模式
npx ccdb-mcp-server --stdio
# Streamable HTTP 模式
npx ccdb-mcp-server --http --port 3000npm install -g ccdb-mcp-server
# stdio 模式
ccdb-mcp --stdio
# Streamable HTTP 模式
ccdb-mcp --http --port 3000git clone https://github.com/carbonstop/ccdb-mcp.git
cd ccdb-mcp
npm install
npm run build
# stdio 模式
npm start
# Streamable HTTP 模式
node dist/index.js --http# HTTP 模式
npm run dev
# stdio 模式
npm run dev:stdio在 ~/Library/Application Support/Claude/claude_desktop_config.json 中添加:
{
"mcpServers": {
"ccdb-factor-search": {
"command": "npx",
"args": ["-y", "ccdb-mcp-server", "--stdio"]
}
}
}先启动 HTTP 服务:
npx ccdb-mcp-server --http --port 3000然后在 Claude Desktop 配置中添加:
{
"mcpServers": {
"ccdb-factor-search": {
"url": "http://localhost:3000/mcp"
}
}
}在 Cursor 设置的 MCP 配置中添加:
{
"ccdb-factor-search": {
"command": "npx",
"args": ["-y", "ccdb-mcp-server", "--stdio"]
}
}| 方法 | 路径 | 说明 |
|---|---|---|
POST |
/mcp |
MCP 请求(初始化/工具调用) |
GET |
/mcp |
SSE 通知流 |
DELETE |
/mcp |
会话终止 |
GET |
/health |
健康检查 |
ccdb-mcp/
├── src/
│ ├── index.ts # 入口 — CLI 参数解析与传输层分发
│ ├── server.ts # MCP Server 核心 — Tools / Prompts 注册
│ ├── ccdb-api.ts # CCDB API 客户端 — 请求封装与类型定义
│ ├── transport-stdio.ts # stdio 传输层
│ └── transport-http.ts # Streamable HTTP 传输层
├── package.json
├── tsconfig.json
└── README.md
通过 MCP 客户端调用 search_factors 工具:
{
"name": "search_factors",
"arguments": {
"name": "电力",
"lang": "zh"
}
}返回格式化的碳排放因子数据,包含因子值、单位、适用地区、年份、来源机构等详细信息。
npm login
npm publishMIT