Spaces:
Paused
Paused
Commit
·
acc20c1
1
Parent(s):
4ee2352
refactor: update environment variable handling for configuration in main.py and config.py
Browse files- main.py +9 -5
- utils/config.py +5 -9
main.py
CHANGED
|
@@ -5,6 +5,7 @@ from fastmcp import FastMCP, Context
|
|
| 5 |
from loguru import logger
|
| 6 |
from dataclasses import dataclass
|
| 7 |
import uuid
|
|
|
|
| 8 |
|
| 9 |
from utils.config import API_CONFIG
|
| 10 |
from utils.model import MultiModuleRequest, SingleModuleRequest, SearchSpaceRoutingRequest
|
|
@@ -13,6 +14,9 @@ from fastmcp.server.dependencies import get_http_request
|
|
| 13 |
from starlette.requests import Request
|
| 14 |
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
@dataclass
|
| 17 |
class DSContext:
|
| 18 |
"""Typed context for DS MCP server"""
|
|
@@ -386,9 +390,9 @@ Return a 2-3x more detailed/enhanced bug report with precise technical terms for
|
|
| 386 |
|
| 387 |
|
| 388 |
if __name__ == "__main__":
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
|
| 394 |
-
mcp.run(transport=
|
|
|
|
| 5 |
from loguru import logger
|
| 6 |
from dataclasses import dataclass
|
| 7 |
import uuid
|
| 8 |
+
import os
|
| 9 |
|
| 10 |
from utils.config import API_CONFIG
|
| 11 |
from utils.model import MultiModuleRequest, SingleModuleRequest, SearchSpaceRoutingRequest
|
|
|
|
| 14 |
from starlette.requests import Request
|
| 15 |
|
| 16 |
|
| 17 |
+
from dotenv import load_dotenv
|
| 18 |
+
load_dotenv()
|
| 19 |
+
|
| 20 |
@dataclass
|
| 21 |
class DSContext:
|
| 22 |
"""Typed context for DS MCP server"""
|
|
|
|
| 390 |
|
| 391 |
|
| 392 |
if __name__ == "__main__":
|
| 393 |
+
TRANSPORT_MODE = os.getenv("TRANSPORT_MODE", "streamable-http")
|
| 394 |
+
HOST = os.getenv("HOST", "0.0.0.0")
|
| 395 |
+
PORT = int(os.getenv("PORT", "8000"))
|
| 396 |
+
LOG_LEVEL = os.getenv("LOG_LEVEL", "INFO")
|
| 397 |
|
| 398 |
+
mcp.run(transport=TRANSPORT_MODE, host=HOST, port=PORT, log_level=LOG_LEVEL)
|
utils/config.py
CHANGED
|
@@ -5,14 +5,10 @@ load_dotenv()
|
|
| 5 |
|
| 6 |
# API Configuration
|
| 7 |
API_CONFIG = {
|
| 8 |
-
"api_base_url": os.getenv("DS_API_BASE_URL", "https://dnext-ds-api.hf.space"),
|
| 9 |
-
"api_multimodule_endpoint": os.getenv("DS_API_MULTIMODULE_ENDPOINT", "/mcp_multi_module_bug_localization"),
|
| 10 |
-
"api_singlemodule_endpoint": os.getenv("DS_API_SINGLEMODULE_ENDPOINT", "/mcp_single_module_bug_localization"),
|
| 11 |
-
"api_searchspace_endpoint": os.getenv("DS_API_SEARCHSPACE_ENDPOINT", "/mcp_search_space_routing"),
|
| 12 |
"hf_access_token": os.getenv("HF_ACCESS_TOKEN", None),
|
| 13 |
-
"timeout": os.getenv("TIMEOUT", 120),
|
| 14 |
-
"transport_mode": os.getenv("TRANSPORT_MODE", "streamable-http"),
|
| 15 |
-
"host": os.getenv("HOST", "0.0.0.0"),
|
| 16 |
-
"port": os.getenv("PORT", 8000),
|
| 17 |
-
"log_level": os.getenv("LOG_LEVEL", "INFO"),
|
| 18 |
}
|
|
|
|
| 5 |
|
| 6 |
# API Configuration
|
| 7 |
API_CONFIG = {
|
| 8 |
+
"api_base_url": str(os.getenv("DS_API_BASE_URL", "https://dnext-ds-api.hf.space")),
|
| 9 |
+
"api_multimodule_endpoint": str(os.getenv("DS_API_MULTIMODULE_ENDPOINT", "/mcp_multi_module_bug_localization")),
|
| 10 |
+
"api_singlemodule_endpoint": str(os.getenv("DS_API_SINGLEMODULE_ENDPOINT", "/mcp_single_module_bug_localization")),
|
| 11 |
+
"api_searchspace_endpoint": str(os.getenv("DS_API_SEARCHSPACE_ENDPOINT", "/mcp_search_space_routing")),
|
| 12 |
"hf_access_token": os.getenv("HF_ACCESS_TOKEN", None),
|
| 13 |
+
"timeout": int(os.getenv("TIMEOUT", 120)),
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|