Skip to content

Commit e03c0d8

Browse files
authored
Merge branch 'main' into migration/resize-url-slug-columns
2 parents 97bb774 + 778492f commit e03c0d8

File tree

672 files changed

+71407
-21754
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

672 files changed

+71407
-21754
lines changed

.env.example

Lines changed: 247 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ DATABASE_URL=sqlite:///./mcp.db
5252
# Database Connection Pool Configuration
5353
# Maximum number of persistent connections (default: 200, optimized for SQLite)
5454
DB_POOL_SIZE=200
55-
# Additional connections beyond pool_size (default: 10, reduced for SQLite)
55+
# Additional connections beyond pool_size (default: 10, reduced to 5 for SQLite)
5656
DB_MAX_OVERFLOW=5
57-
# Seconds to wait for connection before timeout (increased for reliability)
57+
# Seconds to wait for connection before timeout (default: 30, increased to 60 for reliability)
5858
DB_POOL_TIMEOUT=60
5959
# Seconds before recreating connection (default: 3600)
6060
DB_POOL_RECYCLE=3600
61-
# Maximum database retry attempts (default: 3, increased for stability)
61+
# Maximum database retry attempts (default: 3, increased to 5 for stability)
6262
DB_MAX_RETRIES=5
6363
# Retry interval in milliseconds (default: 2000)
6464
DB_RETRY_INTERVAL_MS=2000
@@ -215,47 +215,47 @@ OAUTH_DEFAULT_TIMEOUT=3600
215215
# Enable Dynamic Client Registration (RFC 7591)
216216
# When enabled, MCP Gateway can automatically register as an OAuth client with Authorization Servers
217217
# that support DCR, eliminating the need for manual client credential configuration.
218-
MCPGATEWAY_DCR_ENABLED=true
218+
DCR_ENABLED=true
219219

220220
# Auto-register when gateway has issuer but no client_id
221221
# When true, gateway automatically registers with the Authorization Server when configured
222222
# with an issuer URL but no client credentials.
223-
MCPGATEWAY_DCR_AUTO_REGISTER_ON_MISSING_CREDENTIALS=true
223+
DCR_AUTO_REGISTER_ON_MISSING_CREDENTIALS=true
224224

225225
# Default scopes to request during DCR
226-
# Comma-separated list of OAuth scopes to request when auto-registering
227-
MCPGATEWAY_DCR_DEFAULT_SCOPES=mcp:read
226+
# JSON array of OAuth scopes to request when auto-registering
227+
DCR_DEFAULT_SCOPES=["mcp:read"]
228228

229229
# Optional allowlist of issuer URLs for DCR (empty = allow any)
230-
# Comma-separated list of trusted Authorization Server issuer URLs
231-
# Example: https://auth.example.com,https://auth2.example.com
232-
# Leave empty to allow DCR with any issuer (not recommended for production)
233-
MCPGATEWAY_DCR_ALLOWED_ISSUERS=
230+
# JSON array of trusted Authorization Server issuer URLs
231+
# Example: ["https://auth.example.com", "https://auth2.example.com"]
232+
# Empty array [] allows DCR with any issuer (not recommended for production)
233+
DCR_ALLOWED_ISSUERS=[]
234234

235235
# Token endpoint authentication method for DCR
236236
# Options: client_secret_basic (default), client_secret_post, none
237237
# - client_secret_basic: Send credentials via HTTP Basic Auth header
238238
# - client_secret_post: Send credentials in POST body
239239
# - none: Public client (no client secret, PKCE-only)
240-
MCPGATEWAY_DCR_TOKEN_ENDPOINT_AUTH_METHOD=client_secret_basic
240+
DCR_TOKEN_ENDPOINT_AUTH_METHOD=client_secret_basic
241241

242242
# AS metadata cache TTL in seconds (RFC 8414 discovery)
243243
# How long to cache Authorization Server metadata after discovery
244-
MCPGATEWAY_DCR_METADATA_CACHE_TTL=3600
244+
DCR_METADATA_CACHE_TTL=3600
245245

