Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/middleware/express/src/express.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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) {
Expand Down
Loading