VOOZH about

URL: https://deepwiki.com/Digilac/simap-mcp/3-architecture

⇱ Architecture | Digilac/simap-mcp | DeepWiki


Loading...
Menu

Architecture

This document provides a comprehensive overview of the simap-mcp system architecture, explaining how the server is structured to bridge AI assistants with the SIMAP.ch public procurement platform. It covers the layered design, communication patterns, and key architectural decisions.

For detailed information on specific aspects:

  • System Overview — High-level architecture: MCP server, stdio transport, and data flow from client to SIMAP API.
  • Tool Architecture — Structure, registration, and categorization of the 14 available tools.
  • API Integration LayerSimapClient implementation, endpoint management, and HTTP communication patterns.
  • Type System and Utilities — Type definitions, Zod validation, translation fallbacks, and Markdown helpers.

System Context

The simap-mcp server operates as a stdio-based MCP server that acts as a bridge between AI assistants (primarily Claude) and the SIMAP.ch public procurement API. The server runs as a child process of the MCP client, communicating via JSON-RPC over standard input/output streams.

System Context and Process Boundary


Sources: src/index.ts10-15 src/server.ts5-35 ARCHITECTURE.md3-17

Key Architectural Characteristics:

AspectDesign DecisionRationale
TransportStdioServerTransportStandard MCP protocol, no network configuration needed. src/server.ts32-33
CommunicationSynchronous request/responseSimplifies implementation, matches API query pattern.
AuthenticationNoneSIMAP.ch API is public, no auth required.
Data OperationsRead-only queriesServer only retrieves data, never modifies.
State ManagementStatelessEach request is independent, no session management.
Rate LimitingSlidingWindowRateLimiterProtects upstream API with FIFO-ordered queueing. src/api/rate-limiter.ts43
Language SupportMultilingual (de/fr/it/en)Swiss context requires all four national languages. CLAUDE.md81

Sources: src/server.ts28-35 ARCHITECTURE.md89-107 CLAUDE.md77-81

Layered Architecture

The codebase follows a strict three-layer architecture with unidirectional dependencies: ToolsAPI ClientExternal SIMAP API. Support layers (types, utils) are used orthogonally across all layers.

Architectural Layers and Code Entities


Sources: ARCHITECTURE.md19-68 src/server.ts22 CLAUDE.md33-70

Layer Responsibilities

Presentation Layer (Tools)

API Integration Layer

Support Layers

  • Types: Centralized definitions for API responses (api.ts), tool parameters (tools.ts), and common interfaces (common.ts). CLAUDE.md59-64
  • Utils: Logic for i18n translation fallbacks (translation.ts), Markdown formatting helpers (formatting.ts), and standardized error mapping via toToolErrorResult(). CLAUDE.md65-69 CLAUDE.md78
  • For details, see Type System and Utilities.

Request Flow and Data Transformation

Every MCP tool invocation follows a consistent pipeline from user input to formatted output.

MCP Tool Request Lifecycle


Sources: src/server.ts16-25 ARCHITECTURE.md72-107 CLAUDE.md74-81

Design Patterns

Tool Registration Pattern

The server uses a decentralized registration pattern. Each tool file exports an *InputShape (raw Zod shape), an *InputSchema (z.object(shape)), and a register* function. These are aggregated in src/tools/index.ts and called during server initialization in src/server.ts. ARCHITECTURE.md72-83 CLAUDE.md76


Sources: ARCHITECTURE.md72-83 src/server.ts22 CLAUDE.md76

Multilingual Fallback

Translation logic implements a fallback chain to ensure data availability in the Swiss context: Requested Language → defrenit. CLAUDE.md81 ARCHITECTURE.md93-95

Sources: CLAUDE.md81 ARCHITECTURE.md95 src/utils/translation.ts1-20

Error Mapping Pattern

Tool handlers route caught errors through toToolErrorResult() (src/utils/errors.ts) which transforms technical exceptions (like 404s, timeouts, or network failures) into human-readable messages for the AI. CLAUDE.md78 ARCHITECTURE.md97-107

Sources: CLAUDE.md78 ARCHITECTURE.md99-107 src/utils/errors.ts5-40