-
Notifications
You must be signed in to change notification settings - Fork 79
feat: add session management for streamableHttp [MCP-52] #379
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
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.
LGTM
src/common/sessionStore.ts
Outdated
import logger, { LogId } from "./logger.js"; | ||
|
||
export class SessionStore { | ||
private sessions: { [sessionId: string]: StreamableHTTPServerTransport | undefined } = {}; |
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] Is there a reason why they value is nullable?
I don't see any location where the value (StreamableHTTPServerTransport) is set to undefined
/removed
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.
for the case where a key is not found
src/transports/streamableHttp.ts
Outdated
app.use(express.json()); | ||
|
||
const handleRequest = async (req: express.Request, res: express.Response) => { | ||
const sessionId = req.headers["mcp-session-id"] as string; |
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.
Wouldn't the better way to write this be:
const sessionId = req.headers["mcp-session-id"];
if (typeof sessionId !== 'string' || !sessionId) {
Or at least use as string | undefined
, instead of as string
, which is incorrect?
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.
good catch, I had an issue on my IDE before I think
src/transports/streamableHttp.ts
Outdated
const transport = new StreamableHTTPServerTransport({ | ||
sessionIdGenerator: undefined, | ||
}); | ||
const sessionId = req.headers["mcp-session-id"] as string; |
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.
Same as previous remark
Proposed changes
add session management for streamableHttp
Checklist