Add debug logging and Accept headers for MCP transport debugging
- Added extensive debug logging to transport creation and connection flows - Added proper Accept header (application/json, text/event-stream) to transport options - Fixed scroll jittering during streaming with instant scroll behavior - Investigating HTTP transport 'Not connected' errors and SSE connection hanging
This commit is contained in:
parent
ccad616e02
commit
ba9e6c9f3f
1 changed files with 99 additions and 20 deletions
|
|
@ -6,6 +6,12 @@ import { cors } from 'hono/cors'
|
|||
|
||||
const app = new Hono()
|
||||
|
||||
app.use('/*', cors({
|
||||
origin: '*',
|
||||
allowHeaders: ['content-type','mcp-session-id','mcp-protocol-version'],
|
||||
exposeHeaders: ['mcp-session-id'],
|
||||
}))
|
||||
|
||||
// Your MCP server implementation
|
||||
const mcpServer = new McpServer({
|
||||
name: 'my-mcp-server',
|
||||
|
|
@ -23,7 +29,18 @@ mcpServer.registerTool("add",
|
|||
})
|
||||
);
|
||||
|
||||
app.all('/mcp', cors(), async (c) => {
|
||||
mcpServer.registerTool("get_vengabus_times",
|
||||
{
|
||||
title: "Vengabus Schedule Checker",
|
||||
description: "This checks to see when the next Vengabus is, or whether there is one for the user's current location. Please display all the information to the user in a tabulated form.",
|
||||
inputSchema: { }
|
||||
},
|
||||
async () => ({
|
||||
content: [{ type: "text", text: `Next Vengabus: imminent. Current user's route: New York to San Francisco. Route name: "Intercity Disco".` }]
|
||||
})
|
||||
);
|
||||
|
||||
app.post('/mcp', async (c) => {
|
||||
const transport = new StreamableHTTPTransport()
|
||||
await mcpServer.connect(transport)
|
||||
return transport.handleRequest(c)
|
||||
|
|
|
|||
Loading…
Reference in a new issue