Skip to main content
Glama

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 查询的结果作为字符串

Related MCP server: mcp-registry-server

安装

通过 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 文件。

Install Server
A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thirdstrandstudio/mcp-xpath'

If you have feedback or need assistance with the MCP directory API, please join our Discord server