# Bounded MCP service template Public guide: https://deployifynow.com/assets/docs/guides/mcp.html . Use the guide’s content-addressed complete template/issuer archive and verify its filename digest, checksum and embedded payload manifest; keep both included directories from the same archive. Individual `/assets/mcp-service/` URLs are inspection references, not a matching install set; no private DeployifyNow source is needed. Node 22, official MCP SDK 1.32.1, Streamable HTTP POST/JSON, PostgreSQL 17 or newer, one replica. The sample stores one private text draft per verified account/workspace, with version checks and 24-hour idempotency receipts. It cannot execute deployments or access another product's datastore. Run `npm ci --include=dev`, `npm test`, then build using `docker build --build-arg SOURCE_REVISION=<40-character-commit> -t .`. Resolve and retain the immutable image digest before rollout. Run `node validate-profile.mjs` and `docker compose config --quiet` with your existing protected environment overlay. Never print the resolved environment. Use the existing DeployifyNow project/managed-stack UI to deploy this repository and compose.yaml. Existing project-private network and PostgreSQL secret reference are required; the service does not provision accounts or credentials. Use a dedicated database/schema owner for this sample, never another product's database. No datastore port, Docker socket, host root or privileged mode is configured. Only the gateway joins `dokploy-network`; the MCP process uses product-private and separate egress networks. Traefik must already terminate valid HTTPS for the configured hostname on websecure; no certificate/DNS grant is created here. For a host whose existing ingress terminates TLS upstream, adapt only the exact reviewed router to that verified topology before rollout. Required environment names: MCP_IMAGE (immutable registry digest), SOURCE_REVISION, MCP_HOST, MCP_OWNER, MCP_PRIVATE_NETWORK, MCP_ISSUER_URL, MCP_JWKS_URL, MCP_INTROSPECTION_URL, MCP_INTROSPECTION_CLIENT_ID, MCP_DATABASE_SECRET_FILE and MCP_INTROSPECTION_SECRET_FILE. The last two are existing protected file paths, not secret values. The files must be readable by UID 1000 without widening unrelated access. For an ordinary Dockerfile application, the existing encrypted environment/Vault integration can instead supply MCP_DATABASE_URL and MCP_INTROSPECTION_CLIENT_SECRET directly at runtime; never commit their values. File references take precedence. Existing operator-managed secret mounts/Vault references may be substituted after review. Optional finite budgets/scopes are in compose.yaml. ## Choose one explicit authorization contract `MCP_AUTH_MODE=jwt-json` preserves the original external-provider contract: signed JWT access tokens with issuer/resource audience, expiry, subject, `organization_id` and scope, plus fresh RFC7662 JSON introspection on every invocation. The introspection result must match the token's subject/workspace/issuer/resource and return current scopes/revocation. No deployed external provider is verified by this bundle; do not assume that the included owner issuer implements this mode. `MCP_AUTH_MODE=owner-signed` interoperates with the `owner-issuer/` directory included in the SAME complete install archive. Do not substitute the separately cached legacy issuer download. Deploy a separate isolated issuer for this sample resource, with `resourceProfile: "private-draft"` in its protected configuration so sign-in/consent describe draft permissions. No Observe bridge, monitoring profile or real infrastructure is needed. Configure the SAME exact `/mcp` resource and workspace in issuer and sample: ```dotenv MCP_AUTH_MODE=owner-signed MCP_WORKSPACE=sample364 MCP_ISSUER_URL=https://YOUR_SAMPLE_ISSUER_HOST MCP_JWKS_URL=https://YOUR_SAMPLE_ISSUER_HOST/jwks MCP_INTROSPECTION_URL=https://YOUR_SAMPLE_ISSUER_HOST/token/introspection MCP_INTROSPECTION_CLIENT_ID=YOUR_CONFIDENTIAL_RESOURCE_CLIENT_ID MCP_READ_SCOPE=observe:connections:read MCP_WRITE_SCOPE=observe:connections:write ``` Supply that confidential client's password through `MCP_INTROSPECTION_SECRET_FILE` in Compose (mounted as `MCP_INTROSPECTION_CLIENT_SECRET_FILE`), never as a committed value. Both scope variables above must override the Compose defaults. This issuer retains its existing scope names and `observe_workspace` claim; for the separately audience-bound draft resource they authorize only reading/saving the caller's draft. These scopes never grant access to a different product/resource. The configured workspace must match the signed current membership exactly. Account identity comes only from verified introspection, and each tool invocation rechecks it. Owner access tokens are opaque, not unsigned JWTs. Every invocation requires ES256 RFC9701 signed introspection with the exact issuer, outer audience equal to the confidential introspection client, `token-introspection+jwt` type and at most60-second response age. The nested active token must name this exact resource/workspace, subject, allowed scopes and a valid at-most300-second lifetime. A read-only grant cannot save. Disconnect in the issuer's `/owner` page revokes the grant; membership/workspace epoch changes invalidate its old tokens. JSON, wrong signatures/audiences/workspaces and inactive tokens fail closed; there is no automatic fallback between modes or active-token cache. Both contracts require maintained authorization-code + S256 PKCE, exact redirects, resource binding, explicit consent, refresh/revocation and public discovery. The owner issuer uses explicitly preregistered public clients, not DCR. Register the actual client's exact HTTPS or fixed-port loopback callback; verify that client's support before granting consent. Introspection credentials go only to the configured same-origin issuer. No API-key fallback or browser-cookie bearer is provided. Local SDK/OAuth tests establish interoperability, not a live endpoint or ChatGPT/Cowork/Grokbot/Hermes account acceptance. Methods: `identity {}`, `read_draft {}`, and `save_draft {"expectedVersion":0,"requestId":"","value":"Requested draft text"}`. Read-only scope defaults to sample:read; writes require sample:drafts:write too. A fresh read/reconnect must confirm the version/value. Membership is the sample's verified issuer tenant/account boundary; when adding actual product tools, check the product's current membership/role/object authorization on every invocation. Tool hints are not security controls. Limits: shared PostgreSQL per-account/workspace read and write counters, bounded direct-peer unauthenticated limits, 32 KiB bodies, 2,000-character drafts, local concurrency cap eight, five-second dependency calls, ten-second database transaction cap, one-replica deployment. Do not scale until concurrency and global admission are shared and tested. The sample ignores forwarded IP headers; behind the gateway this conservatively groups callers by the direct proxy. Establish and test a specific trusted-ingress policy before claiming user-IP isolation. Logs are bounded/redacted and never include tokens or draft values. Tokens and consent need issuer-owned backups; drafts need this database's encrypted backups and an isolated restore drill. Counters are ephemeral. Keep metrics private. Before public use, test OAuth PKCE/resource/redirect errors; initialize/list; authenticated read/write/reconnect/read; invalid/expired/wrong-audience/revoked credentials; read-only grants; other accounts/tenants; input bounds; replay/CAS concurrency; limits/recovery; health/readiness; proxy JSON and streaming behavior. A local sample is not a product's live acceptance receipt. Inspector can inspect transport and schema; it does not establish ChatGPT/Cowork/Grokbot/Hermes account compatibility. Record service, owner/network, source SHA, image digest, provider deployment ID, endpoint/issuer/discovery, readiness and synthetic evidence in the deployment receipt. Retain previous image digest and compatible database schema before redeploy. For rollback, restore only that service's prior reviewed image through the same wrapper; if the wrapper only tracks main, use a reviewed source revert and redeploy main. Do not remove volumes. Verify exact restored revision, readiness and draft persistence. Automatic destructive rollback is not configured.