Convert between XML and JSON (bidirectional) via @mukundakatta/xml-mcp (npx)
XML is still everywhere: RSS feeds, SOAP APIs, config files (pom.xml, .csproj), SVG, XHTML. When an agent needs to parse XML into a JSON structure it can reason about, or generate XML from structured data, this server handles both directions. Attributes become @_ prefixed keys, repeated elements become arrays.
Recipe: XML↔JSON bidirectional conversion via @mukundakatta/xml-mcp
Server: @mukundakatta/xml-mcp v0.1.0 — backed by fast-xml-parser Launch: npx @mukundakatta/xml-mcp (stdio, zero config, no auth) Tools: to_json (XML string → JSON object), to_xml (JSON object → XML string)
What it does
Parses any XML document into a JSON-compatible object (attributes become @_-prefixed keys, repeated elements become arrays, numeric text is auto-parsed) and serializes JSON objects back to well-formed XML (keys with @_ prefix become XML attributes).
Key parameter gotchas
to_jsontakes{ xml: "<xml>..." }(string)to_xmltakes{ value: { ... } }(NOTjson, the param is calledvalue)- The
?xmlprocessing instruction is preserved as a?xmlkey in the output
Verified traces (6 calls across 5 tests, 100% success)
- XML → JSON (book catalog): Parsed 2-book catalog with id attributes →
{ catalog: { book: [{ author, title, price, @_id: "bk101" }, ...] } }(7ms) - JSON → XML (config):
{ config: { host, port, features: { feature: ["auth","logging"] } } }→ well-formatted XML with arrays as repeated<feature>elements (4ms) - RSS XML → JSON: RSS 2.0 feed with
versionattribute →{ rss: { channel: { title, item: [...] }, @_version: "2.0" } }(3ms) - JSON → XML with @_ attributes:
{ person: { @_id: "42", name: "Alice", address: { @_type: "home", street, city } } }→<person id="42"><address type="home">...</address></person>(2ms) - Round-trip XML → JSON → XML:
<note to="user" from="system">→ JSON → back to identical XML. Lossless. (1ms total)
{ "server": "@mukundakatta/xml-mcp", "version": "0.1.0", "transport": "stdio", "launcher": "npx", "tools": [ { "name": "to_json", "description": "Parse XML and return a JSON-compatible value. Attributes are prefixed with @_.", "schema": { "type": "object", "properties": { "xml": { "type": "string" } }, "required": ["xml"] } }, { "name": "to_xml", "description": "Serialize a JSON object back to XML. Keys starting with @_ become attributes.", "schema": { "type": "object", "properties": { "value": { "type": "object" } }, "required": ["value"] } } ], "traces": [ { "call": { "name": "to_json", "arguments": { "xml": "<catalog><book id="bk101"><author>Gambardella</author><price>44.95</price></book></catalog>" } }, "result": { "value": { "catalog": { "book": { "author": "Gambardella", "price": 44.95, "@_id": "bk101" } } } }, "latency_ms": 7 }, { "call": { "name": "to_xml", "arguments": { "value": { "config": { "host": "localhost", "port": 8080, "debug": true } } } }, "result": "<config><host>localhost</host><port>8080</port><debug>true</debug></config>", "latency_ms": 4 }, { "call": { "name": "to_json", "arguments": { "xml": "<rss version="2.0"><channel><title>News</title><item><title>A</title></item></channel></rss>" } }, "result": { "value": { "rss": { "channel": { "title": "News", "item": { "title": "A" } }, "@_version": "2.0" } } }, "latency_ms": 3 }, { "call": { "name": "to_xml", "arguments": { "value": { "person": { "@_id": "42", "name": "Alice" } } } }, "result": "<person id="42"><name>Alice</name></person>", "latency_ms": 2 }, { "call": { "name": "to_json", "arguments": { "xml": "<note to="user" from="system"><body>Hello</body></note>" } }, "result": { "value": { "note": { "body": "Hello", "@_to": "user", "@_from": "system" } } }, "latency_ms": 1 } ], "total_calls": 6, "success_rate": "100%", "p50_ms": 3 }