Jsonaut
JSON repair & validation MCP server for AI agents: fixes malformed JSON (trailing commas, truncation, etc.) and validates/coerces against a JSON Schema, with deterministic free tier and paid LLM-fallback.
README
Jsonaut
JSON repair & validation built for AI agents as the customer. Send possibly-malformed JSON (LLM tool-call output, another agent's message, a flaky upstream), get back parsed, schema-valid JSON.
- Free tier: deterministic repair — trailing commas, single quotes, truncation, markdown code fences, comments, Python literals — plus JSON Schema validation with type coercion (string→number, defaults, stripping hallucinated fields). Rate-limited per IP.
- Paid tier: LLM-fallback repair for inputs the deterministic pass can't fix. $0.01/call, charged only on success, paid autonomously per-call via x402 (USDC on Base) — no accounts, no signup.
Business context, market research, and the full 3-day plan live in IDEA.md and PLAN.md.
Quickstart
npm install
npm test # 27 tests: repair battery, schema coercion, HTTP API, MCP protocol
npm run dev # http://localhost:8787 — demo page + API + MCP endpoint
Try it:
curl -s -X POST http://localhost:8787/v1/repair \
-H "content-type: application/json" \
-d "{\"input\": \"{'name': 'alice', 'count': '42',}\", \"schema\": {\"type\":\"object\",\"properties\":{\"count\":{\"type\":\"number\"}}}}"
{
"valid": true,
"repaired": { "name": "alice", "count": 42 },
"method": "deterministic-repair",
"changes": ["repaired JSON syntax (jsonrepair)", "$.count: coerced string \"42\" to number"]
}
API
| Route | What it does |
|---|---|
POST /v1/repair |
Repair + optional schema validation/coercion. Body: {input, schema?, allow_llm_fallback?} |
POST /v1/validate |
Validate only, no repair. Body: {input, schema} |
POST /mcp |
MCP server (Streamable HTTP, stateless). Tools: repair_json, validate_json |
GET / |
Interactive demo page |
GET /llms.txt |
Agent-readable capability + pricing description |
GET /openapi.yaml |
OpenAPI 3.1 spec |
Response method values: direct (was already valid), deterministic-repair (free fix), llm-repair (paid fix), failed. changes[] lists every modification so callers can audit what was done to their data.
Using it from an agent (MCP)
claude mcp add --transport http jsonaut https://YOUR-DEPLOYMENT/mcp
Or in any MCP client config:
{ "mcpServers": { "jsonaut": { "type": "http", "url": "https://YOUR-DEPLOYMENT/mcp" } } }
For the paid tier, clients pay via x402 and retry with the X-PAYMENT header (the payment receipt). No accounts or API keys — agents pay per call.
Payment flow (x402)
- Agent calls
/v1/repairwithallow_llm_fallback: true; deterministic repair fails. - Server responds
402with an x402acceptsarray (USDC on Base, amount =PRICE_USD). - Agent pays and retries with the
X-PAYMENTheader; server verifies via the facilitator, runs the LLM repair, and settles only if the repair succeeds.
Configuration
| Env var | Purpose | Required for |
|---|---|---|
OPENROUTER_API_KEY |
Enables the paid LLM-fallback tier (via OpenRouter; free model by default) | Paid tier |
OPENROUTER_MODEL |
Override the model (default meta-llama/llama-3.3-70b-instruct:free) |
— |
X402_PAY_TO |
Wallet address on Base receiving USDC | x402 rail |
X402_NETWORK |
base or base-sepolia (default base) |
x402 rail |
FACILITATOR_URL |
x402 facilitator for verify/settle | x402 rail |
FREE_DAILY_LIMIT |
Free calls per IP per day (default 100) | — |
PRICE_USD |
Paid-tier price (default 0.01) | — |
DEV_ALLOW_FREE_LLM |
true opens the paid tier for local dev only |
— |
Local dev secrets go in a .dev.vars file (git-ignored) or your shell env.
Deployment (Cloudflare Workers)
npx wrangler login
npx wrangler kv namespace create KV # then paste the id into wrangler.toml
npx wrangler secret put OPENROUTER_API_KEY
npx wrangler deploy
The same codebase runs on Node for local dev (npm run dev) and on Workers in production — storage falls back to in-memory when no KV binding exists.
Project structure
src/core/ pipeline.ts (repair engine) · coerce.ts (schema coercion) · llm.ts (paid tier)
src/http/ app.ts (routes) · payment.ts (x402 rail) · ratelimit.ts · demo.ts · billing.ts (parked, unused)
src/mcp/ server.ts (stateless Streamable HTTP MCP server)
src/worker.ts Cloudflare Workers entry
src/dev.ts Node dev entry
test/ full battery: broken-JSON cases, coercion, HTTP, MCP protocol
Known limitations (MVP)
- Schema coercion does not resolve
$reforoneOf/anyOfbranches. - x402 verification requires an external facilitator (
FACILITATOR_URL); there is no on-chain verification built in. - Free-tier rate limiting is approximate under high concurrency (KV read-modify-write).
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。