VOOZH about

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

⇱ Tool Architecture | Digilac/simap-mcp | DeepWiki


Loading...
Menu

Tool Architecture

This document explains the structure, organization, and registration of the 14 MCP tools exposed by the simap-mcp server. It covers tool categorization by domain, the registration pattern, and the anatomy of individual tool implementations using the McpServer SDK.

Tool Inventory

The simap-mcp server exposes 14 tools organized into three functional domains.

DomainTool NameDescriptionRegistration Function
Core Tenderssearch_tendersSearch tenders with filtersregisterSearchTenders
get_tender_detailsGet full details of a tenderregisterGetTenderDetails
Nomenclature Codessearch_cpv_codesSearch CPV codes (EU procurement vocabulary)registerSearchCpvCodes
browse_cpv_treeNavigate CPV code hierarchyregisterBrowseCpvTree
search_bkp_codesSearch BKP codes (construction)registerSearchBkpCodes
browse_bkp_treeNavigate BKP code hierarchyregisterBrowseBkpTree
search_npk_codesSearch NPK codes (standardized positions)registerSearchNpkCodes
browse_npk_treeNavigate NPK code hierarchyregisterBrowseNpkTree
search_oag_codesSearch OAG codes (object types)registerSearchOagCodes
browse_oag_treeNavigate OAG code hierarchyregisterBrowseOagTree
list_cantonsList all Swiss cantonsregisterListCantons
Organizationslist_institutionsList public institutionsregisterListInstitutions
search_proc_officesSearch procurement officesregisterSearchProcOffices
get_publication_historyGet publication history for a projectregisterGetPublicationHistory

Sources: src/tools/index.ts7-10 src/tools/index.ts17-24 CLAUDE.md7-8

Domain Organization

Registration Hierarchy

The server uses a hierarchical registration pattern where the root registerTools function delegates to domain-specific registration functions.

Title: Tool Registration Hierarchy


Sources: src/tools/index.ts15-25 src/tools/index.ts7-10 src/tools/codes/index.ts19-32 src/tools/organizations/index.ts13-20

Domain Categories

Core Tender Tools

Located directly in src/tools/, these provide the primary workflow for discovering and viewing procurement opportunities:

  • search_tenders: Entry point for tender discovery with extensive filtering. src/tools/index.ts17
  • get_tender_details: Deep-dive into specific tender details, including support for fullRaw output for LLM analysis. src/tools/index.ts18

Nomenclature Code Tools (src/tools/codes/)

Nine tools organized around Swiss classification systems. These are registered via registerCodeTools in src/tools/codes/index.ts.

Organization Tools (src/tools/organizations/)

Three tools for working with contracting entities, registered via registerOrganizationTools in src/tools/organizations/index.ts.

Sources: src/tools/index.ts7-10 src/tools/index.ts15-25 CLAUDE.md49-58

Tool Implementation Pattern

Code Entity to MCP Mapping

Each tool is implemented in its own file and follows a standard pattern to bridge TypeScript logic to the MCP McpServer.tool() registration.

Title: Bridge between MCP Protocol and Code Implementation


Sources: CLAUDE.md76-78 src/tools/index.ts15-25

Standard Tool Structure

Each tool file follows a strict convention to maintain consistency and testability:

  1. Input Shape: An exported *InputShape object containing raw Zod field definitions. This is passed directly to the third argument of server.tool(). CONTRIBUTING.md143-146
  2. Input Schema: An exported *InputSchema (defined as z.object(*InputShape)) used for unit testing to avoid drift between registration and tests. CONTRIBUTING.md149
  3. Input Type: An exported *Input type inferred from the schema. CONTRIBUTING.md150
  4. Handler: An async function that receives the validated parameters, interacts with the SimapClient (singleton simap), and returns the tool result. Errors are routed through toToolErrorResult(). CONTRIBUTING.md152-169
  5. Registration: A function (e.g., registerSearchTenders(server: McpServer)) that calls server.tool(). CONTRIBUTING.md171-174

Sources: CLAUDE.md76-78 CONTRIBUTING.md131-174

Registration Logic

McpServer.tool() Usage

The McpServer.tool() method is the core registration mechanism from @modelcontextprotocol/sdk. It takes primary arguments including:

  1. Name: The snake_case string identifying the tool to the MCP client (e.g., search_tenders). CLAUDE.md88
  2. Description: A string explaining the tool's purpose to the LLM. CONTRIBUTING.md172
  3. Schema: The Zod shape defining parameters (*InputShape). CONTRIBUTING.md172
  4. Callback: The logic to execute when the tool is called (handler). CONTRIBUTING.md172

Sources: CLAUDE.md76-78 src/tools/index.ts15-25 CONTRIBUTING.md171-174

Registration Entry Point

The root registerTools function in src/tools/index.ts acts as the entry point for all tool registrations, ensuring modularity by delegating to domain-specific files.


Sources: src/tools/index.ts15-25

Domain Indexers

Domain indexers group related registrations to keep the root registerTools clean and maintainable.

Title: Domain Registration Pattern


Sources: src/tools/index.ts21-24 src/tools/codes/index.ts19-32 src/tools/organizations/index.ts13-20