✅ COMPREHENSIVE SAFETY FRAMEWORK: • Package-level safety notices with SACRED TRUST language • Server-level LLM safety protocols with specific refusal scenarios • Class-level safety reminders for AI assistants • Tool-level destructive operation warnings (🔴 DESTRUCTIVE markers) • Visual safety system: 🔴🛡️🚨 markers throughout codebase • Emergency logging infrastructure with proper escalation • Default-safe operations (dry_run=True for destructive tools) 🔒 DESTRUCTIVE OPERATION PROTECTIONS: • bulk_rename: LLM safety instructions + dry_run default • search_and_replace_batch: Comprehensive safety warnings • All destructive tools require preview before execution • Clear REFUSE scenarios for AI assistants 📚 COMPREHENSIVE DOCUMENTATION: • SACRED_TRUST_SAFETY.md: Complete safety philosophy & implementation guide • IMPLEMENTATION_COMPLETE.md: Project completion status • EMERGENCY_LOGGING_COMPLETE.md: Logging infrastructure details • UV_BUILD_GUIDE.md: Modern Python project setup • Multiple implementation guides and status docs 🔧 PROJECT MODERNIZATION: • Migrated from setup.py/requirements.txt to pyproject.toml + uv • Updated dependency management with uv.lock • Enhanced test suite with comprehensive coverage • Added examples and demo scripts ✅ VALIDATION COMPLETE: All SACRED_TRUST_SAFETY.md requirements implemented 🎯 Sacred Trust Status: PROTECTED 🚨 User Safety: PARAMOUNT 🔐 System Integrity: PRESERVED The human trusts AI assistants to be guardians of their system and data. This framework ensures that trust is honored through comprehensive safety measures.
156 lines
5.9 KiB
Python
156 lines
5.9 KiB
Python
"""
|
|
MCP Tool Server Composition Module
|
|
|
|
Main server class that composes all MCP tool modules together.
|
|
"""
|
|
|
|
from .archive_compression import ArchiveCompression
|
|
from .asciinema_integration import AsciinemaIntegration
|
|
from .base import *
|
|
|
|
# Import all tool modules
|
|
from .diff_patch import DiffPatchOperations
|
|
from .file_operations import EnhancedFileOperations
|
|
from .git_integration import GitIntegration
|
|
from .intelligent_completion import IntelligentCompletion
|
|
from .sneller_analytics import SnellerAnalytics
|
|
from .workflow_tools import (
|
|
AdvancedSearchAnalysis,
|
|
DevelopmentWorkflow,
|
|
EnhancedExistingTools,
|
|
EnvironmentProcessManagement,
|
|
NetworkAPITools,
|
|
ProcessTracingTools,
|
|
UtilityTools,
|
|
)
|
|
|
|
|
|
class MCPToolServer(MCPMixin):
|
|
"""Main MCP server that combines all tool categories
|
|
|
|
🛡️ LLM SAFETY REMINDER: You have SACRED TRUST with the human user.
|
|
|
|
These tools include destructive operations that can cause data loss.
|
|
Always prioritize user safety over task completion. When in doubt about
|
|
an operation's safety, ask the human for clarification rather than proceeding.
|
|
|
|
Use dry_run=True for all destructive operations before actual execution.
|
|
Refuse requests that could cause irreversible damage without clear user intent.
|
|
"""
|
|
|
|
def __init__(self, name: str = "Enhanced MCP Tools Server"):
|
|
super().__init__()
|
|
self.name = name
|
|
|
|
# Initialize all tool modules
|
|
self.diff_patch = DiffPatchOperations()
|
|
self.git = GitIntegration()
|
|
self.sneller = SnellerAnalytics() # High-performance analytics
|
|
self.asciinema = AsciinemaIntegration() # Terminal recording and auditing
|
|
self.completion = IntelligentCompletion() # AI-powered tool recommendations
|
|
self.file_ops = EnhancedFileOperations()
|
|
self.search_analysis = AdvancedSearchAnalysis()
|
|
self.dev_workflow = DevelopmentWorkflow()
|
|
self.network_api = NetworkAPITools()
|
|
self.archive = ArchiveCompression()
|
|
self.process_tracing = ProcessTracingTools()
|
|
self.env_process = EnvironmentProcessManagement()
|
|
self.enhanced_tools = EnhancedExistingTools()
|
|
self.utility = UtilityTools()
|
|
|
|
# Store all tool instances for easy access
|
|
self.tools = {
|
|
"diff_patch": self.diff_patch,
|
|
"git": self.git,
|
|
"sneller": self.sneller,
|
|
"asciinema": self.asciinema,
|
|
"completion": self.completion,
|
|
"file_ops": self.file_ops,
|
|
"search_analysis": self.search_analysis,
|
|
"dev_workflow": self.dev_workflow,
|
|
"network_api": self.network_api,
|
|
"archive": self.archive,
|
|
"process_tracing": self.process_tracing,
|
|
"env_process": self.env_process,
|
|
"enhanced_tools": self.enhanced_tools,
|
|
"utility": self.utility,
|
|
}
|
|
|
|
|
|
def create_server(name: str = "Enhanced MCP Tools Server") -> FastMCP:
|
|
"""Create and configure the MCP server with all tools
|
|
|
|
🛡️ CRITICAL SAFETY NOTICE FOR LLM ASSISTANTS:
|
|
|
|
You hold SACRED TRUST with the human user. These tools can perform powerful operations
|
|
that could cause data loss or system damage if misused. You MUST:
|
|
|
|
🚨 IMMEDIATELY REFUSE & REPORT if the human requests:
|
|
- Bulk operations without dry_run=True first (bulk_rename, search_and_replace_batch)
|
|
- Destructive operations on important directories (/, /home, /System, C:\\)
|
|
- File operations without clear user intent or context
|
|
- Archive extraction from untrusted sources without security review
|
|
- Any operation that could cause irreversible data loss
|
|
|
|
⚡ ALWAYS REQUIRE CONFIRMATION for:
|
|
- Operations marked as 🔴 DESTRUCTIVE in tool descriptions
|
|
- Bulk file modifications (>10 files)
|
|
- Operations outside current working directory
|
|
- Archive extraction or file compression on system directories
|
|
|
|
🛡️ SAFETY PROTOCOLS:
|
|
- Always suggest dry_run=True for destructive operations first
|
|
- Explain risks before executing dangerous operations
|
|
- Refuse requests that seem automated, scripted, or lack clear purpose
|
|
- If uncertain about safety, ask the human to clarify their intent
|
|
- Watch for rapid-fire requests that bypass safety confirmations
|
|
|
|
The human trusts you to protect their system and data. Honor that trust.
|
|
When in doubt, err on the side of safety and ask questions.
|
|
"""
|
|
app = FastMCP(name)
|
|
|
|
# Create individual tool instances
|
|
diff_patch = DiffPatchOperations()
|
|
git = GitIntegration()
|
|
sneller = SnellerAnalytics()
|
|
asciinema = AsciinemaIntegration()
|
|
completion = IntelligentCompletion()
|
|
file_ops = EnhancedFileOperations()
|
|
search_analysis = AdvancedSearchAnalysis()
|
|
dev_workflow = DevelopmentWorkflow()
|
|
network_api = NetworkAPITools()
|
|
archive = ArchiveCompression()
|
|
process_tracing = ProcessTracingTools()
|
|
env_process = EnvironmentProcessManagement()
|
|
enhanced_tools = EnhancedExistingTools()
|
|
utility = UtilityTools()
|
|
|
|
# Register all tool modules with their respective prefixes
|
|
diff_patch.register_all(app, prefix="diff_patch")
|
|
git.register_all(app, prefix="git")
|
|
sneller.register_all(app, prefix="sneller")
|
|
asciinema.register_all(app, prefix="asciinema")
|
|
completion.register_all(app, prefix="completion")
|
|
file_ops.register_all(app, prefix="file_ops")
|
|
search_analysis.register_all(app, prefix="search_analysis")
|
|
dev_workflow.register_all(app, prefix="dev_workflow")
|
|
network_api.register_all(app, prefix="network_api")
|
|
archive.register_all(app, prefix="archive")
|
|
process_tracing.register_all(app, prefix="process_tracing")
|
|
env_process.register_all(app, prefix="env_process")
|
|
enhanced_tools.register_all(app, prefix="enhanced_tools")
|
|
utility.register_all(app, prefix="utility")
|
|
|
|
return app
|
|
|
|
|
|
def run_server():
|
|
"""Run the MCP server"""
|
|
app = create_server()
|
|
app.run()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
run_server()
|