Skip to content

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

Conversation

Badrinath-Chandi
Copy link

  • 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

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

- 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]

// 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 {
Copy link
Member

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Copy link

@avidubey avidubey left a 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.


#### New Streamable HTTP Approach
```
[MCP Client] → [HTTP POST with SigV4] → [Lambda Function URL]
Copy link

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

@clareliguori
Copy link
Member

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.

Badrinath Chandi added 2 commits July 8, 2025 12:19
- 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
@clareliguori
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants