AI Prompt for MCP Servers
Production MCP server exposing fetch Stripe invoice over stdio. Tested with VS Code with MCP extension — includes auth (mTLS), schema validation (Zod), error handling, and host-specific install instructions.
More prompts for MCP Servers.
Opinionated recipe for turning an existing send email via SendGrid API into a clean MCP tool. Focus: tight schema, JWT bearer token flow, retries, and Zod-backed input validation.
Opinionated recipe for turning an existing invoke AWS Lambda API into a clean MCP tool. Focus: tight schema, JWT bearer token flow, retries, and TypeBox-backed input validation.
Opinionated recipe for turning an existing create Linear issue API into a clean MCP tool. Focus: tight schema, API key in header flow, retries, and Zod-backed input validation.
Opinionated recipe for turning an existing query BigQuery API into a clean MCP tool. Focus: tight schema, OAuth 2.0 authorization code flow flow, retries, and ArkType-backed input validation.
Opinionated recipe for turning an existing search Notion pages API into a clean MCP tool. Focus: tight schema, JWT bearer token flow, retries, and Zod-backed input validation.
Production MCP server exposing query Elasticsearch index over WebSocket. Tested with custom host via MCP SDK — includes auth (JWT bearer token), schema validation (TypeBox), error handling, and host-specific install instructions.
You are a senior agent engineer building a production-grade Model Context Protocol (MCP) server.
**Goal:** Expose "fetch Stripe invoice" as a callable MCP tool that is reachable from VS Code with MCP extension over the stdio transport. Runtime: TypeScript + Node 20. Auth: mTLS. Schema validator: Zod.
## Deliverables
1. **Project scaffold** — complete file tree with:
- `package.json` / `pyproject.toml` with pinned deps (`@modelcontextprotocol/sdk` or `mcp` Python SDK)
- `src/server.ts` or `src/server.py` entrypoint
- `src/tools/fetch Stripe invoice.ts` tool implementation
- `src/auth.ts` auth middleware
- `tests/` folder with unit + integration tests
- `Dockerfile` and `README.md`
2. **Tool schema** — write the exact Zod schema for:
- Inputs (with descriptions, examples, enum constraints where relevant)
- Outputs (typed, not free-form strings)
- Derive the JSON Schema the MCP SDK will advertise to clients
3. **Transport setup for stdio**
- If stdio: how to wire stdin/stdout, flush buffers, handle SIGTERM
- If SSE: `/sse` endpoint, `POST /message` for client→server, session ID correlation
- If HTTP streaming / Streamable HTTP: single endpoint, `Mcp-Session-Id` header, resumability
- If WebSocket: frame handling, ping/pong, reconnection
4. **Authentication (mTLS)** — justify this choice for this tool and implement:
- Where credentials live (env var, OAuth token store, keychain)
- Refresh / rotation strategy
- Failure mode when auth expires mid-session
- Redaction in logs
5. **Error handling** — handle each of:
- Invalid input (return `isError: true` with actionable message, never throw)
- Upstream service failure (retry with backoff; surface which downstream failed)
- Timeout (set a hard deadline, cancel in-flight work)
- Permission denied (never leak why in prod; log full reason server-side)
- Rate limiting (respect Retry-After, queue vs. reject)
6. **Example client flow**
- How VS Code with MCP extension discovers this tool via `tools/list`
- A sample `tools/call` request + response JSON
- What the user types in VS Code with MCP extension to trigger it
- How the tool result is rendered back to the model
7. **Host-specific install instructions for VS Code with MCP extension**
- Exact config file path (e.g. `~/Library/Application Support/Claude/claude_desktop_config.json` for Claude Desktop, `~/.cursor/mcp.json` for Cursor, `.mcp.json` at repo root for Claude Code)
- The JSON block to paste in, with all required env vars
- How to verify the server connected (log lines to look for, UI indicator)
- Common gotchas specific to VS Code with MCP extension
8. **Test harness**
- Unit tests for the tool handler in isolation (mock the upstream)
- Integration test that spawns the server and drives it via the MCP SDK client
- Manual smoke test checklist for VS Code with MCP extension
9. **Observability**
- Structured logging (request ID, tool name, duration, outcome)
- Metrics counter (calls, errors, p95 latency)
- How to tail logs when running under VS Code with MCP extension
10. **Production hardening**
- Resource limits (max concurrent calls, max payload size)
- Graceful shutdown
- Secret rotation without restart
- Security review checklist (injection, SSRF, path traversal for file tools)
Write real, copy-pasteable code for the server entrypoint, the tool schema, and the auth middleware. No pseudocode. Treat this as a PR-ready implementation.