# Build-it-yourself prompts

Canonical URL: https://vercel-mcp-reference.vercel.app/examples/prompts/
Markdown: https://vercel-mcp-reference.vercel.app/examples/prompts.md
Audience: engineer, non-technical. MCP spec version: 2026-07-28. Last reviewed: 2026-08-26. Status: stable.

Every runnable example in this repo can be rebuilt from a single prompt. Copy the block for the example you want, paste it into your AI coding agent (Claude Code, Cursor, or similar), and you get your own local version: same stack, same behaviors, same tests, green on your machine.

Four things make these prompts reliable rather than hopeful:

- **Exact version pins.** `mcp-handler` 2.1.1 peer-requires `@modelcontextprotocol/server` ^2.0.0 (the v2 SDK is split into a server package and a client package, the latter used by tests only), and the v2 SDK has a hard zod floor: zod 4.2.0 or newer. zod ^3 installs cleanly and then fails typecheck and tests, and a prompt that says "latest" or keeps the v1 pins produces a project that fails. Every prompt carries the working pins.
- **Verified SDK behaviors.** Each prompt tells the agent what the pinned v2 stack actually does, confirmed by live runs: an unknown tool name rejects with a `ProtocolError` matching the spec (v1 returned `isError` results here; that divergence is gone), schema-invalid arguments on a known tool still come back as `isError: true` tool results, the in-memory `connect()` performs the legacy initialize handshake (a bare `McpServer` over `InMemoryTransport` answers `server/discover` with `-32601`, and the `Client` defaults to legacy negotiation), and on that path results carry no `resultType` and list results no `ttlMs`/`cacheScope` at the client API. So its tests assert reality instead of guesses, and each prompt explains that limit rather than forbidding those assertions outright: the same server serves the modern frames over HTTP. Wire status: the pinned stack (`mcp-handler` 2.1.1 on `@modelcontextprotocol/server` 2.0.0) serves the 2026-07-28 contract natively over Streamable HTTP and falls back to stateless 2025-11-25 Streamable HTTP for legacy clients; the SDK `Client` defaults to that legacy handshake unless you opt in to modern version negotiation, so the examples' in-memory test suites exercise only the legacy path.
- **A definition of done.** Install, typecheck, and tests green, then a by-hand check with MCP Inspector. If the agent stalls, every prompt links the reference implementation to compare against.
- **Cold-session tested.** The `sampling-server` and `auth-server` prompts, the two with the trickiest test harnesses, were pasted verbatim into fresh agent sessions with no other context; both produced projects that passed typecheck and their full suites without consulting the reference implementations, and the auth-server's route layer was then exercised live (401 with the RFC 9728 resource metadata pointer, the well-known metadata endpoint, a valid bearer completing the handshake, an expired token failing closed). Those tests are v1-era: they predate the v2 migration and validated the prompt format on the old pins. What has been re-verified on the v2 stack is the template itself: the migrated `examples/minimal-server` (in the repository) every other prompt copies structurally, whose install, typecheck, and tests are green on the v2 pins and whose behavior facts above come from live runs against it.

