@@ -22,7 +22,7 @@ A simple, reusable Model Context Protocol (MCP) server framework written in Go.
2222go run cmd/mcp-server/main.go
2323
2424# SSE transport
25- go run cmd/mcp-server/main.go -transport=sse -addr=: 8080
25+ go run cmd/mcp-server/main.go -transport=sse -addr=8080
2626```
2727
2828### As a Library
@@ -35,8 +35,8 @@ import (
3535 " encoding/json"
3636 " log"
3737
38- " github.com/openhands /mcp-server-framework/internal /transport"
39- " github.com/openhands /mcp-server-framework/pkg/mcp"
38+ " github.com/protobomb /mcp-server-framework/pkg /transport"
39+ " github.com/protobomb /mcp-server-framework/pkg/mcp"
4040)
4141
4242func main () {
@@ -158,7 +158,12 @@ go get github.com/openhands/mcp-server-framework
158158
159159``` bash
160160docker pull ghcr.io/openhands/mcp-server-framework:latest
161- docker run -p 8080:8080 ghcr.io/openhands/mcp-server-framework:latest -transport=sse
161+
162+ # Run with SSE transport (default)
163+ docker run -p 8080:8080 ghcr.io/openhands/mcp-server-framework:latest
164+
165+ # Run with STDIO transport
166+ docker run -i ghcr.io/openhands/mcp-server-framework:latest -transport=stdio
162167```
163168
164169## API Reference
@@ -265,47 +270,91 @@ transport := transport.NewSSETransport(":8080")
265270```
266271
267272SSE endpoints:
268- - ` GET /events ` - SSE event stream
269- - ` POST /send ` - Send messages to server
273+ - ` GET /sse ` - SSE event stream (with optional ?sessionId parameter)
274+ - ` POST /message ` - Send messages to server (requires ?sessionId parameter)
270275- ` GET /health ` - Health check
271276
272277## Built-in Handlers
273278
274- The framework includes these built-in handlers:
279+ The framework includes these built-in MCP handlers:
275280
276- - ` initialize ` - MCP initialization
281+ - ` initialize ` - MCP initialization handshake
277282- ` initialized ` - MCP initialization complete notification
283+ - ` tools/list ` - List available tools
284+ - ` tools/call ` - Call a specific tool
278285
279- ## Example Handlers
286+ ## Built-in Tools
280287
281- The standalone server includes example handlers :
288+ The framework includes these example tools :
282289
283- - ` echo ` - Echo back the input message
284- - ` add ` - Add two numbers
285- - ` listMethods ` - List available methods
286- - ` ping ` - Ping notification handler
290+ - ` echo ` - Echo back the provided message
291+ - Parameters: ` message ` (string) - The message to echo back
292+ - Returns: Text content with "Echo: {message}"
287293
288294## Testing
289295
296+ The framework includes comprehensive testing with both unit and integration tests.
297+
298+ ### Quick Testing
299+
290300``` bash
291- # Run all tests
301+ # Run all tests (unit + integration)
302+ make test-all
303+
304+ # Run only unit tests
292305make test
293306
307+ # Run only integration tests
308+ make test-integration
309+
294310# Run tests with coverage
295311make test-coverage
296312
313+ # Run all checks (format, lint, test)
314+ make check
315+ ```
316+
317+ ### Test Coverage
318+
319+ The framework has ** 42 comprehensive test cases** covering:
320+
321+ - ** SSE Transport** : 14 tests covering session management, message handling, CORS, error handling
322+ - ** STDIO Transport** : 9 tests covering transport lifecycle and message handling
323+ - ** MCP Server** : 13 tests covering handlers, tools, capabilities, and protocol compliance
324+ - ** MCP Client** : 14 tests covering client operations, timeouts, and error handling
325+
326+ ### Integration Testing
327+
328+ Integration tests automatically:
329+ 1 . Start the MCP server with SSE transport
330+ 2 . Test complete MCP protocol flow (initialize → initialized → tools/list → tools/call)
331+ 3 . Verify request/response matching and notification handling
332+ 4 . Clean up server process
333+
334+ ### Manual Testing
335+
336+ ``` bash
337+ # Manual unit testing
338+ go test ./pkg/...
339+ go test -v -race ./pkg/...
340+ go test -cover ./pkg/...
341+
342+ # Test with mcp-cli (requires Node.js)
343+ ./mcp-server -transport=sse -addr=8080 &
344+ npx @modelcontextprotocol/cli connect sse http://localhost:8080/sse
345+
297346# Test client with STDIO server
298347make test-client-stdio
299348
300349# Test client with HTTP server
301350make test-client-http
302-
303- # Manual testing
304- go test ./...
305- go test -cover ./...
306- go test -v ./...
307351```
308352
353+ ### Test Scripts
354+
355+ - ` scripts/test_sse_integration.py ` - Python-based SSE integration test
356+ - ` scripts/test-examples.sh ` - Bash-based endpoint testing script
357+
309358## Building
310359
311360``` bash
@@ -340,11 +389,14 @@ GOOS=darwin GOARCH=amd64 go build -o mcp-server-darwin cmd/mcp-server/main.go
340389# Build Docker image
341390docker build -t mcp-server-framework .
342391
343- # Run with STDIO
344- docker run -i mcp-server-framework
392+ # Run with SSE transport (default)
393+ docker run -p 8080:8080 mcp-server-framework
394+
395+ # Run with STDIO transport
396+ docker run -i mcp-server-framework -transport=stdio
345397
346- # Run with SSE
347- docker run -p 8080:8080 mcp-server-framework -transport=sse - addr=:8080
398+ # Run with custom SSE address
399+ docker run -p 9090:9090 mcp-server-framework -addr=9090
348400```
349401
350402## Examples
@@ -356,7 +408,7 @@ docker run -p 8080:8080 mcp-server-framework -transport=sse -addr=:8080
356408./mcp-client -transport=stdio -command=' ./mcp-server'
357409
358410# Test with HTTP server (start server first)
359- ./mcp-server -transport=sse -addr=: 8080 &
411+ ./mcp-server -transport=sse -addr=8080 &
360412./mcp-client -transport=http -addr=http://localhost:8080
361413
362414# Interactive demo
@@ -372,16 +424,19 @@ echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' | ./mcp-server
372424### SSE Client Example
373425
374426``` javascript
427+ // Generate or get session ID
428+ const sessionId = ' your-session-id' ; // or generate one
429+
375430// Connect to SSE endpoint
376- const eventSource = new EventSource (' http://localhost:8080/events ' );
431+ const eventSource = new EventSource (` http://localhost:8080/sse?sessionId= ${ sessionId } ` );
377432
378433eventSource .onmessage = function (event ) {
379434 const data = JSON .parse (event .data );
380435 console .log (' Received:' , data);
381436};
382437
383438// Send a message
384- fetch (' http://localhost:8080/send ' , {
439+ fetch (` http://localhost:8080/message?sessionId= ${ sessionId } ` , {
385440 method: ' POST' ,
386441 headers: { ' Content-Type' : ' application/json' },
387442 body: JSON .stringify ({
0 commit comments