Skip to main content
Glama
cmendezs

mcp-facture-electronique-fr

search_establishment

Find establishments in the French PPF directory by SIRET, SIREN, or status. Use to verify registration and administrative status before invoicing.

Instructions

Search for establishments (SIRETs) in the PPF directory by criteria.

An establishment is a physical place of business activity identified by its 14-digit SIRET. Each company (SIREN) can have multiple establishments.

BEHAVIOR:

  • Returns a paginated list of matching establishments; empty list if none match.

  • At least one search criterion should be provided; omitting all returns an error.

  • Pagination: if the response includes 'nextUpdatedAfter', pass it as updated_after to get the next page.

RESPONSE: each item includes siret, siren, name, administrativeStatus (Active/Inactive), approvedPlatformId, and timestamps (createdAt, updatedAt).

USAGE GUIDELINES:

  • Prefer get_establishment_by_siret when you already know the exact SIRET (faster, direct lookup).

  • Use search_establishment with siren to enumerate all establishments of a company.

  • Always verify administrativeStatus == Active before sending an invoice to that establishment.

  • Call this before create_directory_line to confirm the target SIRET is registered in the PPF directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siretNoEstablishment SIRET number (14 digits, no spaces). Example: '12345678900012'. Use when you know the exact establishment; returns at most one result.
sirenNoParent company SIREN (9 digits). Returns all establishments registered under this company. Use to discover all SIRETs for a given SIREN.
administrative_statusNoAdministrative status of the establishment in the PPF directory. Active: establishment is open and reachable for invoicing. Inactive: establishment is closed; invoices cannot be sent to it.
updated_afterNoPagination cursor: only return establishments updated after this date/time (ISO 8601, e.g. 2024-09-01T00:00:00Z). Use the 'nextUpdatedAfter' field from the previous response to fetch the next page.
limitNoMaximum number of results per page (1-500, default 50).

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for search_establishment — validates SIREN/SIRET via Luhn checks, then delegates to the HTTP client.
    async def search_establishment(
        siret: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Establishment SIRET number (14 digits, no spaces). "
                    "Example: '12345678900012'. "
                    "Use when you know the exact establishment; returns at most one result."
                ),
            ),
        ] = None,
        siren: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Parent company SIREN (9 digits). "
                    "Returns all establishments registered under this company. "
                    "Use to discover all SIRETs for a given SIREN."
                ),
            ),
        ] = None,
        administrative_status: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Administrative status of the establishment in the PPF directory. "
                    "Active: establishment is open and reachable for invoicing. "
                    "Inactive: establishment is closed; invoices cannot be sent to it."
                ),
            ),
        ] = None,
        updated_after: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Pagination cursor: only return establishments updated after this "
                    "date/time (ISO 8601, e.g. 2024-09-01T00:00:00Z). "
                    "Use the 'nextUpdatedAfter' field from the previous response to fetch the next page."
                ),
            ),
        ] = 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 for establishments (SIRETs) in the PPF directory by criteria.
    
        An establishment is a physical place of business activity identified by its 14-digit SIRET.
        Each company (SIREN) can have multiple establishments.
    
        BEHAVIOR:
        - Returns a paginated list of matching establishments; empty list if none match.
        - At least one search criterion should be provided; omitting all returns an error.
        - Pagination: if the response includes 'nextUpdatedAfter', pass it as updated_after to get the next page.
    
        RESPONSE: each item includes siret, siren, name, administrativeStatus (Active/Inactive),
        approvedPlatformId, and timestamps (createdAt, updatedAt).
    
        USAGE GUIDELINES:
        - Prefer get_establishment_by_siret when you already know the exact SIRET (faster, direct lookup).
        - Use search_establishment with siren to enumerate all establishments of a company.
        - Always verify administrativeStatus == Active before sending an invoice to that establishment.
        - Call this before create_directory_line to confirm the target SIRET is registered in the PPF directory.
        """
        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_establishment(
            siret=siret,
            siren=siren,
            administrative_status=administrative_status,
            updated_after=updated_after,
            limit=limit,
        )
  • HTTP client method that sends POST /v1/siret/search to the PPF Directory Service API.
    async def search_establishment(
        self,
        siret: Optional[str] = None,
        siren: Optional[str] = None,
        administrative_status: Optional[str] = None,
        updated_after: Optional[str] = None,
        limit: int = 50,
    ) -> dict[str, Any]:
        """POST /v1/siret/search — Search establishments in the directory."""
        body: dict[str, Any] = {"limit": limit}
        if siret:
            body["siret"] = siret
        if siren:
            body["siren"] = siren
        if administrative_status:
            body["administrativeStatus"] = administrative_status
        if updated_after:
            body["updatedAfter"] = updated_after
        response = await self._request("POST", "/v1/siret/search", json=body)
        if response.status_code == 204:
            return {"total": 0}
        return response.json()
  • Pydantic Field annotations defining the input parameters for the search_establishment tool.
        siret: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Establishment SIRET number (14 digits, no spaces). "
                    "Example: '12345678900012'. "
                    "Use when you know the exact establishment; returns at most one result."
                ),
            ),
        ] = None,
        siren: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Parent company SIREN (9 digits). "
                    "Returns all establishments registered under this company. "
                    "Use to discover all SIRETs for a given SIREN."
                ),
            ),
        ] = None,
        administrative_status: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Administrative status of the establishment in the PPF directory. "
                    "Active: establishment is open and reachable for invoicing. "
                    "Inactive: establishment is closed; invoices cannot be sent to it."
                ),
            ),
        ] = None,
        updated_after: Annotated[
            Optional[str],
            Field(
                default=None,
                description=(
                    "Pagination cursor: only return establishments updated after this "
                    "date/time (ISO 8601, e.g. 2024-09-01T00:00:00Z). "
                    "Use the 'nextUpdatedAfter' field from the previous response to fetch the next page."
                ),
            ),
        ] = None,
        limit: Annotated[
            int,
            Field(default=50, ge=1, le=500, description="Maximum number of results per page (1-500, default 50)."),
        ] = 50,
    ) -> dict:
  • The @mcp.tool() decorator on search_establishment (line 195) registers it as an MCP tool when register_directory_tools(mcp) is called.
    def register_directory_tools(mcp: FastMCP) -> None:
        """Registers the 12 Directory Service tools on the FastMCP instance."""
    
        # ------------------------------------------------------------------
        # SIREN — Legal units
        # ------------------------------------------------------------------
Behavior4/5

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

No annotations are provided, so the description must cover behavioral traits. It does so by detailing pagination, error conditions (omitting all criteria), and response structure. It is thorough, though it doesn't explicitly state that the tool is read-only, which is implied but not definitive.

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-organized with clear sections (overview, behavior, response, usage guidelines). Every sentence serves a purpose, and it is concise without sacrificing completeness.

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?

For a tool with 5 parameters, pagination, and a specific output schema, the description covers all necessary aspects: behavior, error handling, pagination mechanism, response fields, and related tool usage. 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.

Parameters5/5

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

Schema coverage is 100%. The description adds value beyond the schema by clarifying semantics like 'at least one criterion required', 'siret returns at most one', 'siren returns all', and pagination cursor usage. This helps the agent use parameters correctly.

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 defines the tool's function as searching for establishments by criteria, explains what establishments are (SIRETs), and distinguishes it from sibling tools via usage guidelines. It uses specific verb+resource and provides context.

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?

Explicitly advises when to use alternatives (e.g., prefer get_establishment_by_siret for exact SIRET, use search_establishment with siren to enumerate). Also provides best practices like verifying administrative status and calling before create_directory_line.

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