compare-json
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"compare-json": {
"args": [
"@compare-json/cli@latest",
"--mcp"
],
"command": "npx"
}
}
}
服务介绍
启动MCP服务器
# from a global install
compare-json --mcp
# or via npx
npx @compare-json/cli --mcp
服务器通过标准输入输出进行通信。
在线游乐场
在 https://comparejson.com 上试用
可用工具
compare_json
比较两个JSON值并返回它们之间的差异。
输入参数:
| 参数 | 类型 | 是否必需 | 描述 |
|---|---|---|---|
baseJSON |
any |
条件性 | 基础JSON值(已解析)。 |
baseJSONString |
string |
条件性 | 作为字符串的基础JSON值(由服务器解析)。 |
baseJSONFilePath |
string |
条件性 | 基础JSON文件的路径(由服务器读取和解析)。 |
contrastJSON |
any |
条件性 | 对比JSON值(已解析)。 |
contrastJSONString |
string |
条件性 | 作为字符串的对比JSON值。 |
contrastJSONFilePath |
string |
条件性 | 对比JSON文件的路径。 |
options |
object |
否 | 比较选项(见下文)。 |
必须至少提供一个baseJSON / baseJSONString / baseJSONFilePath,以及至少一个contrastJSON / contrastJSONString / contrastJSONFilePath。当为某一方设置了多个时,文件路径优先级最高,其次是字符串,最后是原始值。
选项:
| 选项 | 类型 | 默认值 | 描述 |
|---|---|---|---|
arrayCompareMethod |
'byIndex' | 'lcs' | 'unordered' |
'byIndex' |
数组比较策略。 |
keyCaseInsensitive |
boolean |
false |
键名大小写不敏感比较。 |
valueCaseInsensitive |
boolean |
false |
值大小写不敏感比较。 |
numericStringEqualsNumber |
boolean |
false |
将数字字符串视为与数字相等。 |
输出:
返回structuredContent.differences — 一个JSONValueDifference对象数组 — 以及content[0].text形式的相同数据的JSON文本镜像。
{
"differences": [
{
"pathSegments": ["name"],
"pathString": "name",
"pathBelongsTo": "both",
"diffType": "valueChanged"
}
]
}
MCP客户端配置
将以下内容添加到您的MCP客户端配置中(例如mcp.json):
{
"mcpServers": {
"compare-json": {
"command": "npx",
"args": ["@compare-json/cli@latest", "--mcp"]
}
}
}