Security-first Python MCP server template

Security-first Python MCP server template

python-mcp-server-template-aj-geddes•byaj-geddes

A template that provides a production-ready Python Model Context Protocol server scaffold with built-in tools, resources, prompts, Docker support, and testing.

License: MIT License•Runtime: Awaiting documentation review•Category: developer tools

WHAT IT DOES

  • •Ships default tools including health check, echo, file listing/reading/writing, and shell command execution.
  • •Exposes a file resource and a code review prompt.
  • •Includes an interactive setup wizard that renames and configures the server for your project.
  • •Supports stdio, HTTP, and SSE transports plus Docker deployment.

BEST FOR

  • •Developers who want to bootstrap a custom MCP server quickly with tools already wired in.
  • •Teams needing a security-focused MCP server base with path validation and command sandboxing.
  • •Projects that need Dockerized, testable MCP server deployment.

ABOUT PYTHON-MCP-SERVER-TEMPLATE-AJ-GEDDES

Security-first Python MCP server template is cataloged as an MCP server attributed to aj-geddes. A template that provides a production-ready Python Model Context Protocol server scaffold with built-in tools, resources, prompts, Docker support, and testing. It is categorized under developer tools. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Security-first Python MCP server template are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

What default tools does the template server include?

It includes health_check, echo, list_files, read_file, write_file, and run_shell_command tools with security controls.

Which transports does the server support?

It supports stdio, HTTP, and SSE transports.

Can I add my own tools?

Yes, tools are added in tools/custom_tools.py, which contains a template for tool implementations.

Upstream README

View this exact version on GitHub

README.md · a8122bcd4074 · Fetched 2026-11-13 13:55:36 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

🚀 Python MCP Server Template

Python FastMCP License Docker Tests Security Production Ready Setup Time

Create production-ready MCP servers in minutes, not hours

Transform this template into your custom MCP server with our interactive setup wizard. Everything is centralized, documented, and ready for production deployment.

A comprehensive, security-first template for building Model Context Protocol (MCP) servers with Python. Get from zero to production in minutes with built-in Docker support, automated testing, and enterprise-grade CI/CD.

⚡ 2-Minute MCP Server Setup

# 1. Clone and enter directory
git clone https://github.com/aj-geddes/python-mcp-server-template.git
cd python-mcp-server-template

# 2. Install dependencies
pip install -r requirements.txt

# 3. Run interactive setup wizard
python quick_setup.py

# 4. Start your custom MCP server!
python mcp_server.py

That's it! 🎉 Your production-ready MCP server is running with:

  • ✅ Custom tools configured
  • ✅ Security scanning enabled
  • ✅ Docker deployment ready
  • ✅ Monitoring and logging active

🎯 Perfect For Building

Use CaseExample ToolsSetup Time
🤖 AI Tool ServersFile processors, calculators, formatters2 minutes
🔌 API IntegrationsDatabase queries, web APIs, cloud services3 minutes
🛠️ Custom AutomationSystem commands, workflows, data pipelines2 minutes
🏢 Enterprise SolutionsSecure, monitored, compliant MCP servers5 minutes

✨ Why Developers Choose This Template

  • ⚡ 2-Minute Setup - Interactive wizard configures everything
  • 🎯 Centralized Config - All settings in config.py, not scattered across files
  • 🛠️ Easy Tool Addition - Add tools in tools/custom_tools.py with examples
  • 🔒 Security Built-In - A+ grade security with automated scanning
  • 📊 Production Ready - Monitoring, logging, Docker, and health checks included

🚀 From Template to Your MCP Server

Interactive Setup

python quick_setup.py

