Skip to content

artubss/SKILLS-CLAUDE-CODE / claude-skills-main/claude-skills-main/plugins/integrations/skills/mcp-builder

mcp-builder

Verified

Build MCP servers in Python with FastMCP. Define tools / resources / prompts, build the server, test locally, deploy to FastMCP Cloud or Docker. Use whenever the user mentions building an MCP server, exposing tools to LLMs, FastMCP, building a Claude integration, or troubleshooting FastMCP module-level server, storage, lifespan, middleware, OAuth, or deployment errors.

assets/basic-server.py

View on GitHub
"""
Basic FastMCP Server Template
==============================
A minimal working FastMCP server with essential patterns.
"""

from fastmcp import FastMCP
import os

# Load environment variables (optional)
from dotenv import load_dotenv
load_dotenv()

# ============================================================================
# CRITICAL: Server must be at module level for FastMCP Cloud
# ============================================================================

mcp = FastMCP(
    name="My Basic Server",
    instructions="""
    This is a basic MCP server demonstrating core patterns.

    Available tools:
    - greet: Say hello to someone
    - calculate: Perform basic math operations

    Available resources:
    - info://status: Server status information
    """
)

# ============================================================================
# Tools
# ============================================================================

@mcp.tool()
def greet(name: str, greeting: str = "Hello") -> str:
    """
    Greet someone by name.

    Args:
        name: The name of the person to greet
        greeting: The greeting to use (default: "Hello")

    Returns:
        A greeting message
    """
    return f"{greeting}, {name}!"


@mcp.tool()
async def calculate(operation: str, a: float, b: float) -> dict:
    """
    Perform a mathematical operation.

    Args:
        operation: The operation to perform (add, subtract, multiply, divide)
        a: First number
        b: Second number

    Returns:
        Dictionary with the result or error message
    """
    operations = {
        "add": lambda x, y: x + y,
        "subtract": lambda x, y: x - y,
        "multiply": lambda x, y: x * y,
        "divide": lambda x, y: x / y if y != 0 else None
    }

    if operation not in operations:
        return {
            "error": f"Unknown operation: {operation}",
            "valid_operations": list(operations.keys())
        }

    result = operations[operation](a, b)

    if result is None:
        return {"error": "Division by zero"}

    return {
        "operation": operation,
        "a": a,
        "b": b,
        "result": result
    }


# ============================================================================
# Resources
# ============================================================================

@mcp.resource("info://status")
def server_status() -> dict:
    """Get current server status."""
    from datetime import datetime

    return {
        "server": "My Basic Server",
        "status": "operational",
        "timestamp": datetime.now().isoformat(),
        "version": "1.0.0"
    }


# ============================================================================
# Main Execution
# ============================================================================

if __name__ == "__main__":
    # Run with stdio transport (default)
    mcp.run()

    # Alternative: HTTP transport for testing
    # mcp.run(transport="http", port=8000)
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 197kUpdated Claude CodeCodexVerifiedInstall