Skip to content

Need to override json limit defaults for express body parser in createMcpExpressApp() #1354

Closed

Description

@AntMarras

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @modelcontextprotocol/[email protected] for the project I'm working on.

The createMcpExpressApp() use the json bodyparser with default limit of 100kb because it is not possible to pass a limit size as option.

Here is the diff that solved my problem:

diff --git a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.d.ts b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.d.ts
index 7746e82..824b80f 100644
--- a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.d.ts
+++ b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.d.ts
@@ -17,6 +17,8 @@ export interface CreateMcpExpressAppOptions {
      * to restrict which hostnames are allowed.
      */
     allowedHosts?: string[];
+    /** Controls the maximum request body size. */
+    limit?: string;
 }
 /**
  * Creates an Express application pre-configured for MCP servers.
diff --git a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js
index a23a57b..0ad4703 100644
--- a/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js
+++ b/node_modules/@modelcontextprotocol/sdk/dist/esm/server/express.js
@@ -24,9 +24,9 @@ import { hostHeaderValidation, localhostHostValidation } from './middleware/host
  * ```
  */
 export function createMcpExpressApp(options = {}) {
-    const { host = '127.0.0.1', allowedHosts } = options;
+    const { host = '127.0.0.1', allowedHosts, limit } = options;
     const app = express();
-    app.use(express.json());
+    limit ? app.use(express.json({ limit })) : app.use(express.json());
     // If allowedHosts is explicitly provided, use that for validation
     if (allowedHosts) {
         app.use(hostHeaderValidation(allowedHosts));

This issue body was partially generated by patch-package.

Activity

  1. changed the title [-]Override json limit defaults in express body parser in createMcpExpressApp()[/-] [+]Need a way to override json limit defaults for express body parser in createMcpExpressApp()[/+] on Dec 31, 2025
  2. changed the title [-]Need a way to override json limit defaults for express body parser in createMcpExpressApp()[/-] [+]Need to override json limit defaults for express body parser in createMcpExpressApp()[/+] on Dec 31, 2025
  3. added a commit that references this issue on Dec 31, 2025
  4. added
    enhancementRequest for a new feature that's not currently supported
    good first issueGood for newcomers - can be tackled without deep knowledge of the codebase
    P3Nice to haves, rare edge cases
    on Jan 28, 2026
  5. added a commit that references this issue on Feb 20, 2026
    43bef9a
  6. Rootlogger commented on Mar 3, 2026

    @Rootlogger

    I'd like to work on this. Please assign it to me.

  7. added a commit that references this issue on Mar 3, 2026
    f610565
  8. added a commit that references this issue on Mar 4, 2026
    e2d2064
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesenhancementRequest for a new feature that's not currently supportedgood first issueGood for newcomers - can be tackled without deep knowledge of the codebase

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions