Index of every page on this site: llms.txt
All skills
github avatar

/python-mcp-server-generator

@f10fdb8 official
by githubgithub/awesome-copilot41k stars
5,399
Run it yourself

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.

Use this Skill: https://skilld.dev/gh/github/awesome-copilot/python-mcp-server-generator

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesstreamable-http.md

≈485 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Streamable HTTP Servers

Use this transport only for a remote server. A local server uses stdio.

Run the server

Replace mcp.run() in server.py:

import os

if __name__ == "__main__":
    mcp.run(
        transport="streamable-http",
        host=os.environ.get("HOST", "127.0.0.1"),
        port=int(os.environ.get("PORT", "8000")),
    )

Clients connect to http://HOST:PORT/mcp. For VS Code, write .vscode/mcp.json:

{
  "servers": {
    "demo": {
      "type": "http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

Mount the server in an ASGI app

  1. Use mcp.streamable_http_app() to mount the server in a Starlette or FastAPI app.
  2. Give the transport options to streamable_http_app(). This method has no port option.
  3. Make the lifespan of the host app enter mcp.session_manager.run().

Gotchas

  • Requests on the 2026-07-28 revision have no session. Any replica can answer a request.
  • stateless_http=True changes only how the server serves clients of earlier revisions.
  • json_response=True sends one JSON body for each request. In this mode, the server cannot send progress notifications during the request.
  • If you do not set transport_security, the SDK checks the Host and Origin headers only when the host is 127.0.0.1, localhost, or ::1. For all other hosts, for example 0.0.0.0 or a public host name, the server does no check. For these hosts, give transport_security=TransportSecuritySettings(allowed_hosts=[...], allowed_origins=[...]) (from mcp.server.transport_security) to run() or streamable_http_app().
  • For browser clients, add CORS to the host app. Allow the Mcp-* request headers. Expose the Mcp-Session-Id response header.
  • For more than one worker, set request_state_security=RequestStateSecurity(keys=[...]) (from mcp.server.mcpserver) on MCPServer. Use the same keys and the same server name on all workers.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning29d5 checks · Risk SAFE
  • Gen Agent Trust Hub29d

    This skill provides instructions and templates for generating Python-based Model Context Protocol (MCP) servers using the official SDK. It uses standard development tools and follows secure practices for configuring server transports and tool definitions.

  • Socket29d

    No alerts

  • Snyk29d

    Risk: LOW · No issues

  • Runlayer8mo

    1/1 file flagged

  • ZeroLeaks7mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at f10fdb8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated last month
Other metadata
compatibility
Requires uv, Python 3.10 or later, and network access to install packages. The MCP Inspector also requires Node.js.
  • Python
  • MCP
  • server
  • fastmcp
  • tools
  • sdk
  • asyncio
  • type-hints
  • pydantic

README badge

README badge for github/awesome-copilot/python-mcp-server-generator

Generates a complete Model Context Protocol (MCP) server in Python with tools, resources, and proper configuration using the FastMCP framework. Targets developers building AI agent integrations that need stdio or HTTP transport, type-safe tool definitions, and proper error handling.

Generated from the current SKILL.md.

What transport types does this skill support?
The skill supports stdio (for local use, tested with MCP Inspector or Claude Desktop) and streamable-http (for remote deployment with optional host/port configuration and stateless mode).
Do I need to use async/await for all tools?
No. The skill recommends async for I/O-bound tasks, but synchronous tools with type hints are valid. Type hints are required for all function parameters and returns.
Can I add resources and prompts, or just tools?
You can add all three. The skill shows how to use @mcp.resource() and @mcp.prompt() decorators alongside @mcp.tool(), with support for URI templates and dynamic resources.
How do I test the generated server?
Use `uv run mcp dev server.py` to run the MCP Inspector, or `python server.py` to start the server directly. For HTTP servers, connect to http://localhost:PORT/mcp. The skill includes installation steps for Claude Desktop.
What Python project structure does this create?
The skill uses `uv init` to scaffold a new project with proper Python structure, adds mcp[cli] as a dependency, and expects a main server.py file with if __name__ == "__main__" for direct execution.

Generated from the current SKILL.md. These answers refresh after source changes.