auto-backup: 2025-12-11 20:35:05 (68 files: +19 ~23 -25)
Generated by DSS Git Backup Hook
This commit is contained in:
@@ -494,8 +494,7 @@ async def health():
|
||||
if str(project_root) not in sys.path:
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
from dss.mcp.handler import get_mcp_handler
|
||||
|
||||
from dss.mcp_server.handler import get_mcp_handler
|
||||
handler = get_mcp_handler()
|
||||
mcp_ok = handler is not None
|
||||
except Exception as e:
|
||||
@@ -2425,10 +2424,16 @@ async def claude_chat(request_data: ClaudeChatRequest):
|
||||
"model": "error",
|
||||
}
|
||||
|
||||
# Import MCP handler
|
||||
from dss_mcp.handler import MCPContext, get_mcp_handler
|
||||
|
||||
mcp_handler = get_mcp_handler()
|
||||
# Import MCP handler (may fail if database not migrated)
|
||||
mcp_handler = None
|
||||
MCPContext = None
|
||||
try:
|
||||
from dss_mcp.handler import get_mcp_handler, MCPContext as _MCPContext
|
||||
MCPContext = _MCPContext
|
||||
mcp_handler = get_mcp_handler()
|
||||
except Exception as e:
|
||||
# MCP handler not available, proceed without tools
|
||||
enable_tools = False
|
||||
|
||||
# Build system prompt with design system context
|
||||
system_prompt = """You are a design system assistant with access to DSS (Design System Server) tools.
|
||||
@@ -2449,7 +2454,7 @@ RULES:
|
||||
- Always provide actionable insights from tool data"""
|
||||
|
||||
# Add project context if available
|
||||
if project_id:
|
||||
if project_id and mcp_handler:
|
||||
try:
|
||||
project_context = await mcp_handler.get_project_context(project_id, user_id)
|
||||
if project_context:
|
||||
@@ -2462,6 +2467,8 @@ CURRENT PROJECT CONTEXT:
|
||||
- Integrations: {', '.join(project_context.integrations.keys()) if project_context.integrations else 'None configured'}"""
|
||||
except:
|
||||
system_prompt += f"\n\nProject ID: {project_id} (context not loaded)"
|
||||
elif project_id:
|
||||
system_prompt += f"\n\nProject ID: {project_id}"
|
||||
|
||||
# Add user context
|
||||
if context:
|
||||
@@ -2477,11 +2484,16 @@ CURRENT PROJECT CONTEXT:
|
||||
|
||||
# Get tools if enabled
|
||||
tools = None
|
||||
if enable_tools and project_id:
|
||||
if enable_tools and project_id and mcp_handler:
|
||||
tools = mcp_handler.get_tools_for_claude()
|
||||
|
||||
# Create MCP context
|
||||
mcp_context = MCPContext(project_id=project_id, user_id=user_id)
|
||||
# Create MCP context (or None if MCP not available)
|
||||
mcp_context = None
|
||||
if MCPContext is not None:
|
||||
mcp_context = MCPContext(
|
||||
project_id=project_id,
|
||||
user_id=user_id
|
||||
)
|
||||
|
||||
# Call AI provider with all context
|
||||
result = await provider.chat(
|
||||
@@ -3087,7 +3099,8 @@ def kill_port(port: int, wait: float = 0.5) -> None:
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
port = int(os.getenv("PORT", "3456"))
|
||||
# DSS Ports: API=6220, Admin=6221, MCP=6222, Storybook=6226
|
||||
port = int(os.getenv("DSS_API_PORT", "6220"))
|
||||
host = os.getenv("HOST", "0.0.0.0")
|
||||
|
||||
# Kill any existing process on the port (twice to handle respawning)
|
||||
|
||||
Reference in New Issue
Block a user