Fastmcp creator

From BbgnsurfTech/claude-skills-collection · View interactive version

Fastmcp creator is an AI agent skill from the GitHub repository BbgnsurfTech/claude-skills-collection. Build Model Context Protocol (MCP) servers - comprehensive coverage of generic MCP protocol AND FastMCP framework specialization. Use when creating any MCP server (Python FastMCP preferred, TypeScript/Node also covered). Includes agent-centric design principles, evaluation creation, Pydantic/Zod val

How to use this skill

Skill file

MCP Server Development

Scope

TRIGGER: The model must activate when building MCP (Model Context Protocol) servers

SPECIALIZATION: FastMCP framework (Python, decorator-based) FALLBACK: Generic Python SDK, TypeScript SDK also covered

COVERAGE:

EXCLUSIONS:

High-Level Workflow

TRIGGER: The model must follow this 4-phase workflow when building MCP servers

Phase 1: Deep Research and Planning

1.1 Understand Agent-Centric Design Principles

RULE: The model must design tools for AI agents, not just API wrappers

PRINCIPLES:

Build for Workflows, Not Just API Endpoints:

Optimize for Limited Context:

Design Actionable Error Messages:

Follow Natural Task Subdivisions:

Use Evaluation-Driven Development:

1.2 Study MCP Protocol Documentation

RESOURCE: https://modelcontextprotocol.io/llms-full.txt PURPOSE: Complete MCP specification and guidelines

RESEARCH TOOL PREFERENCE (in order):

  1. Preferred: mcp__Ref__ref_search_documentation(query="Model Context Protocol specification") - High-fidelity verbatim documentation
  2. Alternative: mcp__exa__get_code_context_exa(query="MCP protocol server implementation examples") - Code context and examples
  3. Fallback: WebFetch - Use only when MCP tools don't provide needed content

RATIONALE: MCP tools provide higher fidelity (verbatim source) compared to WebFetch (AI summaries)

Web resource access, definitive guide for getting accurate data for high quality results

1.3 Study Framework Documentation

DECISION_TREE:

IF implementing in Python THEN
  - Load FastMCP patterns from references/development-guidelines.md
  - Load Python SDK documentation from official source
  - Focus on decorator-based patterns and Pydantic validation

ELSE IF implementing in TypeScript/Node THEN
  - Load TypeScript patterns from references/typescript-mcp-server.md
  - Load TypeScript SDK documentation from official source
  - Focus on registerTool patterns and Zod validation

ELSE
  - Load generic best practices from references/mcp-best-practices.md
  - Adapt to target language/framework

REFERENCES_IN_SKILL:

1.4 Exhaustively Study API Documentation

RULE: The model must read through ALL available API documentation for target service

REQUIREMENTS:

RESEARCH TOOL HIERARCHY (use in this order):

  1. MCP Ref tool: mcp__Ref__ref_search_documentation for official API documentation (verbatim, high-fidelity)
  2. MCP exa tool: mcp__exa__get_code_context_exa for code examples and SDK usage patterns
  3. MCP exa web search: mcp__exa__web_search_exa for general research with LLM-optimized results
  4. Fallback: WebFetch only when MCP tools don't work

RATIONALE: MCP tools provide superior accuracy, precision, and fidelity for technical documentation

1.5 Create Comprehensive Implementation Plan

PLAN_COMPONENTS:

Tool Selection:

Shared Utilities and Helpers:

Input/Output Design:

Error Handling Strategy:

Phase 2: Implementation

RULE: The model must implement following language-specific best practices

For Python (FastMCP)

Python Project Setup:

RULE: The model must activate the python3-development skill before setting up Python MCP server projects

CONSTRAINT: The python3-development skill contains:

ACTIVATION:

Skill(command: "python3-development")

The model must defer to python3-development for general Python project structure.

Basic Server Structure:

from fastmcp import FastMCP
from pydantic import Field
from typing import Annotated

mcp = FastMCP("service_mcp")

@mcp.tool()
def tool_name(
    param: Annotated[str, Field(description="Parameter description")]
) -> dict:
    """Tool description for the AI."""
    return {"result": "value"}

if __name__ == "__main__":
    mcp.run()  # Defaults to STDIO transport

Key Patterns:

See: FastMCP Development Guidelines for complete Python patterns

For TypeScript/Node

Basic Server Structure:

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: "service-mcp-server",
  version: "1.0.0",
});

const InputSchema = z
  .object({
    param: z.string().describe("Parameter description"),
  })
  .strict();

server.registerTool(
  "tool_name",
  {
    title: "Tool Title",
    description: "Tool description for the AI",
    inputSchema: InputSchema,
    annotations: { readOnlyHint: true },
  },
  async (params) => {
    return { content: [{ type: "text", text: "result" }] };
  },
);

