The XPath MCP Server acts like a high-precision search tool for structured documents. Instead of forcing an AI to read through a whole mess of computer code or massive data files, this tool allows it to pinpoint and extract exactly what it needs from an XML or HTML file. It serves as a bridge that lets AI assistants look at a webpage or a data document and pull out only the relevant bits, such as specific product prices, headlines, or links, without getting bogged down by the surrounding "noise." For developers, this server provides two primary functions: `xpath` and `xpathwithurl`. The first tool processes raw XML or HTML content provided directly in a prompt, while the second can actively visit a live website to fetch and analyze content on the fly. By supporting various MIME types—including standard XML, XHTML, and even traditional HTML—it ensures that the data returned to the model is clean, structured, and ready for immediate processing. This precision is a significant advantage for building sophisticated LLM workflows because it helps manage the "context window" more effectively. Rather than forcing an AI to ingest several kilobytes of raw, messy HTML, a developer can use this server to retrieve only the specific data nodes required. This leads to faster response times, lower token costs, and much higher accuracy when the AI is performing tasks like web scraping, data mining, or navigating complex technical documentation.
Category: Browser & Web Automation
Tags: data-extraction, html, web scraping, xml, xpath
bash npx -y @smithery/cli install @thirdstrandstudio/mcp-xpath --client claude Manual Installation (Local Build): bash # Install dependencies npm install # Build the package npm run build ---claude_desktop_config.json file using one of the following methods:json { "mcpServers": { "xpath": { "command": "npx", "args": [ "@thirdstrandstudio/mcp-xpath" ] } } }/path/to/mcp-xpath with the actual path to your repository. json { "mcpServers": { "xpath": { "command": "node", "args": [ "/path/to/mcp-xpath/dist/index.js" ] } } } ---xpath: Query XML content using XPath expressions. * 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). * xpathwithurl: Fetch content from a URL and query it using XPath expressions. * url (string): The URL to fetch XML/HTML content from. * query (string): The XPath query to execute. * mimeType (optional, string): The MIME type. ---<item> elements from this XML: <root><item>value1</item><item>value2</item></root> using the query //item/text()." * "Find all links in this HTML snippet: <html><body><a href='link1.html'>Link 1</a></body></html> using the query //a/@href." Querying content from a URL: * "Get all the links from https://example.com using the XPath query //a/@href with the text/html mimeType."xpathwithurl tool allows an AI to fetch a webpage and extract only the precise data point needed by targeting its specific XPath. This reduces token usage and provides immediate, structured answers. Example: An AI agent is tasked with checking a competitor's website for a specific price. It uses xpathwithurl with the URL and a query like `/span[contains(@class, 'price-amount')]/text()` to return only the numerical price value.
pom.xml, Android AndroidManifest.xml, or enterprise service configurations. Manually searching for a specific dependency version or a nested setting in a 1,000-line file is error-prone and slow. Solution: By using the xpath tool, a developer can provide the XML content to the AI and ask it to find specific values using structured queries. The AI can programmatically verify settings or extract lists of dependencies. Example: "Find the version of the 'spring-core' dependency in this XML." The AI executes `/dependency[artifactId='spring-core']/version/text()` to retrieve the exact string instantly.
xpathwithurl, the AI can act as an automated auditor. It can crawl a provided URL and specifically pull out SEO-relevant tags to report on their presence or content. Example: A user asks, "Does this blog post have a proper meta description and an H1 title?" The AI runs two queries: `/meta[@name='description']/@contentand//h1/text()` to provide a concise report.
Part of MCP Servers