-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
35 lines (30 loc) · 1.27 KB
/
Copy pathserver.py
File metadata and controls
35 lines (30 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from fastmcp import FastMCP
from fastmcp.server.auth.providers.auth0 import Auth0Provider
import os
from typing import Literal
from dotenv import load_dotenv
load_dotenv()
# --- Configuration ---
# You must change these to your actual values
AUTH0_CLIENT_ID = os.environ.get("AUTH0_CLIENT_ID", "")
AUTH0_CLIENT_SECRET = os.environ.get("AUTH0_CLIENT_SECRET", "")
AUTH0_DOMAIN = os.environ.get("AUTH0_DOMAIN", "")
SERVER_BASE_URL = os.environ.get("SERVER_BASE_URL", "")
# --- Authentication Setup ---
auth = Auth0Provider(
config_url=f"https://{AUTH0_DOMAIN}/.well-known/openid-configuration",
client_id=AUTH0_CLIENT_ID,
client_secret=AUTH0_CLIENT_SECRET,
audience=f"https://{AUTH0_DOMAIN}/api/v2/",
base_url=SERVER_BASE_URL,
required_scopes=["openid", "profile", "email"]
)
# --- MCP Server Definition ---
mcp = FastMCP(name="Auth0 FastMCP Server", auth=auth)
@mcp.tool
def get_user_status(level: Literal["basic", "full"]) -> str:
"""Gets the status of the authenticated user based on the requested access level."""
# In a real app, you would inspect the token/context here to get user info.
return f"Status requested at {level} level. Connection successful and authenticated."
if __name__ == "__main__":
mcp.run(transport="http", host="127.0.0.1", port=8000)