Xpath

Xpath

未知

smithery 徽章

概述

XPath MCP 服务器允许您在 XML/HTML 内容上执行 XPath 查询。

功能

  • xpath: 查询 XML/HTML 字符串
  • xpathwithurl: 从 URL 获取并查询内容

安装

通过 Smithery 安装 (推荐)

npx -y @smithery/cli install @JayArrowz/mcp-xpath --client claude

手动安装

# 克隆仓库后
npm install
npm run build

配置

claude_desktop_config.json 中添加:

{
  "mcpServers": {
    "xpath": {
      "command": "npx",
      "args": [
        "@jayarrowz/mcp-xpath"
      ]
    }
  }
}

使用示例

查询 XML 字符串

const result = await callTool("xpath", {
  xml: "<root><item>value1</item><item>value2</item></root>",
  query: "//item/text()",
  mimeType: "text/xml"
});

查询 URL 内容

const result = await callTool("xpathwithurl", {
  url: "https://example.com",
  query: "//a/@href",
  mimeType: "text/html"
});

工具参数

xpath

  • xml: XML/HTML 字符串
  • query: XPath 查询表达式
  • mimeType: (可选) 内容类型

xpathwithurl

  • url: 要获取的 URL
  • query: XPath 查询表达式
  • mimeType: (可选) 内容类型

许可证

MIT