Skip to content

perf(plugin-mcp): minify JSON in MCP tool responses#15598

Open
jhb-dev wants to merge 1 commit intopayloadcms:mainfrom
jhb-dev:feat/plugin-mcp/minify-json-responses
Open

perf(plugin-mcp): minify JSON in MCP tool responses#15598
jhb-dev wants to merge 1 commit intopayloadcms:mainfrom
jhb-dev:feat/plugin-mcp/minify-json-responses

Conversation

@jhb-dev
Copy link
Contributor

@jhb-dev jhb-dev commented Feb 11, 2026

What?

Replaces JSON.stringify(result, null, 2) with JSON.stringify(result) in all MCP tool response handlers — resource CRUD, global find/update, auth tools, and job run.

Why?

MCP tool responses are consumed by AI agents, not humans. Pretty-printed JSON with 2-space indentation adds significant whitespace overhead that inflates response size without benefit. For rich-text-heavy documents, this reduces MCP response payload size by ~50%.

How?

  • Changed all JSON.stringify(x, null, 2) calls to JSON.stringify(x) in MCP tool response code (12 source files)
  • Code-generation files (config.ts, job/create.ts) are intentionally unchanged — they produce human-readable source files
  • Updated existing test assertions to match minified format ("key":"value" instead of "key": "value")
  • Added dedicated Minified JSON responses test suite verifying JSON blocks contain no indentation and are valid JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants