Skip to main content
Glama
cmendezs

mcp-facture-electronique-fr

create_routing_code

Create a routing code for a SIRET to direct incoming invoices to a specific department or service. Required before registering a directory line for multi-address routing.

Instructions

Create a new routing code for a SIRET in the PPF directory.

Routing codes let a recipient company route incoming invoices to specific departments or services. Once created, the code can be referenced in a directory line (create_directory_line) and communicated to senders to use in invoice addressing.

BEHAVIOR:

  • Returns the created routing code object including its instanceId.

  • Fails if the SIRET is not registered or not Active in the PPF directory.

  • Fails if a routing code with the same value already exists for this SIRET (duplicate check).

  • The routing_code value is case-sensitive and must be unique per SIRET.

RESPONSE: includes instanceId (required for update/delete), siret, siren, routingCode, label, createdAt.

USAGE GUIDELINES:

  • Call get_establishment_by_siret first to verify the SIRET is Active before creating a routing code.

  • After creating, call create_directory_line with routing_code set to register the receiving address.

  • If a routing code already exists (duplicate error), use search_routing_code to retrieve its instanceId, then update it with update_routing_code if needed.

  • Routing codes are optional; omit them if the company routes all invoices to a single SIRET address.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siretYesEstablishment SIRET to associate this routing code with (14 digits). The SIRET must already be registered and Active in the PPF directory.
routing_codeYesRouting code value to create (free-form string, e.g. 'PURCHASING-DEPT', 'PARIS-OFFICE'). This exact value will appear in invoicing addresses and must be communicated to senders.
labelNoHuman-readable label for the routing code (e.g. 'Purchasing department - HQ'). Optional but recommended for clarity when multiple codes exist.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for create_routing_code. Decorated with @mcp.tool() inside register_directory_tools(). Accepts siret, routing_code, and optional label. The implementation returns an error message indicating this endpoint was removed in XP Z12-013 v1.2.0 and must be performed through the Approved Platform portal.
    @mcp.tool()
    async def create_routing_code(
        siret: Annotated[
            str,
            Field(
                description=(
                    "Establishment SIRET to associate this routing code with (14 digits). "
                    "The SIRET must already be registered and Active in the PPF directory."
                )
            ),
        ],
        routing_code: Annotated[
            str,
            Field(
                description=(
                    "Routing code value to create (free-form string, e.g. 'PURCHASING-DEPT', 'PARIS-OFFICE'). "
                    "This exact value will appear in invoicing addresses and must be communicated to senders."
                )
            ),
        ],
        label: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Human-readable label for the routing code (e.g. 'Purchasing department - HQ'). "
                    "Optional but recommended for clarity when multiple codes exist."
                ),
            ),
        ] = None,
    ) -> dict:
        """
        Create a new routing code for a SIRET in the PPF directory.
    
        Routing codes let a recipient company route incoming invoices to specific departments or services.
        Once created, the code can be referenced in a directory line (create_directory_line)
        and communicated to senders to use in invoice addressing.
    
        BEHAVIOR:
        - Returns the created routing code object including its instanceId.
        - Fails if the SIRET is not registered or not Active in the PPF directory.
        - Fails if a routing code with the same value already exists for this SIRET (duplicate check).
        - The routing_code value is case-sensitive and must be unique per SIRET.
    
        RESPONSE: includes instanceId (required for update/delete), siret, siren, routingCode, label, createdAt.
    
        USAGE GUIDELINES:
        - Call get_establishment_by_siret first to verify the SIRET is Active before creating a routing code.
        - After creating, call create_directory_line with routing_code set to register the receiving address.
        - If a routing code already exists (duplicate error), use search_routing_code to retrieve its instanceId,
          then update it with update_routing_code if needed.
        - Routing codes are optional; omit them if the company routes all invoices to a single SIRET address.
        """
        return {
            "error": (
                "create_routing_code is not available. "
                "POST /v1/routing-code was removed in XP Z12-013 v1.2.0. "
                "Routing code creation must be performed through your Approved Platform portal."
            )
        }
  • The register_directory_tools() function that registers create_routing_code (and all other directory tools) on the FastMCP instance via the @mcp.tool() decorator.
    def register_directory_tools(mcp: FastMCP) -> None:
        """Registers the 12 Directory Service tools on the FastMCP instance."""
  • The DirectoryClient.create_routing_code() method in the HTTP client layer. Raises NotImplementedError because POST /v1/routing-code was removed in XP Z12-013 v1.2.0.
    async def create_routing_code(
        self, siret: str, routing_code: str, label: Optional[str] = None
    ) -> dict[str, Any]:
        """POST /v1/routing-code — REMOVED in XP Z12-013 v1.2.0."""
        raise NotImplementedError(
            "POST /v1/routing-code was removed in XP Z12-013 v1.2.0. "
            "Routing code creation is now managed through the Approved Platform portal."
        )
  • Expected directory tools set in tests that includes 'create_routing_code' as one of the 12 required directory tools.
    EXPECTED_DIRECTORY_TOOLS = {
        "search_company",
        "get_company_by_siren",
        "search_establishment",
        "get_establishment_by_siret",
        "search_routing_code",
        "create_routing_code",
        "update_routing_code",
        "search_directory_line",
        "get_directory_line",
        "create_directory_line",
        "update_directory_line",
        "delete_directory_line",
    }
  • Audit list of required directory tools, listing 'create_routing_code' as a required tool for the FR implementation.
    _REQUIRED_DIRECTORY_TOOLS: dict[str, str] = {
        "search_company":          "Search companies (SIRENs) in the PPF directory",
        "get_company_by_siren":    "Look up a company by SIREN",
        "search_establishment":    "Search establishments (SIRETs) in the PPF directory",
        "get_establishment_by_siret": "Look up an establishment by SIRET",
        "search_routing_code":     "Search routing codes for a recipient",
        "create_routing_code":     "Create a routing code for a SIRET",
        "update_routing_code":     "Update an existing routing code",
        "search_directory_line":   "Search directory lines (receiving addresses)",
        "get_directory_line":      "Look up a directory line by addressing identifier",
        "create_directory_line":   "Create a directory line (receiving address)",
        "update_directory_line":   "Update an existing directory line",
        "delete_directory_line":   "Delete a directory line",
    }
Behavior5/5

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

Despite no annotations, the description fully discloses behavior: returns created object with instanceId, fails if SIRET not Active or duplicate, case-sensitive uniqueness, and lists response fields. This covers all critical behavioral traits.

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?

Description is well-structured with sections (purpose, behavior, response, usage guidelines). Every sentence adds value, no redundancy. Approximately 150 words with efficient use of text.

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 output schema is described (instanceId, siret, etc.), the description covers behavior, failure modes, prerequisites, and post-conditions. No missing context for a creation tool.

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?

Input schema has 100% coverage, but description adds value by clarifying routing_code is a free-form string with examples and explaining label's optionality. It provides context beyond the schema descriptions.

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 states the purpose clearly: 'Create a new routing code for a SIRET in the PPF directory.' It specifies the verb (create), resource (routing code), and context, and distinguishes from siblings like 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?

A dedicated USAGE GUIDELINES section provides explicit when-to-use (verify SIRET Active first), what to do after (create_directory_line), how to handle duplicates (search then update), and when not needed (optional for single SIRET). It names alternative tools.

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