MCP Tool Servers
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
- AI agentthe model lives here
- JSON-RPCstdio or HTTP
- auth + tool handlerrate-limited
- application servicedependency injection
- REST backendbehind repositories
Simplified, with generic component names. Highlighted steps use a model; the rest is software.