You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/examples/README.md
+77-70
Original file line number
Diff line number
Diff line change
@@ -2,81 +2,82 @@
2
2
3
3
This directory contains example implementations of MCP clients and servers using the TypeScript SDK.
4
4
5
+
## Table of Contents
6
+
7
+
-[Streamable HTTP Servers - Single Node Deployment](#streamable-http---single-node-deployment-with-basic-session-state-management)
8
+
-[Simple Server with Streamable HTTP](#simple-server-with-streamable-http-transport-serversimplestreamablehttpts)
9
+
-[Server Supporting SSE via GET](#server-supporting-with-sse-via-get-serverstandalonessewithgetstreamablehttpts)
10
+
-[Server with JSON Response Mode](#server-with-json-response-mode-serverjsonresponsestreamablehttpts)
11
+
-[Client Example - Streamable HTTP](#client-clientsimplestreamablehttpts)
12
+
-[Useful bash commands for testing](#useful-commands-for-testing)
13
+
5
14
## Streamable HTTP - single node deployment with basic session state management
6
15
7
-
Multi node with stete management example will be added soon after we add support.
16
+
Multi node with state management example will be added soon after we add support.
8
17
9
-
### Server with JSON response mode (`server/jsonResponseStreamableHttp.ts`)
10
18
11
-
A simple MCP server that uses the Streamable HTTP transport with JSON response mode enabled, implemented with Express. The server provides a simple `greet` tool that returns a greeting for a name.
19
+
### Simple server with Streamable HTTP transport (`server/simpleStreamableHttp.ts`)
20
+
21
+
A simple MCP server that uses the Streamable HTTP transport, implemented with Express. The server provides:
22
+
23
+
- A simple `greet` tool that returns a greeting for a name
24
+
- A `greeting-template` prompt that generates a greeting template
### Server supporting SSE via GET (`server/standaloneSseWithGetStreamableHttp.ts`)
42
36
43
-
# Call the greet tool using the saved session ID
44
-
curl -X POST \
45
-
-H "Content-Type: application/json" \
46
-
-H "Accept: application/json" \
47
-
-H "Accept: text/event-stream" \
48
-
-H "mcp-session-id: $SESSION_ID" \
49
-
-d '{
50
-
"jsonrpc": "2.0",
51
-
"method": "tools/call",
52
-
"params": {
53
-
"name": "greet",
54
-
"arguments": {
55
-
"name": "World"
56
-
}
57
-
},
58
-
"id": "2"
59
-
}' \
60
-
http://localhost:3000/mcp
37
+
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).
Note that in this example, we're using plain JSON response mode by setting `Accept: application/json` header.
45
+
The server will start on port 3000 and automatically create new resources every 5 seconds.
64
46
65
-
### Server (`server/simpleStreamableHttp.ts`)
47
+
### Server with JSON response mode (`server/jsonResponseStreamableHttp.ts`)
66
48
67
-
A simple MCP server that uses the Streamable HTTP transport, implemented with Express. The server provides:
49
+
A simple MCP server that uses the Streamable HTTP transport with JSON response mode enabled, implemented with Express. The server provides a simple `greet` tool that returns a greeting for a name.
68
50
69
-
- A simple `greet` tool that returns a greeting for a name
70
-
- A `greeting-template` prompt that generates a greeting template
71
-
- A static `greeting-resource` resource
51
+
_NOTE: This demonstrates a server that does not use SSE at all. Note that this limits its support for MCP features; for example, it cannot provide logging and progress notifications for tool execution._
0 commit comments