xquery-mcp
1.4.0
dotnet tool install --global xquery-mcp --version 1.4.0
dotnet new tool-manifest
dotnet tool install --local xquery-mcp --version 1.4.0
#tool dotnet:?package=xquery-mcp&version=1.4.0
nuke :add-package xquery-mcp --version 1.4.0
xquery-mcp
An MCP (Model Context Protocol) server that gives AI coding assistants first-class XQuery 3.1 / XQuery 4.0 support: spec lookup, expression and function reference, error-code explanation, and live XQuery/XPath execution against a real engine.
Powered by PhoenixmlDb.XQuery — a .NET XQuery 3.1/4.0 engine with 99.7% QT3 conformance.
What it does
When wired into an MCP-aware client (Claude Code, Claude Desktop, Cursor, Windsurf, etc.), the agent gains tools to:
- Look up any XQuery expression, function, prolog declaration, or error code against the W3C specs.
- Search the spec corpus by keyword.
- Evaluate XQuery 3.1/4.0 expressions and XPath expressions against XML input — no temp files or shelling out.
- Validate XQuery for static errors.
- Explain error codes (e.g.,
XPST0003,FORG0001) with spec citations. - Format & validate XML using a real XML parser and XSD validator.
This means an AI assistant can write XQuery, run it, see the actual result, and self-correct — instead of guessing at syntax from training data that's almost certainly missing XQuery 4.0.
Install
Requires the .NET 10 SDK (or runtime).
dotnet tool install --global xquery-mcp
Upgrade later with dotnet tool update --global xquery-mcp.
Configure your MCP client
Claude Code
claude mcp add xquery xquery-mcp
Or edit ~/.claude.json (or the project-local .mcp.json):
{
"mcpServers": {
"xquery": {
"command": "xquery-mcp"
}
}
}
Claude Desktop / Cursor / Windsurf
Add to the client's MCP config file:
{
"mcpServers": {
"xquery": {
"command": "xquery-mcp"
}
}
}
After restarting the client, the XQuery tools appear in the tool list.
Tools exposed
Spec lookup
| Tool | Purpose |
|---|---|
xquery_lookup_expression |
Look up an XQuery expression (flwor, path, if-then-else, …) |
xquery_lookup_function |
Look up a function (fn:tokenize, map:merge, array:flatten, …) |
xquery_lookup_prolog |
Look up a prolog declaration (namespace-declaration, function-declaration, …) |
xquery_lookup_error_code |
Look up an error code (XPST0003, FORG0001, …) |
xquery_search |
Full-text search across the spec corpus |
xquery_list_expressions |
Enumerate every documented expression |
xquery_list_functions |
Enumerate every documented function |
Execution
| Tool | Purpose |
|---|---|
xquery_evaluate |
Run an XQuery expression (optionally against an XML input) and return the result |
xquery_validate |
Static-validate an XQuery expression |
xquery_explain_error |
Explain an error code with spec context |
xpath_evaluate |
Evaluate an XPath expression against an XML document |
XML utility
| Tool | Purpose |
|---|---|
xml_validate_schema |
Validate an XML document against an XSD |
xml_format |
Pretty-print an XML document |
Specs covered
- XQuery 3.1 — W3C Recommendation
- XQuery 4.0 — W3C Working Draft
- XQuery Update Facility 3.0
- XPath and XQuery Functions and Operators 3.1 / 4.0
Security
xquery_evaluate and xpath_evaluate run user-supplied expressions against a sandboxed engine: DTD processing is disabled, external entity resolution is blocked, and result size is bounded. Suitable for agent-driven exploration; not intended for hosting hostile multi-tenant workloads.
Links
- Source & issues: https://github.com/EndpointSystems/phoenixmldb
- PhoenixmlDb engine: https://phoenixml.dev
- Companion package:
xslt-mcpfor XSLT 3.0/4.0 - License: Apache-2.0
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.
Major release — every execution tool now returns structured JSON instead of plain strings, plus new tools for compile-once-run-many, parameter binding, spec-aware analysis, and MCP discoverability. AI agents can now parse failures and self-correct using source-location-aware errors. Highlights: xquery_compile + xquery_run with SHA256 handle cache and external variable binding; xquery_find_examples with 8 curated working examples (FLWOR, try-catch, window-clause, maps/arrays, update facility, fn:transform, module-import); xquery_suggest_fix with top-10 error-code rules; xquery_compare_versions; xquery_test assertion runner; server_capabilities; 4 MCP prompts for guided workflows; browsable spec corpus via xquery://index resources. Runtime exception handling narrowed to engine-specific types — no more silently swallowed OOM/cancellation. Structured error codes XMCP0001 (unknown handle), XMCP0002 (bad JSON args). See RELEASES.md for the full per-phase changelog.