Skip to content

Conversation

@JAORMX
Copy link
Collaborator

@JAORMX JAORMX commented Aug 16, 2025

Description

This PR adds support for streaming HTTP transport to enable MKP to work with environments like ToolHive that require HTTP-based communication.

Changes

  • Added --transport CLI flag to select between sse (default) and streamable-http transport protocols
  • Added support for MCP_TRANSPORT environment variable for transport selection
  • Created CreateStreamableHTTPServer() function in pkg/mcp/server.go to instantiate StreamableHTTP server
  • Updated server startup logic in cmd/server/main.go to dynamically select and start the appropriate transport
  • Added documentation in README.md explaining the new transport configuration options

Why This Change?

As reported in #82, the current implementation only supports SSE transport, which doesn't work with ToolHive's ingress setup. ToolHive sets the MCP_TRANSPORT environment variable to streamable-http when it needs HTTP-based communication.

This implementation:

  • ✅ Maintains backward compatibility (SSE remains the default)
  • ✅ Automatically works with ToolHive (respects MCP_TRANSPORT env var)
  • ✅ Allows manual transport selection via CLI flag
  • ✅ Uses the existing mcp-go library's StreamableHTTPServer

Testing

  • Built and tested locally with both transport modes
  • All existing tests pass
  • Verified environment variable override works correctly
  • Confirmed CLI flag takes precedence over environment variable

Fixes #82

- Add --transport CLI flag to select between sse and streamable-http
- Add MCP_TRANSPORT environment variable support for transport selection
- Create StreamableHTTPServer wrapper in pkg/mcp/server.go
- Update server startup logic to use selected transport
- Add documentation for transport configuration

This enables MKP to work with environments like ToolHive that require
HTTP-based communication. The default transport remains SSE for backward
compatibility.

Fixes #82
@JAORMX JAORMX force-pushed the feat/streaming-http-transport branch from 7bf2823 to 28c0716 Compare August 16, 2025 19:20
Shutdown(context.Context) error
}

switch strings.ToLower(*transport) {
Copy link

Choose a reason for hiding this comment

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

the string is alrady ToLowered (yeah, a nit, but I read the patch!)

// Create SSE server
sseServer := mcp.CreateSSEServer(mcpServer)
// Create and start the appropriate transport server
var transportServer interface {
Copy link

Choose a reason for hiding this comment

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

every single one of our MCP servers defines an interface like this. thought: should we work on a library or enhance upstream?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, a library would be a good idea.

@JAORMX JAORMX merged commit 22393b7 into main Aug 18, 2025
7 checks passed
@likku123
Copy link

@JAORMX @jhrozek
Does the latest included in this image as well ghcr.io/stackloklabs/mkp/server ?
Thank you !

@JAORMX
Copy link
Collaborator Author

JAORMX commented Aug 18, 2025

Not yet. I'll cut a release today

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.

transport: streamable-http support

4 participants