Skip to main content
Glama
VladimirBigunenko

mcp-utility-server

README.md
# MCP Utility Server

A production-grade [Model Context Protocol](https://modelcontextprotocol.io) server with **10 utility tools** for daily operations. Built with FastMCP, stdlib-first, fully tested (TDD).

**Why this server:** it demonstrates real MCP engineering — not a hello-world. It includes:
- **Retry/backoff with jitter** on all external HTTP calls (429/5xx handling)
- **State persistence** for page monitoring (SHA-256 diff tracking)
- **Observability** — per-tool retry counters exposed as an MCP tool
- **Sandboxing** for file operations (optional `FILE_SANDBOX`)
- **Deterministic outputs** (word-of-day selection is hash-based, same all day)
- **~30 pytest tests** with mocked network (no external deps in CI)

## Tools

| Tool | Description |
|------|-------------|
| `file_convert` | Convert MD/HTML/CSV/JSON/Text formats (stdlib-only) |
| `page_monitor` | Poll a URL, SHA-256 diff, optional Telegram notify on change |
| `telegram_poll` | Send Telegram polls (2-10 options) |
| `trade_signal` | Binance OHLCV → RSI(14) + SMA20/SMA50 cross → BUY/SELL/HOLD |
| `backtest_report` | Parse Freqtrade backtest JSON → markdown digest |
| `word_of_day` | German word (A1/A2) with translations, IPA, examples — deterministic per date |
| `soc_lang_card` | Daily language card: German word + SOC term (EN/DE/RU) |
| `weather_alert` | Open-Meteo threshold alerts (wind/rain) for configured cities |
| `antimatter_scan` | Scan trading logs for trades/errors/signals + resonance score |
| `mcp_stats` | Retry/backoff observability snapshot |

## Quick start

```bash
# Install
uv sync

# Run (stdio transport — default for MCP clients)
uv run server.py

# Run (SSE transport — for remote clients)
uv run server.py --transport sse

# Test
uv run pytest
```

## Configuration (env vars)

| Env | Default | Purpose |
|-----|---------|---------|
| `TELEGRAM_BOT_TOKEN` | — | Required for `telegram_poll` / page_monitor notify |
| `TELEGRAM_CHAT_ID` | — | Default chat for Telegram tools |
| `FILE_SANDBOX` | unset (allow-all) | Restrict `file_convert` to a directory. **Set on production!** |
| `STATE_DIR` | `~/.mcp-utility/state` | Page-monitor state location |
| `HTTP_MAX_RETRIES` | `2` | Max retries on 429/5xx (1 initial + N retries) |
| `HTTP_RETRY_DELAY` | `1.0` | Base backoff seconds (exponential, ±20% jitter) |
| `MCP_STATS_PATH` | `/tmp/mcp_utility_stats.json` | Retry stats persistence |
| `MCP_LOG` | `INFO` | Logging level |
| `MCP_TRANSPORT` | `stdio` | `stdio` or `sse` |

## Example: Claude Desktop

```json
{
  "mcpServers": {
    "mcp-utility": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/mcp-utility-server", "server.py"]
    }
  }
}
```

## Example: trade signal

```bash
echo '{"symbol":"BTCUSDT","interval":"1d"}' | uv run server.py
# → {"status":"ok","symbol":"BTCUSDT","rsi":42.3,"ma_fast":42100.0,
#    "ma_slow":41800.5,"signal":"BUY","reasons":["MA20 > MA50"],...}
```

## Security notes

- `file_convert` accepts **any path** when `FILE_SANDBOX` is unset — always set it in production
- Telegram token is read from env only, never logged
- `antimatter_scan("docker:...")` executes `docker logs` — requires docker socket access

## License

MIT

TDQS

B3.4/5.0

Scored across 10 tools

Disambiguation4/5

Most tools target clearly distinct functions such as file conversion, Telegram polls, trading signals, weather alerts, and log scanning. The main ambiguity is between word_of_day and soc_lang_card, since both serve daily German A1/A2 content and soc_lang_card largely supersedes word_of_day.

Naming Consistency3/5

All names use lowercase snake_case, but the pattern is inconsistent: some are noun_action (file_convert, page_monitor), while others are noun_noun or phrase-like (mcp_stats, soc_lang_card, word_of_day). The names are readable but not highly predictable.

Tool Count4/5

Ten tools is a reasonable count for a general utility server and none are clearly redundant. However, the server has no unified scope—monitoring, trading, language learning, weather, and observability are all mixed together—so the count fits numerically but the scope is broad.

Completeness3/5

Individual utilities are mostly self-contained, but there are notable gaps: page_monitor lacks monitor management, weather_alert has no city configuration, and the trading/log tools are one-shot analyzers without related operations. Because the server's domain is generic 'utilities,' completeness is hard to establish.

Maintenance

ActivityMaintained
ResponsivenessNo issues