@@ -8,7 +8,7 @@ This directory contains examples of how to use the Model Context Protocol (MCP)
88A simple server that communicates over standard input/output. This is useful for desktop applications and command-line tools.
99
1010** Usage:**
11- ``` bash
11+ ``` console
1212$ ruby examples/stdio_server.rb
1313{"jsonrpc":"2.0","id":0,"method":"tools/list"}
1414```
@@ -24,7 +24,7 @@ A standalone HTTP server built with Rack that implements the MCP Streamable HTTP
2424- Full MCP protocol compliance
2525
2626** Usage:**
27- ``` bash
27+ ``` console
2828$ ruby examples/http_server.rb
2929```
3030
@@ -40,12 +40,12 @@ A client that demonstrates how to interact with the HTTP server using all MCP pr
4040
4141** Usage:**
42421 . Start the HTTP server in one terminal:
43- ``` bash
43+ ``` console
4444 $ ruby examples/http_server.rb
4545 ```
4646
47472 . Run the client example in another terminal:
48- ``` bash
48+ ``` console
4949 $ ruby examples/http_client.rb
5050 ```
5151
@@ -70,7 +70,7 @@ A specialized HTTP server designed to test and demonstrate Server-Sent Events (S
7070- ` echo ` - Simple echo tool for basic testing
7171
7272** Usage:**
73- ``` bash
73+ ``` console
7474$ ruby examples/streamable_http_server.rb
7575```
7676
@@ -87,12 +87,12 @@ An interactive client that connects to the SSE stream and provides a menu-driven
8787
8888** Usage:**
89891 . Start the SSE test server in one terminal:
90- ``` bash
90+ ``` console
9191 $ ruby examples/streamable_http_server.rb
9292 ```
9393
94942 . Run the SSE test client in another terminal:
95- ``` bash
95+ ``` console
9696 $ ruby examples/streamable_http_client.rb
9797 ```
9898
@@ -107,19 +107,19 @@ The client will:
107107You can also test SSE functionality manually using cURL:
108108
1091091 . Initialize a session:
110- ``` bash
110+ ``` console
111111SESSION_ID=$(curl -D - -s -o /dev/null -X POST http://localhost:9393 \
112112 -H "Content-Type: application/json" \
113113 -d '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"curl-test","version":"1.0"}}}' | grep -i "Mcp-Session-Id:" | cut -d' ' -f2- | tr -d '\r')
114114```
115115
1161162 . Connect to SSE stream (in one terminal):
117- ``` bash
117+ ``` console
118118curl -i -N -H "Mcp-Session-Id: $SESSION_ID" http://localhost:9393
119119```
120120
1211213 . Trigger notifications (in another terminal):
122- ``` bash
122+ ``` console
123123# Send immediate notification
124124curl -i -X POST http://localhost:9393 \
125125 -H "Content-Type: application/json" \
@@ -151,22 +151,22 @@ The HTTP server implements the MCP Streamable HTTP transport protocol:
151151### Example cURL Commands
152152
153153Initialize a session:
154- ``` bash
154+ ``` console
155155curl -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
160160List tools (using the session ID from initialization):
161- ``` bash
161+ ``` console
162162curl -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
168168Call a tool:
169- ``` bash
169+ ``` console
170170curl -i -X POST http://localhost:9292 \
171171 -H "Content-Type: application/json" \
172172 -H "Mcp-Session-Id: YOUR_SESSION_ID" \
0 commit comments