
python-mcp-server-generator
Use this skill when the user wants to create a new Model Context Protocol (MCP) server in Python. Also use it to expose Python functions, an API, or a database to AI clients as MCP tools. The skill makes a uv project with the MCP Python SDK v2 (MCPServer), typed tools, in-memory tests, and client configuration. Do not use it for an MCP client or for a server in another language.
- Installs
- 10.4K
- Last 24h
- —
- Trending rank
- —
- Security
- Warn
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/github/awesome-copilot --skill python-mcp-server-generator- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads python-mcp-server-generator automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
Security audits
Independent scans of the skill's instructions and bundled files.
SKILL.md
The instructions your agent reads when the skill is triggered.
Python MCP Server Generator
Create a Model Context Protocol (MCP) server in Python with the official MCP Python SDK v2. SDK v2 supports the MCP specification revision 2026-07-28. The same server also serves clients that use earlier revisions.
Workflow
Copy this checklist and track your progress:
- Step 1: Create the project.
- Step 2: Write the server.
- Step 3: Write the tests.
- Step 4: Run the tests until they pass.
- Step 5: Configure the client.
Step 1: Create the project
Run these commands:
uv init --app --no-package project-name
cd project-name
uv add "mcp[cli]>=2,<3"
uv add --dev pytest
Then delete main.py. The server goes in server.py.
- Without
--no-package, uv makes asrc/package layout, and the tests cannot importserver.py. uv initmakes the.gitignorefile. Do not write a different one.
Step 2: Write the server
Start from this template:
from mcp.server import MCPServer
from mcp.server.mcpserver.exceptions import ToolError
mcp = MCPServer("Demo", version="0.1.0")
@mcp.tool()
def divide(a: float, b: float) -> float:
"""Divide a by b."""
if b == 0:
raise ToolError("b must not be zero.")
return a / b
if __name__ == "__main__":
mcp.run() # stdio is the default transport
Then change the template for the request of the user:
- Replace
dividewith the tools that the user needs. - Give each tool full type hints and a docstring. The SDK makes the input schema from the type hints. The docstring becomes the tool description.
- Return a Pydantic model or a
TypedDictwhen the client needs machine-readable data. The SDK makes the output schema from the return type. - Use
async deffor I/O. The SDK runs a sync tool on a worker thread. - Mark a read-only tool with
@mcp.tool(annotations=ToolAnnotations(read_only_hint=True))(frommcp.types). Usedestructive_hint=Truefor a destructive tool. - Add resources (
@mcp.resource("users://{user_id}")) and prompts (@mcp.prompt()) only when the user asks for them.
Use stdio by default. Read references/streamable-http.md only when the user asks for a remote server or an HTTP server.
Step 3: Write the tests
Put test_server.py next to server.py. Write a test for each tool and for each ToolError:
import pytest
from mcp import Client
from server import mcp
@pytest.mark.anyio
async def test_divide():
async with Client(mcp) as client:
result = await client.call_tool("divide", {"a": 6, "b": 3})
assert result.structured_content == {"result": 2.0}
@pytest.mark.anyio
async def test_divide_by_zero():
async with Client(mcp) as client:
result = await client.call_tool("divide", {"a": 1, "b": 0})
assert result.is_error
assert "must not be zero" in result.content[0].text
- The in-memory
Clientneeds no subprocess and no port. It connects with the 2026-07-28 revision. - The
mcppackage installsanyio, which supplies theanyiomarker. Do not addpytest-asyncio.
Step 4: Run the tests until they pass
- Run
uv run pytest. - If a test fails, read the error. Fix the server or the test.
- Run
uv run pytestagain. - Continue only when all tests pass.
Step 5: Configure the client
For VS Code, write .vscode/mcp.json:
{
"servers": {
"demo": {
"type": "stdio",
"command": "uv",
"args": ["--directory", "/absolute/path/to/project", "run", "server.py"]
}
}
}
For Claude Desktop, run uv run mcp install server.py.
Tell the user these commands:
uv run server.pystarts the stdio server. The server waits for a host on stdin and prints nothing.uv run mcp dev server.pyopens the MCP Inspector. The Inspector needs Node.js.
Gotchas
SDK v2 and the 2026-07-28 revision changed many SDK v1 patterns. Do not copy SDK v1 examples.
- SDK v2 removed
FastMCPandmcp.server.fastmcp. Import the server class withfrom mcp.server import MCPServer. - Import
Context,Image,Audio,Resolve,Elicit,ElicitationResult,AcceptedElicitation,Message,UserMessage, andAssistantMessagefrommcp.server.mcpserver. - Give the server name as the first
MCPServerargument. Give all other constructor arguments as keyword arguments. Their positional order changed in SDK v2. - Set
version. If you do not set it, the server reports an empty version. - Give the transport options (
transport,host,port,json_response,stateless_http,transport_security) torun(), not toMCPServer(...). - The SDK v2 types use snake_case fields, for example
read_only_hint,structured_content, andis_error. - Raise
ToolErrorfor an error that the model must read. For other exceptions, the model gets only a generic error message. - Do not raise
MCPErrorfor a tool failure. The client gets a protocol error, not a tool result withis_error. Many hosts do not show this error to the model. - In a stdio server, stdout is the protocol channel. Do not call
print(). Log to stderr with theloggingmodule. - Do not use
ctx.elicit(). It fails on a 2026-07-28 connection. For user input during a tool call, annotate a parameter withResolve(fn). ReturnElicit(message, Model)fromfn. - Send list change notifications with
await ctx.notify_tools_changed(). A 2026-07-28 connection dropsctx.session.send_tool_list_changed(). - For stdio and HTTP, the lifespan runs one time, when the server starts. Each in-memory
Client(mcp)in a test runs the lifespan again. Read its object withctx.request_context.lifespan_context. - The 2026-07-28 revision deprecates these features (SEP-2577). Do not add them to a new server:
- Sampling (
ctx.session.create_message()): Call the LLM provider API directly. - Protocol logging (
ctx.log(),ctx.info(), and similar methods): Use the standardloggingmodule. - Roots (
ctx.session.list_roots()): Get paths from tool parameters, resource URIs, or the server configuration.
- Sampling (
- The 2026-07-28 revision has no SSE transport. Use Streamable HTTP.
FAQ
What does the python-mcp-server-generator skill do?
Use this skill when the user wants to create a new Model Context Protocol (MCP) server in Python. Also use it to expose Python functions, an API, or a database to AI clients as MCP tools. The skill makes a uv project with the MCP Python SDK v2 (MCPServer), typed tools, in-memory tests, and client configuration. Do not use it for an MCP client or for a server in another language.
How do I install python-mcp-server-generator?
Run npx skills add https://github.com/github/awesome-copilot --skill python-mcp-server-generator in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/python-mcp-server-generator/ (personal) or .claude/skills/python-mcp-server-generator/ (project).
Which AI agents can use python-mcp-server-generator?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is python-mcp-server-generator safe to install?
Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk passed; Runlayer flagged items to review; ZeroLeaks passed. As with any skill, read the SKILL.md and bundled scripts before installing.
Who maintains python-mcp-server-generator?
It is published by github in github/awesome-copilot, and it is an official skill from the maker of the technology it covers. It has 10,432 recorded installs.
More from github/awesome-copilot
git-commit
github/awesome-copilot
Use this skill when the user wants to make a Git commit or split changes into more than one commit. Also use it when the user types "/commit" or asks for a conventional commit. The skill examines the diff, stages the related files, writes a Conventional Commits message, and runs git commit. Do not use it when the user wants only a commit message and no commit. Do not use it to push, open a pull request, rebase, or change the commit history.
excalidraw-diagram-generator
github/awesome-copilot
Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.
multi-stage-dockerfile
github/awesome-copilot
Create optimized multi-stage Dockerfiles for any language or framework
documentation-writer
github/awesome-copilot
Diátaxis Documentation Expert. An expert technical writer specializing in creating high-quality software documentation, guided by the principles and structure of the Diátaxis technical documentation authoring framework.
prd
github/awesome-copilot
Generate high-quality Product Requirements Documents (PRDs) for software systems and AI-powered features. Includes executive summaries, user stories, technical specifications, and risk analysis.
refactor
github/awesome-copilot
Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.