.skill/skills/mcp-python/SKILL.md
Create and extend MCP (Model Context Protocol) servers in Python using FastMCP and the official SDK. Covers tools, resources, prompts, STDIO vs HTTP transports, logging rules for STDIO, and production best practices. Use when building or modifying MCP servers in Python, adding tools/resources/prompts, debugging MCP servers, or choosing transport and client config.
npx skillsauth add antoinebou12/uml-mcp mcp-pythonInstall 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.
Create and extend MCP servers in Python with FastMCP and the official MCP Python SDK. Based on MCP Build a server and MCP Best Practices.
Python 3.12, MCP Python SDK 1.2.0+. Use uv add "mcp[cli]" or uv add fastmcp (or project may use fastmcp package).
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("my-server")
@mcp.tool()
async def get_forecast(latitude: float, longitude: float) -> str:
"""Get weather forecast for a location.
Args:
latitude: Latitude of the location
longitude: Longitude of the location
"""
# ... fetch and return string
return result
@mcp.resource("config://{key}")
def get_config(key: str) -> str:
"""Get config value by key."""
return config_store.get(key, "")
@mcp.prompt()
def plan_task(goal: str, steps: int = 5) -> str:
"""Generate a step-by-step plan. Args: goal, steps (default 5)."""
return f"Plan for: {goal} in {steps} steps."
def main():
mcp.run(transport="stdio")
if __name__ == "__main__":
main()
mcp.run(transport="stdio") for stdio; use streamable HTTP for remote deployment.For STDIO-based servers, never write to stdout. JSON-RPC uses stdout; any print or stdout write corrupts messages and breaks the server.
print("Processing"), sys.stdout.write(...)import logging and logging.info(...) (logging writes to stderr by default), or log to a file.For HTTP-based servers, stdout logging is fine.
uvx create-mcp-server
# Follow prompts; then:
cd <generated-project>
uv sync --dev --all-extras
uv run <server-module>
Example for Claude Desktop or Cursor MCP (stdio, using uv):
{
"mcpServers": {
"my-server": {
"command": "uv",
"args": ["--directory", "/absolute/path/to/project", "run", "server.py"]
}
}
}
Use absolute path to the project directory. On Windows use forward slashes or escaped backslashes in JSON.
tools
Create and validate diagrams with the uml-mcp MCP server (generate_uml, validate_uml, list_diagram_types, generate_uml_batch). Use for UML, Mermaid, D2, Graphviz, Kroki URLs, or diagram_type questions.
tools
Creates diagrams via the uml-mcp MCP server (generate_uml, validate_uml, list_diagram_types, generate_uml_batch) and returns shareable Kroki URLs plus optional playground links. Use when the user wants a diagram, asks for PlantUML/Mermaid/D2/UML, wants a URL instead of a saved file, or mentions uml-mcp, Kroki, or diagram_type.
tools
Produces Mermaid or PlantUML diagram code from user specifications for UML, architecture, and flow diagrams. Use when the user asks for a diagram (sequence, class, activity, use case, component, state, deployment), diagram code, or when generating diagram script for documentation, design, or the generate_uml MCP tool. Supports Kroki-renderable output.
tools
Modern Python tooling and best practices using uv, ruff, ty, and pytest. Covers project setup with pyproject.toml (PEP 735), src layout, linting/formatting with ruff, type checking with ty, testing with pytest and coverage, pre-commit with prek, and security (pip-audit, detect-secrets, actionlint). Use when setting up or working on Python projects, replacing pip/virtualenv with uv, replacing flake8/black/mypy with ruff/ty, adding pre-commit or security scanning, or when the user mentions uv, ruff, ty, pytest, or cookiecutter-python patterns.