Skip to content

Commit 830bfd7

Browse files
Update README.md with comprehensive HTTP Streams transport documentation (#6)
- Add HTTP Streams as the default transport option - Create dedicated Transport Options section with detailed comparison - Update all examples to show HTTP Streams as default - Add links to detailed documentation for each transport - Update Docker examples to reflect new default - Add comprehensive transport comparison table - Include documentation section with links to all guides Co-authored-by: openhands <[email protected]>
1 parent 76ecd6f commit 830bfd7

File tree

1 file changed

+87
-7
lines changed

1 file changed

+87
-7
lines changed

README.md

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# MCP Server Framework
22

3-
A simple, reusable Model Context Protocol (MCP) server framework written in Go. This framework supports both STDIO and Server-Sent Events (SSE) transports and can be used as both a library and a standalone executable.
3+
A simple, reusable Model Context Protocol (MCP) server framework written in Go. This framework supports multiple transport mechanisms including HTTP Streams (MCP-compliant), SSE (Server-Sent Events), and STDIO transports and can be used as both a library and a standalone executable.
44

55
## Features
66

7-
- 🚀 **Multiple Transports**: Support for STDIO and SSE (Server-Sent Events)
7+
- 🚀 **Multiple Transports**: Support for HTTP Streams (MCP-compliant), SSE (Server-Sent Events), and STDIO
88
- 📦 **Library & Standalone**: Use as a Go library or run as a standalone server
99
- 🧪 **Well Tested**: Comprehensive test coverage
1010
- 🔄 **JSON-RPC 2.0**: Full JSON-RPC 2.0 protocol support
@@ -18,11 +18,14 @@ A simple, reusable Model Context Protocol (MCP) server framework written in Go.
1818
### As a Standalone Server
1919

2020
```bash
21-
# STDIO transport (default)
22-
go run cmd/mcp-server/main.go
21+
# HTTP Streams transport (default)
22+
go run cmd/mcp-server/main.go -addr=8080
2323

2424
# SSE transport
2525
go run cmd/mcp-server/main.go -transport=sse -addr=8080
26+
27+
# STDIO transport
28+
go run cmd/mcp-server/main.go -transport=stdio
2629
```
2730

2831
### As a Library
@@ -40,9 +43,10 @@ import (
4043
)
4144

4245
func main() {
43-
// Create transport (STDIO or SSE)
44-
transport := transport.NewSTDIOTransport()
46+
// Create transport (HTTP Streams, SSE, or STDIO)
47+
transport := transport.NewHTTPStreamsTransport(mcp.NewServerWithoutTransport(), transport.HTTPStreamsTransportOptions{})
4548
// transport := transport.NewSSETransport(":8080")
49+
// transport := transport.NewSTDIOTransport()
4650

4751
// Create server
4852
server := mcp.NewServer(transport)
@@ -159,13 +163,80 @@ go get github.com/openhands/mcp-server-framework
159163
```bash
160164
docker pull ghcr.io/openhands/mcp-server-framework:latest
161165

162-
# Run with SSE transport (default)
166+
# Run with HTTP Streams transport (default)
163167
docker run -p 8080:8080 ghcr.io/openhands/mcp-server-framework:latest
164168

169+
# Run with SSE transport
170+
docker run -p 8080:8080 ghcr.io/openhands/mcp-server-framework:latest -transport=sse
171+
165172
# Run with STDIO transport
166173
docker run -i ghcr.io/openhands/mcp-server-framework:latest -transport=stdio
167174
```
168175

176+
## Transport Options
177+
178+
The framework supports multiple transport mechanisms to suit different use cases:
179+
180+
### 1. HTTP Streams Transport (Default)
181+
- **MCP Streamable HTTP (2024-11-05) compliant**
182+
- Modern HTTP + SSE hybrid approach
183+
- Built-in session management with secure session IDs
184+
- Batch request support for improved efficiency
185+
- Excellent proxy and firewall compatibility
186+
- Full MCP specification compliance
187+
- **Endpoints**: `/mcp` (POST/GET), `/health` (GET)
188+
- **📖 [Detailed Documentation](docs/HTTP_STREAMS.md)**
189+
190+
```bash
191+
# Start HTTP Streams server
192+
./mcp-server -addr=8080
193+
194+
# Test with curl
195+
curl http://localhost:8080/health
196+
```
197+
198+
### 2. SSE (Server-Sent Events) Transport
199+
- Custom SSE implementation for real-time communication
200+
- Bidirectional communication via SSE + HTTP POST
201+
- Built-in session management
202+
- CORS support for web browsers
203+
- **Endpoints**: `/sse` (GET), `/message` (POST), `/health` (GET)
204+
- **📖 [Detailed Documentation](docs/SSE.md)**
205+
206+
```bash
207+
# Start SSE server
208+
./mcp-server -transport=sse -addr=8080
209+
210+
# Test SSE connection
211+
curl -N -H "Accept: text/event-stream" http://localhost:8080/sse
212+
```
213+
214+
### 3. STDIO Transport
215+
- Standard input/output communication
216+
- Perfect for command-line tools and scripts
217+
- Lightweight and efficient
218+
- No network dependencies
219+
220+
```bash
221+
# Start STDIO server
222+
./mcp-server -transport=stdio
223+
224+
# Communicate via stdin/stdout
225+
echo '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{}}' | ./mcp-server -transport=stdio
226+
```
227+
228+
### Transport Comparison
229+
230+
| Feature | HTTP Streams | SSE Transport | STDIO |
231+
|---------|-------------|---------------|-------|
232+
| MCP Compliance | ✅ Full (2024-11-05) | ⚠️ Custom | ✅ Standard |
233+
| Session Management | ✅ Built-in | ✅ Built-in | ❌ N/A |
234+
| Batch Requests | ✅ Supported | ❌ Not supported | ✅ Supported |
235+
| Web Browser Support | ✅ Excellent | ✅ Good | ❌ N/A |
236+
| Proxy Compatibility | ✅ Excellent | ⚠️ Limited | ❌ N/A |
237+
| Network Required | ✅ Yes | ✅ Yes | ❌ No |
238+
| Use Case | Web apps, APIs | Real-time apps | CLI tools |
239+
169240
## API Reference
170241

171242
### Server
@@ -448,6 +519,15 @@ fetch(`http://localhost:8080/message?sessionId=${sessionId}`, {
448519
});
449520
```
450521

522+
## Documentation
523+
524+
Comprehensive documentation is available for all transport mechanisms and features:
525+
526+
- **[HTTP Streams Transport](docs/HTTP_STREAMS.md)** - Complete guide to the MCP-compliant HTTP Streams transport
527+
- **[SSE Transport](docs/SSE.md)** - Server-Sent Events transport documentation
528+
- **[API Reference](docs/API.md)** - Complete API documentation with examples
529+
- **[Testing Guide](docs/TESTING.md)** - Testing strategies and coverage information
530+
451531
## Contributing
452532

453533
1. Fork the repository

0 commit comments

Comments
 (0)