skills/new-mcp-server/SKILL.md
--- name: new-mcp-server description: Scaffold a new MCP server (Model Context Protocol). Two transports — hosted (Cloudflare Workers via McpAgent) and local (stdio). Wires tools, resources, prompts with Zod schemas, optional WorkOS auth for hosted multi-tenant servers, optional /.well-known/mcp/server-card.json for the in-flight server-card spec, and the MCP Inspector for local dev. Use when user wants to create an MCP server, new MCP server, scaffold an MCP server, build an MCP server, MCP ser
npx skillsauth add RonanCodes/ronan-skills skills/new-mcp-serverInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Scaffold a new MCP server using the user's conventions. Two transports:
cloudflare:build-mcp skill rather than re-implementing it. This skill is the opinionated wrapper that adds auth, observability, server-card scaffolding, and the user's project conventions.@modelcontextprotocol/sdk over stdio.Default is --stdio unless the server is multi-tenant.
/ro:new-mcp-server my-server # interactive picker (asks transport)
/ro:new-mcp-server my-server --stdio # local stdio server
/ro:new-mcp-server my-server --hosted # Cloudflare Workers + McpAgent
/ro:new-mcp-server my-server --hosted --with-auth=workos
/ro:new-mcp-server my-server --hosted --with-card # also serve /.well-known/mcp/server-card.json
Will more than one person use it (or you across machines)?
├── No → --stdio (run locally, install via npx)
└── Yes
├── Does it need user-specific data or per-user auth?
│ ├── No → --hosted (public, anonymous, rate-limited)
│ └── Yes → --hosted --with-auth=workos (multi-tenant)
└── Want it discoverable for AI clients to enumerate?
└── Add --with-card (opt-in, schema is Draft, see below)
--hosted: wrangler (pnpm add -g wrangler), Cloudflare account, the cloudflare:build-mcp skill from the Cloudflare plugin reachable via Skill tool--hosted --with-auth=workos: a WorkOS account (the auth handler dispatches to /ro:workos)Both transports share these conventions:
my-server/
├── package.json # name, mcp keyword, bin (stdio) or build script (hosted)
├── tsconfig.json
├── src/
│ ├── server.ts # McpServer instance + tool/resource/prompt registrations
│ ├── tools/ # one file per tool (Zod schema + handler colocated)
│ ├── resources/ # one file per resource
│ └── prompts/ # one file per prompt
└── README.md # how to install + an example tool call
Hosted variant adds wrangler.toml, src/index.ts (Workers entry), and optionally src/well-known.ts.
Stdio variant adds bin/cli.ts (the entry that wires StdioServerTransport).
mkdir my-server && cd my-server
pnpm init
pnpm add @modelcontextprotocol/sdk zod
pnpm add -D typescript tsx @types/node
/ro:harden-npm/ro:harden-npm
MCP servers often get published to npm, so they need especially tight supply-chain controls (a poisoned MCP server gets executed inside Claude Code with full filesystem access). See llm-wiki-security/wiki/playbooks/npm-supply-chain-hardening.md.
package.json:
{
"name": "my-mcp-server",
"version": "0.1.0",
"type": "module",
"bin": { "my-mcp-server": "./dist/cli.js" },
"keywords": ["mcp", "modelcontextprotocol"],
"scripts": {
"dev": "npx @modelcontextprotocol/inspector tsx src/cli.ts",
"build": "tsc",
"start": "node dist/cli.js"
}
}
The mcp and modelcontextprotocol keywords are how clients discover the server on npm.
src/server.tsimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
export function createServer() {
const server = new McpServer({ name: 'my-mcp-server', version: '0.1.0' });
server.registerTool(
'hello',
{
title: 'Say hello',
description: 'Return a greeting for a given name',
inputSchema: z.object({ name: z.string() }),
annotations: { readOnlyHint: true, idempotentHint: true },
},
async ({ name }) => ({
content: [{ type: 'text', text: `Hello, ${name}!` }],
}),
);
return server;
}
The MCP TypeScript SDK requires inputSchema to be wrapped with z.object() (Zod v4); raw shapes from v1 of the SDK no longer work. Note that for --hosted (McpAgent in Cloudflare's agents SDK), the McpAgent wrapper still accepts the v1 raw-shape form for backward compatibility, but new code should use z.object() everywhere for consistency.
src/cli.ts#!/usr/bin/env node
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { createServer } from './server.js';
async function main() {
const server = createServer();
const transport = new StdioServerTransport();
await server.connect(transport);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
pnpm dev
The MCP Inspector opens a UI at http://localhost:5173, connects to your server over stdio, lets you call tools and inspect resources without wiring a real client.
After pnpm build:
claude mcp add my-mcp-server -- node /absolute/path/to/dist/cli.js
Or publish to npm (pnpm publish) and consumers add via npx:
claude mcp add my-mcp-server -- npx -y my-mcp-server
For the canonical Cloudflare McpAgent flow, dispatch first:
Skill cloudflare:build-mcp
Read its scaffold steps, then layer the user's conventions on top. The differences from the bare Cloudflare scaffold:
Match the rest of the user's stack. After npx create-cloudflare@latest --template cloudflare/agents-starter, swap to pnpm:
rm -rf node_modules package-lock.json
pnpm install
wrangler.toml[observability]
enabled = true
head_sampling_rate = 1
200K events/day free, no separate setup. This is non-negotiable for a public MCP server you cannot debug in person.
Same McpServer API as stdio, registered inside init() of your McpAgent subclass. Example from the Cloudflare scaffold annotated for the user's conventions:
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { McpAgent } from 'agents/mcp';
import { z } from 'zod';
export class MyMCP extends McpAgent<Env, {}, {}> {
server = new McpServer({ name: 'my-server', version: '0.1.0' });
async init() {
this.server.registerTool(
'fetch_user',
{
description: 'Look up a user by ID',
inputSchema: z.object({ id: z.string() }),
},
async ({ id }) => {
const user = await this.env.DB.prepare('SELECT * FROM users WHERE id = ?').bind(id).first();
return {
content: [{ type: 'text', text: JSON.stringify(user) }],
structuredContent: user,
};
},
);
}
}
export default {
fetch(request: Request, env: Env, ctx: ExecutionContext) {
return MyMCP.serve('/mcp', { binding: 'MyMCP' }).fetch(request, env, ctx);
},
};
MyMCP.serve('/mcp') is the Streamable HTTP transport (recommended). serveSSE('/sse') is deprecated.
wrangler deploy
Consumers add the public URL to their mcp.json:
{
"mcpServers": {
"my-server": { "url": "https://my-server.<account>.workers.dev/mcp" }
}
}
When the server is multi-tenant (different users see different tools or different data), wire WorkOS first:
Skill ro:workos
Then in src/index.ts, gate the MyMCP.serve call behind a WorkOS-issued bearer:
import { getAuth } from './lib/auth';
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
const auth = getAuth(env);
const result = await auth.withAuth(request);
if (!result.auth.user) return new Response('Unauthorized', { status: 401 });
// pass user context into the agent state
const agent = MyMCP.serve('/mcp', { binding: 'MyMCP' });
return agent.fetch(request, env, ctx);
},
};
In tools, read this.props (set by McpAgent from request context) to scope queries to the current user. WorkOS organisations let you scope further (per-org tools, per-org data).
For a public anonymous MCP server, skip auth. Most public MCP servers should be anonymous + rate-limited rather than authenticated.
The MCP Server Card spec (SEP-2127, working group chartered 2026-03-26) defines a /.well-known/mcp/server-card.json document that clients can fetch to discover the server's identity, capabilities, and auth requirements without connecting first.
Status as of 2026-04-30: Draft. The PR is open in the modelcontextprotocol/spec repo, not merged. The shape is mostly stable but the final field set may shift before merge, especially tools and auth.
This skill ships the route as opt-in. Default scaffold structures the server's metadata so adding the route later is a 30-minute job, but does not serve the route by default.
When --with-card is passed:
// src/well-known.ts
export function serverCard(env: Env) {
return {
schema: 'https://modelcontextprotocol.io/schemas/server-card-draft.json',
name: 'my-server',
version: '0.1.0',
description: 'What this server does in one sentence.',
transport: { type: 'streamable-http', url: 'https://my-server.workers.dev/mcp' },
auth: env.AUTH_REQUIRED === 'true' ? { type: 'oauth2', authorization_url: env.WORKOS_AUTH_URL } : { type: 'none' },
capabilities: {
tools: true,
resources: false,
prompts: false,
},
contact: { url: 'https://github.com/<you>/<repo>' },
};
}
// src/index.ts (additions)
import { serverCard } from './well-known';
export default {
async fetch(request: Request, env: Env, ctx: ExecutionContext) {
const url = new URL(request.url);
if (url.pathname === '/.well-known/mcp/server-card.json') {
return Response.json(serverCard(env), {
headers: { 'cache-control': 'public, max-age=300' },
});
}
return MyMCP.serve('/mcp', { binding: 'MyMCP' }).fetch(request, env, ctx);
},
};
Re-check the schema URL and field set when the spec lands. Comparison context: llm-wiki-ai-research/wiki/concepts/mcp-server-cards.md.
Same registration shape as tools.
server.registerResource(
'docs',
'docs://readme',
{ title: 'Project README', mimeType: 'text/markdown' },
async () => ({
contents: [{ uri: 'docs://readme', mimeType: 'text/markdown', text: '# Hello\n' }],
}),
);
server.registerPrompt(
'review',
{
title: 'Code review prompt',
description: 'Generate a structured review for a diff',
argsSchema: z.object({ diff: z.string() }),
},
async ({ diff }) => ({
messages: [{ role: 'user', content: { type: 'text', text: `Review this diff:\n\n${diff}` } }],
}),
);
pnpm build
pnpm publish --access public
Consumers install via npx:
claude mcp add my-mcp-server -- npx -y my-mcp-server
Or via package manager + manual mcp.json entry pointing at the installed binary.
wrangler deploy
Consumers add the URL to mcp.json. No npm publish step.
For discoverability, register in community MCP catalogs (e.g. mcp.so, smithery.ai). The opt-in server-card route helps once the spec lands; until then, a clean README is the discoverability surface.
wrangler.toml snippet above. Query via the Cloudflare dashboard or the cloudflare-observability MCP (/ro:cloudflare-mcp-setup wires it).console.error() is fine; for structured logs use pino writing to process.stderr.console.error(JSON.stringify({ level: 'info', tool: 'fetch_user', userId: id, ms: Date.now() - start }));
Never write to stdout from a stdio server outside the MCP transport. Stray stdout breaks the JSON-RPC framing and clients disconnect.
--hosted, set rate limits in wrangler.toml ([[unsafe.bindings]] Rate Limiting binding) before going public. A public anonymous MCP with no rate limit is a bill-amplifier.--with-auth=workos, gate the auth check at the Worker entry, not inside individual tools. A tool that forgets to check this.props.user is an authorisation bug waiting to happen.fs and child_process access as a security boundary; document any tool that reads files or runs commands.pnpm dev) is local-only. Do not point a deployed Inspector at a hosted server; the protocol is unauthenticated by default and the Inspector is for development.cloudflare:build-mcp for the upstream Cloudflare McpAgent scaffold (composes with this skill)/ro:workos when wiring --with-auth=workos/ro:cf-ship to deploy the hosted variant the canonical way/ro:cloudflare-mcp-setup to wire the cloudflare-observability MCP for log querieshttps://github.com/modelcontextprotocol/typescript-sdk, context7 ID /modelcontextprotocol/typescript-sdkllm-wiki-ai-research/wiki/concepts/mcp-server-cards.mdtesting
--- name: linear-pipeline description: The Fable orchestrator for a single dispatched Linear ticket. Holds almost no context itself; it receives `--issue <ID> --detached`, decides the stage sequence, and fans out a sub-agent per stage, passing forward only each stage's artifact (never re-derived, never inlined into its own context). Step zero, before any planning or stage routing, is a boundary triage against `canon/security-boundary.md` (#199): a match tags Ronan Connolly and stops the run, no
development
--- name: in-your-face description: Capture a chat-only answer into a durable artifact (markdown + HTML, PDF when cheap) and launch it automatically so the user cannot miss it. Use when user says "in your face", "don't let me lose this", "save that answer", "make that durable", or right after answering a substantive side question (a recipe, comparison, how-to, or generated prompt) that would otherwise die with the context. category: workflow argument-hint: [--no-open] [--vault <short>] [hint of
tools
One-shot headless OpenAI Codex CLI calls for background/admin AI tasks — summaries, classification, extraction, admin glue. The default engine for anything that runs AI constantly in the background (daemon-driven, per-event), because it bills the flat ChatGPT subscription instead of Claude usage or per-token API spend, and it keeps working while Claude is rate-limited. NEVER for coding — coding stays Claude. Use when a skill or daemon needs a cheap always-on AI call, when the user says "use codex", "ask codex", "codex as backup", or when building a background summarizer/classifier into a listener or loop. Reads auth from ~/.codex/auth.json (ChatGPT account, no API key).
research
Turn a warranty rejection, repair quote, or RMA email into a cited decision brief — legal read (NL/EU consumer law), is the part user-serviceable, live part and new-unit prices, repair-vs-DIY-vs-new economics, before-you-send-it checklist, deadlines. Use when the user pastes or screenshots a repair quote, warranty rejection, "not covered" email, onderzoekskosten fee, or asks "should I repair or replace this".