Skip to content

Commit b11b343

Browse files
committed
use environment variables to create verifier
Signed-off-by: Maia Iyer <maia.raj.iyer@gmail.com>
1 parent 2eb828d commit b11b343

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

mcp/slack_tool/slack_tool.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import List, Dict, Any
55
from fastmcp import FastMCP
66
from fastmcp.server.dependencies import get_access_token, AccessToken
7+
from fastmcp.server.auth.providers.jwt import JWTVerifier
78
from slack_sdk import WebClient
89
from slack_sdk.errors import SlackApiError
910

@@ -48,9 +49,19 @@ def get_slack_client(access_token=None):
4849
return slack_client_from_bot_token(SLACK_BOT_TOKEN)
4950

5051

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)
5465

5566
@mcp.tool()
5667
def get_channels() -> List[Dict[str, Any]]:
@@ -130,7 +141,7 @@ def run_server():
130141
run_server()
131142
else: # two tokens set -> we validate the JWT and connect to slack based on access token scope
132143
# check if other required Auth variables are set
133-
auth = os.getenv("FASTMCP_SERVER_AUTH")
144+
auth = os.getenv("JWKS_URI")
134145
if auth is None:
135146
logger.error("Configured ADMIN_SLACK_BOT_TOKEN but auth is not configured - fine grained authz requires token validation")
136147
else:

0 commit comments

Comments
 (0)