246246
# Template for client_name in DCR requests
247247
# {gateway_name} will be replaced with the actual gateway name
248-
MCPGATEWAY_DCR_CLIENT_NAME_TEMPLATE=MCP Gateway ({gateway_name})
248+
DCR_CLIENT_NAME_TEMPLATE=MCP Gateway ({gateway_name})
249249

250250
# Enable OAuth AS metadata discovery (RFC 8414)
251251
# When enabled, gateway automatically discovers Authorization Server endpoints
252252
# from the issuer URL using well-known metadata endpoints
253-
MCPGATEWAY_OAUTH_DISCOVERY_ENABLED=true
253+
OAUTH_DISCOVERY_ENABLED=true
254254

255255
# Preferred PKCE code challenge method
256256
# Options: S256 (SHA-256, recommended), plain (not recommended)
257257
# PKCE (Proof Key for Code Exchange) is always enabled for Authorization Code flows
258-
MCPGATEWAY_OAUTH_PREFERRED_CODE_CHALLENGE_METHOD=S256
258+
OAUTH_PREFERRED_CODE_CHALLENGE_METHOD=S256
259259

260260
# ==============================================================================
261261
# SSO (Single Sign-On) Configuration
@@ -290,13 +290,49 @@ SSO_OKTA_ENABLED=false
290290
# SSO_OKTA_CLIENT_SECRET=your-okta-client-secret
291291
# SSO_OKTA_ISSUER=https://your-okta-domain.okta.com
292292

293+
# Keycloak OIDC Configuration (with auto-discovery)
294+
SSO_KEYCLOAK_ENABLED=false
295+
# SSO_KEYCLOAK_BASE_URL=https://keycloak.example.com
296+
# SSO_KEYCLOAK_REALM=master
297+
# SSO_KEYCLOAK_CLIENT_ID=mcp-gateway
298+
# SSO_KEYCLOAK_CLIENT_SECRET=your-keycloak-client-secret
299+
# SSO_KEYCLOAK_MAP_REALM_ROLES=true
300+
# SSO_KEYCLOAK_MAP_CLIENT_ROLES=false
301+
# SSO_KEYCLOAK_USERNAME_CLAIM=preferred_username
302+
# SSO_KEYCLOAK_EMAIL_CLAIM=email
303+
# SSO_KEYCLOAK_GROUPS_CLAIM=groups
304+
305+
# Microsoft Entra ID (Azure AD) OIDC Configuration
306+
SSO_ENTRA_ENABLED=false
307+
# SSO_ENTRA_CLIENT_ID=your-entra-application-client-id
308+
# SSO_ENTRA_CLIENT_SECRET=your-entra-client-secret-value
309+
# SSO_ENTRA_TENANT_ID=your-entra-tenant-id
310+
311+
# Generic OIDC Provider Configuration (Keycloak, Auth0, Authentik, etc.)
312+
SSO_GENERIC_ENABLED=false
313+
# SSO_GENERIC_PROVIDER_ID=keycloak
314+
# SSO_GENERIC_DISPLAY_NAME=Keycloak
315+
# SSO_GENERIC_CLIENT_ID=your-oidc-client-id
316+
# SSO_GENERIC_CLIENT_SECRET=your-oidc-client-secret
317+
# SSO_GENERIC_AUTHORIZATION_URL=https://keycloak.company.com/auth/realms/master/protocol/openid-connect/auth
318+
# SSO_GENERIC_TOKEN_URL=https://keycloak.company.com/auth/realms/master/protocol/openid-connect/token
319+
# SSO_GENERIC_USERINFO_URL=https://keycloak.company.com/auth/realms/master/protocol/openid-connect/userinfo
320+
# SSO_GENERIC_ISSUER=https://keycloak.company.com/auth/realms/master
321+
# SSO_GENERIC_SCOPE=openid profile email
322+
293323
# SSO General Settings
294324
SSO_AUTO_CREATE_USERS=true
295325
# JSON array of trusted email domains, e.g., ["example.com", "company.org"]
296326
SSO_TRUSTED_DOMAINS=[]
297327
# Keep local admin authentication when SSO is enabled
298328
SSO_PRESERVE_ADMIN_AUTH=true
299329

