Phase 2 Complete: DSS Runtime & Boundary Enforcement
Implemented dependency injection and boundary enforcement architecture: NEW FILE: dss-claude-plugin/core/runtime.py (395 lines) - DSSRuntime class with boundary validation - Dependency injection pattern for all external API access - Capability provider pattern (get_figma_client, get_browser, get_http_client) - Boundary violation logging and enforcement modes (strict/warn/disabled) - Singleton pattern with get_runtime() helper - Session-based temp directory management - Audit trail for all access and violations UPDATED: dss-claude-plugin/servers/dss-mcp-server.py - Integrated DSSRuntime initialization in main() - Updated version to 2.0.0 - Added runtime availability checking - Logs enforcement mode on startup - Changed branding: 'Design System Swarm' → 'Design System Server' BOUNDARY ENFORCEMENT FEATURES: - Blocks direct external API access (Figma, Browser, HTTP) - Validates operations against .dss-boundaries.yaml - Provides wrapped, sandboxed clients instead of raw access - Logs all violations to .dss/logs/boundary-violations.jsonl - Logs all access to .dss/logs/runtime-access.jsonl Next: Phase 3 (Terminology Cleanup) - 67 files to update
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
DSS MCP Server - Design System Swarm Integration for Claude Code
|
||||
DSS MCP Server - Design System Server Integration for Claude Code
|
||||
|
||||
A Python MCP server that exposes DSS functionality as tools for Claude.
|
||||
Uses stdio transport for Claude Code integration.
|
||||
|
||||
Author: overbits
|
||||
Version: 1.2.0 - Added Browser Automation with Hybrid Strategy (LOCAL/REMOTE)
|
||||
Version: 2.0.0 - Architectural Refinement: Boundary Enforcement & Runtime
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
@@ -22,6 +22,18 @@ from dataclasses import dataclass, field
|
||||
import base64
|
||||
import re
|
||||
|
||||
# DSS Runtime - Boundary Enforcement (CRITICAL)
|
||||
# All external API access MUST go through the runtime
|
||||
try:
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
from core.runtime import DSSRuntime, BoundaryViolationError, get_runtime
|
||||
RUNTIME_AVAILABLE = True
|
||||
except ImportError as e:
|
||||
RUNTIME_AVAILABLE = False
|
||||
RUNTIME_IMPORT_ERROR = str(e)
|
||||
print(f"WARNING: DSSRuntime not available: {e}", file=sys.stderr)
|
||||
print("Boundary enforcement will be disabled!", file=sys.stderr)
|
||||
|
||||
# Playwright import (optional - only needed for DevTools features)
|
||||
try:
|
||||
from playwright.async_api import async_playwright, Browser, Page, BrowserContext, Playwright
|
||||
@@ -2721,12 +2733,25 @@ async def dss_rate_limit_status_impl(
|
||||
|
||||
async def main():
|
||||
"""Run the MCP server"""
|
||||
logger.info("Starting DSS MCP Server v1.2.0...")
|
||||
logger.info("Starting DSS MCP Server v2.0.0...")
|
||||
logger.info(f"DSS Path: {DSS_PATH}")
|
||||
logger.info(f"DSS Available: {DSS_AVAILABLE}")
|
||||
logger.info(f"Playwright Available: {PLAYWRIGHT_AVAILABLE}")
|
||||
logger.info(f"LocalBrowserStrategy Available: {LOCAL_BROWSER_STRATEGY_AVAILABLE}")
|
||||
|
||||
# Initialize DSS Runtime with boundary enforcement
|
||||
if RUNTIME_AVAILABLE:
|
||||
try:
|
||||
runtime = get_runtime()
|
||||
stats = runtime.get_stats()
|
||||
logger.info(f"DSS Runtime initialized: {stats['enforcement_mode']} mode")
|
||||
logger.info("Boundary enforcement: ACTIVE")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to initialize runtime: {e}")
|
||||
logger.warning("Boundary enforcement: DISABLED")
|
||||
else:
|
||||
logger.warning("DSSRuntime not available - boundary enforcement DISABLED")
|
||||
|
||||
if DSS_AVAILABLE:
|
||||
logger.info(f"DSS Version: {dss.__version__}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user