Skip to main content
Glama
cmendezs

mcp-facture-electronique-fr

search_routing_code

Search routing codes for a SIRET or SIREN to find department-level invoice addresses. Verify a routing code exists before addressing an invoice to a specific unit.

Instructions

Search routing codes registered in the PPF directory for a recipient.

Routing codes subdivide a SIRET receiving address to department or service level, allowing a company to route invoices to different internal units (e.g. purchasing, accounting).

BEHAVIOR:

  • Returns a paginated list of matching routing codes; empty list if none defined for the criteria.

  • At least one of siret, siren, or routing_code should be provided.

  • A SIRET may have zero or more routing codes; zero means invoices go to the SIRET-level address.

RESPONSE: each item includes instanceId, siret, siren, routingCode, label (optional), and timestamps. The instanceId is required to update or delete a routing code.

USAGE GUIDELINES:

  • Call before create_directory_line with a routing_code to confirm the code exists on the target SIRET.

  • Call to enumerate available routing codes when helping a sender choose the correct recipient address.

  • If no routing codes exist for a SIRET, the invoice must be addressed at SIRET level without a routing code.

  • Use create_routing_code to create a new code; use update_routing_code with instanceId to rename it.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siretNoEstablishment SIRET (14 digits). Returns all routing codes associated with this establishment. Most common filter: use when building a directory line for a specific SIRET.
