Skip to content

Conversation

@SpringMT
Copy link
Contributor

@SpringMT SpringMT commented Nov 5, 2025

In examples/http, previous HTTP-level logging middleware blocked SSE streaming because handler.ServeHTTP() does not return until the connection closes for GET requests (SSE streams).
This prevented response headers from being sent to the client.

Changes:

  • Replace HTTP-level logging handler with MCP middleware pattern
  • Implement logging at the MCP protocol layer using mcp.Middleware
  • Add middleware to server using AddReceivingMiddleware()
  • Simplify main.go by removing HTTP handler wrapping

This allows SSE streams to work properly while still providing detailed logging for all MCP protocol-level method calls.

… layer

The previous HTTP-level logging middleware blocked SSE streaming because
handler.ServeHTTP() does not return until the connection closes for GET
requests (SSE streams). This prevented response headers from being sent
to the client.

Changes:
- Replace HTTP-level logging handler with MCP middleware pattern
- Implement logging at the MCP protocol layer using mcp.Middleware
- Log session ID, method names, duration, and error status
- Add middleware to server using AddReceivingMiddleware()
- Simplify main.go by removing HTTP handler wrapping
- Use standard log package with structured format for clarity

This allows SSE streams to work properly while still providing detailed
logging for all MCP protocol-level method calls.
@findleyr findleyr requested a review from jba November 7, 2025 21:24
@findleyr
Copy link
Contributor

findleyr commented Nov 7, 2025

Thank you. I'll see if @jba wants to review, since he reviewed the original. Otherwise, I will review on Monday.

jba
jba previously requested changes Nov 9, 2025

// Log request details.
log.Printf("[REQUEST] %s | Session: %s | Method: %s",
start.Format(time.RFC3339),
Copy link
Contributor

Choose a reason for hiding this comment

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

The log package already prints the time by default. I know the previous code had this, but I think it's redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed e8b1d4b

@findleyr findleyr removed the request for review from jba November 11, 2025 16:26
@findleyr findleyr dismissed jba’s stale review November 11, 2025 16:27

OOO; comments addressed.

@findleyr findleyr merged commit 35dfcf2 into modelcontextprotocol:main Nov 11, 2025
5 checks passed
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