返回顶部
m

mcp-integrationMCP集成

Use Model Context Protocol servers to access external tools and data sources. Enable AI agents to discover and execute tools from configured MCP servers (legal databases, APIs, database connectors, weather services, etc.).

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 0.1.0
安全检测
已通过
4,526
下载量
免费
免费
4
收藏
概述
安装方式
版本历史

mcp-integration

MCP 集成使用指南

概述

使用 MCP 集成插件来发现并执行外部 MCP 服务器提供的工具。此技能使您能够访问法律数据库、查询 API、搜索数据库,并与任何提供 MCP 接口的服务进行集成。

该插件提供了一个统一的 mcp 工具,包含两个操作:

  • - list - 发现所有已连接服务器提供的可用工具
  • call - 使用参数执行特定工具



流程

🔍 阶段一:工具发现

1.1 检查可用工具

始终从列出可用工具开始,以查看哪些 MCP 服务器已连接以及它们提供哪些功能。

操作:

{
tool: mcp,
args: {
action: list
}
}

响应结构:
json
[
{
id: server:toolname,
server: server-name,
name: tool-name,
description: 该工具的功能说明,
inputSchema: {
type: object,
properties: {...},
required: [...]
}
}
]

1.2 理解工具模式

对于每个工具,检查:

  • - id:格式为 server:toolname - 以 : 分割获取服务器和工具名称
  • description:理解工具的功能
  • inputSchema:定义参数的 JSON Schema

- properties:可用参数及其类型和描述
- required:必填参数名称数组

1.3 将工具与用户请求匹配

常见工具命名模式:

  • - search - 查找或搜索操作(例如 searchstatute、searchusers)
  • get - 检索特定数据(例如 getstatutefulltext、getweather)
  • query - 执行查询(例如 database:query)
  • analyze - 分析操作(例如 analyzelaw)
  • resolve - 解析引用(例如 resolvecitation)



🎯 阶段二:工具执行

2.1 验证参数

在调用工具之前:

  1. 1. 从 inputSchema.required 中识别所有必填参数
  2. 验证参数类型与模式匹配(字符串、数字、布尔值、数组、对象)
  3. 检查约束条件(最小值、最大值、枚举值、模式)
  4. 确保您拥有用户提供的必要信息

2.2 构建工具调用

操作:

{
tool: mcp,
args: {
action: call,
server: ,
tool: ,
args: {
// 来自 inputSchema 的工具特定参数
}
}
}

示例 - 韩国法律搜索:

{
tool: mcp,
args: {
action: call,
server: kr-legal,
tool: search_statute,
args: {
query: 연장근로 수당,
limit: 5
}
}
}

2.3 解析响应

工具响应遵循以下结构:
json
{
content: [
{
type: text,
text: JSON 字符串或文本结果
}
],
isError: false
}

对于 JSON 响应:
javascript
const data = JSON.parse(response.content[0].text);
// 访问 data.result、data.results 或直接属性



🔄 阶段三:多步骤工作流

3.1 链式工具调用

对于复杂请求,按顺序执行多个工具:

示例 - 法律研究工作流:

  1. 1. 搜索 - searchstatute 查找相关法律
  2. 检索 - getstatutefulltext 获取完整文本
  3. 分析 - analyzelaw 进行解释
  4. 判例 - searchcase_law 查找相关案例

每个步骤使用上一步的输出为下一步调用提供信息。

3.2 保持上下文

在工具调用之间:

  • - 从每个响应中提取相关信息
  • 将提取的数据用作后续调用的参数
  • 逐步建立理解
  • 向用户呈现综合结果



⚠ 阶段四:错误处理

4.1 常见错误

Tool not found: server:toolname

  • - 原因:服务器未连接或工具不存在
  • 解决方案:运行 action: list 验证可用工具
  • 检查服务器和工具名称的拼写

Invalid arguments for tool

  • - 原因:缺少必填参数或类型错误
  • 解决方案:查看列表响应中的 inputSchema
  • 确保所有必填参数以正确类型提供

Server connection failed

  • - 原因:MCP 服务器未运行或无法访问
  • 解决方案:告知用户服务暂时不可用
  • 如果可能,建议替代方案

4.2 错误响应格式

错误返回:
json
{
content: [{type: text, text: Error: message}],
isError: true
}

优雅处理:

  • - 清晰地解释出错原因
  • 不暴露技术实现细节
  • 建议后续步骤或替代方案
  • 不要过度重试



完整示例

用户请求:查找关于加班费的韩国法律

步骤 1:发现工具

{tool: mcp, args: {action: list}}

响应显示 kr-legal:search_statute,包含:

  • - 必填:query(字符串)
  • 可选:limit(数字)、category(字符串)

步骤 2:执行搜索

{
tool: mcp,
args: {
action: call,
server: kr-legal,
tool: search_statute,
args: {
query: 연장근로 수당,
category: 노동법,
limit: 5
}
}
}

步骤 3:解析并呈现

javascript const data = JSON.parse(response.content[0].text); // 向用户呈现 data.results

面向用户的响应:

找到 5 条关于加班费的韩国法律:

  1. 1. 근로기준법 제56조 (연장·야간 및 휴일 근로)
- 加班工作需支付 50% 的额外工资
  1. 2. 근로기준법 제50조 (근로시간)
- 标准工作时间:每周 40 小时

是否需要我检索任何法律的完整文本?



快速参考

列出工具

{tool: mcp, args: {action: list}}

调用工具

{
tool: mcp,
args: {
action: call,
server: server-name,
tool: tool-name,
args: {param1: value1}
}
}

基本模式

工具 ID 解析: server:toolname → 以 : 分割获取服务器和工具名称

参数验证: 检查 inputSchema.required 和 inputSchema.properties[param].type

响应解析: 对于 JSON 响应使用 JSON.parse(response.content[0].text)

错误检测: 检查 response.isError === true



参考文档

核心文档

使用示例

  • - 示例集合EXAMPLES.md - 13 个实际示例,包括:
- 法律研究工作流 - 数据库查询 - 天气服务集成 - 多步骤复杂工作流 - 错误处理模式
请记住: 当不确定可用工具时,始终从 action: list 开始。

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 mcp-adapter-1776371019 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 mcp-adapter-1776371019 技能

通过命令行安装

skillhub install mcp-adapter-1776371019

下载

⬇ 下载 mcp-integration v0.1.0(免费)

文件大小: 48.98 KB | 发布时间: 2026-4-17 14:36

v0.1.0 最新 2026-4-17 14:36
- Initial release as "mcp-integration" for accessing external data and tool APIs via the Model Context Protocol.
- Provides unified `mcp` tool with `list` and `call` actions for tool discovery and execution.
- Includes detailed usage guide covering tool discovery, parameter validation, tool execution, response parsing, error handling, and multi-step workflows.
- Added real-world examples, error handling patterns, and reference links for setup and troubleshooting.
- Designed to enable AI agents to integrate external services such as legal databases, APIs, and weather data through MCP servers.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部