|
4 | 4 | from typing import List, Dict, Any |
5 | 5 | from fastmcp import FastMCP |
6 | 6 | from fastmcp.server.dependencies import get_access_token, AccessToken |
| 7 | +from fastmcp.server.auth.providers.jwt import JWTVerifier |
7 | 8 | from slack_sdk import WebClient |
8 | 9 | from slack_sdk.errors import SlackApiError |
9 | 10 |
|
@@ -48,9 +49,19 @@ def get_slack_client(access_token=None): |
48 | 49 | return slack_client_from_bot_token(SLACK_BOT_TOKEN) |
49 | 50 |
|
50 | 51 |
|
51 | | -# Create FastMCP app with same parameters as original |
52 | | -# This combines both token_verifier and auth functionality from the original |
53 | | -mcp = FastMCP("Slack") |
| 52 | +# Create FastMCP app |
| 53 | +# Temporary environment variables to manually create verifier |
| 54 | +verifier = None |
| 55 | +JWKS_URI = os.getenv("JWKS_URI") |
| 56 | +ISSUER = os.getenv("ISSUER") |
| 57 | +AUDIENCE = os.getenv("AUDIENCE") |
| 58 | +if not JWKS_URI is None: |
| 59 | + verifier = JWTVerifier( |
| 60 | + jwks_uri = JWKS_URI, |
| 61 | + issuer = ISSUER, |
| 62 | + AUDIENCE = AUDIENCE |
| 63 | + ) |
| 64 | +mcp = FastMCP("Slack", auth=verifier) |
54 | 65 |
|
55 | 66 | @mcp.tool() |
56 | 67 | def get_channels() -> List[Dict[str, Any]]: |
@@ -130,7 +141,7 @@ def run_server(): |
130 | 141 | run_server() |
131 | 142 | else: # two tokens set -> we validate the JWT and connect to slack based on access token scope |
132 | 143 | # check if other required Auth variables are set |
133 | | - auth = os.getenv("FASTMCP_SERVER_AUTH") |
| 144 | + auth = os.getenv("JWKS_URI") |
134 | 145 | if auth is None: |
135 | 146 | logger.error("Configured ADMIN_SLACK_BOT_TOKEN but auth is not configured - fine grained authz requires token validation") |
136 | 147 | else: |
|
0 commit comments