Jeremiah Lowin commited on
Commit
ef267ad
·
1 Parent(s): f9c77fe

Update anthropic + openai to show SHTTP

Browse files
docs/integrations/anthropic.mdx CHANGED
@@ -31,7 +31,7 @@ def roll_dice(n_dice: int) -> list[int]:
31
  return [random.randint(1, 6) for _ in range(n_dice)]
32
 
33
  if __name__ == "__main__":
34
- mcp.run(transport="sse", port=8000)
35
  ```
36
 
37
  ## Deploy the Server
@@ -70,7 +70,7 @@ You'll also need to authenticate with Anthropic. You can do this by setting the
70
  export ANTHROPIC_API_KEY="your-api-key"
71
  ```
72
 
73
- 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.**
74
 
75
  ```python {5, 13-22}
76
  import anthropic
@@ -88,7 +88,7 @@ response = client.beta.messages.create(
88
  mcp_servers=[
89
  {
90
  "type": "url",
91
- "url": f"{url}/sse",
92
  "name": "dice-server",
93
  }
94
  ],
@@ -175,7 +175,7 @@ def roll_dice(n_dice: int) -> list[int]:
175
 
176
  if __name__ == "__main__":
177
  print(f"\n---\n\n🔑 Dice Roller access token:\n\n{access_token}\n\n---\n")
178
- mcp.run(transport="sse", port=8000)
179
  ```
180
 
181
  ### Client Authentication
@@ -213,7 +213,7 @@ response = client.beta.messages.create(
213
  mcp_servers=[
214
  {
215
  "type": "url",
216
- "url": f"{url}/sse",
217
  "name": "dice-server",
218
  "authorization_token": access_token
219
  }
 
31
  return [random.randint(1, 6) for _ in range(n_dice)]
32
 
33
  if __name__ == "__main__":
34
+ mcp.run(transport="streamable-http", port=8000)
35
  ```
36
 
37
  ## Deploy the Server
 
70
  export ANTHROPIC_API_KEY="your-api-key"
71
  ```
72
 
73
+ 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.**
74
 
75
  ```python {5, 13-22}
76
  import anthropic
 
88
  mcp_servers=[
89
  {
90
  "type": "url",
91
+ "url": f"{url}/mcp/",
92
  "name": "dice-server",
93
  }
94
  ],
 
175
 
176
  if __name__ == "__main__":
177
  print(f"\n---\n\n🔑 Dice Roller access token:\n\n{access_token}\n\n---\n")
178
+ mcp.run(transport="streamable-http", port=8000)
179
  ```
180
 
181
  ### Client Authentication
 
213
  mcp_servers=[
214
  {
215
  "type": "url",
216
+ "url": f"{url}/mcp/",
217
  "name": "dice-server",
218
  "authorization_token": access_token
219
  }
docs/integrations/openai.mdx CHANGED
@@ -38,7 +38,7 @@ def roll_dice(n_dice: int) -> list[int]:
38
  return [random.randint(1, 6) for _ in range(n_dice)]
39
 
40
  if __name__ == "__main__":
41
- mcp.run(transport="sse", port=8000)
42
  ```
43
 
44
  ### Deploy the Server
@@ -77,7 +77,7 @@ You'll also need to authenticate with OpenAI. You can do this by setting the `OP
77
  export OPENAI_API_KEY="your-api-key"
78
  ```
79
 
80
- 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.
81
 
82
  ```python {4, 11-16}
83
  from openai import OpenAI
@@ -93,7 +93,7 @@ resp = client.responses.create(
93
  {
94
  "type": "mcp",
95
  "server_label": "dice_server",
96
- "server_url": f"{url}/sse",
97
  "require_approval": "never",
98
  },
99
  ],
@@ -172,7 +172,7 @@ def roll_dice(n_dice: int) -> list[int]:
172
 
173
  if __name__ == "__main__":
174
  print(f"\n---\n\n🔑 Dice Roller access token:\n\n{access_token}\n\n---\n")
175
- mcp.run(transport="sse", port=8000)
176
  ```
177
 
178
  #### Client Authentication
@@ -212,7 +212,7 @@ resp = client.responses.create(
212
  {
213
  "type": "mcp",
214
  "server_label": "dice_server",
215
- "server_url": f"{url}/sse",
216
  "require_approval": "never",
217
  "headers": {
218
  "Authorization": f"Bearer {access_token}"
 
38
  return [random.randint(1, 6) for _ in range(n_dice)]
39
 
40
  if __name__ == "__main__":
41
+ mcp.run(transport="streamable-http", port=8000)
42
  ```
43
 
44
  ### Deploy the Server
 
77
  export OPENAI_API_KEY="your-api-key"
78
  ```
79
 
80
+ 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.
81
 
82
  ```python {4, 11-16}
83
  from openai import OpenAI
 
93
  {
94
  "type": "mcp",
95
  "server_label": "dice_server",
96
+ "server_url": f"{url}/mcp/",
97
  "require_approval": "never",
98
  },
99
  ],
 
172
 
173
  if __name__ == "__main__":
174
  print(f"\n---\n\n🔑 Dice Roller access token:\n\n{access_token}\n\n---\n")
175
+ mcp.run(transport="streamable-http", port=8000)
176
  ```
177
 
178
  #### Client Authentication
 
212
  {
213
  "type": "mcp",
214
  "server_label": "dice_server",
215
+ "server_url": f"{url}/mcp/",
216
  "require_approval": "never",
217
  "headers": {
218
  "Authorization": f"Bearer {access_token}"