MCP Reference

Tool Invocation

Executing tools/call requests, server-side security pipeline order, hybrid preview/apply workflows, and structured response envelopes.

Server-Side Execution Pipeline

Every tools/call request passes through a deterministic nine-stage security and validation pipeline before any database write or Discord REST API mutation occurs.

  1. Bearer Verification:: requireMcpBearerAuth hashes the Bearer token with SHA-256 and resolves ctx.userId, ctx.scopes, and ctx.allowedGuildIds.
  2. Scope & Rate Limit Gate:: Verifies token scopes and sliding-window per-user quotas (60 read/min, 20 write/min, 10 deploy/min, 5 destructive/min).
  3. Strict Zod Validation:: Parses arguments against the tool Zod schema, rejecting malformed snowflakes, out-of-range numbers, unknown keys, or unsafe regex patterns (ReDoS guard).
  4. Guild Allowlist & Blacklist:: Confirms target guildId is allowed by ctx.allowedGuildIds and neither ctx.userId nor guildId is in BotBlacklist.
  5. Live RBAC Verification:: Evaluates live Discord roles and database role assignments matching dashboard/src/lib/permissions.js and dashboard/src/lib/antinuke/access.js.
  6. 18-Surface Premium Policy:: Checks live Free, Pro, or Enterprise entitlements and caps quotas or returns TIER_UPGRADE_REQUIRED.
  7. Cross-Guild & Role Safety:: Verifies all channel IDs belong to guildId and runs isRoleSafeForDelegation on all delegated roles.
  8. Safety & Human Approval Gate:: For destructive or structural changes, verifies mcp:destructive plus human browser approval recorded at /oauth/approve-action matching payloadHash.
  9. DTO Projection & Audit Log:: Strips unauthorized or internal fields and appends an HMAC-SHA256 hash-chained record to taicket_mcp.mcp_audit_logs.

Invocation Examples (Read, Preview, Apply)

1. Inspect live server topology (mcp:read)json
{
  "jsonrpc": "2.0",
  "id": 10,
  "method": "tools/call",
  "params": {
    "name": "get_server_topology",
    "arguments": {
      "guildId": "1189452019384729600"
    }
  }
}
2. Preview a configuration update before applying (mcp:write)json
{
  "jsonrpc": "2.0",
  "id": 11,
  "method": "tools/call",
  "params": {
    "name": "configure_ticket_system",
    "arguments": {
      "guildId": "1189452019384729600",
      "mode": "preview",
      "settings": {
        "ticketCategoryId": "1189452019384729612",
        "logChannelId": "1189452019384729615",
        "routingMode": "manual"
      }
    }
  }
}
3. Execute a previewed multi-module plan via apply_setupjson
{
  "jsonrpc": "2.0",
  "id": 12,
  "method": "tools/call",
  "params": {
    "name": "apply_setup",
    "arguments": {
      "guildId": "1189452019384729600",
      "planId": "plan_4d92f1a8c3e75011",
      "confirmed": true
    }
  }
}

Structured Response Format

Successful tool executions return MCP CallToolResult payloads containing both a human-readable JSON text block inside content and a typed structuredContent object. Application-level errors set isError: true with a sanitized error object so MCP hosts can relay clear next steps without crashing the JSON-RPC transport.

Successful CallToolResult envelopejson
{
  "jsonrpc": "2.0",
  "id": 11,
  "result": {
    "isError": false,
    "content": [
      {
        "type": "text",
        "text": "{\"ok\":true,\"mode\":\"preview\",\"guildId\":\"1189452019384729600\",\"requiresHumanApproval\":false,\"diff\":[{\"field\":\"ticketCategoryId\",\"before\":null,\"after\":\"1189452019384729612\"}]}"
      }
    ],
    "structuredContent": {
      "ok": true,
      "mode": "preview",
      "guildId": "1189452019384729600",
      "requiresHumanApproval": false,
      "diff": [
        {
          "field": "ticketCategoryId",
          "before": null,
          "after": "1189452019384729612"
        }
      ]
    }
  }
}

Related documentation