From 43bef9a202d59b39401c1f2c258a842351dbd7e0 Mon Sep 17 00:00:00 2001 From: corvid-agent <0xOpenBytes@gmail.com> Date: Fri, 20 Feb 2026 09:39:23 -0700 Subject: [PATCH 1/2] feat(express): add jsonBodyLimit option to createMcpExpressApp Allow configuring the maximum request body size for the JSON body parser via a new `jsonBodyLimit` option. This is needed when MCP payloads exceed Express's default 100kb limit. Closes #1354 Co-Authored-By: Claude Opus 4.6 --- packages/middleware/express/src/express.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/middleware/express/src/express.ts b/packages/middleware/express/src/express.ts index ff23cde85..f82a483b5 100644 --- a/packages/middleware/express/src/express.ts +++ b/packages/middleware/express/src/express.ts @@ -22,6 +22,13 @@ export interface CreateMcpExpressAppOptions { * to restrict which hostnames are allowed. */ allowedHosts?: string[]; + + /** + * Controls the maximum request body size for the JSON body parser. + * Accepts a number (bytes) or a string (e.g., '1mb', '500kb'). + * Defaults to Express's built-in default of '100kb' if not specified. + */ + jsonBodyLimit?: string | number; } /** @@ -48,10 +55,10 @@ export interface CreateMcpExpressAppOptions { * ``` */ export function createMcpExpressApp(options: CreateMcpExpressAppOptions = {}): Express { - const { host = '127.0.0.1', allowedHosts } = options; + const { host = '127.0.0.1', allowedHosts, jsonBodyLimit } = options; const app = express(); - app.use(express.json()); + app.use(express.json(jsonBodyLimit !== undefined ? { limit: jsonBodyLimit } : {})); // If allowedHosts is explicitly provided, use that for validation if (allowedHosts) { From 729096c12a06e0dbc86f1e33fd6a6d5ed9310473 Mon Sep 17 00:00:00 2001 From: corvid-agent <0xOpenBytes@gmail.com> Date: Thu, 26 Feb 2026 00:12:32 -0700 Subject: [PATCH 2/2] fix(lint): invert ternary to satisfy unicorn/no-negated-condition Co-Authored-By: Claude Opus 4.5 --- packages/middleware/express/src/express.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/middleware/express/src/express.ts b/packages/middleware/express/src/express.ts index f82a483b5..ff340a551 100644 --- a/packages/middleware/express/src/express.ts +++ b/packages/middleware/express/src/express.ts @@ -58,7 +58,7 @@ export function createMcpExpressApp(options: CreateMcpExpressAppOptions = {}): E const { host = '127.0.0.1', allowedHosts, jsonBodyLimit } = options; const app = express(); - app.use(express.json(jsonBodyLimit !== undefined ? { limit: jsonBodyLimit } : {})); + app.use(express.json(jsonBodyLimit === undefined ? {} : { limit: jsonBodyLimit })); // If allowedHosts is explicitly provided, use that for validation if (allowedHosts) {