Markdown Converter
Agent skill for markdown-converter
The SIM-ONE Framework implements the Five Laws of Cognitive Governance through a sophisticated multi-agent cognitive architecture. This MCP (Cognitive Control Protocol) Server provides the backbone for autonomous AI agents performing complex cognitive tasks.
Sign in to like and favorite skills
The SIM-ONE Framework implements the Five Laws of Cognitive Governance through a sophisticated multi-agent cognitive architecture. This MCP (Cognitive Control Protocol) Server provides the backbone for autonomous AI agents performing complex cognitive tasks.
Current Status: 95% production ready - See project_status.md for details on project status of the backend project.
Framework Principles:
Code Base Location
/code/ (code root)/code/mcp_server/ (backend)/code/astro-chat-interface/ (frontend)Core Components:
# Create and activate virtual environment python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Navigate to code directory cd code # Install core dependencies pip install -r requirements.txt # Install security testing tools pip install pytest bandit safety # Install production server pip install gunicorn # Setup environment configuration cp mcp_server/.env.example mcp_server/.env # Edit .env file with your configuration
Create
mcp_server/.env with required variables:
# API Authentication (comma-separated) VALID_API_KEYS="your-secret-key-1,your-secret-key-2" # External Services OPENAI_API_KEY="your-openai-api-key" SERPER_API_KEY="your-serper-api-key" # Database Configuration REDIS_HOST="localhost" REDIS_PORT=6379 # Security Configuration ALLOWED_ORIGINS="http://localhost:3000,https://yourdomain.com" # Neural Engine Backend NEURAL_ENGINE_BACKEND="openai" LOCAL_MODEL_PATH="models/llama-3.1-8b.gguf" # Logging LOG_LEVEL="INFO"
# Initialize SQLite database for memory management cd code python -m mcp_server.database.memory_database
cd code uvicorn mcp_server.main:app --host 0.0.0.0 --port 8000 --reload
cd code gunicorn -w 4 -k uvicorn.workers.UvicornWorker mcp_server.main:app -b 0.0.0.0:8000
# Run all existing tests cd code python -m unittest discover mcp_server/tests/ # Run specific test modules python -m unittest mcp_server.tests.test_main python -m unittest mcp_server.tests.test_esl_protocol python -m unittest mcp_server.tests.test_mtp_protocol python -m unittest mcp_server.tests.test_memory_consolidation python -m unittest mcp_server.tests.test_production_setup
# Security vulnerability scanning bandit -r mcp_server/ safety check # Security-specific tests python -m unittest mcp_server.tests.security.test_cors_security python -m unittest mcp_server.tests.security.test_endpoint_auth python -m unittest mcp_server.tests.security.test_error_handling python -m unittest mcp_server.tests.security.test_cognitive_protocols_with_auth # Run all security tests python -m unittest discover mcp_server/tests/security/
# Test individual protocols curl -X POST "http://localhost:8000/execute" \ -H "X-API-Key: your-key" \ -H "Content-Type: application/json" \ -d '{"protocol_names": ["ReasoningAndExplanationProtocol"], "initial_data": {"facts": ["test fact"]}}' # Test workflow templates curl -X POST "http://localhost:8000/execute" \ -H "X-API-Key: your-key" \ -H "Content-Type: application/json" \ -d '{"template_name": "writing_team", "initial_data": {"topic": "AI safety"}}' # Available templates: analyze_only, full_reasoning, writing_team curl -X GET "http://localhost:8000/templates" -H "X-API-Key: your-key"
# Test coherence validation python -c "from mcp_server.cognitive_governance_engine.coherence_validator.coherence_checker import validate_coherence; print('Coherence validation operational')" # Test quality assurance python -c "from mcp_server.cognitive_governance_engine.quality_assurance.quality_scorer import assess_quality; print('Quality assessment operational')"
| Endpoint | Status | Protection Level | Notes |
|---|---|---|---|
| ✅ Public | None Required | Status endpoint |
| ✅ Public | None Required | Health check endpoint |
| ✅ Public | None Required | Detailed health status |
| ✅ Protected | Admin/User RBAC | Main cognitive workflow endpoint |
| ✅ Protected | Admin/User/Read-only RBAC | Cognitive architecture discovery |
| ✅ Protected | Admin/User/Read-only RBAC | Workflow template access |
| ✅ Protected | User isolation + RBAC | Session management with ownership |
| ✅ Protected | Admin-only RBAC | System metrics (admin access) |
# CURRENT IMPLEMENTATION (SECURE) app.add_middleware( CORSMiddleware, allow_origins=settings.ALLOWED_ORIGINS, # Configurable, no wildcards allow_credentials=True, allow_methods=["GET", "POST"], allow_headers=["X-API-Key", "Content-Type"], ) # Environment Configuration ALLOWED_ORIGINS="http://localhost:3000,https://yourdomain.com"
# RBAC Implementation @app.get("/protocols", dependencies=[Depends(RoleChecker(["admin", "user", "read-only"]))]) @app.get("/templates", dependencies=[Depends(RoleChecker(["admin", "user", "read-only"]))]) @app.post("/execute", dependencies=[Depends(RoleChecker(["admin", "user"]))]) @app.get("/session/{session_id}", dependencies=[Depends(RoleChecker(["admin", "user"]))]) @app.get("/metrics", dependencies=[Depends(RoleChecker(["admin"]))]) # API Key Management # - Hashed storage with individual salts # - Role-based key assignment # - Secure key validation
# Implemented Security Headers 'Content-Security-Policy': "default-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests;" 'X-Frame-Options': 'DENY' 'X-Content-Type-Options': 'nosniff' 'Referrer-Policy': 'strict-origin-when-cross-origin' 'Permissions-Policy': "geolocation=(), microphone=(), camera=()"
# IP-based rate limiting limiter = Limiter(key_func=get_remote_address) @limiter.limit("20/minute") # Configurable per endpoint
The security implementation maintains full compliance with the Five Laws:
# Test cognitive governance after security changes curl -X POST "http://localhost:8000/execute" \ -H "X-API-Key: your-key" \ -H "Content-Type: application/json" \ -d '{"template_name": "full_reasoning", "initial_data": {"facts": ["Security test"]}}' # Verify protocol discovery curl -X GET "http://localhost:8000/protocols" -H "X-API-Key: your-key" # Test memory persistence with session isolation curl -X GET "http://localhost:8000/session/test-session" -H "X-API-Key: your-key"
# Test production server startup gunicorn -w 4 -k uvicorn.workers.UvicornWorker mcp_server.main:app -b 0.0.0.0:8000 # Verify all cognitive protocols work in production curl -X GET "http://localhost:8000/protocols" -H "X-API-Key: your-key" # Test workflow execution under load for i in {1..10}; do curl -X POST "http://localhost:8000/execute" \ -H "X-API-Key: your-key" \ -H "Content-Type: application/json" \ -d '{"template_name": "analyze_only", "initial_data": {"text": "test"}}' & done wait # Health check validation curl -X GET "http://localhost:8000/health/detailed"
# Security implementation validation: python -m unittest mcp_server.tests.security.test_cors_security python -m unittest mcp_server.tests.security.test_endpoint_auth python -m unittest mcp_server.tests.security.test_error_handling python -m unittest mcp_server.tests.security.test_cognitive_protocols_with_auth # Cognitive governance functionality validation: python -m unittest mcp_server.tests.test_esl_protocol python -m unittest mcp_server.tests.test_mtp_protocol python -m unittest mcp_server.tests.test_main python -m unittest mcp_server.tests.test_memory_consolidation # Production readiness validation: python -m unittest mcp_server.tests.test_production_setup
# Docker development environment docker-compose -f docker-compose.dev.yml up # Production containerization docker-compose -f docker-compose.prod.yml up # Kubernetes deployment kubectl apply -f k8s/
# Automated testing and deployment - Security scanning (bandit, safety) - Unit test execution - Integration testing - Production deployment - Health check validation
# Check environment configuration cd code && python -c "from mcp_server.config import settings; print(settings.model_dump_json(indent=2))" # Test API key system cd code && python -c "from mcp_server.security.key_manager import validate_api_key; print('Key validation:', validate_api_key('test-key'))" # Verify protocol loading cd code && python -c "from mcp_server.protocol_manager.protocol_manager import ProtocolManager; pm = ProtocolManager(); print('Protocols:', list(pm.protocols.keys()))" # Test security configuration cd code && python -c "from mcp_server.config import settings; print('CORS Origins:', settings.ALLOWED_ORIGINS)"
# Monitor security logs tail -f security_events.log # Check rate limiting status curl -X GET "http://localhost:8000/health/detailed" # Validate security headers curl -I "http://localhost:8000/"
Mission Accomplished: The MCP server has been transformed from development prototype to production-ready system while maintaining full cognitive governance functionality and SIM-ONE Framework compliance.
Current Status: 85% Production Ready
Remember: "In structure there is freedom" - The implemented security structure provides the freedom to deploy confidently in production environments while preserving and enhancing the cognitive capabilities that make the SIM-ONE Framework revolutionary.
See project_status.md for the comprehensive roadmap of remaining infrastructure and enterprise feature implementation.