ScaleDock MCP server
An MCP server that is a correct OAuth 2.1 resource server, acts as the signed-in user, and asks PermDock for every tool call. The spec skills carry the rules of each standard; this skill says which ones apply, how they fit the ScaleDock stack, and where PermDock takes over.
Follow the workflow below step by step. Read the installed SDK and PermDock docs before you configure anything; option names drift between versions.
Inputs (fill in, or ask before starting)
- Repo: an existing ScaleDock repo with an
mcp surface, or a new one (then run scaledock-repo-standard first).
- Authorization server: Supabase Auth's OAuth 2.1 server (default), or another issuer the user names.
- Tools: the contract procedures to expose, and which of them write or destroy data.
- Approval store: where
approval-required decisions wait for a human (required when any tool is destructive).
Skills to install
npx skills add ScaleDockHQ/scaledock-skills --skill mcp --skill mcp-authorization --skill oauth --skill jwt --skill problem-details --skill json-rpc --skill server-sent-events
npx skills add ScaleDockHQ/PermDock
Optional: mcp-apps (npx skills add ScaleDockHQ/scaledock-skills --skill mcp-apps) when a tool ships an interactive ui:// view next to its text result.
scaledock-repo-standard (its references/mcp.md and references/auth.md) owns the app layout: the @modelcontextprotocol/server package, the Hono mount, the per-request server factory and tools from the contract.
Invariants
- The spec skills win on protocol details. Messages, transports,
tools/list, tool results and errors follow mcp; UI views follow mcp-apps. Protected Resource Metadata, the WWW-Authenticate challenge, resource indicators and audience checks follow mcp-authorization and oauth; token checks follow jwt. Do not restate them here or in the app; link the skill in code review.
- Every tool call is a PermDock decision. Tools register through
createPermDock(...).protectServer(server) from permdock/mcp, one permission per tool. PermDock filters tools/list, validates arguments against the resource schema, and audits each call.
- Authorization comes from the user, not from scopes. Scopes say what the client may ask for; PermDock and RLS say what the user may do. Enforce a scope only when the authorization server can issue it.
- The subject is never model-supplied. It comes from the verified access token (
authInfo) through the PermDock subject resolver, never from tool arguments.
- Destructive tools wait for a human. A tool that deletes, pays, publishes or changes access has
approval on its grant, so PermDock returns approval-required and the MCP adapter turns it into an elicitation.
- One error shape. Denials and failures are RFC 9457 Problem Details: HTTP responses use
application/problem+json, tool results use isError: true with the problem as text and structuredContent.
- Never pass a token through. The server never forwards the client's access token to another API; it calls
services as the user.
Workflow
- Set the inputs and read the docs. Read the installed
@modelcontextprotocol/server docs, the permdock/mcp page through the PermDock docs MCP (https://permdock.dev/mcp), and the mcp and mcp-authorization skills' Invariants.
✓ You can name the spec revision the SDK serves and the PermDock options you will set.
- Resource server. Serve Protected Resource Metadata, return 401 with the
resource_metadata challenge, and verify every bearer token (signature, issuer, expiry, audience) as mcp-authorization and jwt require. With Supabase, compose withOAuthProtectedResource and then withSupabase({ auth: "user" }) from @supabase/server in a pipeline from @supabase/middleware, and serve the OAuth Consent block at /oauth/consent in the app.
-> references/stack.md (how each requirement maps to the ScaleDock stack)
✓ An unauthenticated request gets 401 with the metadata URL, a token for another resource is rejected, and a signed-out user reaching /oauth/consent signs in and returns to the consent screen.
- Permissions. Define one permission per tool in
permissions.ts, grant them in policy.ts, and register tools with protectServer. Follow wire-permdock from ScaleDockHQ/PermDock. With mcp-apps, link each UI tool to its ui:// resource and keep its text result; a view's tools/call goes through the same PermDock decision.
✓ tools/list differs per role, and a call without a grant returns a Problem Details denial.
- Approvals and step-up. Put
approval on every destructive grant and configure a durable approval store. When a tool needs a scope the token lacks, return the scope challenge that mcp-authorization describes.
✓ A destructive call returns approval-required and resumes only after a distinct approver accepts.
- Errors. Route every error through one
problemResult() helper that follows problem-details.
✓ No stack trace or raw provider message reaches a client.
- Test and audit. Run the MCP tests from
scaledock-repo-standard (tools/list per role, 401 with metadata, a denial, structured output, the approval path), then run audit-permissions from ScaleDockHQ/PermDock.
✓ The tests pass and the audit has no blocker.
Verify before done
Reference index
references/stack.md: each spec requirement mapped to the ScaleDock stack and the PermDock adapter.
1---2name: scaledock-mcp-server3description: Build or harden a ScaleDock MCP server that follows the MCP base protocol and authorization spec, OAuth 2.1, JWT verification and Problem Details, with PermDock deciding every tool call. Use when adding an MCP surface, protecting MCP tools, wiring Protected Resource Metadata, scope challenges or step-up, filtering tools/list per user, adding MCP Apps UI to tools, adding human approval to destructive tools, or reviewing an MCP server against the specs.4license: MIT5metadata:6 source: https://skillmd.com/skills/scaledockhq/scaledock-mcp-server7 author: ScaleDockHQ8 version: "1.4.0"9---1011# ScaleDock MCP server1213An MCP server that is a correct OAuth 2.1 resource server, acts as the signed-in user, and asks PermDock for every tool call. The spec skills carry the rules of each standard; this skill says which ones apply, how they fit the ScaleDock stack, and where PermDock takes over.1415**Follow the workflow below step by step.** Read the installed SDK and PermDock docs before you configure anything; option names drift between versions.1617## Inputs (fill in, or ask before starting)1819- Repo: an existing ScaleDock repo with an `mcp` surface, or a new one (then run `scaledock-repo-standard` first).20- Authorization server: Supabase Auth's OAuth 2.1 server (default), or another issuer the user names.21- Tools: the contract procedures to expose, and which of them write or destroy data.22- Approval store: where `approval-required` decisions wait for a human (required when any tool is destructive).2324## Skills to install2526```bash27npx skills add ScaleDockHQ/scaledock-skills --skill mcp --skill mcp-authorization --skill oauth --skill jwt --skill problem-details --skill json-rpc --skill server-sent-events28npx skills add ScaleDockHQ/PermDock29```3031Optional: `mcp-apps` (`npx skills add ScaleDockHQ/scaledock-skills --skill mcp-apps`) when a tool ships an interactive `ui://` view next to its text result.3233`scaledock-repo-standard` (its `references/mcp.md` and `references/auth.md`) owns the app layout: the `@modelcontextprotocol/server` package, the Hono mount, the per-request server factory and tools from the contract.3435## Invariants36371. **The spec skills win on protocol details.** Messages, transports, `tools/list`, tool results and errors follow `mcp`; UI views follow `mcp-apps`. Protected Resource Metadata, the `WWW-Authenticate` challenge, resource indicators and audience checks follow `mcp-authorization` and `oauth`; token checks follow `jwt`. Do not restate them here or in the app; link the skill in code review.382. **Every tool call is a PermDock decision.** Tools register through `createPermDock(...).protectServer(server)` from `permdock/mcp`, one permission per tool. PermDock filters `tools/list`, validates arguments against the resource schema, and audits each call.393. **Authorization comes from the user, not from scopes.** Scopes say what the client may ask for; PermDock and RLS say what the user may do. Enforce a scope only when the authorization server can issue it.404. **The subject is never model-supplied.** It comes from the verified access token (`authInfo`) through the PermDock subject resolver, never from tool arguments.415. **Destructive tools wait for a human.** A tool that deletes, pays, publishes or changes access has `approval` on its grant, so PermDock returns `approval-required` and the MCP adapter turns it into an elicitation.426. **One error shape.** Denials and failures are RFC 9457 Problem Details: HTTP responses use `application/problem+json`, tool results use `isError: true` with the problem as text and `structuredContent`.437. **Never pass a token through.** The server never forwards the client's access token to another API; it calls `services` as the user.4445## Workflow46471. **Set the inputs and read the docs.** Read the installed `@modelcontextprotocol/server` docs, the `permdock/mcp` page through the PermDock docs MCP (`https://permdock.dev/mcp`), and the `mcp` and `mcp-authorization` skills' Invariants.48 ✓ You can name the spec revision the SDK serves and the PermDock options you will set.492. **Resource server.** Serve Protected Resource Metadata, return 401 with the `resource_metadata` challenge, and verify every bearer token (signature, issuer, expiry, audience) as `mcp-authorization` and `jwt` require. With Supabase, compose `withOAuthProtectedResource` and then `withSupabase({ auth: "user" })` from `@supabase/server` in a `pipeline` from `@supabase/middleware`, and serve the OAuth Consent block at `/oauth/consent` in the app.50 -> [`references/stack.md`](references/stack.md) (how each requirement maps to the ScaleDock stack)51 ✓ An unauthenticated request gets 401 with the metadata URL, a token for another resource is rejected, and a signed-out user reaching `/oauth/consent` signs in and returns to the consent screen.523. **Permissions.** Define one permission per tool in `permissions.ts`, grant them in `policy.ts`, and register tools with `protectServer`. Follow `wire-permdock` from `ScaleDockHQ/PermDock`. With `mcp-apps`, link each UI tool to its `ui://` resource and keep its text result; a view's `tools/call` goes through the same PermDock decision.53 ✓ `tools/list` differs per role, and a call without a grant returns a Problem Details denial.544. **Approvals and step-up.** Put `approval` on every destructive grant and configure a durable approval store. When a tool needs a scope the token lacks, return the scope challenge that `mcp-authorization` describes.55 ✓ A destructive call returns `approval-required` and resumes only after a distinct approver accepts.565. **Errors.** Route every error through one `problemResult()` helper that follows `problem-details`.57 ✓ No stack trace or raw provider message reaches a client.586. **Test and audit.** Run the MCP tests from `scaledock-repo-standard` (`tools/list` per role, 401 with metadata, a denial, structured output, the approval path), then run `audit-permissions` from `ScaleDockHQ/PermDock`.59 ✓ The tests pass and the audit has no blocker.6061## Verify before done6263- [ ] Every item in the `mcp` and `mcp-authorization` Verify lists passes (and `mcp-apps` when installed).64- [ ] Every tool has exactly one permission, and an unmapped tool is not listed.65- [ ] `/oauth/consent` is reachable signed out and returns to the consent screen after sign-in.66- [ ] The subject comes from `authInfo`; no tool reads a user, tenant or actor id from its arguments.67- [ ] Every destructive tool returns `approval-required` without an approval.68- [ ] Every denial is a Problem Details object with a stable `type`.69- [ ] `permdock doctor` reports no error, and `pnpm verify` passes.7071## Reference index7273- **[`references/stack.md`](references/stack.md)**: each spec requirement mapped to the ScaleDock stack and the PermDock adapter.