Skip to content

Commit b8f11cd

Browse files
committed
Remove but document mcp auth
1 parent e95a02a commit b8f11cd

File tree

4 files changed

+59
-25
lines changed

4 files changed

+59
-25
lines changed

docs/mcp_server.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Capturing the notes from auth install before deleting for docs...
2+
3+
### Auth section:
4+
Requires and app registration as in azure_app_service_auth_setup.md so not deployed by default.
5+
6+
To setup basic auth with FastMCP - bearer token - you can integrate with Azure by using it as your token provider.
7+
8+
``` from fastmcp.server.auth import JWTVerifier```
9+
10+
```
11+
auth = JWTVerifier(
12+
jwks_uri="https://login.microsoftonline.com/52b39610-0746-4c25-a83d-d4f89fadedfe/discovery/v2.0/keys",
13+
#issuer="https://login.microsoftonline.com/52b39610-0746-4c25-a83d-d4f89fadedfe/v2.0",
14+
# This issuer is not correct in the docs. Found by decoding the token.
15+
issuer="https://sts.windows.net/52b39610-0746-4c25-a83d-d4f89fadedfe/",
16+
algorithm="RS256",
17+
audience="api://7a95e70b-062e-4cd3-a88c-603fc70e1c73"
18+
)
19+
```
20+
21+
Requires env vars:
22+
```
23+
export MICROSOFT_CLIENT_ID="your-client-id"
24+
export MICROSOFT_CLIENT_SECRET="your-client-secret"
25+
export MICROSOFT_TENANT="common" # Or your tenant ID
26+
```
27+
28+
```mcp = FastMCP("My MCP Server", auth=auth)```
29+
30+
For more complex and production - supports OAuth and PKCE
31+
32+
Enabled through MCP enabled base - see lifecycle.py
33+
34+

src/backend/v3/api/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ async def select_team_endpoint(selection: TeamSelectionRequest, request: Request
727727
session_id = selection.session_id or str(uuid.uuid4())
728728

729729
# save to in-memory config for current user
730-
team_config.set_current_team(user_id=user_id, team_config=team_configuration)
730+
team_config.set_current_team(user_id=user_id, team_configuration=team_configuration)
731731

732732
# Track the team selection event
733733
track_event_if_configured(

src/backend/v3/magentic_agents/common/lifecycle.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,29 @@ async def _after_open(self) -> None:
6060
"""Subclasses must build self._agent here."""
6161
raise NotImplementedError
6262

63-
# Internals
64-
def _build_mcp_headers(self) -> dict:
65-
if not self.mcp_cfg.client_id:
66-
return {}
67-
self.cred = InteractiveBrowserCredential(
68-
tenant_id=self.mcp_cfg.tenant_id or None,
69-
client_id=self.mcp_cfg.client_id,
70-
)
71-
tok = self.cred.get_token(f"api://{self.mcp_cfg.client_id}/access_as_user")
72-
return {
73-
"Authorization": f"Bearer {tok.token}",
74-
"Content-Type": "application/json",
75-
}
63+
# For use when implementing bearer token auth
64+
# def _build_mcp_headers(self) -> dict:
65+
# if not self.mcp_cfg.client_id:
66+
# return {}
67+
# self.cred = InteractiveBrowserCredential(
68+
# tenant_id=self.mcp_cfg.tenant_id or None,
69+
# client_id=self.mcp_cfg.client_id,
70+
# )
71+
# tok = self.cred.get_token(f"api://{self.mcp_cfg.client_id}/access_as_user")
72+
# return {
73+
# "Authorization": f"Bearer {tok.token}",
74+
# "Content-Type": "application/json",
75+
# }
7676

7777
async def _enter_mcp_if_configured(self) -> None:
7878
if not self.mcp_cfg:
7979
return
80-
headers = self._build_mcp_headers()
80+
#headers = self._build_mcp_headers()
8181
plugin = MCPStreamableHttpPlugin(
8282
name=self.mcp_cfg.name,
8383
description=self.mcp_cfg.description,
8484
url=self.mcp_cfg.url,
85-
headers=headers,
85+
#headers=headers,
8686
)
8787
# Enter MCP async context via the stack to ensure correct LIFO cleanup
8888
if self._stack is None:

src/mcp_server/my_mcp_server/my_mcp_server.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
from fastmcp.server.auth import JWTVerifier
55
from utils_date import format_date_for_user
66

7-
auth = JWTVerifier(
8-
jwks_uri="https://login.microsoftonline.com/52b39610-0746-4c25-a83d-d4f89fadedfe/discovery/v2.0/keys",
9-
#issuer="https://login.microsoftonline.com/52b39610-0746-4c25-a83d-d4f89fadedfe/v2.0",
10-
# This issuer is not correct in the docs. Found by decoding the token.
11-
issuer="https://sts.windows.net/52b39610-0746-4c25-a83d-d4f89fadedfe/",
12-
algorithm="RS256",
13-
audience="api://7a95e70b-062e-4cd3-a88c-603fc70e1c73"
14-
)
7+
# auth = JWTVerifier(
8+
# jwks_uri="https://login.microsoftonline.com/52b39610-0746-4c25-a83d-d4f89fadedfe/discovery/v2.0/keys",
9+
# #issuer="https://login.microsoftonline.com/52b39610-0746-4c25-a83d-d4f89fadedfe/v2.0",
10+
# # This issuer is not correct in the docs. Found by decoding the token.
11+
# issuer="https://sts.windows.net/52b39610-0746-4c25-a83d-d4f89fadedfe/",
12+
# algorithm="RS256",
13+
# audience="api://7a95e70b-062e-4cd3-a88c-603fc70e1c73"
14+
# )
1515

1616
class Domain(Enum):
1717
HR = "hr"
@@ -21,7 +21,7 @@ class Domain(Enum):
2121
TECH_SUPPORT = "tech_support"
2222
RETAIL = "Retail"
2323

24-
mcp = FastMCP("My MCP Server", auth=auth)
24+
mcp = FastMCP("My MCP Server")
2525

2626
formatting_instructions = "Instructions: returning the output of this function call verbatim to the user in markdown. Then write AGENT SUMMARY: and then include a summary of what you did."
2727

0 commit comments

Comments
 (0)