Dockerized MCP Server Template

by zantis

5 stars
231 downloads
Not rated
GitHub

About

A reusable Dockerized Python server template implementing the Model Context Protocol (MCP) with Streamable HTTP transport, built using the official MCP Python SDK (v1.8.0+) for easy integration with Large Language Models (LLMs).

Details

Author
zantis
GitHub stars
5
Downloads
231
Categories
Developer Tools

- Dockerized for easy deployment and portability
- Uses Streamable HTTP for stateless, real-time communication
- Built on the Python Model Context Protocol SDK (v1.8.0+)
- Compatible with serverless architectures and standard web infrastructure
- Includes an example add tool to demonstrate functionality
- Eliminates persistent connections for better resource efficiency

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Dockerized MCP Server Template
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Build and run with Docker Compose using docker-compose up --build, or run directly with Python after installing dependencies (pip install -r src/requirements.txt) by executing python src/server.py. The server becomes accessible at http://localhost:8080/mcp.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "dockerized mcp server template": {
            "dockerized-mcp-server-template": {
                "command": "python",
                "args": [
                    "src/server.py"
                ]
            }
        }
    }
}

McpServers

{
    "dockerized-mcp-server-template": {
        "command": "python",
        "args": [
            "src/server.py"
        ]
    }
}

Dockerized MCP Server Template

This repository provides a reusable template for a Python server implementing the Model Context Protocol (MCP), running in a Docker container and utilizing Streamable HTTP for real-time communication. Built on the Python implementation of the Model Context Protocol (MCP), this template enables easy integration with Large Language Models (LLMs).

What is MCP?

The Model Context Protocol (MCP) lets you build servers that expose data and functionality to LLM applications in a secure, standardized way.

This template demonstrates a production-ready MCP server running in a Docker container, utilizing stateless Streamable HTTP for real-time communication.

Project Structure

dockerized-mcp-server-template/
├── src/
│   ├── Dockerfile
│   ├── requirements.txt
│   └── server.py
├── docker-compose.yml
└── README.md

Getting Started

Build and Run with Docker Compose

docker-compose up --build

The server will be accessible at:

http://localhost:8080/mcp

Running Directly (without Docker)

Alternatively, you can run the server directly using Python. First, install dependencies:

pip install -r src/requirements.txt

Then run the server:

python src/server.py

The server will be accessible at:

http://localhost:8080/mcp

Example Usage

The example includes a simple MCP tool function add:

@mcp.tool()
def add(a: int, b: int) -> int:
    """Add two numbers"""
    return a + b

You can invoke this tool via MCP client requests.

Technical Notes

This template uses Streamable HTTP transport, which is available in the Model Context Protocol starting with the Python SDK v1.8.0 (https://github.com/modelcontextprotocol/python-sdk).

Why Streamable HTTP?

Streamable HTTP significantly improves upon the previous SSE transport by enabling stateless operation, making MCP compatible with serverless architectures and standard web infrastructure. This approach eliminates the need for persistent connections, resulting in better resource efficiency and cost effectiveness, while offering a more straightforward implementation for developers. The result is an MCP server that's easier to deploy, more scalable, and more resource-efficient without sacrificing functionality.

Resources

- MCP Documentation
- MCP Specification
- Python SDK

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.