python-mcp-server-generator
github/awesome-copilot
Generate a complete, production-ready MCP server in Python with tools, resources, and proper configuration.
What is python-mcp-server-generator?
This skill scaffolds a full Model Context Protocol (MCP) server project in Python using uv, with built-in support for tools, resources, prompts, and multiple transport types. Use it when you need to create a new MCP server that integrates with Claude or other MCP clients.
- Initializes a Python project structure with uv and MCP SDK dependencies
- Generates server configuration with choice of stdio or HTTP transport
- Creates decorated tool functions with automatic schema generation from type hints
- Implements error handling, validation, and async/await support
- Optionally adds resources and prompts with URI templates and dynamic content
- Provides testing and installation guidance for Claude Desktop and MCP Inspector
How to install python-mcp-server-generator
npx skills add https://github.com/github/awesome-copilot --skill python-mcp-server-generator- Node.js and npm (to run npx skills add)
- Python 3.8 or later
- uv package manager installed
How to use python-mcp-server-generator
- 1.Run npx skills add to install the skill
- 2.Choose your transport type (stdio for local, HTTP for remote)
- 3.Define your tool functions with type hints and docstrings
- 4.Optionally add resources or prompts using decorators
- 5.Test locally with uv run mcp dev server.py
- 6.Install to Claude Desktop with uv run mcp install server.py
Use cases
- Building a custom MCP server that exposes file system operations or data processing tools to Claude
- Creating an HTTP-based MCP server for remote access with stateless scaling
- Integrating external APIs or databases as MCP tools with proper type safety
- Generating a local stdio server for testing MCP functionality before deployment
- Setting up a production-ready server with comprehensive error handling and logging
- Python developers building MCP integrations
- AI engineers creating custom tools for Claude or other MCP clients
- Backend developers exposing internal APIs as MCP servers
- Teams standardizing on MCP for agent-based workflows
python-mcp-server-generator FAQ
stdio is for local execution (simpler, direct) while HTTP is for remote servers with optional stateless mode for scalability. Choose stdio for testing and local use, HTTP for production deployments.
No. Type hints on your tool functions automatically generate schemas. Just use proper Python type annotations and the MCP SDK handles schema generation.
Yes. The skill supports async/await for I/O-bound operations. Use async functions with the @mcp.tool() decorator for better performance.
Run uv run mcp dev server.py to start the MCP Inspector, which lets you test tools and resources interactively before installation.
Return structured data when possible using Pydantic models or TypedDicts. For simple cases, return strings or basic types. Avoid writing to stdout; use stderr or Context logging instead.
Full instructions (SKILL.md)
Source of truth, from github/awesome-copilot.
name: python-mcp-server-generator description: 'Generate a complete MCP server project in Python with tools, resources, and proper configuration'
Generate Python MCP Server
Create a complete Model Context Protocol (MCP) server in Python with the following specifications:
Requirements
- Project Structure: Create a new Python project with proper structure using uv
- Dependencies: Include mcp[cli] package with uv
- Transport Type: Choose between stdio (for local) or streamable-http (for remote)
- Tools: Create at least one useful tool with proper type hints
- Error Handling: Include comprehensive error handling and validation
Implementation Details
Project Setup
- Initialize with
uv init project-name - Add MCP SDK:
uv add "mcp[cli]" - Create main server file (e.g.,
server.py) - Add
.gitignorefor Python projects - Configure for direct execution with
if __name__ == "__main__"
Server Configuration
- Use
FastMCPclass frommcp.server.fastmcp - Set server name and optional instructions
- Choose transport: stdio (default) or streamable-http
- For HTTP: optionally configure host, port, and stateless mode
Tool Implementation
- Use
@mcp.tool()decorator on functions - Always include type hints - they generate schemas automatically
- Write clear docstrings - they become tool descriptions
- Use Pydantic models or TypedDicts for structured outputs
- Support async operations for I/O-bound tasks
- Include proper error handling
Resource/Prompt Setup (Optional)
- Add resources with
@mcp.resource()decorator - Use URI templates for dynamic resources:
"resource://{param}" - Add prompts with
@mcp.prompt()decorator - Return strings or Message lists from prompts
Code Quality
- Use type hints for all function parameters and returns
- Write docstrings for tools, resources, and prompts
- Follow PEP 8 style guidelines
- Use async/await for asynchronous operations
- Implement context managers for resource cleanup
- Add inline comments for complex logic
Example Tool Types to Consider
- Data processing and transformation
- File system operations (read, analyze, search)
- External API integrations
- Database queries
- Text analysis or generation (with sampling)
- System information retrieval
- Math or scientific calculations
Configuration Options
-
For stdio Servers:
- Simple direct execution
- Test with
uv run mcp dev server.py - Install to Claude:
uv run mcp install server.py
-
For HTTP Servers:
- Port configuration via environment variables
- Stateless mode for scalability:
stateless_http=True - JSON response mode:
json_response=True - CORS configuration for browser clients
- Mounting to existing ASGI servers (Starlette/FastAPI)
Testing Guidance
- Explain how to run the server:
- stdio:
python server.pyoruv run server.py - HTTP:
python server.pythen connect tohttp://localhost:PORT/mcp
- stdio:
- Test with MCP Inspector:
uv run mcp dev server.py - Install to Claude Desktop:
uv run mcp install server.py - Include example tool invocations
- Add troubleshooting tips
Additional Features to Consider
- Context usage for logging, progress, and notifications
- LLM sampling for AI-powered tools
- User input elicitation for interactive workflows
- Lifespan management for shared resources (databases, connections)
- Structured output with Pydantic models
- Icons for UI display
- Image handling with Image class
- Completion support for better UX
Best Practices
- Use type hints everywhere - they're not optional
- Return structured data when possible
- Log to stderr (or use Context logging) to avoid stdout pollution
- Clean up resources properly
- Validate inputs early
- Provide clear error messages
- Test tools independently before LLM integration
Generate a complete, production-ready MCP server with type safety, proper error handling, and comprehensive documentation.
Related skills
More from github/awesome-copilot and the wider catalog.
git-commit
Execute semantic git commits with conventional message analysis and intelligent staging.
excalidraw-diagram-generator
Generate Excalidraw diagrams from natural language descriptions.
documentation-writer
Create structured technical documentation using the Diátaxis framework for tutorials, how-to guides, references, and explanations.
gh-cli
GitHub CLI comprehensive reference for repositories, issues, PRs, Actions, projects, releases, and all GitHub operations from the command line.
prd
Generate comprehensive Product Requirements Documents with executive summaries, user stories, technical specs, and risk analysis.
refactor
Surgical code refactoring to improve maintainability without changing behavior.