Skip to main content
Glama
sh-aidev

MCP Server Template

by sh-aidev
README.md
<div align="center">

# MCP Server Template

[![python](https://img.shields.io/badge/-Python_%7C_3.12-blue?logo=python&logoColor=white)](https://www.python.org/)
[![mcp](https://img.shields.io/badge/MCP_%7C_1.28+-000000?logo=modelcontextprotocol&logoColor=white)](https://modelcontextprotocol.io/)
[![uv](https://img.shields.io/badge/uv_%7C_0.11+-de5fe9?logo=uv&logoColor=white)](https://github.com/astral-sh/uv)
![license](https://img.shields.io/badge/License-MIT-green?logo=mit&logoColor=white)

A minimal MCP (Model Context Protocol) server template managed with [uv](https://github.com/astral-sh/uv), exposing a string-reversal tool and basic two-integer arithmetic tools (`add`, `subtract`, `multiply`, `divide`).

</div>

## šŸ“Œ Feature
- [x] `uv` for dependency management
- [x] TOML + Pydantic based config
- [x] `reverse_string` tool
- [x] `add` / `subtract` / `multiply` / `divide` tools
- [x] Centralized logging (loguru)
- [x] Custom exception handling
- [x] Standalone stdio client for manual testing

## šŸ“ Project Structure
The directory structure of the project looks like this:

```
ā”œā”€ā”€ LICENSE
ā”œā”€ā”€ Makefile
ā”œā”€ā”€ README.md
ā”œā”€ā”€ client.py
ā”œā”€ā”€ main.py
ā”œā”€ā”€ configs
│   └── config.toml
ā”œā”€ā”€ outputs
ā”œā”€ā”€ pyproject.toml
└── src
    ā”œā”€ā”€ __init__.py
    ā”œā”€ā”€ app.py
    ā”œā”€ā”€ server
    │   ā”œā”€ā”€ __init__.py
    │   └── server.py
    └── utils
        ā”œā”€ā”€ __init__.py
        ā”œā”€ā”€ config.py
        ā”œā”€ā”€ exceptions.py
        ā”œā”€ā”€ logger.py
        └── models.py
```

## šŸš€ Getting Started

### Step 1: Install dependencies
```bash
uv sync
```

### Step 2: Run the server
```bash
uv run python main.py
# or
make run
```

The server communicates over stdio and is meant to be launched by an MCP client (see Step 3), not run standalone in a terminal.

### Step 3: Try it with the bundled client
```bash
uv run python client.py
# or
make client
```

This spawns `main.py` as a subprocess over stdio, lists the available tools, then prompts you to try `reverse_string` and the arithmetic tools.

### Step 4 (optional): Inspect it with the MCP Inspector
```bash
uv run mcp dev main.py:mcp
```
Opens a browser UI to browse and call the registered tools interactively. `main.py` exposes a lazily-built `mcp` attribute for this purpose (see `__getattr__` at the bottom of the file) — normal runs via `make run` / `make client` don't trigger it.

## šŸ“œ References
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk)
- [uv](https://github.com/astral-sh/uv)

TDQS

A3.6/5.0

Scored across 5 tools

Disambiguation5/5

Each tool has a clear, distinct purpose: four basic arithmetic operations on integers and one string reversal. There is no overlap in functionality.

Naming Consistency5/5

All tool names are verbs or verb_noun in lowercase with underscores where needed, following a consistent pattern (e.g., add, divide, reverse_string).

Tool Count5/5

With 5 tools, the count is well within the ideal range (3-15) and each tool serves a distinct function.

Completeness3/5

The arithmetic operations are basic but missing common ones like modulo or power. The single string operation feels isolated and incomplete without other string utilities.

Maintenance

ActivityInactive
ResponsivenessNo issues