home / mcp / template mcp server

Template MCP Server

A production-ready template MCP server in Python with FastMCP, showing tool registration, structured logging, and multiple transport protocols for MCP clients.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "redhat-data-and-ai-template-mcp-server": {
      "command": "template-mcp-server",
      "args": [],
      "env": {
        "MCP_HOST": "0.0.0.0",
        "MCP_PORT": "3000",
        "MCP_SSL_KEYFILE": "NONE",
        "MCP_SSL_CERTFILE": "NONE",
        "PYTHON_LOG_LEVEL": "INFO",
        "MCP_TRANSPORT_PROTOCOL": "streamable-http"
      }
    }
  }
}

You have a production-ready MCP server scaffold you can run locally to expose a set of MCP tools, including a simple calculator, a logo resource retriever, and a code-review prompt generator. This server demonstrates how to register tools, handle errors, and support multiple transport protocols so clients can interact with your MCP endpoints in flexible ways.

How to use

You will run the server and connect with an MCP client to call tools or list available tools. The server supports multiple transport protocols (HTTP, SSE, and a streamable HTTP style) and exposes a /health endpoint for status checks. Use an MCP client to request tool definitions, then execute the tools you need; results are returned in a structured JSON format suitable for downstream automation.

How to install

Prerequisites: Install Python 3.12 or higher and a Python package manager. You will also need a tool to run the development server (you can use the provided console script or start it directly with Python or UVICorn).

# Prerequisites
python3 --version
# Ensure you have Python 3.12+ installed

# Optional: install uv for running commands as shown
# Install the package in editable mode with all dependencies
uv pip install -e .

# Prepare environment variables (example)
cp .env.example .env
# Edit .env to customize MCP_HOST, MCP_PORT, and transport settings

# Start the server using the console script
template-mcp-server

# Or start directly with Python
python -m template_mcp_server.src.main

# Or use uv to run directly
uv run python -m template_mcp_server.src.main

Additional sections

Configuration and tooling details are provided to help you tailor the server to your environment. The server reads its settings from environment variables and uses a structured logging system to produce JSON logs that include timestamps and context. SSL can be enabled by providing key and certificate files.

You can verify the installation and basic operation by checking the health endpoint and invoking a sample tool call through the MCP endpoint. Use the included tests and development tooling to extend or customize the server for your needs.

Development workflow includes unit tests, integration tests, and code quality checks to ensure reliability as you add new tools or resources. Follow the standard practice of validating configurations, running tests, and performing linting and type checks before merging changes.

Available tools

multiply_numbers

Demonstrates basic arithmetic operations with input validation and error handling.

redhat_logo

Reads a static image asset and returns its content base64-encoded for transmission.

code_review_prompt

Generates formatted prompts for code review tasks across multiple languages.