Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid transport type specified #165

Open
liu-collab opened this issue Feb 28, 2025 · 0 comments
Open

Invalid transport type specified #165

liu-collab opened this issue Feb 28, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@liu-collab
Copy link

liu-collab commented Feb 28, 2025

Describe the bug

import express from "express";
import {
  McpServer,
  ResourceTemplate,
} from "@modelcontextprotocol/sdk/server/mcp.js";
import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
import { z } from "zod";

const server = new McpServer({
  name: "example-server",
  version: "1.0.0",
});

server.tool("add", { a: z.number(), b: z.number() }, async ({ a, b }) => ({
  content: [{ type: "text", text: String(a + b) }],
}));

// Add a dynamic greeting resource
server.resource(
  "greeting",
  new ResourceTemplate("greeting://{name}", { list: undefined }),
  async (uri, { name }) => ({
    contents: [
      {
        uri: uri.href,
        text: `Hello, ${name}!`,
      },
    ],
  })
);

const app = express();

app.get("/sse", async (req, res) => {
  const transport = new SSEServerTransport("/messages", res);
  await server.connect(transport);
});

// app.post("/messages", async (req, res) => {
//   const transport = new SSEServerTransport("/messages", res);

//   // Note: to support multiple simultaneous connections, these messages will
//   // need to be routed to a specific matching transport. (This logic isn't
//   // implemented here, for simplicity.)
//   await transport.handlePostMessage(req, res);
// });

app.listen(3000);

npx @modelcontextprotocol/inspector index.js
Expected behavior
not working
Image

Logs

$ npx @modelcontextprotocol/inspector index.js
Starting MCP inspector...
Proxy server listening on port 3000

🔍 MCP Inspector is up and running at http://localhost:5173 🚀
New SSE connection
Query parameters: { transportType: 'sse', url: 'http://localhost:3000/sse' }
sse transportType
SSE transport: url=http://localhost:3000/sse, headers=
New SSE connection
Query parameters: {}
undefined transportType
Invalid transport type: undefined
undefined transportType
Error in /sse route: Error: Invalid transport type specified
    at createTransport (file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:74:15)
    at file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:82:44
    at Layer.handle [as handle_request] (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\route.js:149:13)
    at Route.dispatch (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\route.js:119:3)
    at Layer.handle [as handle_request] (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\layer.js:95:5)
    at C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:284:15  
    at Function.process_params (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:346:12)
    at next (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\express\lib\router\index.js:280:10)
    at cors (C:\Users\Administrator\AppData\Local\npm-cache\_npx\5a9d879542beca3a\node_modules\cors\lib\index.js:188:7)      
Error in /sse route: SseError: SSE error: Non-200 status code (500)
    at _eventSource.onerror (file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/sse.js:69:31)
    at EventSource.failConnection_fn (file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/eventsource/dist/index.js:234:53)
    at file:///C:/Users/Administrator/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/eventsource/dist/index.js:76:74
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  code: 500,
  event: {
    type: 'error',
    message: 'Non-200 status code (500)',
    code: 500,
    defaultPrevented: false,
    cancelable: false,
    timeStamp: 8331.5268
  }
}

Additional context
Add any other context about the problem here.

@liu-collab liu-collab added the bug Something isn't working label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant