Skip to content

Commit 9a85975

Browse files
committed
Log headers in all curl examples
The examples showcase to the user how the server works, so it makes sense to include headers to show the full picture.
1 parent cccb749 commit 9a85975

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

examples/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ SESSION_ID=$(curl -D - -s -o /dev/null -X POST http://localhost:9393 \
115115

116116
2. Connect to SSE stream (in one terminal):
117117
```bash
118-
curl -N -H "Mcp-Session-Id: $SESSION_ID" http://localhost:9393
118+
curl -i -N -H "Mcp-Session-Id: $SESSION_ID" http://localhost:9393
119119
```
120120

121121
3. Trigger notifications (in another terminal):
122122
```bash
123123
# Send immediate notification
124-
curl -X POST http://localhost:9393 \
124+
curl -i -X POST http://localhost:9393 \
125125
-H "Content-Type: application/json" \
126126
-H "Mcp-Session-Id: $SESSION_ID" \
127127
-d '{"jsonrpc":"2.0","method":"tools/call","id":2,"params":{"name":"notification_tool","arguments":{"message":"Hello from cURL!"}}}'
@@ -152,22 +152,22 @@ The HTTP server implements the MCP Streamable HTTP transport protocol:
152152

153153
Initialize a session:
154154
```bash
155-
curl -X POST http://localhost:9292 \
155+
curl -i -X POST http://localhost:9292 \
156156
-H "Content-Type: application/json" \
157157
-d '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
158158
```
159159

160160
List tools (using the session ID from initialization):
161161
```bash
162-
curl -X POST http://localhost:9292 \
162+
curl -i -X POST http://localhost:9292 \
163163
-H "Content-Type: application/json" \
164164
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
165165
-d '{"jsonrpc":"2.0","method":"tools/list","id":2}'
166166
```
167167

168168
Call a tool:
169169
```bash
170-
curl -X POST http://localhost:9292 \
170+
curl -i -X POST http://localhost:9292 \
171171
-H "Content-Type: application/json" \
172172
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
173173
-d '{"jsonrpc":"2.0","method":"tools/call","id":3,"params":{"name":"ExampleTool","arguments":{"a":5,"b":3}}}'

examples/streamable_http_server.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ def call(message:, delay: 0)
151151
puts ' -d \'{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"sse-test","version":"1.0"}}}\''
152152
puts ""
153153
puts "2. Connect SSE stream (use the session ID from step 1):"
154-
puts ' curl -N -H "Mcp-Session-Id: YOUR_SESSION_ID" http://localhost:9393'
154+
puts ' curl -i -N -H "Mcp-Session-Id: YOUR_SESSION_ID" http://localhost:9393'
155155
puts ""
156156
puts "3. In another terminal, test tools (responses will be sent via SSE if stream is active):"
157157
puts ""
158158
puts " Echo tool:"
159-
puts ' curl -X POST http://localhost:9393 -H "Content-Type: application/json" -H "Mcp-Session-Id: YOUR_SESSION_ID" \\'
159+
puts ' curl -i -X POST http://localhost:9393 -H "Content-Type: application/json" -H "Mcp-Session-Id: YOUR_SESSION_ID" \\'
160160
puts ' -d \'{"jsonrpc":"2.0","method":"tools/call","id":2,"params":{"name":"echo","arguments":{"message":"Hello SSE!"}}}\''
161161
puts ""
162162
puts " Notification tool (with 2 second delay):"
163-
puts ' curl -X POST http://localhost:9393 -H "Content-Type: application/json" -H "Mcp-Session-Id: YOUR_SESSION_ID" \\'
163+
puts ' curl -i -X POST http://localhost:9393 -H "Content-Type: application/json" -H "Mcp-Session-Id: YOUR_SESSION_ID" \\'
164164
puts ' -d \'{"jsonrpc":"2.0","method":"tools/call","id":3,"params":{"name":"notification_tool","arguments":{"message":"Hello SSE!", "delay": 2}}}\''
165165
puts ""
166166
puts "Note: When an SSE stream is active, tool responses will appear in the SSE stream and the POST request will return {\"accepted\": true}"

0 commit comments

Comments
 (0)