Token导航 LogoToken导航TokenDH.com
Fetch JSONPath MCP logo
AI代理stdio官方级别未说明来源级核验

Fetch JSONPath MCP

MCP Server

一个用于从URL获取JSON数据和网页内容的工具,支持JSONPath模式提取和智能文本提取,旨在减少LLM令牌使用和幻觉。

工具数

0

提示词数

0

GitHub Stars

2

资源数

0
令牌优化PythonClaude浏览器自动化ClaudeCursorWindsurfVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

ackness

提供方

ackness

最后核验

2026/5/17 20:23

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run demo-server

详细介绍

获取JSONPath MCP

](https://pypi.org/project/fetch-jsonpath-mcp/) ![简体中文](./docs/README.zh-CN.md)

一种模型上下文协议(MCP)服务器,提供从URL获取JSON数据和web内容的工具。具有智能内容提取、多种HTTP方法和类似浏览器的标头,可实现可靠的web抓取。

🎯 为什么使用这个?

减少LLM代币的使用和幻觉 -与其获取整个JSON响应并浪费令牌,不如只提取所需的数据。

传统提取与JSONPath提取

❌ 传统获取(浪费):

// API returns 2000+ tokens
{
  "data": [
    {
      "id": 1,
      "name": "Alice",
      "email": "alice@example.com", 
      "avatar": "https://...",
      "profile": {
        "bio": "Long bio text...",
        "settings": {...},
        "preferences": {...},
        "metadata": {...}
      },
      "posts": [...],
      "followers": [...],
      "created_at": "2023-01-01",
      "updated_at": "2024-01-01"
    },
    // ... 50 more users
  ],
  "pagination": {...},
  "meta": {...}
}

✅ JSONPath提取(高效):

// Only 10 tokens - exactly what you need!
["Alice", "Bob", "Charlie"]

使用模式: data[*].name 保存 99%代币 并从无关数据中消除模型幻觉。

安装

对于大多数IDE,使用 uvx 运行服务器的工具。

{
  "mcpServers": {
    "fetch-jsonpath-mcp": {
      "command": "uvx",
      "args": [
        "fetch-jsonpath-mcp"
      ]
    }
  }
}

Install in Claude Code

claude mcp add fetch-jsonpath-mcp -- uvx fetch-jsonpath-mcp

Install in Cursor

{
  "mcpServers": {
    "fetch-jsonpath-mcp": {
      "command": "uvx",
      "args": ["fetch-jsonpath-mcp"]
    }
  }
}

Install in Windsurf

将此添加到您的Windsurf MCP配置文件中。看 Windsurf MCP文件 了解更多信息。

Windsurf本地服务器连接

{
  "mcpServers": {
    "fetch-jsonpath-mcp": {
      "command": "uvx",
      "args": ["fetch-jsonpath-mcp"]
    }
  }
}

Install in VS Code

"mcp": {
  "servers": {
    "fetch-jsonpath-mcp": {
      "type": "stdio",
      "command": "uvx",
      "args": ["fetch-jsonpath-mcp"]
    }
  }
}

开发设置

1.安装依赖项

uv sync

2.启动演示服务器(可选)

# Install demo server dependencies
uv add fastapi uvicorn

# Start demo server on port 8080
uv run demo-server

3.运行MCP服务器

uv run fetch-jsonpath-mcp

演示服务器数据

演示服务器位于 http://localhost:8080 返回:

{
  "foo": [{"baz": 1, "qux": "a"}, {"baz": 2, "qux": "b"}],
  "bar": {
    "items": [10, 20, 30], 
    "config": {"enabled": true, "name": "example"}
  },
  "metadata": {"version": "1.0.0"}
}

可用工具

fetch-json

使用支持所有HTTP方法的JSONPath模式提取JSON数据。

{
  "name": "fetch-json",
  "arguments": {
    "url": "http://localhost:8080",
    "pattern": "foo[*].baz",
    "method": "GET"
  }
}

退货: [1, 2]

参数:

  • url (必填):目标URL
  • pattern (可选):用于数据提取的JSONPath模式
  • method (可选):HTTP方法(GET、POST、PUT、DELETE等)-默认值:“GET”
  • data (可选):POST/PUT请求的请求体
  • headers (可选):其他HTTP标头

fetch-text

通过智能文本提取获取网络内容。 默认为Markdown格式 为了更好的可读性。

{
  "name": "fetch-text",
  "arguments": {
    "url": "http://localhost:8080",
    "output_format": "clean_text"
  }
}

返回:JSON数据的纯文本表示

输出格式:

  • "markdown" (默认):将HTML转换为干净的Markdown格式
  • "clean_text":删除HTML标签的纯文本
  • "raw_html":原始HTML内容

参数:

  • url (必填):目标URL
  • method (可选):HTTP方法-默认值:“GET”
  • data (可选):POST/PUT请求的请求体
  • headers (可选):其他HTTP标头
  • output_format (可选):输出格式-默认值:“markdown”

batch-fetch-json

同时处理具有不同JSONPath模式的多个URL。

{
  "name": "batch-fetch-json",
  "arguments": {
    "requests": [
      {"url": "http://localhost:8080", "pattern": "foo[*].baz"},
      {"url": "http://localhost:8080", "pattern": "bar.items[*]"}
    ]
  }
}

退货: [{"url": "http://localhost:8080", "pattern": "foo[*].baz", "success": true, "content": [1, 2]}, {"url": "http://localhost:8080", "pattern": "bar.items[*]", "success": true, "content": [10, 20, 30]}]

请求对象参数:

  • url (必填):目标URL
  • pattern (可选):JSONPath模式
  • method (可选):HTTP方法-默认值:“GET”
  • data (可选):请求正文
  • headers (可选):其他HTTP标头

batch-fetch-text

通过智能文本提取从多个URL获取内容。

{
  "name": "batch-fetch-text",
  "arguments": {
    "requests": [
      "http://localhost:8080",
      {"url": "http://localhost:8080", "output_format": "raw_html"}
    ],
    "output_format": "markdown"
  }
}

退货: [{"url": "http://localhost:8080", "success": true, "content": "# Demo Server Data\n\n..."}, {"url": "http://localhost:8080", "success": true, "content": "{\"foo\": [{\"baz\": 1, \"qux\": \"a\"}, {\"baz\": 2, \"qux\": \"b\"}]..."}]

支持:

  • 简单URL字符串
  • 具有自定义方法和标头的完整请求对象
  • 同一批次中的混合输入类型

JSONPath示例

此项目使用 Jsonpath螺母 用于JSONPath实现。

模式结果描述
foo[*].baz[1, 2]获取所有baz值
bar.items[*][10, 20, 30]获取所有项目
metadata.version["1.0.0"]获取版本

有关完整的JSONPath语法参考,请参阅 jsonpath ng文档.

🚀 性能优势

  • 代币效率:仅提取所需数据,而不是整个JSON响应
  • 更快的处理速度:更小的有效载荷=更快的LLM响应
  • 减少幻觉:更少的无关数据=更准确的输出
  • 成本节约:更少的代币=更低的API成本
  • 更专注:干净的数据有助于模型保持任务
  • 智能标头:默认浏览器标头可防止阻止并改善访问
  • Markdown转换:保持结构清晰可读的格式

配置

设置环境变量以自定义行为:

# Request timeout in seconds (default: 10.0)
export JSONRPC_MCP_TIMEOUT=30

# SSL verification (default: true)
export JSONRPC_MCP_VERIFY=false

# Follow redirects (default: true)
export JSONRPC_MCP_FOLLOW_REDIRECTS=true

# Custom headers (will be merged with default browser headers)
export JSONRPC_MCP_HEADERS='{"Authorization": "Bearer token"}'

# HTTP proxy configuration
export JSONRPC_MCP_PROXY="http://proxy.example.com:8080"

默认浏览器标题:服务器会自动包含逼真的浏览器标头以防止阻塞:

  • 用户代理:Chrome浏览器模拟
  • 接受:标准浏览器内容类型
  • 接受语言,接受编码:浏览器默认值
  • 安全标头:适用于现代浏览器的Sec Fetch-\*标头

自定义标题 JSONRPC_MCP_HEADERS 当发生冲突时,将覆盖默认值。

发展

# Run tests
pytest

# Check code quality
ruff check --fix

# Build and test locally
uv build

v1.1.0的新增功能

  • 多方法HTTP支持:获取、发布、放置、删除、补丁、头部、选项
  • 🔄 工具重命名: get-jsonfetch-json, get-textfetch-text
  • 📄 Markdown转换:默认HTML到Markdown转换 markdownify
  • 🌐 智能浏览器标题:自动浏览器模拟标题
  • 🎛️ 格式控制:文本内容的三种输出格式(markdown、clean_text、raw_html)
  • 🚀 增强的批处理:支持批量操作中的不同方法

目录标签

目录标签

令牌优化PythonClaude浏览器自动化JSONPath本地部署数据提取网页抓取LLM集成

支持客户端

ClaudeCursorWindsurfVS Code

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

token

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiotoken部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP