Navigation
Xpath: Surgical Precision Extraction | Effortless Web Navigation - MCP Implementation

Xpath: Surgical Precision Extraction | Effortless Web Navigation

Xpath: Master complex data extraction with surgical precision. Effortlessly navigate even the trickiest web structures. Your workflow’s new game-changer!

Developer Tools
4.5(177 reviews)
265 saves
123 comments

This tool saved users approximately 11617 hours last month!

About Xpath

What is Xpath: Surgical Precision Extraction | Effortless Web Navigation?

Xpath is a query language designed for navigating and extracting data from XML and HTML documents with unparalleled precision. The MCP Server implementation enhances this capability by providing a streamlined interface for developers to execute XPath queries programmatically. Think of it as a digital scalpel: precise enough to isolate specific nodes in complex documents while remaining user-friendly enough for routine web scraping tasks.

How to use Xpath: Surgical Precision Extraction | Effortless Web Navigation?

Integration follows a two-step process. Firstly, install the server via Smithery using the dedicated CLI command, ensuring dependencies are properly resolved. Once installed, configure your environment by adding server parameters to your claude_desktop_config.json. For instance:


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

Queries can then be executed dynamically using either direct XML input or URL-based fetch operations, as demonstrated in the provided examples.

Xpath Features

Key Features of Xpath: Surgical Precision Extraction | Effortless Web Navigation?

  • Context-Aware Execution: Supports both static XML parsing and dynamic URL fetching through distinct tools (xpath and xpathwithurl), accommodating real-time data requirements.
  • MIME-Type Flexibility: Automatically handles content negotiation via optional MIME parameters, ensuring compatibility with XML, HTML, and XHTML formats.
  • Atomic Results: Returns query results as clean strings, eliminating boilerplate parsing logic for consumers.

These features make it ideal for scenarios requiring both precision and agility, such as extracting product prices from e-commerce pages or aggregating metadata from syndicated feeds.

Use cases of Xpath: Surgical Precision Extraction | Effortless Web Navigation?

Consider a newsletter aggregator needing to extract <title> elements from RSS feeds:


const feedData = await callTool("xpath", {
  xml: rssContent,
  query: "//item/title/text()",
  mimeType: "application/rss+xml"
});
  

Or a pricing scraper fetching live data:


const productPrices = await callTool("xpathwithurl", {
  url: "https://example-store.com/pricing",
  query: "//div[@class='price']/@data-value",
  mimeType: "text/html"
});
  

Xpath FAQ

FAQ from Xpath: Surgical Precision Extraction | Effortless Web Navigation?

Does the server support XPath 3.0 functions?

Currently supports core XPath 1.0 functionality. Advanced features like fn:format-date() may require custom extensions.

How is error handling implemented?

Invalid queries return standardized error objects with descriptive messages, simplifying debugging workflows.

Is there a rate limiter for URL requests?

No built-in throttling, but developers can implement concurrency controls via upstream request managers.

Content

XPath MCP Server

MCP Server for executing XPath queries on XML content.

image

smithery badge

Tools

  1. xpath
* Query XML content using XPath expressions
* Inputs: 
  * `xml` (string): The XML content to query
  * `query` (string): The XPath query to execute
  * `mimeType` (optional, string): The MIME type (e.g. text/xml, application/xml, text/html, application/xhtml+xml)
* Returns: The result of the XPath query as a string
  1. xpathwithurl
* Fetch content from a URL and query it using XPath expressions
* Inputs: 
  * `url` (string): The URL to fetch XML/HTML content from
  * `query` (string): The XPath query to execute
  * `mimeType` (optional, string): The MIME type (e.g. text/xml, application/xml, text/html, application/xhtml+xml)
* Returns: The result of the XPath query as a string

Installation

Installing via Smithery

To install mcp-xpath for Claude Desktop automatically via Smithery:

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



# Install dependencies
npm install

# Build the package
npm run build

Setup

Usage with Claude Desktop

Add the following to your claude_desktop_config.json:

npx

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

Direct Node.js

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

Replace /path/to/mcp-xpath with the actual path to your repository.

Examples

Query XML content

// 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"
});

Query HTML content

// 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"
});

Query URL content

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

Development

# Install dependencies
npm install

# Start the server in development mode
npm start

License

This MCP server is licensed under the MIT License. This means you are free to use, modify, and distribute the software, subject to the terms and conditions of the MIT License. For more details, please see the LICENSE file in the project repository.

Related MCP Servers & Clients