MCP Tool Servers

Role
Primary author
Type
MVP, NDA
Focus
Agent tooling

Model Context Protocol servers that give AI agents tools, resources and prompt templates backed by a REST API. Under NDA, so this covers the architecture only.

Architecture

Selectable transports
stdio, Server-Sent Events or streamable HTTP, chosen by configuration.
Clean architecture
Domain, application, infrastructure and presentation layers wired with a dependency-injection container; tools are thin wrappers over services.
Repository pattern
The backend API sits behind repository interfaces, so tools never talk HTTP directly.
Provider-agnostic channels
Outbound messaging goes through a strategy / factory layer, and each tool can be switched on or off.
Layered auth
API-key verification on the way in, self-refreshing service JWTs on the way out.
Hardening
Sliding-window rate limiting, input validation, a state machine that enforces valid transitions and a non-root container with health checks.
Shared lifespan resources
Clients and repositories are created once at startup and injected into tools through the request context.

Main processing path

  1. AI agentthe model lives here
  2. JSON-RPCstdio or HTTP
  3. auth + tool handlerrate-limited
  4. application servicedependency injection
  5. REST backendbehind repositories

Simplified, with generic component names. Highlighted steps use a model; the rest is software.

Stack

  • Python
  • MCP SDK
  • FastMCP
  • FastAPI
  • Pydantic
  • dependency-injector
  • PyJWT
  • Docker