330+
# SSO Issuers Configuration
331+
# Optional JSON array of issuer URLs for SSO providers
332+
# Example: ["https://idp1.example.com", "https://idp2.example.com"]
333+
# Default: null (not set)
334+
# SSO_ISSUERS=["https://idp.example.com"]
335+
300336
# SSO Admin Assignment Settings
301337
# Email domains that automatically get admin privileges, e.g., ["yourcompany.com"]
302338
SSO_AUTO_ADMIN_DOMAINS=[]
@@ -494,6 +530,46 @@ REMOVE_SERVER_HEADERS=true
494530
# Uses the same credentials as BASIC_AUTH_USER and BASIC_AUTH_PASSWORD
495531
# DOCS_ALLOW_BASIC_AUTH is already defined in Basic Server Configuration section
496532

533+
#####################################
534+
# Response Compression Configuration
535+
#####################################
536+
537+
# Enable response compression (Brotli, Zstd, GZip)
538+
# Options: true (default), false
539+
# Reduces bandwidth by 30-70% for text-based responses (JSON, HTML, CSS, JS)
540+
# Automatically negotiates compression algorithm based on client Accept-Encoding header
541+
# Priority: Brotli (best compression) > Zstd (fast) > GZip (universal fallback)
542+
COMPRESSION_ENABLED=true
543+
544+
# Minimum response size in bytes to compress
545+
# Responses smaller than this won't be compressed (compression overhead not worth it)
546+
# Default: 500 bytes
547+
# Set to 0 to compress all responses
548+
COMPRESSION_MINIMUM_SIZE=500
549+
550+
# GZip compression level (1-9)
551+
# 1 = fastest compression, larger files
552+
# 6 = balanced (recommended default)
553+
# 9 = best compression, slower
554+
# Default: 6
555+
COMPRESSION_GZIP_LEVEL=6
556+
557+
# Brotli compression quality (0-11)
558+
# 0-3 = fast compression (lower quality)
559+
# 4-9 = balanced compression (recommended)
560+
# 10-11 = maximum compression (slower)
561+
# Default: 4 (balanced)
562+
# Note: Brotli offers 15-20% better compression than GZip at similar speeds
563+
COMPRESSION_BROTLI_QUALITY=4
564+
565+
# Zstd compression level (1-22)
566+
# 1-3 = fast compression
567+
# 4-9 = balanced compression
568+
# 10+ = slower, maximum compression
569+
# Default: 3 (fast)
570+
# Note: Zstd is the fastest algorithm with good compression ratio
571+
COMPRESSION_ZSTD_LEVEL=3
572+
497573
#####################################
498574
# Retry Config for HTTP Requests
499575
#####################################
@@ -537,6 +613,12 @@ LOG_FORMAT=json
537613
# Options: true, false (default)
538614
LOG_TO_FILE=false
539615

616+
# Enable request payload logging for debugging
617+
# Options: true, false (default)
618+
# When enabled, logs HTTP request method, headers, query params, and body
619+
# Sensitive data (passwords, tokens, etc.) is automatically masked
620+
LOG_REQUESTS=false
621+
540622
# File write mode when LOG_TO_FILE=true
541623
# Options: a+ (append, default), w (overwrite on startup)
542624
LOG_FILEMODE=a+
@@ -694,6 +776,15 @@ PLUGINS_ENABLED=true
694776
# Default: plugins/config.yaml
695777
PLUGIN_CONFIG_FILE=plugins/config.yaml
696778

