Get the FREE Ultimate OpenClaw Setup Guide →

mcp -template

This template provides a streamlined foundation for building Model Context Protocol (MCP) servers in Python. It's designed to make AI-assisted development of MCP tools easier and more efficient.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio ntk148v-mcp-server-template python -m module_name \
  --env MODULE_NAME="your_module_name (replace with the generated module name)"

How to use

This MCP server is a Python-based template that uses the FastMCP framework to expose Tools, Resources, and Prompts which an LLM can leverage to perform actions, fetch data, and template conversations. After generating a project from this cookiecutter, you will have a ready-to-run server that can be started in development mode. The template organizes code under src/<your_module>/server with subpackages for tools, resources, and prompts. The server is designed to be run via Python (for development) and can be extended by implementing new tools, resources, and prompts in their respective directories. Use the provided Makefile targets to run and test the server locally, or containerize it for deployment with Docker.

How to install

Prerequisites:

  • Python 3.12
  • Cookiecutter
  • (Optional) Make and Docker if you plan to use make targets or containerization

Installation steps:

  1. Install dependencies and cookiecutter
    • On Unix-like systems:
      • python3 -m pip install --upgrade pip
      • python3 -m pip install cookiecutter
  2. Generate a new project from the template
    • Using GitHub: cookiecutter gh:ntk148v/mcp-server-template
    • Or from a local copy: cookiecutter path/to/mcp-server-template
  3. Navigate to the generated project directory and install project dependencies
    • If using Poetry (recommended for Python projects in templates): poetry install
    • Or install via pip if a pyproject.toml defines setup.cfg / dependencies: pip install -e .
  4. Run the server in development mode
    • From the project root: make dev
  5. (Optional) Run with Docker
    • Build and run the container per the project’s Dockerfile and docker-compose if available

Notes:

  • The template follows a standard MCP server structure with main.py configuration and a FastMCP-based server under src/<module>/server.
  • Replace placeholder module names with your actual package/module name when generated.
  • If you prefer manual execution, you can run the server with Python using the module path specified in mcp_config.

Additional notes

Tips and common issues:

  • Ensure you are using Python 3.12 as required by the template.
  • When generated, update the module_name in the config to match your actual module/package name.
  • The Makefile provides targets such as dev for quick testing and install for deploying to Claude Desktop or similar environments. Use make dev during development to watch for live changes.
  • Docker support is available for containerized deployment; ensure Docker is installed and the project’s Dockerfile is used as the basis for builds.
  • If you extend tools/resources/prompts, follow the existing package structure under src/<module>/server and corresponding subpackages.
  • If environment variables are needed by tools or resources, define them in the mcp_config env section or via a dedicated .env file as appropriate for your deployment.

Related MCP Servers

Sponsor this space

Reach thousands of developers