skills/mcp-mastery/mcp-server-authoring/SKILL.md
Build production-quality MCP (Model Context Protocol) servers that expose tools, resources, and prompts to AI clients like Claude Desktop, Claude Code, Cursor, and the Claude Agent SDK. Use this skill when the user wants to build an MCP server, expose internal tooling to an AI agent, wrap an API for agents, or publish a reusable MCP server to a registry. Activate when: MCP server, Model Context Protocol, expose tools to Claude, @modelcontextprotocol/sdk, mcp.json, stdio server, HTTP MCP server.
npx skillsauth add latestaiagents/agent-skills mcp-server-authoringInstall 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.
Build MCP servers in TypeScript or Python that any MCP-compatible client can consume.
An MCP server exposes three primitives:
| Primitive | Purpose | Side effects | |---|---|---| | Tool | Action the agent calls | May have side effects (writes, network calls) | | Resource | Data the agent reads | Read-only, addressed by URI | | Prompt | Reusable prompt template | No side effects; user-invocable |
Pick the right primitive — exposing read operations as tools wastes context when they should be resources.
npm init -y
npm i @modelcontextprotocol/sdk zod
npm i -D typescript tsx @types/node
// src/server.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
const server = new McpServer({
name: "weather-server",
version: "1.0.0",
});
server.tool(
"get_forecast",
"Get a weather forecast for a location",
{
location: z.string().describe("City name or lat,lng"),
days: z.number().int().min(1).max(14).default(3),
},
async ({ location, days }) => {
const data = await fetchForecast(location, days);
return {
content: [{ type: "text", text: JSON.stringify(data) }],
};
},
);
server.resource(
"station",
"weather://stations/{id}",
async (uri) => {
const id = uri.pathname.split("/").pop()!;
const station = await fetchStation(id);
return {
contents: [{ uri: uri.href, mimeType: "application/json", text: JSON.stringify(station) }],
};
},
);
const transport = new StdioServerTransport();
await server.connect(transport);
Run it and register in the client's mcp.json:
{
"mcpServers": {
"weather": {
"command": "npx",
"args": ["-y", "tsx", "src/server.ts"]
}
}
}
uv add "mcp[cli]"
# server.py
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("weather-server")
@mcp.tool()
async def get_forecast(location: str, days: int = 3) -> dict:
"""Get a weather forecast for a location."""
return await fetch_forecast(location, days)
@mcp.resource("weather://stations/{id}")
async def station(id: str) -> dict:
return await fetch_station(id)
if __name__ == "__main__":
mcp.run()
search_issues, not IssueSearcher).describe() on every field{ content: [{ type: "text", text: ... }] } — wrap JSON as textisError: true. Include remediation in the messageidempotency_key when possibleDon't dump 40 tools on the client. Expose a small stable surface and let tools return follow-up handles:
server.tool("list_projects", "List accessible projects", {}, async () => {
const projects = await api.listProjects();
return {
content: [{
type: "text",
text: `Found ${projects.length} projects. Use get_project with id to read one:\n` +
projects.map(p => `- ${p.id}: ${p.name}`).join("\n"),
}],
};
});
Use the MCP Inspector during development:
npx @modelcontextprotocol/inspector tsx src/server.ts
It gives you a UI to call every tool, inspect every resource, and replay prompts. Run it in CI against a mock backend to catch schema regressions.
bin entry so users run npx your-mcp-serversmithery.yaml with config schema for one-click installcommand at docker runserver.sendNotification progress eventsname suffix (github-v2) when making breaking changesdevelopment
Test skills for correct activation, content quality, and regression — both automated checks (frontmatter validity, lint) and manual verification (query-suite activation testing). Covers CI integration and how to catch skill regressions before users do. Use this skill when adding skills to a repo, setting up CI for a skill library, or debugging "the skill exists but doesn't work". Activate when: test skills, validate skills, skill CI, skill linting, skill activation test, skill regression.
documentation
Write the YAML frontmatter for a SKILL.md file so it activates reliably — name, description, and activation keywords that the model matches against. Covers length, tone, and the most common frontmatter mistakes. Use this skill when authoring a new skill, fixing a skill that isn't auto-activating, or reviewing skills for publication. Activate when: SKILL.md frontmatter, skill description, skill activation, skill YAML, write a skill, author a skill.
development
Design skills that fire at the right moment — neither over-eager (noise) nor under-eager (silent). Covers activation specificity, trigger phrases, disambiguation between overlapping skills, and debugging activation. Use this skill when multiple skills could fire on the same query, a skill never fires, or a skill fires too often. Activate when: skill won't activate, skill over-activates, overlapping skills, skill triggers, skill selection, skill disambiguation.
development
Structure SKILL.md content so the model reads just enough — concise summary up front, progressively deeper detail, examples on demand. Covers section ordering, length budgets, when to split into multiple skills. Use this skill when writing or refactoring a skill body, one skill has grown too long, or a skill is wordy but not useful. Activate when: SKILL.md structure, skill content, skill too long, split skill, progressive disclosure, skill body.