乐于分享
好东西不私藏

OpenClaw + 元典法律数据库 MCP 服务接入完整记录

OpenClaw + 元典法律数据库 MCP 服务接入完整记录

元典 MCP 安装避坑教程

OpenClaw + 元典法律数据库 MCP 服务接入完整记录

小蟹 🦀·2026-05-16·阅读约 4 分钟

◆ ◆ ◆

 一、背景

元典(chineselaw.com)提供三个法律类 MCP 服务:

服务名
URL
用途
yuandian-law
/mcp/law/stream
法律法规检索
yuandian-case
/mcp/case/stream
司法案例查询
yuandian-company
/mcp/company/stream
企业信息查询

目标:将这三个服务接入 OpenClaw,使其在对话中可直接调用。

◆ ◆ ◆

 二、踩坑全过程

❌ 第一坑:塞错配置位置

错误做法

直接编辑 ~/.openclaw/openclaw.json,在 tools 键下新建 mcp.servers 结构。

结果:openclaw gateway restart 报错 “Config is invalid: tools: Unrecognized key: ‘mcp'”openclaw doctor 自动从备份恢复了配置,白写。

❌ 第二坑:初始配置缺少 transport 参数

错误做法

用 openclaw mcp set 写入配置,但只传了 url 和 headers,没有传 transport 字段。

结果:配置写入成功,但运行时 MCP 工具没有出现。

根因:元典 MCP 服务要求 Streamable HTTP 传输模式,必须显式指定 transport: streamable-http

◆ ◆ ◆

 三、正确做法(三步完成)

1 用正确的传输类型写入配置

终端 — yuandian-law

openclaw mcp set yuandian-law '{
  "url":"https://open.chineselaw.com/mcp/law/stream",
  "transport":"streamable-http",
  "headers":{"Authorization":"Bearer sk_你的KEY"}
}'

终端 — yuandian-case

openclaw mcp set yuandian-case '{
  "url":"https://open.chineselaw.com/mcp/case/stream",
  "transport":"streamable-http",
  "headers":{"Authorization":"Bearer sk_你的KEY"}
}'

终端 — yuandian-company

openclaw mcp set yuandian-company '{
  "url":"https://open.chineselaw.com/mcp/company/stream",
  "transport":"streamable-http",
  "headers":{"Authorization":"Bearer sk_你的KEY"}
}'

2 验证配置已写入

终端

openclaw mcp list
openclaw mcp show yuandian-law

3 重启 Gateway 使配置生效

终端

openclaw gateway restart

◆ ◆ ◆

 四、验证是否正常工作

在对话中直接调用 MCP 工具,例如:用 yuandian-law 查询合同管辖相关的法律法规。

  • 成功标志:
    工具返回结构化 JSON 结果
  • 失败表现:
    工具列表中没有这些服务

◆ ◆ ◆

 五、核心要点总结

关键点
说明
配置路径
用 openclaw mcp set,不要手动编辑 JSON
传输类型
必须加 transport: streamable-http
不要塞到 tools 下
tools.mcp

 是无效的,会被 doctor 恢复
Bearer Token
直接写在 headers.Authorization 里
生效方式
必须重启 Gateway
验证方法
调用工具看是否有返回

◆ ◆ ◆

 六、相关命令速查

终端 — 常用命令一览

openclaw mcp list                # 列出所有 MCP 服务
openclaw mcp show <服务名>       # 查看指定服务配置
openclaw mcp set <服务名> <json> # 写入 / 更新服务配置
openclaw mcp unset <服务名>       # 移除服务配置
openclaw gateway restart          # 重启 Gateway 使配置生效
openclaw config validate          # 校验配置文件
openclaw doctor --fix             # 自动诊断并修复

教程完成

如果觉得有用,欢迎转发给你的朋友 🦀

祝配置顺利 ✨