Skip to content

πŸš€ The fast, Pythonic way to build MCP servers and clients.

Update anthropic + openai to show SHTTP

Jeremiah Lowinb4b9c57bddbc
diff --git a/docs/integrations/anthropic.mdx b/docs/integrations/anthropic.mdx
index e9ebe8601..476569b42 100644
--- a/docs/integrations/anthropic.mdx
+++ b/docs/integrations/anthropic.mdx
@@ -31,7 +31,7 @@ def roll_dice(n_dice: int) -> list[int]:
return [random.randint(1, 6) for _ in range(n_dice)]
if __name__ == "__main__":
- mcp.run(transport="sse", port=8000)
+ mcp.run(transport="streamable-http", port=8000)
```
## Deploy the Server
@@ -70,7 +70,7 @@ You'll also need to authenticate with Anthropic. You can do this by setting the
export ANTHROPIC_API_KEY="your-api-key"
```
-Here is an example of how to call your server from Python. Note that you'll need to replace `https://your-server-url.com` with the actual URL of your server. In addition, we use `/sse` as the endpoint because we deployed an SSE server with the default path; you may need to use a different endpoint if you customized your server's deployment. **At this time you must also include the `extra_headers` parameter with the `anthropic-beta` header.**
+Here is an example of how to call your server from Python. Note that you'll need to replace `https://your-server-url.com` with the actual URL of your server. In addition, we use `/mcp/` as the endpoint because we deployed a streamable-HTTP server with the default path; you may need to use a different endpoint if you customized your server's deployment. **At this time you must also include the `extra_headers` parameter with the `anthropic-beta` header.**
```python {5, 13-22}
import anthropic
@@ -88,7 +88,7 @@ response = client.beta.messages.create(
mcp_servers=[
{
"type": "url",
- "url": f"{url}/sse",
+ "url": f"{url}/mcp/",
"name": "dice-server",
}
],
@@ -175,7 +175,7 @@ def roll_dice(n_dice: int) -> list[int]:
if __name__ == "__main__":
print(f"\n---\n\nπŸ”‘ Dice Roller access token:\n\n{access_token}\n\n---\n")
- mcp.run(transport="sse", port=8000)
+ mcp.run(transport="streamable-http", port=8000)
```
### Client Authentication
@@ -213,7 +213,7 @@ response = client.beta.messages.create(
mcp_servers=[
{
"type": "url",
- "url": f"{url}/sse",
+ "url": f"{url}/mcp/",
"name": "dice-server",
"authorization_token": access_token
}
diff --git a/docs/integrations/openai.mdx b/docs/integrations/openai.mdx
index ba0d00941..fe3447dec 100644
--- a/docs/integrations/openai.mdx
+++ b/docs/integrations/openai.mdx
@@ -38,7 +38,7 @@ def roll_dice(n_dice: int) -> list[int]:
return [random.randint(1, 6) for _ in range(n_dice)]
if __name__ == "__main__":
- mcp.run(transport="sse", port=8000)
+ mcp.run(transport="streamable-http", port=8000)
```
### Deploy the Server
@@ -77,7 +77,7 @@ You'll also need to authenticate with OpenAI. You can do this by setting the `OP
export OPENAI_API_KEY="your-api-key"
```
-Here is an example of how to call your server from Python. Note that you'll need to replace `https://your-server-url.com` with the actual URL of your server. In addition, we use `/sse` as the endpoint because we deployed an SSE server with the default path; you may need to use a different endpoint if you customized your server's deployment.
+Here is an example of how to call your server from Python. Note that you'll need to replace `https://your-server-url.com` with the actual URL of your server. In addition, we use `/mcp/` as the endpoint because we deployed a streamable-HTTP server with the default path; you may need to use a different endpoint if you customized your server's deployment.
```python {4, 11-16}
from openai import OpenAI
@@ -93,7 +93,7 @@ resp = client.responses.create(
{
"type": "mcp",
"server_label": "dice_server",
- "server_url": f"{url}/sse",
+ "server_url": f"{url}/mcp/",
"require_approval": "never",
},
],
@@ -172,7 +172,7 @@ def roll_dice(n_dice: int) -> list[int]:
if __name__ == "__main__":
print(f"\n---\n\nπŸ”‘ Dice Roller access token:\n\n{access_token}\n\n---\n")
- mcp.run(transport="sse", port=8000)
+ mcp.run(transport="streamable-http", port=8000)
```
#### Client Authentication
@@ -212,7 +212,7 @@ resp = client.responses.create(
{
"type": "mcp",
"server_label": "dice_server",
- "server_url": f"{url}/sse",
+ "server_url": f"{url}/mcp/",
"require_approval": "never",
"headers": {
"Authorization": f"Bearer {access_token}"