779+
# Optional defaults for mTLS when connecting to external MCP plugins (STREAMABLEHTTP transport)
780+
# Provide file paths inside the container. Plugin-specific TLS blocks override these defaults.
781+
# PLUGINS_MTLS_CA_BUNDLE=/app/certs/plugins/ca.crt
782+
# PLUGINS_MTLS_CLIENT_CERT=/app/certs/plugins/gateway-client.pem
783+
# PLUGINS_MTLS_CLIENT_KEY=/app/certs/plugins/gateway-client.key
784+
# PLUGINS_MTLS_CLIENT_KEY_PASSWORD=
785+
# PLUGINS_MTLS_VERIFY=true
786+
# PLUGINS_MTLS_CHECK_HOSTNAME=true
787+
697788
#####################################
698789
# Well-Known URI Configuration
699790
#####################################
@@ -840,3 +931,143 @@ REQUIRE_STRONG_SECRETS=false
840931
# Set to false to allow startup with security warnings
841932
# NOT RECOMMENDED for production!
842933
# REQUIRE_STRONG_SECRETS=false
934+
935+
#####################################
936+
# LLM Chat MCP Client Configuration
937+
#####################################
938+
939+
# Enable the LLM Chat functionality (true/false)
940+
# When disabled, LLM chat features will be completely hidden from UI and APIs
941+
# Default: false (must be explicitly enabled)
942+
LLMCHAT_ENABLED=false
943+
944+
# LLM Provider Selection
945+
# Options: azure_openai, openai, anthropic, aws_bedrock, ollama
946+
# Default: azure_openai
947+
# LLM_PROVIDER=azure_openai
948+
949+
#####################################
950+
# Azure OpenAI Configuration
951+
#####################################
952+
# Use for Microsoft Azure OpenAI Service deployments
953+
# AZURE_OPENAI_API_KEY=<your_api_key>
954+
# AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
955+
# AZURE_OPENAI_API_VERSION=2024-02-15-preview
956+
# AZURE_OPENAI_DEPLOYMENT=gpt-4o
957+
# AZURE_OPENAI_MODEL=gpt-4o
958+
# AZURE_OPENAI_TEMPERATURE=0.7
959+
960+
#####################################
961+
# OpenAI Configuration
962+
#####################################
963+
# Use for direct OpenAI API access (non-Azure) or OpenAI-compatible endpoints
964+
# OPENAI_API_KEY=sk-...
965+
# OPENAI_MODEL=gpt-4o-mini
966+
# OPENAI_BASE_URL=https://api.openai.com/v1 # Optional: for OpenAI-compatible endpoints
967+
# OPENAI_TEMPERATURE=0.7
968+
# OPENAI_MAX_RETRIES=2
969+
970+
#####################################
971+
# Anthropic Claude Configuration
972+
#####################################
973+
# Use for Anthropic Claude API
974+
# Requires: pip install langchain-anthropic
975+
# ANTHROPIC_API_KEY=sk-ant-...
976+
# ANTHROPIC_MODEL=claude-3-5-sonnet-20241022
977+
# ANTHROPIC_TEMPERATURE=0.7
978+
# ANTHROPIC_MAX_TOKENS=4096
979+
# ANTHROPIC_MAX_RETRIES=2
980+
981+
#####################################
982+
# AWS Bedrock Configuration
983+
#####################################
984+
# Use for AWS Bedrock LLM services
985+
# Requires: pip install langchain-aws boto3
986+
# Note: Uses AWS credential chain if credentials not explicitly provided
987+
# AWS_BEDROCK_MODEL_ID=anthropic.claude-v2
988+
# AWS_BEDROCK_REGION=us-east-1
989+
# AWS_BEDROCK_TEMPERATURE=0.7
990+
# AWS_BEDROCK_MAX_TOKENS=4096
991+
# Optional AWS credentials (uses default credential chain if not provided):
992+
# AWS_ACCESS_KEY_ID=<your_access_key>
993+
# AWS_SECRET_ACCESS_KEY=<your_secret_key>
994+
# AWS_SESSION_TOKEN=<your_session_token>
995+
996+
#####################################
997+
# Ollama Configuration
998+
#####################################
999+
# Use for local or self-hosted Ollama instances
1000+
# OLLAMA_MODEL=llama3
1001+
# OLLAMA_BASE_URL=http://localhost:11434
1002+
# OLLAMA_TEMPERATURE=0.7
1003+
1004+
#####################################
1005+
# Pagination Configuration
1006+
#####################################
1007+
1008+
# Default number of items per page for paginated endpoints
1009+
# Applies to: tools, resources, prompts, servers, gateways, users, teams, tokens, etc.
1010+
# Default: 50, Min: 1, Max: 1000
1011+
PAGINATION_DEFAULT_PAGE_SIZE=50
1012+
1013+
# Maximum allowed items per page (prevents abuse)
1014+
# Default: 500, Min: 1, Max: 10000
1015+
PAGINATION_MAX_PAGE_SIZE=500
1016+
1017+
# Minimum items per page
1018+
# Default: 1
1019+
PAGINATION_MIN_PAGE_SIZE=1
1020+
1021+
# Threshold for switching from offset to cursor-based pagination
1022+
# When result set exceeds this count, use cursor-based pagination for performance
1023+
# Default: 10000
1024+
PAGINATION_CURSOR_THRESHOLD=10000
1025+
1026+
# Enable cursor-based pagination globally
1027+
# Options: true (default), false
1028+
# When false, only offset-based pagination is used
1029+
PAGINATION_CURSOR_ENABLED=true
1030+
1031+
# Default sort field for paginated queries
1032+
# Default: created_at
1033+
PAGINATION_DEFAULT_SORT_FIELD=created_at
1034+
1035+
# Default sort order for paginated queries
1036+
# Options: asc, desc (default)
1037+
PAGINATION_DEFAULT_SORT_ORDER=desc
1038+
1039+
# Maximum offset allowed for offset-based pagination (prevents abuse)
1040+
# Default: 100000 (100K records)
1041+
PAGINATION_MAX_OFFSET=100000
1042+
1043+
# Cache pagination counts for performance (seconds)
1044+
# Set to 0 to disable caching
1045+
# Default: 300 (5 minutes)
1046+
PAGINATION_COUNT_CACHE_TTL=300
1047+
1048+
# Enable pagination links in API responses
1049+
# Options: true (default), false
1050+
PAGINATION_INCLUDE_LINKS=true
1051+
1052+
# Base URL for pagination links (defaults to request URL)
1053+
# PAGINATION_BASE_URL=https://api.example.com
1054+
1055+
#####################################
1056+
# gRPC Support Settings (EXPERIMENTAL)
1057+
#####################################
1058+
1059+
# Enable gRPC to MCP translation support (disabled by default)
1060+
# Requires: pip install mcp-contextforge-gateway[grpc]
1061+
# MCPGATEWAY_GRPC_ENABLED=false
1062+
1063+
# Enable gRPC server reflection by default for service discovery
1064+
# MCPGATEWAY_GRPC_REFLECTION_ENABLED=true
1065+
1066+
# Maximum gRPC message size in bytes (4MB default)
1067+
# MCPGATEWAY_GRPC_MAX_MESSAGE_SIZE=4194304
1068+
1069+
# Default gRPC call timeout in seconds
1070+
# MCPGATEWAY_GRPC_TIMEOUT=30
1071+
1072+
# Enable TLS for gRPC connections by default
1073+
# MCPGATEWAY_GRPC_TLS_ENABLED=false

