Keep the scope, sandbox, credentials and approval settings supplied by the user or host. Obtain authorization before delegating, exposing project files to another provider, enabling connectors or hooks, using paid services or deploying. Use synthetic or redacted inputs for examples. Keep security reviews static and defensive, with findings and fixes grounded in source inspection.
Before adding a remote MCP server or tool to a web product, adding OAuth to it, or listing it in a directory: ship it right the first time, tests included.
Build the remote MCP server and prove it before listing it. This skill covers serving outside agents and getting listed without relearning the same lessons. Its examples use Next.js, Supabase, Clerk and Netlify.
Start with one hosted endpoint and prove it with one real client. Build a package or submit to directories only when the owner chooses those distribution targets.
Keep product-specific facts in that product's own records. This skill names those records by what they hold:
Apply clerk-production § MCP OAuth before writing the route. Discovery lists differ from token shape. Return 503 on verifier outages, refuse unknown kid values before calling Clerk and recheck live workspace access on every call because revocation remains unseen until expiry.
saas-authorization first because a tool is a route. Its caller is resolved by the three functions, deterministic code decides what it may do, and everything it returns that a person wrote is untrusted text.clerk-production § MCP OAuth.Record these decisions before building the server or its tools. Use the product's decision log.
| Decision | The default | The other choice, and what it costs | Where |
|---|---|---|---|
| Does anything answer without sign-in? | Authenticate every call, including initialize, by default. Use Clerk OAuth or a workspace API token | An anonymous surface buys users who have no account, such as a ChatGPT plugin that makes a room with no sign-up. It costs a new kind of caller, an identity only the platform can vouch for, limits and a lifetime of its own, a disclosure burden, and in OpenAI's directory a package that declares it before the first upload. | references/server.md § Who may call it · the chatgpt-plugin skill |
| Who may connect? | An admitted OAuth caller gets the full grant a new API token carries, so admit by the permission that mints such a token, checked through the three functions on every call | A role compared by name, or a neighbouring permission the same role happens to hold today, hands write to whichever role is given that permission later. A caller without the permission gets a clear 403, never a narrower connection | references/server.md § Who may call it |
| What must an agent never do? | A written list, held in code, and said in the instructions and the README | Examples: an audience product's agents cannot ask, vote or delete; a monitoring product's cannot delete, change billing, manage tokens or publish an incident note | references/tools.md § Choosing the tools |
| What if the workspace has yet to be created? | Return 403 organization_not_found with a message to open the organization's dashboard first | When the owner chooses agent-started sign-up, configure Clerk and provision the workspace on the first authorized call | references/server.md § The first call |
| The path | /api/mcp or /mcp, chosen once | The OAuth audience and both protected-resource documents (the path's own and the root alias) name that exact URL, and the 401 challenge points at the path's own document; the authorization-server document stays Clerk's, relayed | references/server.md § The route |
references/tools.md.outputSchema, and a test holds both against the real handlers. Smithery scores each out of 10 (observed 2026-10). references/tools.md § The tests.title and the hints a directory requires. Claude's directory flags tools lacking a title and readOnlyHint or destructiveHint (observed 2026-10). OpenAI's guidelines keep an action destructive even when another tool can undo it (read 2026-10-26). references/tools.md § Annotations.tools/list has a size budget. Pin it in a test. Every client loads it into the model's context, so per-field descriptions can expand it.references/server.md § The per-call log.references/clients.md.references/companion-repo.md § After a product release.gh api user --jq .login).references/server.md).references/tools.md.clerk-production § MCP OAuth, then references/server.md § Proving it. An anonymous surface the owner chose keeps its own checks (references/server.md § Who may call it).independent-review; descriptions and instructions are in the subject, not context.references/directories.md for listings and references/companion-repo.md for the package. Apply chatgpt-plugin for a ChatGPT plugin.Each rule's origin, the case that taught it, is in receipts.md beside this file; read it when a rule's edge is unclear.
A real client connects to the deployed server, signs in, lists the tools and calls one as a member, and the tests cover each tool's permission check.
| File | Holds | Read when |
|---|---|---|
references/server.md | who may call it, and what an anonymous surface costs; missing workspaces and agent-started sign-up; the route, its errors and transport; limits; the per-call log; proving it works | building or changing the route, its auth or its limits; deciding on an anonymous surface or agent-started sign-up |
references/tools.md | naming; choosing the tools; descriptions, arguments, results, output schemas, annotations, the server's instructions; the two tests | adding or changing any tool, or the instructions |
references/directories.md | each directory and registry: what it lists, requires, scores or refuses, and how a listing is kept current | listing the server, answering a review, rescanning after a change |
references/clients.md | each client: how it connects, what to verify, what is known about it | writing setup instructions, or saying which clients work |
references/companion-repo.md | the public repository and the stdio package: layout, README, the package's rules, one version everywhere, the release procedure, what a product release owes it | creating the repository, changing the package, releasing it |
app-stack pack in every agent that builds the server. Keep no product copy: it freezes at its copied version, and Claude Code loads it twice beside the pack. For an existing copy (.claude/skills/mcp-server/, .agents/skills/mcp-server/), move additions into the product's repository (above) or a change for this collection. Then delete the copy.mcp-server.For a report-listing tool, use a read-only identity, enforce tenant ownership in the server and test an empty list and a valid nonempty result with synthetic records.
Treat upstream examples as patterns. Validate scope and results against current project constraints, available tools and decisions recorded by the owner.
Adapted from Pawel Huryn’s upstream skill.