{
  "name": "SkematIA",
  "description": "AI-powered Backend as a Service (BaaS) with Firebird 5.0. Design database schemas from natural language, query data conversationally, and manage your backend through MCP or REST API. No direct database access needed — all operations go through HTTP.",
  "url": "https://skematia.com/mcp/mcp",
  "version": "1.27.0",
  "protocolVersion": "0.2.6",
  "documentationUrl": "https://skematia.com/docs/mcp-connection-guide",
  "provider": {
    "organization": "SkematIA",
    "url": "https://skematia.com",
    "contactEmail": "soporte@skematia.com"
  },
  "capabilities": {
    "streaming": false,
    "pushNotifications": false,
    "stateTransitionHistory": false
  },
  "security": {
    "model": "Zero-Trust Agentes (Fase 3)",
    "pillars": {
      "permissions": "Granular per-key permissions (read_only, read_write, full). Enforced at SQL execution, MCP tools, and REST endpoints.",
      "auditTrail": "All operations are logged with user, project, action, SQL, duration, and result. Immutable audit log in central database.",
      "rateLimiting": "Sliding window rate limiting with Redis. Per-key limits by plan. Graceful degradation if Redis unavailable."
    }
  },
  "authentication": {
    "schemes": ["bearer"],
    "credentials": "API Key (sk_...) obtained from the SkematIA dashboard at https://skematia.com. Each API key is bound to a specific project.",
    "permissions": {
      "description": "Each API key has a permission level that controls what operations are allowed.",
      "levels": {
        "read_only": "SELECT queries only. All DML/DDL operations are rejected.",
        "read_write": "SELECT + INSERT/UPDATE/DELETE. DDL operations (CREATE, ALTER, DROP) are rejected.",
        "full": "All operations including DDL. Required for design_schema, modify_schema, and schema management."
      },
      "default": "full"
    },
    "rateLimiting": {
      "description": "Sliding window rate limiting per API key. Limits are per minute and vary by plan.",
      "limits": {
        "free": "30 requests/minute",
        "beta": "30 requests/minute",
        "pro": "100 requests/minute",
        "business": "1000 requests/minute"
      },
      "headers": {
        "X-RateLimit-Limit": "Maximum requests per minute for this key",
        "X-RateLimit-Remaining": "Requests remaining in the current window",
        "X-RateLimit-Reset": "Unix timestamp when the window resets"
      },
      "exceeded": "HTTP 429 with retry_after in seconds. Graceful degradation: if the rate limiter backend is unavailable, requests are allowed."
    }
  },
  "defaultInputModes": ["text/plain", "application/json"],
  "defaultOutputModes": ["application/json"],

  "integration": {
    "transport": "Streamable HTTP (stateless — no sessions, no WebSocket, no SDK required)",
    "mcpEndpoint": "https://skematia.com/mcp/mcp",
    "restEndpoint": "https://skematia.com/api",
    "note": "You do NOT need node-firebird, database drivers, or direct Firebird access. All operations go through HTTP requests. Choose MCP or REST — both work with the same API key.",

    "quickstart": {
      "steps": [
        "1. Get an API key from https://skematia.com (sign up → create project → copy API key)",
        "2. Choose your connection method: MCP (for AI agents) or REST (for any HTTP client)",
        "3. Set header: Authorization: Bearer sk_your_api_key",
        "4. Start with list_tables or get_schema to see your database"
      ]
    },

    "connectViaMCP": {
      "description": "For AI agents (Claude, GPT, custom agents) that speak Model Context Protocol",
      "claudeDesktop": "npx mcp-remote https://skematia.com/mcp/mcp --header 'Authorization: Bearer sk_...'",
      "claudeCode": "claude mcp add skematia --transport http https://skematia.com/mcp/mcp",
      "pythonSDK": "from mcp.client.streamable_http import streamablehttp_client\nasync with streamablehttp_client('https://skematia.com/mcp/mcp', headers={'Authorization': 'Bearer sk_...'}) as (r, w, _):\n    # use r/w with ClientSession"
    },

    "connectViaREST": {
      "description": "For any HTTP client (Node.js fetch/axios, Python requests, curl, etc.). No MCP needed.",
      "baseUrl": "https://skematia.com/api",
      "important": "ALL REST URLs MUST include the /api/ prefix. Without it you will get 405 errors because requests hit the frontend instead of the backend. Do NOT use trailing slashes — /api/projects works, /api/projects/ returns 404.",
      "sqlDialect": "Firebird 5.0 — Column aliases REQUIRE the AS keyword (use SELECT COUNT(*) AS TOTAL, not SELECT COUNT(*) TOTAL). Table and column names are UPPERCASE by default. Use double quotes for case-sensitive identifiers. Use ROWS N instead of LIMIT N. Use FIRST/SKIP instead of LIMIT/OFFSET.",
      "endpoints": {
        "GET  /api/explorer/{id}/schema": "Get full database schema (tables, fields, PKs, FKs, generators)",
        "GET  /api/explorer/{id}/tables": "List all tables",
        "GET  /api/explorer/{id}/tables/{table}/structure": "Get table structure (columns, PKs, FKs, indexes)",
        "GET  /api/explorer/{id}/tables/{table}/data": "Get paginated table data",
        "POST /api/data/{id}/raw-sql": "Execute raw SQL (body: {\"sql\": \"SELECT ...\"})",
        "GET  /api/data/{id}/{table}": "List rows from a table",
        "POST /api/data/{id}/{table}": "Insert record (body: column-value pairs)",
        "PUT  /api/data/{id}/{table}/{pk}": "Update record by PK",
        "DELETE /api/data/{id}/{table}/{pk}": "Delete record by PK",
        "GET  /api/projects": "List user projects",
        "POST /api/projects": "Create new project",
        "GET  /api/projects/{id}": "Get project details",
        "GET  /api/projects/{id}/schema": "Get project schema (alternative to explorer)",
        "POST /api/ai/start": "Start AI design session",
        "POST /api/ai/chat": "Chat with AI for schema design",
        "POST /api/ai/execute-schema": "Execute AI-generated schema",
        "GET  /api/explorer/{id}/schema/suggestions": "Analyze schema and return improvement suggestions (missing indexes, NOT NULL, UNIQUE, etc.)",
        "POST /api/explorer/{id}/schema/apply-suggestions": "Apply all fixable suggestions from the schema advisor",
        "GET  /api/explorer/{id}/schema/history": "Get DDL version history (params: limit, source, operation)",
        "GET  /api/explorer/{id}/schema/version": "Get current schema version summary",
        "POST /api/api-keys": "Create a new API key for a project (body: {project_id, name, permissions})",
        "GET  /api/api-keys": "List API keys (optional ?project_id= filter)",
        "DELETE /api/api-keys/{id}": "Revoke an API key",
        "GET  /api/health": "Health check (returns status, version, service name)",
        "GET  /health/mcp": "MCP server status (mounted, SDK versions)",
        "GET  /health/ai": "AI provider connectivity check",
        "GET  /health/firebird": "Firebird server connectivity check"
      },
      "exampleCurl": "curl -H 'Authorization: Bearer sk_...' https://skematia.com/api/explorer/{id}/schema",
      "exampleNode": "const res = await fetch('https://skematia.com/api/explorer/{id}/schema', {\n  headers: { 'Authorization': 'Bearer sk_...' }\n});\nconst schema = await res.json();",
      "examplePython": "import httpx\nr = httpx.get('https://skematia.com/api/explorer/{id}/schema',\n  headers={'Authorization': 'Bearer sk_...'})\nschema = r.json()",
      "examplePowerShell": "$headers = @{ 'Authorization' = 'Bearer sk_...' }\nInvoke-RestMethod -Uri 'https://skematia.com/api/explorer/{id}/schema' -Headers $headers -Method GET"
    }
  },

  "skills": [
    {
      "id": "design_schema",
      "name": "AI Schema Designer",
      "description": "Design a complete Firebird 5.0 database schema from a natural language description. The AI generates tables, fields, relationships, constraints, and executes everything automatically.",
      "tags": ["ai", "schema", "design", "database", "ddl"],
      "examples": [
        "Create a schema for an e-commerce store with products, orders, and customers",
        "Design a project management database with tasks, teams, and deadlines"
      ]
    },
    {
      "id": "modify_schema",
      "name": "AI Schema Modifier",
      "description": "Modify an existing database schema using natural language instructions. Generates ALTER TABLE, CREATE TABLE, or other DDL statements and executes them.",
      "tags": ["ai", "schema", "alter", "modify", "ddl"],
      "examples": [
        "Add an email field to the users table",
        "Create a products table with price and inventory fields"
      ]
    },
    {
      "id": "query",
      "name": "Natural Language Query",
      "description": "Query your database using natural language. The AI converts your question to Firebird SQL and returns the results.",
      "tags": ["ai", "query", "sql", "natural-language", "select"],
      "examples": [
        "How many products cost more than 100?",
        "Show me the top 5 customers by total orders"
      ]
    },
    {
      "id": "execute_sql",
      "name": "Execute SQL",
      "description": "Execute raw SQL against your Firebird database. Allowed operations depend on the API key's permission level: read_only allows SELECT only, read_write adds DML, full allows DDL. All executions are audit-logged.",
      "tags": ["sql", "execute", "raw", "firebird"],
      "examples": [
        "SELECT * FROM \"PRODUCTS\" ROWS 10",
        "INSERT INTO \"USERS\" (\"NAME\", \"EMAIL\") VALUES ('Juan', 'juan@test.com')"
      ]
    },
    {
      "id": "get_schema",
      "name": "Get Schema",
      "description": "Retrieve the complete schema of a project including tables, fields, primary keys, foreign keys, and relationships.",
      "tags": ["schema", "inspect", "metadata"]
    },
    {
      "id": "list_tables",
      "name": "List Tables",
      "description": "List all tables in a project's database with field counts.",
      "tags": ["tables", "list", "metadata"]
    },
    {
      "id": "insert_data",
      "name": "Insert Data",
      "description": "Insert one or more records into a table using column-value pairs.",
      "tags": ["insert", "data", "dml"],
      "examples": [
        "Insert a new product with name 'Widget' and price 29.99"
      ]
    },
    {
      "id": "update_data",
      "name": "Update Data",
      "description": "Update a single record by its primary key.",
      "tags": ["update", "data", "dml"]
    },
    {
      "id": "delete_data",
      "name": "Delete Data",
      "description": "Delete a single record by its primary key.",
      "tags": ["delete", "data", "dml"]
    },
    {
      "id": "bulk_update",
      "name": "Bulk Update",
      "description": "Update multiple records matching a WHERE condition.",
      "tags": ["update", "bulk", "data", "dml"]
    },
    {
      "id": "list_projects",
      "name": "List Projects",
      "description": "List projects accessible with the current API key.",
      "tags": ["projects", "list", "metadata"]
    },
    {
      "id": "create_project",
      "name": "Create Project",
      "description": "Get instructions for creating a new SkematIA project with a Firebird database.",
      "tags": ["projects", "create"]
    },
    {
      "id": "list_backups",
      "name": "List Backups",
      "description": "List available backups for a project with size, date, and type (scheduled, pre-restore, manual).",
      "tags": ["backups", "list", "metadata"]
    },
    {
      "id": "schema_suggestions",
      "name": "Schema Advisor",
      "description": "Analyze the project's database schema and return improvement suggestions: missing indexes on FK columns, fields that should be NOT NULL or UNIQUE, tables without primary key, and BLOB TEXT used for short fields. Each suggestion includes severity, description, and a ready-to-execute SQL fix.",
      "tags": ["schema", "advisor", "suggestions", "optimization", "best-practices"],
      "examples": [
        "Analyze my schema for potential improvements",
        "Check if any foreign keys are missing indexes"
      ]
    },
    {
      "id": "schema_history",
      "name": "Schema Version History",
      "description": "Retrieve the DDL change history for a project's database. Every CREATE, ALTER, DROP, and RECREATE operation is automatically recorded with version number, timestamp, source (ai_studio, explorer, mcp, api), and executing agent. Supports filtering by limit, source, and operation type.",
      "tags": ["schema", "history", "versioning", "audit", "ddl"],
      "examples": [
        "Show me the last 10 schema changes",
        "What DDL changes were made by the AI studio?"
      ]
    }
  ]
}
