Architecture
Standalone service topology for taicket-mcp: single PM2 process on port 4130, 11-database Mongoose layer with isolated taicket_mcp, Express Streamable HTTP transport, and bundled static docs.
Single-service runtime architecture
The Taicket MCP platform runs inside mcp/ as a standalone ESM TypeScript service compiled with Node.js 22+ and managed by one PM2 process named taicket-mcp bound to 127.0.0.1:4130. It sits behind one dedicated Nginx virtual host (nginx/mcp.taicket.xyz.conf) and makes zero modifications to dashboard/, bot/, docs/, profile/, tournament/, activity/, or club/.
- Public origin
- https://mcp.taicket.xyz
- Internal bind address
- 127.0.0.1:4130 (configured via MCP_HOST and MCP_PORT)
- HTTP framework
- Express 5 with helmet, cors, cookie-parser, and Pino structured logging
- MCP SDK & transport
- @modelcontextprotocol/sdk Streamable HTTP on /mcp (POST, GET, DELETE)
- Static docs bundle
- Next.js 14 static export built in mcp/docs-site/ and served from mcp/dist/site/
- PM2 process
- Single instance (instances: 1, max_memory_restart: 1G)
11-database Mongoose topology
mcp/src/db/connections.ts lazily initializes and pools 11 Mongoose connections. All MCP authentication state, OAuth grants, hashed tokens, setup previews, and HMAC hash-chained audit logs live in a physically isolated database (MCP_MONGODB_URI / taicket_mcp). Configuration and read-only diagnostic queries connect directly to Taicket main MongoDB and nine dedicated module databases.
| # | Database Role | URI Variable | Default DB Name | MCP Access Mode |
|---|---|---|---|---|
| 1 | Isolated MCP Auth & Audit | MCP_MONGODB_URI | taicket_mcp | Read / Write (append-only on mcp_audit_logs) |
| 2 | Main Taicket Core | MONGODB_URI | Main cluster DB | Read / Write (module configs & panels) + Read-Only (billing, blacklist, logs) |
| 3 | Anti-Nuke Engine | ANTINUKE_MONGODB_URI | taicket_antinuke | Read / Write (modules & backup schedule) + Read-Only (trusted staff & logs) |
| 4 | Booster Perks | BOOSTER_MONGODB_URI | taicket_booster | Read / Write (setup & panel deployment) |
| 5 | Economy System | ECONOMY_MONGODB_URI | taicket_economy | Read / Write (guild config, store, recipes, income, custom replies) |
| 6 | Giveaways | GIVEAWAYS_MONGODB_URI | taicket_giveaways | Read / Write (guild defaults only; active giveaways untouched) |
| 7 | JARVIS Auditor | JARVIS_MONGODB_URI | taicket_jarvis | Read / Write (Enterprise config) + Read-Only (saved reports) |
| 8 | Match Together | MATCH_TOGETHER_MONGODB_URI | taicket_match_together | Read / Write (lobby & module setup) |
| 9 | Reaction Roles | REACTION_ROLES_MONGODB_URI | taicket_reaction_roles | Read / Write (role-safe panels) |
| 10 | Reaction Triggers | REACTION_TRIGGER_MONGODB_URI | taicket_reaction_trigger | Read / Write (trigger rules with ReDoS guard) |
| 11 | Starboard | STARBOARD_MONGODB_URI | taicket_starboard | Read / Write (starboard configuration) |
Repository directory structure
mcp/
package.json # Runtime & build scripts (build:all, typecheck, test)
tsconfig.json # Strict TypeScript ESM configuration
vitest.config.ts # Automated Vitest runner configuration
scripts/
generate-docs-manifest.ts # Extracts Zod schemas from registry.ts to JSON
src/
index.ts # Process entrypoint, graceful shutdown
server.ts # Express app wiring: /mcp, /oauth/*, /account, /health, static docs
config/env.ts # Zod-validated root .env loader + redacted summary
db/
connections.ts # 11 lazy pooled Mongoose connections
models/mcpAuth.ts # 8 collections strictly bound to taicket_mcp
models/taicketCore.ts # Main DB models (excluding internal admin collections)
models/taicketDedicated.ts # 9 dedicated module DB models
security/ # crypto, validation, errors, rateLimit, discord, permissions, premium, audit
oauth/ # metadata, clients, routes, bearerAuth, accountRoutes, views
tools/ # registry + domain tool modules + resources & prompts
tests/ # oauth, security, premium, governance, docs-quality suites
docs-site/ # Next.js 14 static export app compiled into mcp/dist/site/Request lifecycle on /mcp
- 1
Edge termination and IP restoration
Cloudflare routes https://mcp.taicket.xyz to Nginx, which terminates TLS 1.2/1.3, validates Cloudflare CIDRs, restores real client IP, enforces taicket_mcp_limit (25r/s), and proxies to 127.0.0.1:4130 with proxy_buffering off.
- 2
Bearer authentication and identity binding
requireMcpBearerAuth hashes the Authorization Bearer token via SHA-256, loads the active McpAccessToken from taicket_mcp, checks expiry, revocation, RFC 8707 resource, and derives immutable ctx.userId.
- 3
Guard pipeline before tool execution
The tool dispatcher checks scope coverage, BotBlacklist, grant allowedGuildIds, sliding-window rate limits, live Discord RBAC, and 18-surface tier gates.
- 4
DTO projection, error sanitization, and HMAC audit
Tool output is mapped through an explicit DTO, unexpected exceptions are scrubbed via sanitizeMcpError, and the outcome is appended to taicket_mcp.mcp_audit_logs with hash chaining and HMAC-SHA256.