Platform services
These are infrastructure integrations, not sales channels.
| System | Role | Failure observed |
|---|---|---|
| S3-compatible storage | Required at boot. Presigned upload and download. Label artifacts | Missing settings fail boot. Public URL fallback 404s on R2 if AWS_S3_PUBLIC_URL is unset |
SMTP (nodemailer) | Welcome, password reset, tenant invite, ticket notification on email_queue | If SMTP_HOST is set, port and from-address are mandatory. 3 attempts. Forgot-password still returns success to the client |
| Sentry | 5xx, terminal Bull failures, TrackedCron, outbox consumers, reportError | Initialized from src/instrument.ts. DSN required in production |
| Prometheus | /metrics | Bypasses JWT |
| AI gateway | AI_BASE_URL, AI_API_KEY, AI_MODEL, AI_EMBEDDING_MODEL. Compose points at Bifrost | Embedding service catches failures so the API still boots |
| Cloudflare Turnstile | Login and signup | Blank keys disable CAPTCHA |
| Twilio | Voice agent | Token stored encrypted on VoiceAgentConfig |
| Faster-Whisper / Kokoro | VOICE_STT_URL, VOICE_TTS_URL | Local defaults. Not shown as Compose services in the portion that was read |
| Bharat Address | Address validation sidecar | BHARATADDRESS_SIDECAR_URL |
Files
POST /v1/files/uploads/:purpose uploads through the API. POST /v1/file/get-presign returns a pre-signed URL so bytes can go to object storage. A separate operations file controller also exists.
MCP
Tenants connect ChatGPT, Claude, Claude Code and other MCP clients to their workspace. The code is in src/modules/automation/mcp, on the official @modelcontextprotocol/sdk.
| Route | What it is |
|---|---|
POST /mcp | MCP endpoint. Streamable HTTP, stateless, JSON responses. GET/DELETE answer 405. |
/.well-known/oauth-protected-resource[/mcp] | Protected resource metadata (RFC 9728). |
/.well-known/oauth-authorization-server | Authorization server metadata (RFC 8414). |
/oauth/authorize, /oauth/token, /oauth/register, /oauth/revoke | OAuth 2.1 with PKCE S256. Clients are identified by metadata document (CIMD) or dynamic registration. |
/v1/mcp/authorization-requests/* | Backs the admin consent page at /oauth/consent. |
/v1/mcp/settings, /v1/mcp/grants, /v1/mcp/activity | Settings → AI Assistants. |
- Two switches, both off by default:
MCP_ENABLED=truefor the deployment (otherwise every route above is 404) andTenantSetting.mcpEnabledper tenant. - A grant (
McpGrant) binds one user, membership, tenant and client. Every request re-checks it within a 30-second cache. It checks the membership is active, the tenant is active and MCP-enabled, the user holdsAI:USE, and the user is not warehouse-confined. - Calls run as
platformRole: NONEin the grant's tenant. A platform-admin context would bypass the tenancy extension. - The code lives at
src/modules/automation/mcp, next to the voice and WhatsApp agents. Like them, it is a channel onto the AI tools. Its tables are reached throughMcpRepository. - Tools are the READ tools from
AiToolRegistryService, filtered by RBAC, plussearchandfetchfor ChatGPT. Write tools are not exposed. Results go through the AI prompt-injection sanitiser. - A tool's
surfacesdecides where it is offered: the in-app workspace, MCP, or both (the default). The read-only insight tools infinance,procurement,inventory-health,sales-insightandoperations-insightare['mcp']. Every report that aggregates over a period usesreportRange: 30 days by default, refused beyond 90. The workspace sends every tool to its smaller model on every turn, so add'workspace'only after testing it there.execute()refuses a tool named from a surface it is not offered on. - Insight tool permissions follow the HTTP endpoints for the same data:
- finance (payouts, receivables and aging, disputes, fee audits, COD, invoices, wallet, freight overcharges):
SETTLEMENT:READ; - procurement and inventory health (purchase orders, goods receipts, vendors, stock counts, expiring lots, reorder suggestions, valuation):
STOCK:READ; REPORT:READ: top products, sales breakdown, coupons, channels;CUSTOMER:READ: customer detail, top customers;RETURN:READ: return analytics;ORDER:READ: SLA breaches, order timeline, exceptions;SHIPMENT:READ: NDR queue, RTO, claims, couriers;FULFILLMENT:READ: manifests;PRODUCT:READ: listing issues.
- finance (payouts, receivables and aging, disputes, fee audits, COD, invoices, wallet, freight overcharges):
- The reorder, valuation and top-product tools use raw SQL, which bypasses the tenancy extension. Each statement filters
tenantIditself. - Analytics queries: those tools run through
AnalyticsDatabaseService(src/common/database). It uses the primary database. Every statement runs under a 15-second timeout scoped to its transaction. - Not built yet: open-ended analytics (a governed metric catalogue with
query_metrics) and an all-history slow-moving-stock report. Both wait for pre-computed daily rollups, so they don't scan live tables on the primary. - Freshness: every MCP tool result carries
_metakeyscom.pointnxt/asOf,timezone,currency,piiModeandstaleChannels. An active channel counts as stale when its order sync is more than 2 hours old. Results other thansearchandfetchalso get a one-line "Data as of …" note. - PII:
MCP_PII_MODEisfull,masked(the default) ornone, set per deployment. It is applied to every tool result inMcpToolService.executebyutils/pii.util.ts. Fields are matched by name. Free-text fields are also scanned for emails and phone numbers. Other strings are left untouched, so AWBs and order numbers survive. - Resources:
pointnxt://workspace/context. - Output schemas: declared for
searchandfetch. - Access tokens are JWTs with audience
$MCP_PUBLIC_URL/mcp, signed withMCP_TOKEN_SECRET. Refresh tokens are opaque, hashed and rotated. Reusing a refresh token revokes the grant. - Rate limits are per grant and per tenant (
MCP_RATE_LIMIT_*). The global per-IP throttle is skipped because AI clients share egress IPs. - Each tool call is logged to
McpToolCallLogwithout arguments or results.