Skip to content

Add streamable HTTP transport support with examples for local and remote servers #57

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Jun 5, 2025

This PR adds comprehensive support for streamable HTTP transport to address the deprecation of SSE, providing modern HTTP transport capabilities with examples for both local and remote server usage.

Changes Made

Core Transport Implementation

  • Added --transport flag supporting http (streamable), sse, with http as default
  • Updated client creation logic to use NewStreamableHttpClient for HTTP URLs
  • Maintained full backward compatibility with existing SSE transport via --transport=sse
  • Enhanced flag processing to handle transport selection

Server Template Support

  • Created templates/ts/server_http.ts using StreamableHTTPServerTransport
  • Implemented session management with UUID generation for stateful connections
  • Added proper Express.js integration with JSON body parsing
  • Updated mcp new command to support --transport=http option

Documentation & Examples

  • Added comprehensive streamable HTTP transport section to README
  • Provided step-by-step examples for local server creation:
    # Create and run a local streamable HTTP server
    mkdir my-http-server && cd my-http-server
    mcp new tool:example_tool --transport=http
    npm install && npm run build && npm start
  • Added examples for connecting to remote servers:
    # Connect to local or remote streamable HTTP servers
    mcp tools http://localhost:3000
    mcp tools https://api.example.com/mcp
    
    # Use SSE for legacy servers
    mcp tools --transport=sse http://legacy-server.com/sse

Testing & Validation

  • Added unit tests for transport flag processing and URL validation
  • Verified all existing functionality remains intact (100% backward compatibility)
  • Validated template generation for all transport types (stdio, sse, http)
  • Confirmed generated projects compile and run successfully

Key Benefits

  1. Modern Transport: Streamable HTTP is now the recommended approach, addressing SSE deprecation
  2. Session Management: Supports stateful connections with automatic session ID generation
  3. Flexibility: Supports both streaming responses and direct JSON responses
  4. Developer Experience: Complete tooling for creating and connecting to streamable HTTP servers
  5. Backward Compatibility: Existing SSE-based workflows continue to work unchanged

Usage Examples

Create a local streamable HTTP server:

mcp new tool:calculator --transport=http
cd calculator && npm install && npm run build && npm start

Connect to servers:

# Default streamable HTTP
mcp tools http://localhost:3000

# Explicit transport selection
mcp tools --transport=http https://remote-mcp-server.com
mcp tools --transport=sse http://legacy-server.com/sse

The implementation leverages the existing NewStreamableHttpClient function in mcp-go v0.24.1 and the StreamableHTTPServerTransport class in the MCP TypeScript SDK, providing a complete solution for modern MCP transport needs.

Fixes #56.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Streamable HTTP supported? Add streamable HTTP transport support with examples for local and remote servers Jun 5, 2025
@Copilot Copilot AI requested a review from f June 5, 2025 23:27
Copilot finished work on behalf of f June 5, 2025 23:27
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.

Streamable HTTP supported?
2 participants