mcp-xpath

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Offers direct Node.js execution capabilities for the MCP server, with configuration options for connecting the XPath functionality to Node.js environments.

  • Enables execution of XPath queries on XML content, allowing content extraction and transformation from XML documents with support for various MIME types including text/xml and application/xml.

XPath MCP 服务器

MCP 服务器用于对 XML 内容执行 XPath 查询。

工具

  1. xpath
    • 使用 XPath 表达式查询 XML 内容
    • 输入:
      • xml (字符串):要查询的 XML 内容
      • query (字符串):要执行的 XPath 查询
      • mimeType (可选,字符串):MIME 类型(例如 text/xml、application/xml、text/html、application/xhtml+xml)
    • 返回:XPath 查询的结果作为字符串
  2. xpathwithurl
    • 从 URL 获取内容并使用 XPath 表达式进行查询
    • 输入:
      • url (字符串): 获取 XML/HTML 内容的 URL
      • query (字符串):要执行的 XPath 查询
      • mimeType (可选,字符串):MIME 类型(例如 text/xml、application/xml、text/html、application/xhtml+xml)
    • 返回:XPath 查询的结果作为字符串

安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 mcp-xpath:

npx -y @smithery/cli install @thirdstrandstudio/mcp-xpath --client claude
# Install dependencies npm install # Build the package npm run build

设置

与 Claude Desktop 一起使用

将以下内容添加到您的claude_desktop_config.json中:

NPX

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

直接使用 Node.js

{ "mcpServers": { "xpath": { "command": "node", "args": [ "/path/to/mcp-xpath/dist/index.js" ] } } }

/path/to/mcp-xpath替换为您的存储库的实际路径。

示例

查询 XML 内容

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

查询 HTML 内容

// Get all links from HTML const result = await callTool("xpath", { xml: "<html><body><a href='link1.html'>Link 1</a><a href='link2.html'>Link 2</a></body></html>", query: "//a/@href", mimeType: "text/html" });

查询 URL 内容

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

发展

# Install dependencies npm install # Start the server in development mode npm start

执照

此 MCP 服务器采用 MIT 许可证。这意味着您可以自由使用、修改和分发该软件,但须遵守 MIT 许可证的条款和条件。更多详情,请参阅项目仓库中的 LICENSE 文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

用于对 XML 内容执行 XPath 查询的 MCP 服务器

  1. Tools
    1. Installation
      1. Installing via Smithery
    2. Setup
      1. Usage with Claude Desktop
    3. Examples
      1. Query XML content
      2. Query HTML content
      3. Query URL content
    4. Development
      1. License
        ID: wdi74fq55l