-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Unable to use async callbacks for tools/resources with Streamable HTTP transport.
To Reproduce
Steps to reproduce the behavior:
const transport = new StreamableHTTPServerTransport({
sessionIdGenerator: () => randomUUID(),
onsessioninitialized: (sessionId) => {
transports[sessionId] = transport;
},
});
transport.onclose = () => {
if (transport.sessionId) {
delete transports[transport.sessionId];
}
};
const server = new McpServer({
name: mcpService.name,
version: "1.0.0",
description: mcpService.description,
});
server.registerTool(
tool.tool_name,
{
title: tool.tool_name,
description: tool.tool_description,
inputSchema: this.convertJsonSchemaToZod(inputSchema),
},
async (args) => {
// some async action
const res = await xxx;
return {
content: [{ type: "text", text: "test" }],
};
}
);
await server.connect(transport);
await transport.handleRequest(req, res, body);But in result, i got the following errors: Error MCP error -32001: Request timed out
But when i delete the async action in callback function, all things are going well.....
Expected behavior
Allows to use async logic inside callbacks.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working