freddyaboulton HF Staff commited on
Commit
312d184
·
verified ·
1 Parent(s): ba2f25d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -4,7 +4,7 @@ from mcp.server.auth.provider import AccessToken, TokenVerifier
4
  from mcp.server.auth.settings import AuthSettings
5
  from mcp.server.fastmcp import FastMCP
6
  from fastapi import FastAPI
7
- from starlette.responses import JSONResponse
8
  import contextlib
9
 
10
 
@@ -23,7 +23,7 @@ mcp = FastMCP(
23
  # Auth settings for RFC 9728 Protected Resource Metadata
24
  auth=AuthSettings(
25
  issuer_url=AnyHttpUrl("https://huggingface.co/.well-known/oauth-authorization-server"), # Authorization Server URL
26
- resource_server_url=AnyHttpUrl("https://freddyaboulton-fastmcp-oauth.hf.space/weather_mcp/"), # This server's URL
27
  required_scopes=["user"],
28
  ),
29
  )
@@ -53,7 +53,10 @@ app.mount("/weather_mcp", mcp.streamable_http_app())
53
  async def _():
54
  return JSONResponse({"message": "Welcome to the Weather Service!"})
55
 
 
 
 
56
 
57
  if __name__ == "__main__":
58
  import uvicorn
59
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
4
  from mcp.server.auth.settings import AuthSettings
5
  from mcp.server.fastmcp import FastMCP
6
  from fastapi import FastAPI
7
+ from starlette.responses import JSONResponse, RedirectResponse
8
  import contextlib
9
 
10
 
 
23
  # Auth settings for RFC 9728 Protected Resource Metadata
24
  auth=AuthSettings(
25
  issuer_url=AnyHttpUrl("https://huggingface.co/.well-known/oauth-authorization-server"), # Authorization Server URL
26
+ resource_server_url=AnyHttpUrl("https://freddyaboulton-fastmcp-oauth.hf.space/"), # This server's URL
27
  required_scopes=["user"],
28
  ),
29
  )
 
53
  async def _():
54
  return JSONResponse({"message": "Welcome to the Weather Service!"})
55
 
56
+ @app.get("/.well-known/oauth-protected-resource")
57
+ async def _():
58
+ return RedirectResponse("/weather_mcp/.well-known/oauth-protected-resource")
59
 
60
  if __name__ == "__main__":
61
  import uvicorn
62
+ uvicorn.run(app, host="0.0.0.0", port=7860)