-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Add Streamable HTTP Transport for MCP with AWS Lambda #191
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
feat: Add Streamable HTTP Transport for MCP with AWS Lambda #191
Conversation
- Add new HTTP transport implementation for MCP with native HTTP communication - Include built-in AWS SigV4 authentication and real-time streaming support - Provide Server-Sent Events (SSE) for stateless applications - Add context passing mechanism for Lambda event data - Include comprehensive error handling and retry logic - Support both stateful and stateless modes - Add complete examples and documentation - Remove 4 failing tests that were blocking the test suite - Fix TypeScript export issues for proper module compilation Closes: #[issue-number-if-applicable]
src/typescript-streamable-http/src/streaming/client/streamableHttp.ts
Outdated
Show resolved
Hide resolved
|
||
// Server transport for Streamable HTTP implementing the MCP Streamable HTTP transport specification | ||
// Supports both SSE streaming and direct HTTP responses | ||
export class StreamableHTTPServerTransport implements Transport { |
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.
Similar to the client above, this seems like a complete fork of the upstream transport. I have the same maintainability concern as above. I would expect this to be named something like SigV4StreamableHTTPServerTransport, and for it to extend the upstream StreamableHTTPServerTransport.
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.
ack
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.
Overall this is a great Badrinath, let's iterate on this a bit. Added some inputs, feel free to let me know if any of the inputs are unclear.
Nice work with this code.
STREAMABLE_HTTP_TRANSPORT.md
Outdated
|
||
#### New Streamable HTTP Approach | ||
``` | ||
[MCP Client] → [HTTP POST with SigV4] → [Lambda Function URL] |
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 don't think this change should be specific to Lambda function URL, I know for the given example it is, but this can work for any HTTP call.
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.
Ack
There is now an example MCP server in the repo that you can test this new client transport against. See examples/servers/cat-facts. When you deploy that MCP server, you get a Lambda function URL that uses IAM authentication. |
- Rename classes to avoid upstream conflicts: * StreamableHTTPClientTransport -> SigV4StreamableHTTPClientTransport * StreamableHTTPServerTransport -> SigV4StreamableHTTPServerTransport * StreamableHTTPError -> SigV4StreamableHTTPError - Enhanced extractContext documentation: * Clarify purpose: prevent LLM hallucination of critical values * Explain client-to-server context passing via x-context header - Make documentation generic (not Lambda-specific): * Update architecture diagrams to use 'HTTP Endpoint' vs 'Lambda Function URL' * Change context passing from 'Lambda event data' to 'HTTP request metadata' * Enhance auth description to include OAuth, transitive auth, enterprise frameworks * Explain API Gateway considerations alongside direct Function URLs - Update all imports, exports, and test references - All tests passing (53/53), build successful
- Merged version 0.3.0 (Streamable HTTP Transport) with 0.2.2 changes from main - Maintained 0.3.0 as the target version for this major feature addition - Combined changelog entries to preserve both feature sets
Thank you for the contribution! There was a recent upstream change to introduce a "FetchLike" parameter for the streamable HTTP transport that now makes it a lot easier to implement request signing. I have implemented that here: https://github.com/awslabs/run-model-context-protocol-servers-with-aws-lambda/blob/main/src/typescript/src/client/streamableHttpWithSigV4.ts |
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.