Merge pull request #33 from Ginja/streamable-http
Implement Streamable HTTP transport
This commit is contained in:
commit
382ae13e25
1 changed files with 2463 additions and 9 deletions
41
README.md
41
README.md
|
|
@ -33,6 +33,8 @@ It implements the Model Context Protocol specification, handling model context r
|
|||
- Manages tool registration and invocation
|
||||
- Supports prompt registration and execution
|
||||
- Supports resource registration and retrieval
|
||||
- Supports stdio & Streamable HTTP (including SSE) transports
|
||||
- Supports notifications for list changes (tools, prompts, resources)
|
||||
|
||||
### Supported Methods
|
||||
- `initialize` - Initializes the protocol and returns server capabilities
|
||||
|
|
@ -45,20 +47,53 @@ It implements the Model Context Protocol specification, handling model context r
|
|||
- `resources/read` - Retrieves a specific resource by name
|
||||
- `resources/templates/list` - Lists all registered resource templates and their schemas
|
||||
|
||||
### Notifications
|
||||
|
||||
The server supports sending notifications to clients when lists of tools, prompts, or resources change. This enables real-time updates without polling.
|
||||
|
||||
#### Notification Methods
|
||||
|
||||
The server provides three notification methods:
|
||||
- `notify_tools_list_changed()` - Send a notification when the tools list changes
|
||||
- `notify_prompts_list_changed()` - Send a notification when the prompts list changes
|
||||
- `notify_resources_list_changed()` - Send a notification when the resources list changes
|
||||
|
||||
#### Notification Format
|
||||
|
||||
Notifications follow the JSON-RPC 2.0 specification and use these method names:
|
||||
- `notifications/tools/list_changed`
|
||||
- `notifications/prompts/list_changed`
|
||||
- `notifications/resources/list_changed`
|
||||
|
||||
#### Transport Support
|
||||
|
||||
- **HTTP Transport**: Notifications are sent as Server-Sent Events (SSE) to all connected sessions
|
||||
- **Stdio Transport**: Notifications are sent as JSON-RPC 2.0 messages to stdout
|
||||
|
||||
#### Usage Example
|
||||
|
||||
```ruby
|
||||
server = MCP::Server.new(name: "my_server")
|
||||
transport = MCP::Transports::HTTP.new(server)
|
||||
server.transport = transport
|
||||
|
||||
# When tools change, notify clients
|
||||
server.define_tool(name: "new_tool") { |**args| { result: "ok" } }
|
||||
server.notify_tools_list_changed()
|
||||
```
|
||||
|
||||
### Unsupported Features ( to be implemented in future versions )
|
||||
|
||||
- Notifications
|
||||
- Log Level
|
||||
- Resource subscriptions
|
||||
- Completions
|
||||
- Complete StreamableHTTP implementation with streaming responses
|
||||
|
||||
### Usage
|
||||
|
||||
#### Rails Controller
|
||||
|
||||
When added to a Rails controller on a route that handles POST requests, your server will be compliant with non-streaming
|
||||
[StreamableHTTP](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) transport
|
||||
[Streamable HTTP](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) transport
|
||||
requests.
|
||||
|
||||
You can use the `Server#handle_json` method to handle requests.
|
||||
|
|
|
|||
Loading…
Reference in a new issue