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
server =newMcpServer({ name: "Demo", version: "1.0.0" });
20
-
21
-
async init() {
22
-
this.server.tool(
23
-
"add",
24
-
{ a: z.number(), b: z.number() },
25
-
async ({ a, b }) => ({
26
-
content: [{ type: "text", text: String(a+b) }],
27
-
}),
28
-
);
29
-
}
20
+
server =newMcpServer({ name: "Demo", version: "1.0.0" });
21
+
22
+
async init() {
23
+
this.server.tool(
24
+
"add",
25
+
{ a: z.number(), b: z.number() },
26
+
async ({ a, b }) => ({
27
+
content: [{ type: "text", text: String(a+b) }],
28
+
}),
29
+
);
30
+
}
30
31
}
31
32
```
32
33
@@ -48,6 +49,19 @@ You can use the APIs below in order to do so.
48
49
#### Hibernation Support
49
50
`McpAgent` instances automatically support [WebSockets Hibernation](/durable-objects/best-practices/websockets/#websocket-hibernation-api), allowing stateful MCP servers to sleep during inactive periods while preserving their state. This means your agents only consume compute resources when actively processing requests, optimizing costs while maintaining the full context and conversation history.
50
51
52
+
Hibernation is enabled by default and requires no additional configuration.
53
+
54
+
#### Authentication & Authorization
55
+
56
+
The McpAgent class provides seamless integration with the [OAuth Provider Library](https://github.com/cloudflare/workers-oauth-provider) for [authentication and authorization](/agents/model-context-protocol/authorization/).
57
+
58
+
When a user authenticates to your MCP server, their identity information and tokens are made available through the `props` parameter, allowing you to:
59
+
60
+
- access user-specific data
61
+
- check user permissions before performing operations
62
+
- customize responses based on user attributes
63
+
- use authentication tokens to make requests to external services on behalf of the user
64
+
51
65
### State synchronization APIs
52
66
53
67
The `McpAgent` class makes the following subset of methods from the [Agents SDK](/agents/api-reference/agents-api/) available:
0 commit comments