Skip to content

Commit 2382722

Browse files
committed
add cors middleware
1 parent e160752 commit 2382722

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/worker.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
def setup_server():
88
from mcp.server.fastmcp import FastMCP
9+
from starlette.middleware import Middleware
10+
from starlette.middleware.cors import CORSMiddleware
911

1012
from exceptions import HTTPException, http_exception
1113
mcp = FastMCP("Demo", stateless_http=True)
@@ -32,6 +34,7 @@ def echo_prompt(message: str) -> str:
3234

3335
app = mcp.streamable_http_app()
3436
app.add_exception_handler(HTTPException, http_exception)
37+
app.add_middleware(CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"])
3538
return mcp, app
3639

3740

0 commit comments

Comments
 (0)