Skip to content

basalt / mcp-core/src / dispatchPayload

Function: dispatchPayload() ​

> dispatchPayload(server, payload, ctx?): Promise<JsonRpcResponse | JsonRpcResponse[] | null>

Defined in: mcp-core/src/dispatch.ts:17

Dispatch one decoded JSON-RPC payload — a single message or a batch — to a server. A batch (a JSON array, required by protocol revision 2025-03-26) is answered with an array holding one response per request, in any order; notifications contribute nothing, and a batch of only notifications is answered with null (no reply), exactly like a single notification. An empty array is an invalid request. initialize must not be batched (spec), so it is rejected inside a batch.

Every transport (stdio, serveHttp, the runtime /mcp route) goes through this, so batching behaves the same everywhere.

Parameters ​

server ​

StdioServerLike

payload ​

unknown

ctx? ​

CallContext = {}

Returns ​

Promise<JsonRpcResponse | JsonRpcResponse[] | null>

Released under the MIT License.