Skip to content

Conversation

@sambostock
Copy link
Contributor

@sambostock sambostock commented Jun 24, 2025

Motivation and Context

The SSE example instructs the user to run a curl command to initialize the session, and then use the session ID in subsequent requests, but the session ID appears in a header and headers aren't shown.

Therefore, it makes sense to pass the -i flag to show headers in the output.

-curl -X POST http://localhost:9393 -H "Content-Type: application/json" \                                               
+curl -i -X POST http://localhost:9393 -H "Content-Type: application/json" \
 -d '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"sse-test","version":"1.0"}}}'
+HTTP/1.1 200 OK
+Content-Type: application/json
+Mcp-Session-Id: a3b4361f-1527-481e-96fb-4ec419645c41
+Content-Length: 152
 
 {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{}},"serverInfo":{"name":"sse_test_server","version":"0.1.0"}}}

Since the purpose of the examples is to demonstrate how things work, it makes sense to do this for all curl commands, so the user sees what's being sent/received.

How Has This Been Tested?

Not applicable

Breaking Changes

Nope

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

The user needs the `mcp-session-id` header, so we should log headers.
The examples showcase to the user how the server works, so it makes
sense to include headers to show the full picture.
@sambostock sambostock changed the title Include headers in curl examples Include response headers in curl examples Jun 24, 2025
@sambostock sambostock merged commit 40e8b47 into modelcontextprotocol:main Jun 24, 2025
5 checks passed
@sambostock sambostock deleted the curl-headers branch June 24, 2025 17:17
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.

2 participants