Skip to main content
Glama
MCP Tool Server

MCP Tool Server

by nuvolalabs

MCP Tool Server

A Model Context Protocol (MCP) server implemented from scratch over stdio using JSON-RPC 2.0 — plus a tiny client to drive it. No SDK, no dependencies: ~350 lines that show exactly how MCP handshakes and tool calls work on the wire.

Why MCP

MCP is the emerging standard for connecting LLM agents to external tools and data. This repo demonstrates the protocol mechanics — initialize, notifications/initialized, tools/list, tools/call, ping — so an agent (Claude, Copilot, custom) can discover and invoke tools over a pipe.

Related MCP server: MCP Boilerplate

Architecture

  MCP client  ──JSON-RPC over stdio──▶  mcp_server
  (client.py)      newline-delimited      ├── protocol.py  (errors, envelopes)
                   {jsonrpc,id,method}    ├── server.py    (dispatch + stdio loop)
                                          └── tools.py     (echo, add, sqrt, now_utc)

Quickstart

# run the demo client against a live server subprocess
PYTHONPATH=src python3 client.py

# run the server directly (speak JSON-RPC on stdin)
PYTHONPATH=src python3 -m mcp_server

# tests (in-process dispatch + a real spawned-subprocess handshake)
python3 tests/test_mcp_server.py

Protocol coverage

Method

Behaviour

initialize

Negotiates protocol version, returns capabilities + serverInfo

notifications/initialized

Marked initialized; no response (correct notification semantics)

tools/list

Returns each tool's name, description, inputSchema

tools/call

Runs the handler; tool errors return in-band (isError: true)

ping

Liveness check

Malformed JSON → -32700 parse error; unknown method → -32601; bad params → -32602. Notifications never get a reply, as the spec requires.

Design notes

  • Handler errors never kill the server — they're converted to JSON-RPC errors or in-band tool results, so one bad call can't take the transport down.

  • Injectable streams (serve(lines=..., stdout=...)) make the stdio loop unit-testable without spawning processes; a separate test does the real spawn.

  • Tool schemas are JSON Schema, matching MCP's inputSchema contract.

Skills demonstrated

Model Context Protocol (MCP) · JSON-RPC 2.0 · stdio transport · tool schemas · protocol error handling · subprocess integration testing · Python packaging

License

MIT

Available Tools

4 tools
addC

Add two numbers.

Inputs: a (required), b (required).

echoC

Echo back a message.

Inputs: message (required).

now_utcC

Current UTC time.

Inputs: format.

sqrtA

Square root of a non-negative number.

Inputs: number (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct operation: echoing, addition, square root, and current UTC time. There is no realistic overlap or ambiguity between them.

    Naming Consistency4/5

    All names are short, lowercase, and readable, with only now_utc using an underscore. The set is mostly consistent, though it does not follow a single verb_noun convention.

    Tool Count5/5

    Four tools is a reasonable size for a small utility server, and each tool covers a distinct basic operation. None feels redundant or out of place.

    Completeness3/5

    The surface is usable but thin: math support only includes add and sqrt, missing subtract/multiply/divide, and time support only exposes current UTC time. These are notable gaps for a general utility toolset.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      Not graded
      maintenance
      A minimal Node.js Model Context Protocol server that exposes two simple tools ('add' and 'getTime') that can be called from AI assistants like Claude Desktop or Cursor.
      2
      118 npm
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A minimal, production-ready MCP server with a simple addition calculator tool that demonstrates integration with the Model Context Protocol.
      10 npm
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A Python-based demonstration server showcasing multiple Model Context Protocol transport mechanisms, including stdio, SSE, and HTTP. It provides a functional reference for tool discovery and execution using a sample number addition tool.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A model-agnostic MCP server exposing example tools (add1, multiply2, greet) for learning purposes, working with any LLM through stdio transport.
      -