.github/tools/check_security.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
import sys
66
import os
7+
78
# Add the project root to the path (two levels up from .github/tools/)
89
project_root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
910
sys.path.insert(0, project_root)
1011

1112
from mcpgateway.config import get_settings
1213

14+
1315
def main():
1416
"""Check security configuration and exit with appropriate code."""
1517
try:
@@ -19,16 +21,16 @@ def main():
1921
print(f"Security Score: {status['security_score']}/100")
2022
print(f"Warnings: {len(status['warnings'])}")
2123

22-
if status['warnings']:
24+
if status["warnings"]:
2325
print("\nSecurity Warnings:")
24-
for warning in status['warnings']:
26+
for warning in status["warnings"]:
2527
print(f" - {warning}")
2628

2729
# Exit with error if score is too low
28-
if status['security_score'] < 60:
30+
if status["security_score"] < 60:
2931
print("\n❌ Security score too low for deployment")
3032
sys.exit(1)
31-
elif status['security_score'] < 80:
33+
elif status["security_score"] < 80:
3234
print("\n⚠️ Security could be improved")
3335
sys.exit(0)
3436
else:
@@ -39,5 +41,6 @@ def main():
3941
print(f"❌ Security validation failed: {e}")
4042
sys.exit(2)
4143

44+
4245
if __name__ == "__main__":
4346
main()

0 commit comments

Comments
 (0)