Merge pull request #72 from koic/use_console_instead_of_bash
[Doc] Use `console` instead of `bash` for code block highlighting
This commit is contained in:
commit
db98dbc13d
2 changed files with 16 additions and 16 deletions
|
|
@ -12,13 +12,13 @@ gem 'mcp'
|
||||||
|
|
||||||
And then execute:
|
And then execute:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
$ bundle install
|
$ bundle install
|
||||||
```
|
```
|
||||||
|
|
||||||
Or install it yourself as:
|
Or install it yourself as:
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
$ gem install mcp
|
$ gem install mcp
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -155,7 +155,7 @@ transport.open
|
||||||
|
|
||||||
You can run this script and then type in requests to the server at the command line.
|
You can run this script and then type in requests to the server at the command line.
|
||||||
|
|
||||||
```bash
|
```console
|
||||||
$ ruby examples/stdio_server.rb
|
$ ruby examples/stdio_server.rb
|
||||||
{"jsonrpc":"2.0","id":"1","method":"ping"}
|
{"jsonrpc":"2.0","id":"1","method":"ping"}
|
||||||
{"jsonrpc":"2.0","id":"2","method":"tools/list"}
|
{"jsonrpc":"2.0","id":"2","method":"tools/list"}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ This directory contains examples of how to use the Model Context Protocol (MCP)
|
||||||
A simple server that communicates over standard input/output. This is useful for desktop applications and command-line tools.
|
A simple server that communicates over standard input/output. This is useful for desktop applications and command-line tools.
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
```bash
|
```console
|
||||||
$ ruby examples/stdio_server.rb
|
$ ruby examples/stdio_server.rb
|
||||||
{"jsonrpc":"2.0","id":0,"method":"tools/list"}
|
{"jsonrpc":"2.0","id":0,"method":"tools/list"}
|
||||||
```
|
```
|
||||||
|
|
@ -24,7 +24,7 @@ A standalone HTTP server built with Rack that implements the MCP Streamable HTTP
|
||||||
- Full MCP protocol compliance
|
- Full MCP protocol compliance
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
```bash
|
```console
|
||||||
$ ruby examples/http_server.rb
|
$ ruby examples/http_server.rb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -40,12 +40,12 @@ A client that demonstrates how to interact with the HTTP server using all MCP pr
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
1. Start the HTTP server in one terminal:
|
1. Start the HTTP server in one terminal:
|
||||||
```bash
|
```console
|
||||||
$ ruby examples/http_server.rb
|
$ ruby examples/http_server.rb
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Run the client example in another terminal:
|
2. Run the client example in another terminal:
|
||||||
```bash
|
```console
|
||||||
$ ruby examples/http_client.rb
|
$ ruby examples/http_client.rb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ A specialized HTTP server designed to test and demonstrate Server-Sent Events (S
|
||||||
- `echo` - Simple echo tool for basic testing
|
- `echo` - Simple echo tool for basic testing
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
```bash
|
```console
|
||||||
$ ruby examples/streamable_http_server.rb
|
$ ruby examples/streamable_http_server.rb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -87,12 +87,12 @@ An interactive client that connects to the SSE stream and provides a menu-driven
|
||||||
|
|
||||||
**Usage:**
|
**Usage:**
|
||||||
1. Start the SSE test server in one terminal:
|
1. Start the SSE test server in one terminal:
|
||||||
```bash
|
```console
|
||||||
$ ruby examples/streamable_http_server.rb
|
$ ruby examples/streamable_http_server.rb
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Run the SSE test client in another terminal:
|
2. Run the SSE test client in another terminal:
|
||||||
```bash
|
```console
|
||||||
$ ruby examples/streamable_http_client.rb
|
$ ruby examples/streamable_http_client.rb
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -107,19 +107,19 @@ The client will:
|
||||||
You can also test SSE functionality manually using cURL:
|
You can also test SSE functionality manually using cURL:
|
||||||
|
|
||||||
1. Initialize a session:
|
1. Initialize a session:
|
||||||
```bash
|
```console
|
||||||
SESSION_ID=$(curl -D - -s -o /dev/null -X POST http://localhost:9393 \
|
SESSION_ID=$(curl -D - -s -o /dev/null -X POST http://localhost:9393 \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-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')
|
-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')
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Connect to SSE stream (in one terminal):
|
2. Connect to SSE stream (in one terminal):
|
||||||
```bash
|
```console
|
||||||
curl -i -N -H "Mcp-Session-Id: $SESSION_ID" http://localhost:9393
|
curl -i -N -H "Mcp-Session-Id: $SESSION_ID" http://localhost:9393
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Trigger notifications (in another terminal):
|
3. Trigger notifications (in another terminal):
|
||||||
```bash
|
```console
|
||||||
# Send immediate notification
|
# Send immediate notification
|
||||||
curl -i -X POST http://localhost:9393 \
|
curl -i -X POST http://localhost:9393 \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
|
|
@ -151,14 +151,14 @@ The HTTP server implements the MCP Streamable HTTP transport protocol:
|
||||||
### Example cURL Commands
|
### Example cURL Commands
|
||||||
|
|
||||||
Initialize a session:
|
Initialize a session:
|
||||||
```bash
|
```console
|
||||||
curl -i -X POST http://localhost:9292 \
|
curl -i -X POST http://localhost:9292 \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
|
-d '{"jsonrpc":"2.0","method":"initialize","id":1,"params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'
|
||||||
```
|
```
|
||||||
|
|
||||||
List tools (using the session ID from initialization):
|
List tools (using the session ID from initialization):
|
||||||
```bash
|
```console
|
||||||
curl -i -X POST http://localhost:9292 \
|
curl -i -X POST http://localhost:9292 \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
|
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
|
||||||
|
|
@ -166,7 +166,7 @@ curl -i -X POST http://localhost:9292 \
|
||||||
```
|
```
|
||||||
|
|
||||||
Call a tool:
|
Call a tool:
|
||||||
```bash
|
```console
|
||||||
curl -i -X POST http://localhost:9292 \
|
curl -i -X POST http://localhost:9292 \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
|
-H "Mcp-Session-Id: YOUR_SESSION_ID" \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue