-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
66 lines (51 loc) · 1.72 KB
/
main.py
File metadata and controls
66 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""
Main entry point for FastMCP-based dbt context provider.
"""
import os
import sys
import logging
from pathlib import Path
from dotenv import load_dotenv
# Load environment variables
load_dotenv()
# Configure logging
logging.basicConfig(
level=getattr(logging, os.getenv("LOG_LEVEL", "INFO")),
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
def validate_environment():
"""Validate required environment variables."""
required = [
"GITHUB_PERSONAL_ACCESS_TOKEN",
"GITHUB_REPOSITORY"
]
missing = [var for var in required if not os.getenv(var)]
if missing:
logger.error(f"Missing required environment variables: {', '.join(missing)}")
logger.error("Please set these in your .env file or environment")
sys.exit(1)
# Log configuration
logger.info(f"Repository: {os.getenv('GITHUB_REPOSITORY')}")
logger.info(f"Schema patterns: {os.getenv('DBT_SCHEMA_PATTERNS', 'models/**/*.yml')}")
logger.info(f"Project path: {os.getenv('DBT_PROJECT_PATH', 'dbt_project.yml')}")
logger.info(f"Cache TTL: {os.getenv('CACHE_TTL_MINUTES', '60')} minutes")
def main():
"""Main entry point."""
logger.info("Starting dbt-context-provider MCP server...")
# Validate environment
validate_environment()
# Import and run the FastMCP app
from src.server import mcp
# Run the FastMCP server
mcp.run()
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
logger.info("Server shutdown requested")
sys.exit(0)
except Exception as e:
logger.error(f"Fatal error: {e}", exc_info=True)
sys.exit(1)