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
{{ message }}
Repository navigation
Commit c090dd6
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Detailed guides are available at https://ruby.sdk.modelcontextprotocol.io.
6
6
7
7
## Features
8
8
9
-
- Build [MCP servers](https://ruby.sdk.modelcontextprotocol.io/server/) that expose tools, prompts, and resources to any MCP host
9
+
- Build [MCP servers](https://ruby.sdk.modelcontextprotocol.io/server/) that expose tools, prompts, and resources to any MCP host, with OAuth 2.1 resource-server protection
10
10
- Build [MCP clients](https://ruby.sdk.modelcontextprotocol.io/client/) that connect to any MCP server, with automatic lifecycle negotiation and OAuth 2.1 authorization
11
11
- Speak every standard transport: stdio and Streamable HTTP (including SSE), with a Rails integration
12
12
- Cover the full protocol surface: server-to-client requests, multi round-trip requests, notifications, progress, logging, cancellation, completions, and pagination
Copy file name to clipboardExpand all lines: docs/_client/authorization.md
+5Lines changed: 5 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -502,3 +502,8 @@ An authorization server that changes between authorization and refresh is caught
502
502
present a refresh token to a different one, even when the client identity is portable across authorization servers as a Client ID Metadata Document URL is.
503
503
The transport answers that refusal by running a full authorization, which brings the new authorization server back here for you to accept or refuse.
504
504
Tokens stored before this behavior shipped carry no issuer and keep refreshing; the binding applies from their next authorization.
505
+
506
+
## Server Side
507
+
508
+
Protecting a server as an OAuth 2.1 resource server, verifying bearer tokens and serving the Protected Resource Metadata that this client discovers,
509
+
is documented on the server [Authorization](/server/authorization/) page.
Copy file name to clipboardExpand all lines: docs/_server/server-context.md
+9-1Lines changed: 9 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
layout: default
3
3
title: Server Context
4
-
nav_order: 20
4
+
nav_order: 21
5
5
---
6
6
7
7
# Server Context
@@ -29,6 +29,14 @@ Note that the exception reporter does not receive this user-defined hash, and in
29
29
callbacks omit it unless you opt in with `instrument_server_context`.
30
30
See the [Configuration](/server/configuration/) page for the arguments they receive.
31
31
32
+
## Authenticated Identity
33
+
34
+
When the Streamable HTTP transport verifies bearer tokens (see [Authorization](/server/authorization/)), the verified
35
+
`MCP::Server::OAuth::AccessToken` is available to handlers as `server_context.auth_info` (`server_context[:auth_info]` when the context
36
+
is a plain Hash), and `server_context.require_scopes!("some:scope")` rejects the current operation with a JSON-RPC error when the token
37
+
lacks a scope. Without bearer authentication `auth_info` is `nil` and `require_scopes!` fails closed;
38
+
see [Accessing the Token in Handlers](/server/authorization/#accessing-the-token-in-handlers).
39
+
32
40
## Request-specific `_meta` Parameter
33
41
34
42
The MCP protocol supports a special [`_meta` parameter](https://modelcontextprotocol.io/specification/latest/basic#general-fields) in requests that allows clients to pass request-specific metadata. The server automatically extracts this parameter and makes it available to tools and prompts as a nested field within the `server_context`.
Copy file name to clipboardExpand all lines: docs/examples.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ Runnable examples live in [`examples`](https://github.com/modelcontextprotocol/r
16
16
-[`http_server.rb`](https://github.com/modelcontextprotocol/ruby-sdk/blob/main/examples/http_server.rb) - a Rack-based Streamable HTTP server with session management and SSE support
17
17
-[`http_client.rb`](https://github.com/modelcontextprotocol/ruby-sdk/blob/main/examples/http_client.rb) - a client driving the HTTP server through all MCP protocol methods
18
18
-[`streamable_http_server.rb`](https://github.com/modelcontextprotocol/ruby-sdk/blob/main/examples/streamable_http_server.rb) - an SSE-focused server with tools that trigger notifications and progress updates
19
+
-[`streamable_http_server_oauth.rb`](https://github.com/modelcontextprotocol/ruby-sdk/blob/main/examples/streamable_http_server_oauth.rb) - a Streamable HTTP server protected as an OAuth 2.1 resource server, with a `whoami` tool that reads the verified token; `DEV_MODE=1` signs demo tokens locally
19
20
-[`streamable_http_client.rb`](https://github.com/modelcontextprotocol/ruby-sdk/blob/main/examples/streamable_http_client.rb) - an interactive, menu-driven client for testing the SSE stream
20
21
21
22
Each script is standalone and run from the repository root:
0 commit comments