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
Copy file name to clipboardExpand all lines: helpers.md
+86-2Lines changed: 86 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ The stream will be cancelled when the context manager exits but you can also clo
28
28
29
29
See an example of streaming helpers in action in [`examples/messages_stream.py`](examples/messages_stream.py).
30
30
31
-
> [!NOTE]
31
+
> [!NOTE]
32
32
> The synchronous client has the same interface just without `async/await`.
33
33
34
34
### Lenses
@@ -131,7 +131,91 @@ Blocks until the stream has been read to completion and returns the accumulated
131
131
132
132
#### `await .get_final_text()`
133
133
134
-
> [!NOTE]
134
+
> [!NOTE]
135
135
> Currently the API will only ever return 1 content block
136
136
137
137
Blocks until the stream has been read to completion and returns all `text` content blocks concatenated together.
138
+
139
+
## MCP Helpers
140
+
141
+
This SDK provides helpers for integrating with [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers. These helpers convert MCP types to Anthropic API types, reducing boilerplate when working with MCP tools, prompts, and resources.
142
+
143
+
> **Note:** The Claude API also supports an [`mcp_servers` parameter](https://docs.anthropic.com/en/docs/agents-and-tools/mcp) that lets Claude connect directly to remote MCP servers.
144
+
>
145
+
> - Use `mcp_servers` when you have remote servers accessible via URL and only need tool support.
146
+
> - Use the MCP helpers when you need local MCP servers, prompts, resources, or more control over the MCP connection.
The conversion functions raise `UnsupportedMCPValueError` if an MCP value cannot be converted to a format supported by the Claude API (e.g., unsupported content type like audio, unsupported MIME type).
0 commit comments