sirenNoCompany SIREN (9 digits). Returns routing codes for all establishments under this company.
routing_codeNoExact routing code value to look up (e.g. 'ACCOUNTS-DEPT', 'REGION-WEST'). Use to verify a routing code exists before referencing it in an invoice.
limitNoMaximum number of results per page (1-500, default 50).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for search_routing_code. Decorated with @mcp.tool(), it validates SIREN/SIRET inputs and delegates to DirectoryClient.search_routing_code.
    @mcp.tool()
    async def search_routing_code(
        siret: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Establishment SIRET (14 digits). "
                    "Returns all routing codes associated with this establishment. "
                    "Most common filter: use when building a directory line for a specific SIRET."
                ),
            ),
        ] = None,
        siren: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Company SIREN (9 digits). "
                    "Returns routing codes for all establishments under this company."
                ),
            ),
        ] = None,
        routing_code: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Exact routing code value to look up (e.g. 'ACCOUNTS-DEPT', 'REGION-WEST'). "
                    "Use to verify a routing code exists before referencing it in an invoice."
                ),
            ),
        ] = None,
        limit: Annotated[
            int,
            Field(default=50, ge=1, le=500, description="Maximum number of results per page (1-500, default 50)."),
        ] = 50,
    ) -> dict:
        """
        Search routing codes registered in the PPF directory for a recipient.
    
        Routing codes subdivide a SIRET receiving address to department or service level,
        allowing a company to route invoices to different internal units (e.g. purchasing, accounting).
    
        BEHAVIOR:
        - Returns a paginated list of matching routing codes; empty list if none defined for the criteria.
        - At least one of siret, siren, or routing_code should be provided.
        - A SIRET may have zero or more routing codes; zero means invoices go to the SIRET-level address.
    
        RESPONSE: each item includes instanceId, siret, siren, routingCode, label (optional), and timestamps.
        The instanceId is required to update or delete a routing code.
    
        USAGE GUIDELINES:
        - Call before create_directory_line with a routing_code to confirm the code exists on the target SIRET.
        - Call to enumerate available routing codes when helping a sender choose the correct recipient address.
        - If no routing codes exist for a SIRET, the invoice must be addressed at SIRET level without a routing code.
        - Use create_routing_code to create a new code; use update_routing_code with instanceId to rename it.
        """
        if siren is not None:
            try:
                siren = _validate_siren(siren)
            except ValueError as exc:
                return {"error": str(exc)}
        if siret is not None:
            try:
                siret = _validate_siret(siret)
            except ValueError as exc:
                return {"error": str(exc)}
        client = get_directory_client()
        return await client.search_routing_code(
            siret=siret,
            siren=siren,
            routing_code=routing_code,
            limit=limit,
        )
  • The input schema/type definitions for search_routing_code: siret (Optional[str]), siren (Optional[str]), routing_code (Optional[str]), limit (int, default 50, range 1-500). All parameters are optional.
    @mcp.tool()
    async def search_routing_code(
        siret: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Establishment SIRET (14 digits). "
                    "Returns all routing codes associated with this establishment. "
                    "Most common filter: use when building a directory line for a specific SIRET."
                ),
            ),
        ] = None,
        siren: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Company SIREN (9 digits). "
                    "Returns routing codes for all establishments under this company."
                ),
            ),
        ] = None,
        routing_code: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Exact routing code value to look up (e.g. 'ACCOUNTS-DEPT', 'REGION-WEST'). "
                    "Use to verify a routing code exists before referencing it in an invoice."
                ),
            ),
        ] = None,
        limit: Annotated[
            int,
            Field(default=50, ge=1, le=500, description="Maximum number of results per page (1-500, default 50)."),
        ] = 50,
  • Tool registered via @mcp.tool() decorator inside register_directory_tools(), alongside 11 other directory tools.
    @mcp.tool()
    async def search_routing_code(
        siret: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Establishment SIRET (14 digits). "
                    "Returns all routing codes associated with this establishment. "
                    "Most common filter: use when building a directory line for a specific SIRET."
                ),
            ),
        ] = None,
        siren: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Company SIREN (9 digits). "
                    "Returns routing codes for all establishments under this company."
                ),
            ),
        ] = None,
        routing_code: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Exact routing code value to look up (e.g. 'ACCOUNTS-DEPT', 'REGION-WEST'). "
                    "Use to verify a routing code exists before referencing it in an invoice."
                ),
            ),
        ] = None,
        limit: Annotated[
            int,
            Field(default=50, ge=1, le=500, description="Maximum number of results per page (1-500, default 50)."),
        ] = 50,
    ) -> dict:
        """
        Search routing codes registered in the PPF directory for a recipient.
    
        Routing codes subdivide a SIRET receiving address to department or service level,
        allowing a company to route invoices to different internal units (e.g. purchasing, accounting).
    
        BEHAVIOR:
        - Returns a paginated list of matching routing codes; empty list if none defined for the criteria.
        - At least one of siret, siren, or routing_code should be provided.
        - A SIRET may have zero or more routing codes; zero means invoices go to the SIRET-level address.
    
        RESPONSE: each item includes instanceId, siret, siren, routingCode, label (optional), and timestamps.
        The instanceId is required to update or delete a routing code.
    
        USAGE GUIDELINES:
        - Call before create_directory_line with a routing_code to confirm the code exists on the target SIRET.
        - Call to enumerate available routing codes when helping a sender choose the correct recipient address.
        - If no routing codes exist for a SIRET, the invoice must be addressed at SIRET level without a routing code.
        - Use create_routing_code to create a new code; use update_routing_code with instanceId to rename it.
        """
        if siren is not None:
            try:
                siren = _validate_siren(siren)
            except ValueError as exc:
                return {"error": str(exc)}
        if siret is not None:
            try:
                siret = _validate_siret(siret)
            except ValueError as exc:
                return {"error": str(exc)}
        client = get_directory_client()
        return await client.search_routing_code(
            siret=siret,
            siren=siren,
            routing_code=routing_code,
            limit=limit,
        )
  • The HTTP client method that performs the actual API call: POST /v1/routing-code/search with optional siret, siren, routingCode, and limit parameters.
    async def search_routing_code(
        self,
        siret: Optional[str] = None,
        siren: Optional[str] = None,
        routing_code: Optional[str] = None,
        limit: int = 50,
    ) -> dict[str, Any]:
        """POST /v1/routing-code/search — Search routing codes."""
        body: dict[str, Any] = {"limit": limit}
        if siret:
            body["siret"] = siret
        if siren:
            body["siren"] = siren
        if routing_code:
            body["routingCode"] = routing_code
        response = await self._request("POST", "/v1/routing-code/search", json=body)
        if response.status_code == 204:
            return {"total": 0}
        return response.json()
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description fully covers behavior: paginated results, empty list if none, requirement of at least one filter, and explanation that a SIRET may have zero codes. Also describes response fields and the importance of instanceId.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (BEHAVIOR, RESPONSE, USAGE GUIDELINES), no wasted sentences, and information is front-loaded with the main purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 4 parameters, no annotations, and an output schema, the description covers all critical aspects: behavior, filtering, response structure, and usage context. It is complete and self-contained.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds value beyond schema by stating the filter requirement ('at least one of siret, siren, or routing_code should be provided') and explaining use cases for each parameter, but the schema already has good descriptions. Final score reflects moderate added value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Search routing codes registered in the PPF directory for a recipient.' It uses a specific verb and resource, and the context distinguishes it from siblings like create_routing_code and update_routing_code.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The USAGE GUIDELINES section explicitly tells when to use this tool (before create_directory_line, to enumerate routing codes) and when not to (when no codes exist, use alternatives like create_routing_code). This provides full guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cmendezs/mcp-facture-electronique-fr'

If you have feedback or need assistance with the MCP directory API, please join our Discord server