fix saas issues
This commit is contained in:
+3
-2
@@ -4,7 +4,7 @@
|
||||
# Server Configuration
|
||||
HOST=0.0.0.0
|
||||
PORT=8000
|
||||
LOG_LEVEL=info
|
||||
LOG_LEVEL=INFO
|
||||
|
||||
# Authentication Configuration
|
||||
ENABLE_AUTH=false # Set to true in production for JWT validation
|
||||
@@ -48,7 +48,8 @@ EMSAL_TIMEOUT=60
|
||||
# ------ Clerk ------
|
||||
CLERK_PUBLISHABLE_KEY=pk_test_xxx
|
||||
CLERK_SECRET_KEY=sk_test_xxx
|
||||
CLERK_ISSUER=https://your-app.clerk.accounts.dev # issuer & JWKS root
|
||||
CLERK_ISSUER=https://your-app.clerk.accounts.dev # issuer & JWKS root (optional if using CLERK_PUBLIC_KEY)
|
||||
# CLERK_PUBLIC_KEY=-----BEGIN PUBLIC KEY-----\nMIIBIjANBg...\n-----END PUBLIC KEY-----
|
||||
|
||||
# ------ Stripe ------
|
||||
STRIPE_SECRET=sk_live_xxx
|
||||
|
||||
+15
-17
@@ -15,15 +15,12 @@ from fastapi.responses import JSONResponse
|
||||
from starlette.middleware import Middleware
|
||||
from starlette.middleware.cors import CORSMiddleware
|
||||
|
||||
# Import the main MCP app
|
||||
from mcp_factory import create_app
|
||||
# Import the fully configured MCP app with all tools
|
||||
from mcp_server_main import app as mcp_server
|
||||
|
||||
# Import Stripe webhook router
|
||||
from stripe_webhook import router as stripe_router
|
||||
|
||||
# Create MCP server instance
|
||||
mcp_server = create_app()
|
||||
|
||||
# Configure CORS middleware
|
||||
cors_origins = os.getenv("ALLOWED_ORIGINS", "*").split(",")
|
||||
custom_middleware = [
|
||||
@@ -36,23 +33,24 @@ custom_middleware = [
|
||||
),
|
||||
]
|
||||
|
||||
# Create FastAPI wrapper application
|
||||
app = FastAPI(
|
||||
title="Yargı MCP Server",
|
||||
description="MCP server for Turkish legal databases with JWT authentication",
|
||||
version="0.1.0",
|
||||
middleware=custom_middleware
|
||||
)
|
||||
|
||||
# Add Stripe webhook router to FastAPI
|
||||
app.include_router(stripe_router, prefix="/api")
|
||||
|
||||
# Create MCP Starlette sub-application
|
||||
# Create MCP Starlette sub-application first
|
||||
mcp_app = mcp_server.http_app(
|
||||
path="/",
|
||||
middleware=custom_middleware
|
||||
)
|
||||
|
||||
# Create FastAPI wrapper application with MCP app's lifespan
|
||||
app = FastAPI(
|
||||
title="Yargı MCP Server",
|
||||
description="MCP server for Turkish legal databases with JWT authentication",
|
||||
version="0.1.0",
|
||||
middleware=custom_middleware,
|
||||
lifespan=mcp_app.lifespan # Critical: Get lifespan from mcp_app, not mcp_server
|
||||
)
|
||||
|
||||
# Add Stripe webhook router to FastAPI
|
||||
app.include_router(stripe_router, prefix="/api")
|
||||
|
||||
# Mount MCP app as sub-application
|
||||
app.mount("/mcp", mcp_app)
|
||||
|
||||
|
||||
+15
-7
@@ -13,13 +13,21 @@ def create_app() -> FastMCP:
|
||||
dependencies=["httpx", "beautifulsoup4", "markitdown", "pydantic", "aiohttp", "playwright"]
|
||||
)
|
||||
|
||||
issuer = os.environ["CLERK_ISSUER"] # e.g. https://cool-app.clerk.accounts.dev
|
||||
auth = BearerAuthProvider(
|
||||
jwks_uri=f"{issuer}/.well-known/jwks.json", # Clerk JWKS pattern
|
||||
issuer=issuer,
|
||||
audience=os.environ["CLERK_PUBLISHABLE_KEY"], # PK appears in aud claim
|
||||
required_scopes=["yargi.read"],
|
||||
)
|
||||
# Public key'i environment variable'dan al, yoksa None
|
||||
public_key_pem = os.environ.get("CLERK_PUBLIC_KEY")
|
||||
|
||||
if public_key_pem:
|
||||
# Eğer public key varsa, onu kullan (production)
|
||||
auth = BearerAuthProvider(
|
||||
public_key=public_key_pem,
|
||||
# issuer, audience ve required_scopes kontrollerini yapmıyoruz
|
||||
)
|
||||
else:
|
||||
# Public key yoksa JWKS endpoint kullan (development/fallback)
|
||||
clerk_issuer = os.environ.get("CLERK_ISSUER", "https://clerk.accounts.dev")
|
||||
auth = BearerAuthProvider(
|
||||
jwks_uri=f"{clerk_issuer}/.well-known/jwks.json",
|
||||
)
|
||||
return FastMCP(
|
||||
name="Yargı MCP – PROD",
|
||||
auth=auth,
|
||||
|
||||
Reference in New Issue
Block a user