-
Notifications
You must be signed in to change notification settings - Fork 75
feat: add streamable http [MCP-55] #359
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
Conversation
README.md
Outdated
| `transport` | stdio | Either 'stdio' or 'http'. | | ||
| `httpPort` | 3000 | Port number. | | ||
| `httpHost` | 127.0.0.1 | Host to bind the http server. | | ||
| `logger` | disk,mcp | Comma separated values, possible values are `mcp`, `disk` and `stderr`. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we expand a little bit here or below in the features the logger purpose and usage examples?
app.use(express.json()); | ||
app.enable("trust proxy"); // needed for reverse proxy support | ||
app.use(express.urlencoded({ extended: true })); | ||
app.use(express.json()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[q] do we need to call app.use(express.json()); twice?
"streamableHttpTransport", | ||
`Error handling request: ${error instanceof Error ? error.message : String(error)}` | ||
); | ||
res.sendStatus(400); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we have a task for this but we'll need to return JSON-RPC response error body, so this is a non-blocker, just in case its too simple to add here
); | ||
}); | ||
|
||
transport.onclose = () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[q] should we call this in index.ts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, mcpServer.close()
should close the transport
src/transports/stdioTransport.ts
Outdated
@@ -39,7 +39,7 @@ export class EJsonReadBuffer { | |||
// | |||
// This function creates a StdioServerTransport and replaces the internal readBuffer with EJsonReadBuffer | |||
// that uses EJson.parse instead. | |||
export function createEJsonTransport(): StdioServerTransport { | |||
export function createStdioTransport(): StdioServerTransport { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why not call stdio.ts
if we're under transports folder? same for streamableHttp
); | ||
res.status(400).json({ | ||
jsonrpc: "2.0", | ||
error: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
based on the spec we need to also add a request ID field here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(note: feel free to address in the rpc ticket, probably worth just assigning it to you already)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see null ids everywhere in the SDK (https://github.com/modelcontextprotocol/typescript-sdk/blob/a9c907dd700a5c4b977624ac47fd8cc24c6bd473/src/server/streamableHttp.ts#L291). I'll leave it for now.
jsonrpc: "2.0", | ||
error: { | ||
code: JSON_RPC_ERROR_CODE_PROCESSING_REQUEST_FAILED, | ||
message: `Error handling request: ${error instanceof Error ? error.message : String(error)}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should we throw the classic error message and populate any extra info in the error.data
optional field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-blocking comments - but need to fix linting
Proposed changes
Adding streamable http to MCP-42 feature branch.
Note: state management and tests will be added in a future PR.
Checklist