
Mcp Server Skills
- 322 installs
- 22 repo stars
- Updated January 21, 2026
- gocallum/nextjs16-agent-skills
mcp-server-skills is a Next.js integration skill that builds MCP servers with mcp-handler, shared Zod schemas, and reusable server actions for agent-callable tools.
About
mcp-server-skills is an AI & Agent Building skill from gocallum/nextjs16-agent-skills documenting a pattern for MCP servers in Next.js 16 App Router. The layout places a transport handler at `app/api/[transport]/route.ts`, shared logic in `app/actions/mcp-actions.ts`, and tool implementations under `lib/`. The skill references mcp-handler for HTTP transport, Model Context Protocol specs, and a Roll Dice reference implementation. Shared Zod schemas keep MCP tool definitions aligned with Next.js server actions so agents get typed, testable boundaries. Developers reach for mcp-server-skills when exposing app capabilities—dice rolls, data lookups, or mutations—to Claude Desktop via mcp-remote or other MCP clients.
- Next.js 16–aligned MCP server patterns
- Tool schema and handler conventions for agents
- Safer external API exposure via server boundaries
- Fits agent-first SaaS and API products
Mcp Server Skills by the numbers
- 322 all-time installs (skills.sh)
- Ranked #2,228 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Jul 24, 2026 (Skillselion catalog sync)
npx skills add https://github.com/gocallum/nextjs16-agent-skills --skill mcp-server-skillsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 322 |
|---|---|
| repo stars | ★ 22 |
| Last updated | January 21, 2026 |
| Repository | gocallum/nextjs16-agent-skills ↗ |
How do you build MCP servers in Next.js?
Wire MCP servers into a Next.js 16 app so coding agents can call external tools, APIs, and data sources with typed, testable server boundaries.
Who is it for?
Next.js 16 developers exposing typed MCP tool endpoints to Claude Desktop or other MCP clients.
Skip if: Non-Next.js stacks or apps with no need to expose server capabilities to external MCP clients.
When should I use this skill?
A developer is adding an MCP server endpoint to a Next.js 16 App Router project with mcp-handler and shared schemas.
What you get
MCP route handler, Zod-validated tools, and reusable server actions for agent clients.
- MCP route handler
- Zod-validated tool definitions
Files
Links
- Model Context Protocol: https://modelcontextprotocol.io/
- mcp-handler (HTTP): https://www.npmjs.com/package/mcp-handler
- Reference implementation (Roll Dice): https://github.com/gocallum/rolldice-mcpserver
- Claude Desktop + mcp-remote bridge: https://www.npmjs.com/package/mcp-remote
Folder Structure (Next.js App Router)
app/
api/[transport]/route.ts # One handler for all transports (e.g., /api/mcp)
actions/mcp-actions.ts # Server actions reusing the same logic/schemas
lib/
dice.ts | tools.ts # Zod schemas, tool definitions, pure logic
components/ # UI that calls server actions for web testingGoal: Keep route.ts minimal. Put logic + Zod schemas in lib/* so both the MCP handler and server actions share a single source of truth.
Shared Zod Schema + Tool Definition
// lib/dice.ts
import { z } from "zod";
export const diceSchema = z.number().int().min(2);
export function rollDice(sides: number) {
const validated = diceSchema.parse(sides);
const value = 1 + Math.floor(Math.random() * validated);
return { type: "text" as const, text: `🎲 You rolled a ${value}!` };
}
export const rollDiceTool = {
name: "roll_dice",
description: "Rolls an N-sided die",
schema: { sides: diceSchema },
} as const;Reusable Server Actions (Web UI + Tests)
// app/actions/mcp-actions.ts
"use server";
import { rollDice as rollDiceCore, rollDiceTool } from "@/lib/dice";
export async function rollDice(sides: number) {
try {
const result = rollDiceCore(sides);
return { success: true, result: { content: [result] } };
} catch {
return {
success: false,
error: { code: -32602, message: "Invalid parameters: sides must be >= 2" },
};
}
}
export async function listTools() {
return {
success: true,
result: {
tools: [
{
name: rollDiceTool.name,
description: rollDiceTool.description,
inputSchema: {
type: "object",
properties: { sides: { type: "number", minimum: 2 } },
required: ["sides"],
},
},
],
},
};
}Server actions call the same logic as the MCP handler and power the web UI, keeping responses aligned.
Lightweight MCP Route
// app/api/[transport]/route.ts
import { createMcpHandler } from "mcp-handler";
import { rollDice, rollDiceTool } from "@/lib/dice";
const handler = createMcpHandler(
(server) => {
server.tool(
rollDiceTool.name,
rollDiceTool.description,
rollDiceTool.schema,
async ({ sides }) => ({ content: [rollDice(sides)] }),
);
},
{}, // server options
{
basePath: "/api", // must match folder path
maxDuration: 60,
verboseLogs: true,
},
);
export { handler as GET, handler as POST };Pattern highlights
- Route only wires
createMcpHandler; no business logic inline. server.toolconsumes the shared tool schema/description and calls shared logic.basePathshould align with the folder (e.g.,/api/[transport]).- Works for SSE/HTTP transports; stdio can be added separately if needed.
Claude Desktop Config (mcp-remote)
{
"mcpServers": {
"rolldice": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:3000/api/mcp"]
}
}
}Best Practices
1) Single source of truth — schemas + logic in lib/*; both MCP tools and server actions import them. 2) Validation first — use Zod for inputs and reuse the same schema for UI + MCP. 3) Keep route.ts light — only handler wiring, logging, and transport config. 4) Shared responses — standardize { success, result | error } shapes for tools and UI. 5) Vercel-friendly — avoid stateful globals; configure maxDuration and runtime if needed. 6) Multiple transports — expose /api/[transport] for HTTP/SSE; add stdio entrypoint when required. 7) Local testing — hit server actions from the web UI to ensure MCP responses stay in sync.
Related skills
FAQ
What folder structure does mcp-server-skills use?
mcp-server-skills uses `app/api/[transport]/route.ts` for the MCP handler, `app/actions/mcp-actions.ts` for shared logic, and `lib/` for tool implementations. Zod schemas are shared across MCP tools and server actions.
Which npm package handles MCP HTTP transport?
mcp-server-skills uses the mcp-handler npm package for HTTP MCP transport in Next.js. Claude Desktop connects via mcp-remote or compatible MCP clients per the skill's reference links.