Skip to main content
Glama

XML XPath query

xml_query
Read-onlyIdempotent

Run XPath 1.0 queries on XML to extract matching nodes, attributes, text, numbers, strings, or booleans, with namespace support and optional result limits.

Instructions

Run an XPath 1.0 expression on XML: node-sets (elements, attributes, text…), numbers (count(), sum()), strings and booleans. Full XPath 1.0: all axes, predicates, operators and the core function library. Namespace prefixes declared anywhere in the document can be used as-is; a default namespace on the root gets the prefix "d" (e.g. //d:book), as on the website. Each matched node comes back as XML text plus its type, name and XPath location. Web version: https://s3eidat.github.io/xml-format/

Input Schema

NameRequiredDescriptionDefault
pathNoOr: a path to a XML file (UTF-8; use this for big inputs).
textNoThe XML as inline text.
limitNoReturn at most this many nodes (default 1000).
xpathYesXPath 1.0 expression, e.g. "//book[price > 30]/title", "count(//item)", "//d:entry/@id".
namespacesNoExtra or overriding prefix → namespace URI bindings, e.g. {"atom":"http://www.w3.org/2005/Atom"}.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover the safety profile (readOnly, idempotent, closed-world), so the description only needs to add operational context — and it does: it discloses the per-node return shape (XML text plus type, name and XPath location) and the non-obvious namespace rule that a root default namespace is auto-bound to prefix 'd'. It also pins the XPath version to 1.0, which prevents an agent from trying 2.0/3.0 syntax. Minor gaps remain around error behavior for malformed XML.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core capability, then result shape, then the namespace gotcha — the right ordering. The trailing 'Web version:' URL is filler that doesn't help an agent call the tool correctly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With a 5-parameter tool at full schema coverage and no output schema, the description supplies what structure cannot: the shape of each returned node, the namespace defaulting rule, and the XPath version ceiling. An agent has everything needed to construct a working call.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so a 3 is the baseline; the description earns more by explaining namespace resolution semantics that the schema's one-line 'prefix → namespace URI' note does not: in-document prefixes work as-is and the root default namespace is silently remapped to 'd'. That is exactly the detail an agent would otherwise get wrong.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Run an XPath 1.0 expression on XML') and enumerates the result classes (node-sets, numbers, strings, booleans). It never names xml_format or any sibling as the alternative for non-query XML work, so sibling differentiation is left to inference.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied by the mention of count()/sum() and the node examples, which signal the extraction use case. But there is no explicit 'use this when...' guidance, no statement of when xml_format or json_query is the better pick, and no prerequisites (e.g. well-formed XML required).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools