Skip to main content
Glama

MCP Server

An SDK-first MCP (Model Context Protocol) learning and production-readiness project built in Python with the official MCP SDK.

The goal is to understand MCP deeply while building a practical MCP server that can serve as a real integration-testing target for other AI/agent codebases.

Status

  • Phase 6 — LLM / Agent Integration (current): a provider-agnostic agent (examples/agent.py) that discovers tools, selects them, invokes them, and feeds results back (demoed with a deterministic mock LLM).

  • Phase 5 — MCP Client: an example client (examples/mcp_client.py) that connects over stdio and exercises the full lifecycle (tools, resources, prompts, failures).

  • Phase 4 — Prompts: reusable prompt templates (profile_review, analyze_profiles, server_overview).

  • Phase 3 — Resources: resources exposed by URI — application metadata (mcp://server/info), static config (mcp://server/config), and profile data (data://profiles, data://profile/{user_id}).

  • Phase 2 — Tools: deterministic MCP tools (add, multiply, echo, get_user_profile, fail) alongside the Phase 1 health tool.

  • Phase 1 — Minimal MCP Server: a small, runnable server using the MCPServer abstraction over stdio, with a minimal health capability.

See docs/roadmap.md for the full plan, docs/mcp-basics.md for MCP concepts, docs/tools.md for tools, docs/resources.md for resources, docs/prompts.md for prompts, docs/client.md for the client lifecycle, and docs/agent.md for agent integration.

Related MCP server: hello-mcp

Requirements

  • Python 3.11+

  • uv

Setup

uv sync

This creates a virtual environment and installs the MCP SDK and dev tools (including pytest).

Running the server

uv run mcp-server

The server starts over stdio — the appropriate transport for local development. It stays alive until the connecting client closes the stream. To interact with it you need an MCP client (see the MCP basics doc).

Running the example client

uv run python examples/mcp_client.py

The client launches the server over stdio and demonstrates the full lifecycle: initializing, listing/calling tools, listing/reading resources, listing/getting prompts, and handling failures. See docs/client.md.

Running the example agent

uv run python examples/agent.py

The agent discovers the server's tools, selects them for a user request, invokes them, and feeds the results back — running several tool calls in one session. It is provider-agnostic and ships a deterministic MockLLM, so it runs with no API key. See docs/agent.md.

Running the tests

uv run pytest

Project layout

src/mcp_server/       # MCP server implementation
  server.py           # server construction, health tool, stdio entry point
  tools.py            # deterministic tools (business logic + registration)
  resources.py        # resources exposed by URI (data + registration)
  prompts.py          # reusable prompt templates (messages + registration)
examples/
  mcp_client.py       # example client driving the full lifecycle over stdio
  agent.py            # example agent (discover/select/call tools, mock LLM)
tests/
  unit/               # business-logic unit tests
  integration/        # end-to-end tests (real MCP client over stdio)
docs/                 # roadmap and concept documentation

How a client talks to this server

Application / Host
        ↓
MCP Client
        ↓
MCP Protocol
        ↓
MCP Server
        ↓
Application logic

See docs/mcp-basics.md for a deeper explanation.

Available Tools

6 tools
addA

Add two integers.

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

echoA

Echo the input text back unchanged.

Inputs: text (required). Returns: result

failA

Intentionally fail to demonstrate how tool errors reach the client.

Raises a ToolError so the client receives a clean is_error result carrying this message, instead of an unexpected server crash.

Inputs: no named parameters. Returns: result

get_user_profileA

Return a structured user profile by id.

Raises a ToolError for an unknown id — an anticipated failure the client can read, rather than a crash.

Inputs: user_id (required). Returns: object

healthA

Return basic server health and metadata.

A minimal, deterministic capability used to verify that a client can connect, initialize, and invoke the server successfully.

Inputs: no named parameters. Returns: object

multiplyA

Multiply two integers.

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

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 6 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: health checks connectivity, add and multiply perform arithmetic, echo returns text, get_user_profile fetches a profile, and fail deliberately raises an error. There is no meaningful overlap between any pair of tools.

    Naming Consistency3/5

    Most tools use short, lowercase names like add, multiply, echo, and fail, but health is a noun rather than an action and get_user_profile uses a verb_noun pattern. The naming is readable overall but mixes conventions.

    Tool Count4/5

    Six tools is a reasonable size for a small server, and each tool contributes something distinct. However, the set feels like a grab bag of unrelated utilities rather than a tightly scoped collection.

    Completeness2/5

    There is no coherent domain that the tool set fully covers: the math tools only support add and multiply, and the user profile surface has only a single get operation with no list, create, update, or delete. This makes the overall surface feel incomplete and ad hoc.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A minimal demonstration server showcasing MCP protocol capabilities including tools, resources, and prompts with basic examples like hello world functionality.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A minimal learning-focused MCP server that demonstrates core primitives like tools and resources through simple greeting functions. It provides a foundational example for connecting AI models to external data using both Streamable HTTP and stdio transports.
      -
    • A
      license
      A
      quality
      B
      maintenance
      A minimal MCP server that provides health/status checks and multilingual greetings via the server_info and greet tools.
      2
      165 PyPI
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A minimal MCP server over Streamable HTTP demonstrating the MCP protocol with tools for health checks, echo, and text reversal.
      -