JSON Manipulation

JSON Manipulation

🚀 JSON 模型上下文协议 (MCP) 服务器 (@gongrzhe/server-json-mcp@1.0.3)

这是一个用于查询和操作 JSON 数据的 JSON Model Context Protocol (MCP) 服务器实现。该服务器允许大语言模型 (LLMs) 通过一组标准化工具与 JSON 数据进行交互。

🚀 快速开始

JSON 模型上下文协议 (MCP) 服务器可助力大语言模型便捷地与 JSON 数据交互。以下是使用指引:

# 使用 npx 和特定版本(推荐)
npx @gongrzhe/server-json-mcp@1.0.3

# 全局安装特定版本
npm install -g @gongrzhe/server-json-mcp@1.0.3

# 全局安装后运行
server-json-mcp

✨ 主要特性

工具

  • query:
    • 可使用 JSONPath 语法查询 JSON 数据,还支持扩展操作。
    • 输入:
      • url(字符串):JSON 数据源的 URL。
      • jsonPath(字符串):带有可选操作的 JSONPath 表达式。
  • filter:
    • 能根据条件过滤 JSON 数据。
    • 输入:
      • url(字符串):JSON 数据源的 URL。
      • jsonPath(字符串):基础 JSONPath 表达式。
      • condition(字符串):过滤条件。

支持的操作

数组操作

  • 切片:$[0:5]、$[-3:]、$[1:4]。
  • 排序:$.sort(price)、$.sort(-price)。
  • 去重:$.distinct()。
  • 转换:
    • 映射:$.map(fieldName)。
    • 扁平化:$.flatten()。
    • 联合:$.union([1,2,3])。
    • 交集:$.intersection([1,2,3])。

字符串操作

  • 大小写:$.toLowerCase()、$.toUpperCase()。
  • 测试:
    • 以...开头:$.startsWith('test')。
    • 以...结尾:$.endsWith('test')。
    • 包含:$.contains('test')。
    • 正则匹配:$.matches('pattern')。

数值操作

  • 数学运算:$.math(+10)、$.pow2()。
  • 四舍五入:
    • $.round()。
    • $.floor()。
    • $.ceil()。
  • 函数:
    • 绝对值:$.abs()。
    • 平方根:$.sqrt()。

日期操作

  • 格式化:$.format('YYYY-MM-DD')。
  • 检查:
    • 是否为今天:$.isToday()。
  • 修改:$.add(1, 'days')。

聚合操作

  • 分组:$.groupBy(category)。
  • 统计:
    • 求和:$.sum(price)。
    • 平均值:$.avg(price)。
    • 最小值:$.min(price)。
    • 最大值:$.max(price)。

📚 详细文档

配置

与 Claude Desktop 使用

若要在 Claude Desktop 应用中使用此服务器,请将以下配置添加到你的 claude_desktop_config.json 文件:

{
"config": {
"@gongrzhe/server-json-mcp@1.0.3": {
// 配置选项
}
}
}

开发

若要从源代码构建,请执行以下步骤:

  1. 克隆仓库:
git clone https://github.com/your-username/your-repository.git
cd your-repository
  1. 安装依赖:
npm install
  1. 构建项目:
npm run build

⚠️ 重要提示

  • 请确保安装正确版本的依赖。
  • 在生产环境中使用前,请进行全面测试。
  • 0 关注
  • 0 收藏,109 浏览
  • system 提出于 2025-09-21 14:12

相似服务问题

相关AI产品