@modelcontextprotocol/sdk
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -32,3 +32,3 @@ import { IncomingMessage, ServerResponse } from "node:http"; | ||
*/ | ||
handlePostMessage(req: IncomingMessage, res: ServerResponse): Promise<void>; | ||
handlePostMessage(req: IncomingMessage, res: ServerResponse, parsedBody?: unknown): Promise<void>; | ||
/** | ||
@@ -35,0 +35,0 @@ * Handle a client message, regardless of how it arrived. This can be used to inform the server of messages that arrive via a means different than HTTP POST. |
@@ -48,3 +48,3 @@ import { randomUUID } from "node:crypto"; | ||
*/ | ||
async handlePostMessage(req, res) { | ||
async handlePostMessage(req, res, parsedBody) { | ||
var _a, _b, _c; | ||
@@ -62,3 +62,3 @@ if (!this._sseResponse) { | ||
} | ||
body = await getRawBody(req, { | ||
body = parsedBody !== null && parsedBody !== void 0 ? parsedBody : await getRawBody(req, { | ||
limit: MAXIMUM_MESSAGE_SIZE, | ||
@@ -74,3 +74,3 @@ encoding: (_b = ct.parameters.charset) !== null && _b !== void 0 ? _b : "utf-8", | ||
try { | ||
await this.handleMessage(JSON.parse(body)); | ||
await this.handleMessage(typeof body === 'string' ? JSON.parse(body) : body); | ||
} | ||
@@ -77,0 +77,0 @@ catch (_d) { |
@@ -135,3 +135,3 @@ import { CancelledNotificationSchema, ErrorCode, McpError, PingRequestSchema, ProgressNotificationSchema, } from "../types.js"; | ||
_onprogress(notification) { | ||
const { progress, total, progressToken } = notification.params; | ||
const { progressToken, ...params } = notification.params; | ||
const handler = this._progressHandlers.get(Number(progressToken)); | ||
@@ -142,3 +142,3 @@ if (handler === undefined) { | ||
} | ||
handler({ progress, total }); | ||
handler(params); | ||
} | ||
@@ -145,0 +145,0 @@ _onresponse(response) { |
{ | ||
"name": "@modelcontextprotocol/sdk", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Model Context Protocol implementation for TypeScript", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1661074