Skip to main content
Glama
chang0911

丝路E投财务引擎 MCP 适配层

by chang0911
README.md
# 丝路E投财务引擎 MCP 适配层

> **纯转发适配层**:把 21 个财务工具的调用请求转发至丝路E投技能网关。
> 本仓库**不含任何财务算法与业务数据**——财务模型引擎本体由丝路E投云端托管。

## 接入配置

```json
{
  "mcpServers": {
    "slgj-finance": {
      "command": "python3",
      "args": ["server.py"],
      "env": { "SLGJ_TOKEN": "sk-mcp-****" }
    }
  }
}
```

> `SLGJ_TOKEN` 填你的丝路E投调用令牌:[www.slgj.cn](https://www.slgj.cn) → 注册/登录 → 个人中心 → AI接入 → 生成专用令牌。

适配层做三件事:

1. 向客户端暴露 21 个工具(清单从网关实时拉取,自动跟随平台更新);
2. 把 `tools/call` 原样转发到远端 MCP 端点;
3. 按下方规则解析并携带调用令牌。

远端端点(默认):`https://www.slgj.cn/skills-api/api/v1/mcp` · 传输:Streamable HTTP(POST/JSON 档)

## 令牌从哪来

| 优先级 | 来源 | 适用场景 |
|---|---|---|
| 1 | 工具参数 `_token`(转发前自动剥离) | 客户端不支持自定义请求头时,按会话传入 |
| 2 | 环境变量 `SLGJ_TOKEN` | 托管部署(实例级共享)或本机运行 |

两者都缺省时:`tools/list` 免鉴权仍可拉取目录;`tools/call` 会收到网关 401 提示。

> ⚠️ 令牌即账户凭证:**不要把真实令牌提交进任何公开仓库**;托管部署的实例级令牌请自行评估共享范围,正式多用户场景推荐各用户本地运行(下文方式二)或直连远程端点。

## 方式一:魔搭 ModelScope 托管部署

1. ModelScope → MCP 部署服务 → **+新建部署**(或 MCP 广场 → 创建 MCP Server);
2. 来源选本仓库(GitHub 地址),托管类型选云端可用;
3. 环境变量配置:`SLGJ_TOKEN` = 你的丝路E投令牌;
4. 部署完成后在广场/实验场连接使用。

## 方式二:本地运行(stdio,推荐给正式用户)

```bash
pip install -r requirements.txt
SLGJ_TOKEN=*** python3 server.py
```

客户端配置(通用 mcpServers 结构):

```json
{
  "mcpServers": {
    "slgj-finance": {
      "command": "python3",
      "args": ["/path/to/server.py"],
      "env": { "SLGJ_TOKEN": "sk-mcp-****" }
    }
  }
}
```

## 方式三:Streamable HTTP 模式(可选)

```bash
pip install -r requirements.txt uvicorn starlette
python3 server.py --http 0.0.0.0:8000
```

客户端连 `http://<host>:8000`。此模式下也可用自定义请求头携带用户令牌。

## 方式四:不部署,直连远程(最简单)

支持自定义请求头的客户端无需本适配层,直接:

```json
{
  "mcpServers": {
    "slgj-finance": {
      "url": "https://www.slgj.cn/skills-api/api/v1/mcp",
      "headers": { "Authorization": "***" }
    }
  }
}
```

## 环境变量

| 变量 | 默认 | 说明 |
|---|---|---|
| `SLGJ_TOKEN` | 无 | 调用令牌(实例级兜底,可被参数 `_token` 覆盖) |
| `SLGJ_ENDPOINT` | 官方端点 | 远端 MCP 端点,一般无需修改 |
| `SLGJ_TIMEOUT` | 300 | 单次转发超时秒数(不确定性分析完整模式需 1-3 分钟) |

## 已知约束

- 远端仅提供 Streamable HTTP 的 POST/JSON 档(不提供 SSE);
- 八个成品类工具首次调用需经 `get_protocol_instructions` 握手(72 小时内有效),客户端模型会自动完成;
- 按次计费在远端账户体系完成,失败自动退款。

## 许可

MIT。丝路E投名称、标识与云端服务不在本许可范围内。

TDQS

A3.6/5.0

Scored across 21 tools

Disambiguation4/5

Most tools have a clearly distinct output (JSON reports vs Excel vs dashboard vs Word/PPT vs pipeline), so the agent can often tell them apart. However, several tools share the identical '5类输入txt' input and similar names (fast_calc_reports, fast_calc_excel, run_delivery_bundle; estimate_etou_json vs estimate_excel), and the two instruction readers (get_protocol_instructions vs get_skill_instructions) could be confused, though the descriptions do help resolve this.

Naming Consistency3/5

There is a strong verb_noun convention for most tools (query_usage, get_*, run_*, generate_*, submit_feedback). But a competing 'domain-prefix + artifact' convention exists (fast_calc_reports, fast_calc_excel, estimate_excel, permitted_cost_excel, ppt_extract_data), so the surface mixes two readable but different patterns.

Tool Count3/5

21 tools is borderline heavy for a single server and reflects a broad suite spanning estimation, pricing, national econ, reporting, checks and solving. Each tool maps to a specific artifact, but the count pushes toward the '16-25 feels heavy' band and includes some near-duplicative output variants.

Completeness4/5

The surface covers a full financial-modeling lifecycle: protocol/skill instructions, data extraction and matching, calculation, solving, uncertainty, delivery bundles, Word/PPT/dashboard output, model and revenue checks, usage stats and feedback. Only minor gaps remain (e.g. no explicit lifecycle delete/update semantics, and some verification depends on external benchmark lookups).

Maintenance

ActivityMaintained
ResponsivenessNo issues