Skip to content

Commit 755534e

Browse files
committed
clean up examples README
1 parent 0c1a4f2 commit 755534e

File tree

1 file changed

+41
-51
lines changed

1 file changed

+41
-51
lines changed

src/examples/README.md

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This directory contains example implementations of MCP clients and servers using
99
- [Server Supporting SSE via GET](#server-supporting-with-sse-via-get-serverstandalonessewithgetstreamablehttpts)
1010
- [Server with JSON Response Mode](#server-with-json-response-mode-serverjsonresponsestreamablehttpts)
1111
- [Client Example - Streamable HTTP](#client-clientsimplestreamablehttpts)
12+
- [Useful bash commands for testing](#useful-commands-for-testing)
1213

1314
## Streamable HTTP - single node deployment with basic session state management
1415

@@ -31,35 +32,6 @@ npx tsx src/examples/server/simpleStreamableHttp.ts
3132

3233
The server will start on port 3000. You can test the initialization and tool listing:
3334

34-
```bash
35-
# First initialize the server and save the session ID to a variable
36-
SESSION_ID=$(curl -X POST \
37-
-H "Content-Type: application/json" \
38-
-H "Accept: application/json" \
39-
-H "Accept: text/event-stream" \
40-
-d '{
41-
"jsonrpc": "2.0",
42-
"method": "initialize",
43-
"params": {
44-
"capabilities": {},
45-
"protocolVersion": "2025-03-26",
46-
"clientInfo": {
47-
"name": "test",
48-
"version": "1.0.0"
49-
}
50-
},
51-
"id": "1"
52-
}' \
53-
-i http://localhost:3000/mcp 2>&1 | grep -i "mcp-session-id" | cut -d' ' -f2 | tr -d '\r')
54-
echo "Session ID: $SESSION_ID
55-
56-
# Then list tools using the saved session ID
57-
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
58-
-H "mcp-session-id: $SESSION_ID" \
59-
-d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":"2"}' \
60-
http://localhost:3000/mcp
61-
```
62-
6335
### Server supporting with SSE via GET (`server/standaloneSseWithGetStreamableHttp.ts`)
6436

6537
An MCP server that demonstrates how to support SSE notifications via GET requests using the Streamable HTTP transport with Express. The server dynamically adds resources at regular intervals and supports notifications for resource list changes (server notifications are available through the standalone SSE connection established by GET request).
@@ -83,10 +55,31 @@ A simple MCP server that uses the Streamable HTTP transport with JSON response m
8355
npx tsx src/examples/server/jsonResponseStreamableHttp.ts
8456
```
8557

86-
The server will start on port 3000. You can test the initialization and tool calling:
58+
59+
### Client (`client/simpleStreamableHttp.ts`)
60+
61+
A client that connects to the server, initializes it, and demonstrates how to:
62+
63+
- List available tools and call the `greet` tool
64+
- List available prompts and get the `greeting-template` prompt
65+
- List available resources
66+
67+
#### Running the client
68+
69+
```bash
70+
npx tsx src/examples/client/simpleStreamableHttp.ts
71+
```
72+
73+
Make sure the server is running before starting the client.
74+
75+
76+
### Useful commands for testing
77+
78+
#### Initialize
79+
Streamable HTTP transport requires to do the initialization first.
8780

8881
```bash
89-
# Initialize the server and get the session ID from headers
82+
# First initialize the server and save the session ID to a variable
9083
SESSION_ID=$(curl -X POST \
9184
-H "Content-Type: application/json" \
9285
-H "Accept: application/json" \
@@ -105,8 +98,24 @@ SESSION_ID=$(curl -X POST \
10598
"id": "1"
10699
}' \
107100
-i http://localhost:3000/mcp 2>&1 | grep -i "mcp-session-id" | cut -d' ' -f2 | tr -d '\r')
108-
echo "Session ID: $SESSION_ID"
101+
echo "Session ID: $SESSION_ID
102+
103+
```
104+
105+
Once thre is a session we can send POST requests
106+
107+
#### List tools
108+
```bash
109+
# Then list tools using the saved session ID
110+
curl -X POST -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" \
111+
-H "mcp-session-id: $SESSION_ID" \
112+
-d '{"jsonrpc":"2.0","method":"tools/list","params":{},"id":"2"}' \
113+
http://localhost:3000/mcp
114+
```
115+
116+
#### Call tool
109117
118+
```bash
110119
# Call the greet tool using the saved session ID
111120
curl -X POST \
112121
-H "Content-Type: application/json" \
@@ -126,22 +135,3 @@ curl -X POST \
126135
}' \
127136
http://localhost:3000/mcp
128137
```
129-
130-
131-
### Client (`client/simpleStreamableHttp.ts`)
132-
133-
A client that connects to the server, initializes it, and demonstrates how to:
134-
135-
- List available tools and call the `greet` tool
136-
- List available prompts and get the `greeting-template` prompt
137-
- List available resources
138-
139-
#### Running the client
140-
141-
```bash
142-
npx tsx src/examples/client/simpleStreamableHttp.ts
143-
```
144-
145-
Make sure the server is running before starting the client.
146-
147-

0 commit comments

Comments
 (0)