The wizard will ask you:

  • Server name (e.g., "weather-tools-server")
  • Description (what your server does)
  • Your branding (name, email, repository)
  • Tool purpose (what kinds of tools you're building)

Your Files Are Updated

  • config.py - All your settings in one place
  • tools/custom_tools.py - Template for your tool implementations
  • README.md - Updated with your project info

Add Your Tools

# In tools/custom_tools.py
async def my_awesome_tool_impl(param1: str, param2: int) -> Dict[str, Any]:
    # Your tool logic here
    return {"result": f"Processed {param1} with value {param2}"}

Deploy Anywhere

# Local development
python mcp_server.py

# Production with Docker
docker build -t my-mcp-server .
docker run -p 8080:8080 my-mcp-server

🛠️ Development

Code Quality Tools

# Format code
black .
isort .

# Check types
mypy mcp_server/

# Lint code
flake8 mcp_server/

# Security scan
bandit -r mcp_server/

# Run tests
pytest

# Run tests with coverage
pytest --cov=mcp_server --cov-report=html

Available Commands

CommandDescription
pytestRun all tests
pytest -m unitRun unit tests only
pytest -m integrationRun integration tests only
black .Format all Python files
isort .Sort imports
mypy mcp_server/Type checking
flake8 mcp_server/Code linting
bandit -r mcp_server/Security analysis
./build.shBuild and test Docker image

🔧 Configuration

Environment Variables

VariableDefaultDescription
MCP_SERVER_NAME"template-server"Server name identifier
MCP_TRANSPORT"stdio"Transport type (stdio, http, sse)
MCP_HOST"0.0.0.0"Host for HTTP transport
MCP_PORT"8080"Port for HTTP transport
WORKSPACE_PATH"/workspace"Base path for file operations

Security Configuration

⚠️ Important Security Notes:

  • The default host 0.0.0.0 binds to all interfaces. For production, use 127.0.0.1 or a specific IP
  • File operations are restricted to the WORKSPACE_PATH directory
  • Command execution has timeout limits and input validation
  • All file paths are validated to prevent directory traversal attacks

🏗️ Architecture

Core Components

mcp_server/
├── __init__.py          # Main server implementation
├── __main__.py          # Module entry point
└── tools/               # Tool implementations (future)

mcp_server.py            # Application entry point
tests/                   # Comprehensive test suite
docker/                  # Docker configurations
scripts/                 # Build and utility scripts

Available Tools

ToolDescriptionSecurity Features
health_check()Server health statusRead-only operation
echo(message)Echo functionalityInput validation
list_files(directory)Directory listingPath validation
read_file(file_path)File readingSize limits, path validation
write_file(file_path, content)File writingPath validation, encoding checks
run_shell_command(command)Command executionTimeout limits, sandboxing

Available Resources

  • file://{path} - Secure file resource access with path validation

Available Prompts

  • code_review_prompt(code, language, focus) - Structured code review prompting

🐳 Docker Deployment

Build Options

# Standard build
./build.sh

# Build with version tag
./build.sh v1.0.0

# Alternative builds
docker build -f Dockerfile.alternative -t mcp-server-alt .
docker build -f Dockerfile.fixed -t mcp-server-fixed .

Production Deployment

# Run with volume mount
docker run -v /host/workspace:/workspace \
  -e MCP_TRANSPORT=http \
  -e MCP_PORT=8080 \
  -p 8080:8080 \
  python-mcp-server-template:latest

# Run with docker-compose
docker-compose up -d

🧪 Testing

Test Structure

tests/
├── test_mcp_server.py   # Comprehensive server tests
├── test_server.py       # Additional server tests
└── conftest.py          # Test configuration

Test Categories

  • Unit Tests: Individual function testing
  • Integration Tests: End-to-end workflows
  • Security Tests: Path validation and command injection
  • Performance Tests: Timeout and resource limits

Running Tests

# All tests
pytest

# With coverage
pytest --cov=mcp_server --cov-report=html

# Specific test types
pytest -m unit
pytest -m integration
pytest -m "not slow"

# Verbose output
pytest -v

# Stop on first failure
pytest -x

🔒 Security

Security Features

  • Path Validation: Prevents directory traversal attacks
  • Command Sandboxing: Restricted command execution with timeouts
  • File Size Limits: Prevents resource exhaustion
  • Input Validation: Comprehensive input sanitization
  • Environment Configuration: No hardcoded secrets

Security Scanning

# Run security analysis
bandit -r mcp_server/

# Check for known vulnerabilities
safety check

# Generate security report
bandit -r mcp_server/ -f json -o security-report.json

📊 Monitoring & Observability

Health Checks

# Check server health
curl http://localhost:8080/health

# Get server status
python -c "from mcp_server import health_check; import asyncio; print(asyncio.run(health_check()))"

Logging

  • Structured logging with Rich console output
  • Configurable log levels
  • Request/response tracking
  • Error reporting with stack traces

🤝 Contributing

Development Setup

# Install pre-commit hooks
pre-commit install

# Run full quality check
./scripts/quality-check.sh

# Create feature branch
git checkout -b feature/new-tool

Contribution Guidelines

  1. Security First: All code must pass security scans
  2. Test Coverage: Maintain 80%+ test coverage
  3. Code Quality: Pass all linting and type checks
  4. Documentation: Update docs for new features
  5. Backwards Compatibility: Don't break existing APIs

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

📚 Documentation

🌐 Complete Documentation

GuideDescription
🚀 Quick StartGet running in 5 minutes
🔒 Security GuideA+ security features and best practices
🏗️ API ReferenceComplete API documentation
👨‍💻 Development SetupContributing and extending
🐳 Docker GuideProduction Docker deployment

🎓 Quality Assurance

This template has achieved Dr. Alexandra Chen's production standards:

  • 🟢 Final Grade: GOOD (B+) - 78/100
  • 💎 Security Grade: EXCEPTIONAL (A+)
  • ✅ Production Status: APPROVED FOR DEPLOYMENT
  • 🧪 Test Results: 99 passing tests
  • 🔒 Security Scan: SECURE (0 vulnerabilities)

🆘 Support


⭐ Star this repository if it helps you build amazing MCP servers!

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Security-first Python MCP server template from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/python-mcp-server-template-aj-geddes)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related developer tools MCP Servers

Alternative and complementary servers in the same category

View all in developer tools →
Postbye
postbye-mcp•postbye-team

A directory listing describing a cancellation-letter and mailing-address service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools
Singapore Proxy MCP
singapore-proxy-mcp•Xavierfok

A hosted MCP service for browsing and searching through Singapore mobile-network proxies.

0
Developer Tools

A directory listing describing a Markdown-to-PDF service. The configured public GitHub repository returned 404 during source verification.

Repository stats unavailable
Developer Tools