const transport = new StdioServerTransport();
await server.connect(transport);

Key Patterns:

See: TypeScript MCP Server Guide for complete TypeScript patterns

Phase 3: Review and Refine

3.1 Code Quality Review

CHECKLIST:

3.2 Test and Build

Important: MCP servers are long-running processes. Running them directly causes your process to hang indefinitely.

Safe Testing:

For Python:

python -m py_compile your_server.py  # Verify syntax

For TypeScript:

npm run build  # Must complete without errors

Phase 4: Create Evaluations

RULE: The model must create comprehensive evaluations to test server effectiveness

RESOURCE: Evaluation Guide

Purpose: Evaluations test whether LLMs can effectively use your MCP server to answer realistic, complex questions.

Process:

  1. Tool Inspection - List available tools and understand capabilities
  2. Content Exploration - Use READ-ONLY operations to explore available data
  3. Question Generation - Create 10 complex, realistic questions
  4. Answer Verification - Solve each question yourself to verify answers

Requirements: Each question must be:

Output Format:

<evaluation>
  <qa_pair>
    <question>Complex question requiring multiple tool calls</question>
    <answer>Single verifiable answer</answer>
  </qa_pair>
</evaluation>

Evaluation Scripts:

Located in ./scripts/:

Usage:

pip install -r scripts/requirements.txt
export ANTHROPIC_API_KEY=your_api_key

python scripts/evaluation.py \
  -t stdio \
  -c python \
  -a my_mcp_server.py \
  evaluation.xml

Quick Reference

FastMCP (Python) Quick Start

from fastmcp import FastMCP
from pydantic import Field
from typing import Annotated

mcp = FastMCP("my-server")

@mcp.tool()
def search_items(
    query: str,
    limit: Annotated[int, Field(ge=1, le=100)] = 10
) -> dict:
    """Search for items matching the query."""
    results = perform_search(query, limit)
    return {"results": results, "count": len(results)}

@mcp.resource("data://config")
def get_config() -> dict:
    return {"setting": "value"}

@mcp.prompt()
def explain_topic(topic: str) -> str:
    return f"Explain the concept of '{topic}'"

if __name__ == "__main__":
    mcp.run()  # STDIO transport
    # OR: mcp.run(transport="http", port=8000)

TypeScript/Node Quick Start

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: "my-server",
  version: "1.0.0",
});

const SearchSchema = z
  .object({
    query: z.string(),
    limit: z.number().int().min(1).max(100).default(10),
  })
  .strict();

server.registerTool(
  "search_items",
  {
    title: "Search Items",
    description: "Search for items matching the query",
    inputSchema: SearchSchema,
    annotations: { readOnlyHint: true },
  },
  async (params) => {
    const results = await performSearch(params.query, params.limit);
    return {
      content: [
        {
          type: "text",
          text: JSON.stringify({ results, count: results.length }, null, 2),
        },
      ],
    };
  },
);

const transport = new StdioServerTransport();
await server.connect(transport);

Best Practices Summary

MANDATORY_PRACTICES:

Tool Design:

Input/Output:

Validation:

Error Handling:

Security:

Performance:

Deployment:

Resources

COMPREHENSIVE_REFERENCES:

mcp-best-practices.md

Universal MCP guidelines including naming conventions, response formats, pagination, security, and compliance requirements. Use for all MCP implementations regardless of language.

development-guidelines.md

Complete FastMCP development guide covering decorators, Pydantic validation, async patterns, error handling, Context parameters, annotations, transport options, and production deployment.

typescript-mcp-server.md

Complete TypeScript/Node implementation guide covering project structure, registerTool patterns, Zod validation, error handling, and production build process.

community-practices.md

Mid-2025+ best practices including .mcpb packaging, security by design patterns, observability and testing approaches, performance tuning, caching, ecosystem compatibility, and agent orchestration patterns.

prompts-and-templates.md

FastMCP prompt and template system covering @mcp.prompt decorator, system instructions for tool use, configuration for AI-native tools, and prompt engineering for MCP servers.

example-projects.md

Real-world FastMCP implementations demonstrating best practices and patterns from Ultimate MCP Server (AI Agent OS), Hugging Face MCP server, browser automation servers, data/DevOps integrations, coding assistants, and templates/aggregators.

evaluation-guide.md

Complete guide for creating comprehensive evaluations to test whether LLMs can effectively use your MCP server to answer realistic, complex questions. Includes question guidelines, answer requirements, evaluation process, output format, examples, and verification process.

Standalone Operation

CONSTRAINT: This skill is completely standalone with no external dependencies

VERIFICATION:

USAGE: Load this skill to access complete, comprehensive MCP server development guidance without needing any other skills or external resources.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.