get_establishment_by_siret
Look up an establishment in the PPF directory using its SIRET number to verify the receiving address before sending an invoice. Returns establishment details, status, and Approved Platform.
Instructions
Look up an establishment in the PPF directory by its SIRET number. Essential for verifying the receiving address before sending an invoice. Returns the establishment details, its status, and its Approved Platform.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| siret | Yes | Establishment SIRET number (14 digits, no spaces). Example: '12345678900012'. Essential for verifying the receiving address before sending an invoice: confirms the establishment is registered and active in the PPF directory. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- tools/directory_tools.py:285-309 (handler)MCP tool handler for get_establishment_by_siret. Decorated with @mcp.tool() via register_directory_tools. Validates the SIRET input (14 digits, Luhn check), then delegates to DirectoryClient.get_establishment_by_siret which makes a GET /v1/siret/code-insee:{siret} HTTP request.
@mcp.tool() async def get_establishment_by_siret( siret: Annotated[ str, Field( description=( "Establishment SIRET number (14 digits, no spaces). " "Example: '12345678900012'. " "Essential for verifying the receiving address before sending an invoice: " "confirms the establishment is registered and active in the PPF directory." ) ), ], ) -> dict: """ Look up an establishment in the PPF directory by its SIRET number. Essential for verifying the receiving address before sending an invoice. Returns the establishment details, its status, and its Approved Platform. """ try: siret = _validate_siret(siret) except ValueError as exc: return {"error": str(exc)} client = get_directory_client() return await client.get_establishment_by_siret(siret=siret) - tools/directory_tools.py:51-58 (helper)SIRET validation helper used by get_establishment_by_siret handler. Ensures the input is exactly 14 digits and passes Luhn check digit validation.
def _validate_siret(value: str) -> str: """Return the stripped SIRET or raise ValueError if invalid.""" v = value.strip() if not v.isdigit() or len(v) != 14: raise ValueError(f"SIRET must be exactly 14 digits, got {value!r}") if not _luhn_ok(v): raise ValueError(f"SIRET {value!r} fails Luhn check digit validation") return v - clients/directory_client.py:112-115 (helper)HTTP client method that executes the actual API call for get_establishment_by_siret. Sends a GET request to /v1/siret/code-insee:{siret} and returns the JSON response containing establishment details.
async def get_establishment_by_siret(self, siret: str) -> dict[str, Any]: """GET /v1/siret/code-insee:{siret} — Look up an establishment by SIRET.""" response = await self._request("GET", f"/v1/siret/code-insee:{siret}") return response.json() - tools/directory_tools.py:70-76 (registration)Registration function that registers all directory tools on the FastMCP instance. The get_establishment_by_siret handler is registered via @mcp.tool() decorator within this function.
def register_directory_tools(mcp: FastMCP) -> None: """Registers the 12 Directory Service tools on the FastMCP instance.""" # ------------------------------------------------------------------ # SIREN — Legal units # ------------------------------------------------------------------