The prompts ask for the same architecture this repo uses: protocol logic behind a framework-free `configureServer` in `src/`, a thin Next.js route shell, and offline in-memory tests. That split is what makes the projects testable without deploying anything; the [testing guide](https://vercel-mcp-reference.vercel.app/testing/) explains why.

## The prompts

- [minimal-server](https://vercel-mcp-reference.vercel.app/examples/prompts/minimal-server/) - the smallest end-to-end MCP server: one echo tool over Streamable HTTP, the 10-minute path from getting started and the structural template every other example copies.
- [resources-server](https://vercel-mcp-reference.vercel.app/examples/prompts/resources-server/) - a resources-only MCP server, showing where resources and resource templates sit among the server primitives: application-controlled context, no tools at all.
- [secure-tools-server](https://vercel-mcp-reference.vercel.app/examples/prompts/secure-tools-server/) - the house-style security showcase: a single write tool hardened with the controls from the security checklist, input validation, default-deny authorization, and output minimization.
- [db-adapter-server](https://vercel-mcp-reference.vercel.app/examples/prompts/db-adapter-server/) - a read-only MCP wrapper around an untouched legacy backend, with schema-expressed bounds, a scoped read-only credential, and output sanitization.
- [sandbox-isolation-server](https://vercel-mcp-reference.vercel.app/examples/prompts/sandbox-isolation-server/) - a one-tool MCP server that runs untrusted shell commands inside a sandbox microVM behind a frozen deny-by-default egress allowlist, non-persistent, on a pinned image, with no environment passed in and no server-held credential (the Sandbox SDK uses the deployment's OIDC token; `@vercel/sandbox` 3.1.0 is a dev dependency for types only), returning capped output framed as untrusted data.
- [facade-server](https://vercel-mcp-reference.vercel.app/examples/prompts/facade-server/) - one MCP server fronting two backends behind a namespaced tool surface with centralized routing, exception containment, and a secret-free audit log.
- [query-command-server](https://vercel-mcp-reference.vercel.app/examples/prompts/query-command-server/) - read-only query tools paired with a consent-gated, idempotency-keyed write command, with annotations a host can act on.
- [async-jobs-server](https://vercel-mcp-reference.vercel.app/examples/prompts/async-jobs-server/) - a deployable MCP server that runs long jobs behind opaque handles with progress, cooperative cancellation, and idempotent result retrieval, teaching the async jobs pattern.
- [least-privilege-server](https://vercel-mcp-reference.vercel.app/examples/prompts/least-privilege-server/) - a deployable MCP server that enforces declared per-tool scopes, refuse-to-start credential validation, an outbound allowlist, and per-principal default-deny authorization, teaching the least privilege pattern.
- [auth-server](https://vercel-mcp-reference.vercel.app/examples/prompts/auth-server/) - an OAuth-protected MCP server with a scope-gated whoami tool, RFC 9728 discovery metadata, and a fail-closed token verifier; it teaches the authorization and identity story from authorization and identity and principals.
- [sampling-server](https://vercel-mcp-reference.vercel.app/examples/prompts/sampling-server/) - an MCP server whose summarize tool asks the host's own model for a completion instead of bundling one; it teaches the server-to-host sampling flow from sampling-request handling.
- [elicitation-server](https://vercel-mcp-reference.vercel.app/examples/prompts/elicitation-server/) - an MCP server whose book_meeting tool pauses mid-call to ask the user for confirmation through the host, handling accept, decline, and cancel as three distinct outcomes; it teaches the flow from elicitation and the consent rules from consent UX.
- [orchestrator-host](https://vercel-mcp-reference.vercel.app/examples/prompts/orchestrator-host/) - the client side of MCP: a host that runs one client session per connected server, merges every server's tools into a single namespaced list, routes calls back to the owning session, and gates destructive tools behind one fail-closed consent callback, implementing the orchestrator pattern.

## Where to look now

- [Examples index](https://vercel-mcp-reference.vercel.app/examples/) - what each example demonstrates and how they relate.
- [Testing](https://vercel-mcp-reference.vercel.app/testing/) - the in-memory client pattern every prompt requires.
- [Getting started](https://vercel-mcp-reference.vercel.app/getting-started/) - the 10-minute path if you would rather run the finished examples first.

## Bibliography

- Model Context Protocol Specification, *Server features*, version 2026-07-28 - <https://modelcontextprotocol.io/specification/2026-07-28/server>
- Model Context Protocol, *MCP Inspector* - <https://modelcontextprotocol.io/docs/tools/inspector>
- Vercel Documentation, *Deploy MCP servers to Vercel* - <https://vercel.com/docs/mcp/deploy-mcp-servers-to-vercel>
- vercel/mcp-handler, source code - <https://github.com/vercel/mcp-handler>
