Skip to main content
Glama
MCP Utility Tool Server

MCP Utility Tool Server

by Aryanch1
README.md
# MCP Utility Tool Server

A small, working [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server written in Python, built on the official MCP Python SDK. It exposes ten everyday utility tools — text statistics, slugify, Base64, SHA-256, UUIDs, password strength, JSON formatting, and timestamp conversion — that any MCP client can call. Every tool is deterministic and runs fully offline.

**Author:** Aryanmouli Cherupalli · **License:** MIT

## What is MCP, in plain words?

MCP (Model Context Protocol) is a standard way for AI applications to use outside tools. Instead of every app inventing its own plugin format, an MCP *server* offers a list of tools with clear names, inputs, and outputs, and any MCP *client* (for example Claude Desktop or Claude Code) can discover and call them. The client and server talk in JSON-RPC messages; this server uses the stdio transport, meaning the client starts the server as a subprocess and talks to it over standard input and output. This project is a complete, minimal example of that pattern: one server file, ten tools, a client test, and unit tests.

## Tools

| Tool | Input | Output |
| --- | --- | --- |
| `text_stats` | `text` (string) | Character, word, sentence, paragraph, and line counts, average word length, and estimated reading time at 200 words per minute |
| `word_frequency` | `text` (string), `top_n` (int, default 10) | The most common words, lowercased, most frequent first (ties broken alphabetically) |
| `slugify` | `text` (string) | A URL slug: lowercase ASCII words joined by hyphens |
| `base64_encode` | `text` (string) | The Base64 encoding of the text (UTF-8) |
| `base64_decode` | `data` (string) | The decoded text; a clear error on invalid Base64 or non-UTF-8 bytes |
| `sha256_hash` | `text` (string) | The SHA-256 digest as lowercase hex |
| `uuid_generate` | `count` (int, default 1, max 100) | That many random UUID4 values |
| `password_strength` | `password` (string) | A score from 0 to 100, a rating (very weak to strong), and plain-language reasons for every point gained or lost |
| `json_pretty` | `text` (string), `indent` (int, default 2) | `valid: true` with the formatted JSON, or `valid: false` with the exact parse error and its line and column |
| `timestamp_convert` | `value` (string) | Both Unix seconds and ISO 8601 UTC for a Unix timestamp (seconds, or milliseconds when the value is 10^12 or larger) or an ISO 8601 string |

## How to run

```bash
python -m venv .venv
source .venv/bin/activate        # on Windows: .venv\Scripts\activate
pip install -r requirements.txt
python server.py
```

The server speaks MCP over stdio, so running it directly looks quiet: it waits for a client to connect. Use the client test below to see it work end to end.

## How to connect a client

Any MCP client connects the same way: it needs the command that starts the server. For Claude Desktop or Claude Code style configuration, add this to the client's MCP settings file (a ready-to-copy copy lives in `claude_desktop_config.example.json`):

```json
{
  "mcpServers": {
    "utility-tools": {
      "command": "python",
      "args": ["/absolute/path/to/mcp-server/server.py"]
    }
  }
}
```

Replace the path with the real absolute path to `server.py` on your machine, and if you use a virtual environment, point `command` at that environment's Python (for example `/absolute/path/to/mcp-server/.venv/bin/python`). Restart the client, and the ten tools appear in its tool list.

## Client test

`client_test.py` spawns the server as a subprocess, connects with the official SDK client, lists the tools, and calls six of them:

```bash
python client_test.py
```

Real output from an actual run:

```text
Server exposes 10 tools:
  - text_stats
  - word_frequency
  - slugify
  - base64_encode
  - base64_decode
  - sha256_hash
  - uuid_generate
  - password_strength
  - json_pretty
  - timestamp_convert

CALL text_stats({'text': 'The quick brown fox jumps over the lazy dog. The dog was not amused!'})
  {
    "characters": 68,
    "characters_no_spaces": 55,
    "words": 14,
    "sentences": 2,
    "paragraphs": 1,
    "lines": 1,
    "average_word_length": 3.79,
    "reading_time_minutes": 0.07,
    "reading_time_seconds": 4
  }

CALL slugify({'text': 'Hello, World! This is my First Blog Post'})
  hello-world-this-is-my-first-blog-post

CALL base64_encode({'text': 'Model Context Protocol'})
  TW9kZWwgQ29udGV4dCBQcm90b2NvbA==

CALL sha256_hash({'text': 'hello'})
  {
    "algorithm": "SHA-256",
    "hex_digest": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
  }

CALL password_strength({'password': 'Tr0ub4dor&3'})
  {
    "score": 80,
    "rating": "strong",
    "reasons": [
      "Length is 8 to 11 characters (+20)",
      "Uses 4 character types: lowercase letters, uppercase letters, digits, symbols (+60)"
    ]
  }

CALL timestamp_convert({'value': '1767225600'})
  {
    "unix_seconds": 1767225600,
    "iso_utc": "2026-01-01T00:00:00Z"
  }
```

## Tests

The tool logic lives in `tools.py` as plain functions, separate from the protocol layer, so it can be unit tested directly:

```bash
python -m pytest tests/ -q
```

All 32 tests pass, covering known-value hashes, Base64 round trips (including Unicode), slug edge cases, password scoring rules, JSON error reporting, and timestamp conversions in both directions.

## Project structure

```text
mcp-server/
├── server.py                            # MCP server: registers the tools, stdio transport
├── tools.py                             # Pure tool logic (no protocol code, fully testable)
├── client_test.py                       # End-to-end client: spawns the server, lists and calls tools
├── tests/
│   └── test_tools.py                    # pytest unit tests for tools.py
├── claude_desktop_config.example.json   # Example client configuration (mcpServers JSON)
├── requirements.txt                     # mcp (official SDK) and pytest
├── LICENSE                              # MIT
└── README.md
```

## Notes

- The server uses the official `mcp` Python SDK (version 2.x, `MCPServer` API). No protocol code is hand-rolled.
- Tools never touch the network, the filesystem, or the clock, so results are reproducible; `uuid_generate` is the one exception by design, since UUID4 values are random.
- `password_strength` is a transparent heuristic for education and quick checks, not a substitute for a dedicated password strength library or a security audit.