Skip to content

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

Fix CORS documentation example to properly handle preflight requests

Jeremiah Lowinac252fc28f97
diff --git a/CLAUDE.md b/CLAUDE.md
index 24f9846b1..1da059260 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -27,4 +27,9 @@ Only use HTTP transport when testing network-specific features. Prefer Streamabl
# Only when network testing is required
async with Client(transport=StreamableHttpTransport(server_url)) as client:
result = await client.ping()
-```
\ No newline at end of file
+```
+
+## Development Workflow
+
+- You must always run pre-commit if you open a PR, because it is run as part of a required check.
+- When opening PRs, apply labels appropriately for bugs/breaking changes/enhancements/features. Generally, improvements are enhancements (not features) unless told otherwise.
\ No newline at end of file
diff --git a/docs/deployment/asgi.mdx b/docs/deployment/asgi.mdx
index 06da46374..56947cde9 100644
--- a/docs/deployment/asgi.mdx
+++ b/docs/deployment/asgi.mdx
@@ -96,7 +96,13 @@ mcp = FastMCP("MyServer")
# Define custom middleware
custom_middleware = [
- Middleware(CORSMiddleware, allow_origins=["*"]),
+ Middleware(
+ CORSMiddleware,
+ allow_origins=["https://example.com", "https://app.example.com"],
+ allow_credentials=True,
+ allow_methods=["GET", "POST", "OPTIONS"],
+ allow_headers=["Content-Type", "Authorization"],
+ ),
]
# Create ASGI app with custom middleware