Skip to main content
Glama
cornelcroi

French Tax MCP Server

by cornelcroi

get_form_details

Retrieve detailed information about specific French tax forms, including required fields and official instructions, to complete tax documentation accurately.

Instructions

Get detailed information about a specific tax form including fields and instructions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
form_numberYes
yearNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Primary MCP tool handler decorated with @mcp.tool. Calls scraper.get_form_info() or provides hardcoded fallback data for common French tax forms (2042, 2044, 2031).
    @mcp.tool(
        name="get_form_details",
        description="Get detailed information about a specific tax form including fields and instructions",
    )
    async def get_form_details_wrapper(form_number: str, ctx: Context, year: Optional[int] = None) -> Optional[Dict]:
        """Get detailed information about a specific tax form.
    
        Args:
            form_number: The form number (e.g., '2042', '2044', '2072')
            year: Tax year (defaults to current year if not specified)
            ctx: MCP context for logging and state management
    
        Returns:
            Dict: Dictionary containing detailed information about the tax form
        """
        try:
            # Set default year to current year if not specified
            if year is None:
                year = datetime.now().year
    
            await ctx.info(f"Retrieving details for form {form_number} for year {year}")
    
            # Try to get information from the scraper first
            try:
                from french_tax_mcp.scrapers.impots_scraper import get_form_info
                result = await get_form_info(form_number, year)
                if result.get("status") == "success":
                    return result
            except Exception as e:
                await ctx.warning(f"Failed to get form details from web: {e}. Using fallback data.")
    
            # If web scraping fails or returns an error, use fallback data
            form_number = form_number.strip()
    
            # Provide fallback data for common forms
            if form_number == "2042":
                return {
                    "status": "success",
                    "message": f"Retrieved fallback information for form 2042 for {year}",
                    "data": {
                        "form": "2042",
                        "year": year,
                        "title": "Déclaration des revenus",
                        "description": "Formulaire principal de déclaration des revenus des personnes physiques.",
                        "sections": [
                            "État civil et situation de famille",
                            "Traitements, salaires, pensions et rentes",
                            "Revenus de capitaux mobiliers",
                            "Plus-values et gains divers",
                            "Revenus fonciers",
                            "Charges déductibles",
                            "Réductions et crédits d'impôt",
                        ],
                        "deadline": f"31 mai {year} (déclaration en ligne)",
                        "related_forms": [
                            {"number": "2042-C", "title": "Déclaration complémentaire"},
                            {"number": "2042-RICI", "title": "Réductions d'impôt et crédits d'impôt"},
                            {"number": "2044", "title": "Revenus fonciers"},
                        ],
                        "download_link": "https://www.impots.gouv.fr/formulaire/2042/declaration-des-revenus",
                    },
                    "source": "Fallback data",
                }
            elif form_number == "2044":
                return {
                    "status": "success",
                    "message": f"Retrieved fallback information for form 2044 for {year}",
                    "data": {
                        "form": "2044",
                        "year": year,
                        "title": "Déclaration des revenus fonciers",
                        "description": "Formulaire de déclaration des revenus fonciers (locations non meublées).",
                        "sections": [
                            "Propriétés rurales et urbaines",
                            "Recettes brutes",
                            "Frais et charges",
                            "Intérêts d'emprunt",
                            "Détermination du revenu ou déficit",
                        ],
                        "deadline": f"31 mai {year} (avec la déclaration principale)",
                        "related_forms": [
                            {"number": "2042", "title": "Déclaration des revenus"},
                            {
                                "number": "2044-SPE",
                                "title": "Déclaration des revenus fonciers spéciaux",
                            },
                        ],
                        "download_link": "https://www.impots.gouv.fr/formulaire/2044/declaration-des-revenus-fonciers",
                    },
                    "source": "Fallback data",
                }
            elif form_number == "2031":
                return {
                    "status": "success",
                    "message": f"Retrieved fallback information for form 2031 for {year}",
                    "data": {
                        "form": "2031",
                        "year": year,
                        "title": "Déclaration des résultats BIC",
                        "description": "Formulaire de déclaration des bénéfices industriels et commerciaux (BIC) au régime réel.",
                        "sections": [
                            "Identification de l'entreprise",
                            "Résultat fiscal",
                            "Immobilisations et amortissements",
                            "Provisions",
                            "Plus-values et moins-values",
                        ],
                        "deadline": f"Début mai {year} (entreprises soumises à l'IR)",
                        "related_forms": [
                            {"number": "2033-A à G", "title": "Régime simplifié"},
                            {"number": "2042-C-PRO", "title": "Report des revenus professionnels"},
                        ],
                        "download_link": "https://www.impots.gouv.fr/formulaire/2031-sd/declaration-de-resultats",
                    },
                    "source": "Fallback data",
                }
            else:
                # For unknown forms, return a more informative error
                return {
                    "status": "error",
                    "message": f"Information for form {form_number} not available",
                    "form": form_number,
                    "year": year,
                    "available_forms": ["2042", "2044", "2031"],
                }
        except Exception as e:
            await ctx.error(f"Failed to get form details: {e}")
            return {
                "status": "error",
                "message": f"Error retrieving form details: {str(e)}",
                "form": form_number,
                "year": year,
            }
  • Core scraping implementation in ImpotsScraper class. Fetches form page from impots.gouv.fr and extracts structured information using BeautifulSoup.
    async def get_form_info(self, form_number: str, year: Optional[int] = None) -> Dict:
        """Scrape information about a specific tax form from impots.gouv.fr.
    
        Args:
            form_number: The form number (e.g., '2042', '2044')
            year: The tax year. Defaults to current year.
    
        Returns:
            Dictionary containing information about the form
        """
        # Set default year to current year if not specified
        current_year = datetime.now().year
        tax_year = year or current_year
    
        logger.info(f"Scraping information for form {form_number} for year {tax_year}")
    
        try:
            # Construct URL
            url = f"{FORMS_BASE_URL}/formulaire-{form_number}.html"
    
            # Get the page
            response = await self.get_page(url)
    
            # Parse HTML
            soup = self.parse_html(response.text)
    
            # Extract form information
            form_info = self._extract_form_info(soup, form_number, tax_year)
    
            return self.format_result(
                status="success",
                data=form_info,
                message=f"Successfully retrieved information for form {form_number}",
                source_url=f"{BASE_URL}{url}",
            )
    
        except Exception as e:
            logger.error(f"Error scraping form information: {e}")
            return self.format_result(
                status="error",
                message=f"Failed to retrieve form information: {str(e)}",
                data={"form": form_number, "year": tax_year},
                error=e,
            )
  • Top-level exported helper function imported by server.py handler, proxies to singleton ImpotsScraper instance.
    async def get_form_info(form_number: str, year: Optional[int] = None) -> Dict:
        """Scrape information about a specific tax form from impots.gouv.fr.
    
        Args:
            form_number: The form number (e.g., '2042', '2044')
            year: The tax year. Defaults to current year.
    
        Returns:
            Dictionary containing information about the form
        """
        return await impots_scraper.get_form_info(form_number, year)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool retrieves information, implying a read-only operation, but does not mention potential side effects, authentication needs, rate limits, or response format. For a tool with zero annotation coverage, this is a significant gap in transparency.

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

Conciseness4/5

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

The description is a single, efficient sentence that front-loads the purpose without unnecessary details. It could be slightly more structured by including usage hints, but it earns its place by clearly stating what the tool does.

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

Completeness3/5

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

Given the tool's moderate complexity (2 parameters, no annotations, but with an output schema), the description is minimally adequate. It states the purpose but lacks behavioral context and parameter guidance. The output schema reduces the need to explain return values, but the description should do more to compensate for missing annotations.

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

Parameters3/5

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

The description does not mention parameters at all, and schema description coverage is 0%, so it adds no meaning beyond the input schema. However, with only 2 parameters and an output schema present, the baseline is 3 as the schema handles the heavy lifting, though the description fails to compensate for the coverage gap.

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

Purpose4/5

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

The description clearly states the verb ('Get') and resource ('detailed information about a specific tax form'), specifying what information is retrieved ('fields and instructions'). It distinguishes from siblings like 'get_tax_brackets' or 'get_tax_deadlines' by focusing on form details, though it could be more explicit about differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'get_cached_tax_info' or 'get_tax_info_from_web'. It implies usage for retrieving form details but lacks explicit context, exclusions, or prerequisites, leaving the agent to infer based on tool names alone.

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/cornelcroi/french-tax-mcp'

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