Urgent.News

What's breaking now, across thousands of outlets.

Tech

Building an MCP server in Python on open data: French company lookup, tested end to end

I wanted a small, real MCP server to learn the protocol properly: not a "hello world" tool, but something an assistant could use for an actual task. French public data is a good playground. Two official APIs answer most "who is this company?" questions, need no key, and are published under the Licence Ouverte 2.0 (Etalab's open licence, which allows reuse, including commercial, as long as you…

Building an MCP server in Python using open French company data involved creating three read-only tools: search_companies, get_company, and get_bodacc_announcements. The server exposes only these three tools to avoid overwhelming the user with numerous options. The search tool allows users to find a company using its name, while the get_company tool provides full company profiles. Lastly, the get_bodacc_announcements tool offers information about any legal notices associated with the company.

To make the server user-friendly, the server refrains from returning sensitive information such as company officers' details. It also reshapes the raw API responses by mapping common French field names and INSEE codes to readable labels. Unknown codes are returned as-is, and the server annotates the tools as read-only, indicating to clients that they should not expect any changes or destructive actions.

For schema building, the server utilized Python's SDK, which automatically generates JSON schemas based on type hints. This approach led to a more streamlined and efficient development process. The server also accounted for various error scenarios, with each failure resulting in a tool result containing isError: true and a corresponding explanatory sentence. Validation errors, domain validation issues, and upstream failures were all handled separately to provide clear, actionable feedback to the user.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 7 October →