Skip to main content
Glama
cornelcroi

French Tax MCP Server

by cornelcroi

get_tax_brackets

Retrieve French income tax brackets for a specific year to calculate individual tax liability using official government data.

Instructions

Get income tax brackets (tranches d'imposition) for a specific year

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP decorator registering the get_tax_brackets tool with name and description.
    @mcp.tool(
        name="get_tax_brackets",
        description="Get income tax brackets (tranches d'imposition) for a specific year",
    )
  • The MCP tool handler wrapper for get_tax_brackets. It handles the context, sets default year, imports and calls the scraper implementation, and manages errors.
    async def get_tax_brackets_wrapper(ctx: Context, year: Optional[int] = None) -> Optional[Dict]:
        """Get income tax brackets for a specific year.
    
        Args:
            year: Tax year (defaults to current year if not specified)
            ctx: MCP context for logging and state management
    
        Returns:
            Dict: Dictionary containing the tax brackets and rates
        """
        try:
            # Set default year to current year if not specified
            if year is None:
                year = datetime.now().year
    
            await ctx.info(f"Retrieving tax brackets for year {year}")
    
            # Call the implementation from impots_scraper.py (lazy import)
            from french_tax_mcp.scrapers.impots_scraper import get_tax_brackets
            result = await get_tax_brackets(year)
            return result
        except Exception as e:
            await ctx.error(f"Failed to get tax brackets: {e}")
            return {
                "status": "error",
                "message": f"Error retrieving tax brackets: {str(e)}",
                "year": year,
            }
  • Core implementation of get_tax_brackets. Scrapes tax brackets from service-public.fr using MarkItDown, parses the markdown, and falls back to hardcoded data from constants.
    async def get_tax_brackets(year: Optional[int] = None) -> Dict:
        """Get income tax brackets using MarkItDown scraper with fallback to hardcoded data.
    
        Args:
            year: Tax year (defaults to current year)
    
        Returns:
            Dictionary containing the tax brackets and rates
        """
        try:
            # Try MarkItDown scraper first (more reliable)
            from markitdown import MarkItDown
            
            md = MarkItDown()
            url = "https://www.service-public.fr/particuliers/vosdroits/F1419"
            
            logger.info(f"Fetching tax brackets using MarkItDown from {url}")
            result = md.convert_url(url)
            brackets = _parse_brackets_from_markdown(result.text_content)
            
            if brackets:
                current_year = year or datetime.now().year
                logger.info(f"Successfully parsed {len(brackets)} tax brackets using MarkItDown")
                return {
                    "status": "success",
                    "data": {
                        "year": current_year,
                        "brackets": brackets
                    },
                    "source": "service-public.fr (MarkItDown)"
                }
            
            # Fallback to hardcoded data
            logger.warning("MarkItDown parsing failed, using hardcoded tax brackets")
            return _get_fallback_tax_brackets(year)
            
        except Exception as e:
            logger.error(f"MarkItDown scraping failed: {e}")
            return _get_fallback_tax_brackets(year)
  • Helper function providing hardcoded fallback tax brackets from constants.TAX_BRACKETS.
    def _get_fallback_tax_brackets(year: Optional[int] = None) -> Dict:
        """Get hardcoded tax brackets as fallback."""
        from french_tax_mcp.constants import TAX_BRACKETS
        
        current_year = year or datetime.now().year
        brackets = TAX_BRACKETS.get(current_year, TAX_BRACKETS.get(2024, []))
        
        return {
            "status": "success",
            "data": {
                "year": current_year,
                "brackets": brackets
            },
            "source": "hardcoded (fallback)"
        }
  • Helper function to parse tax bracket data from scraped markdown content using regex.
    def _parse_brackets_from_markdown(content: str) -> List[Dict]:
        """Parse tax brackets from markdown content."""
        brackets = []
        
        # Pattern for tax bracket tables: "De X € à Y € | Z%"
        pattern = r'(\d+(?:\s\d+)*)\s*€.*?(\d+(?:\s\d+)*)\s*€.*?(\d+(?:,\d+)?)\s*%'
        matches = re.findall(pattern, content)
        
        for match in matches:
            try:
                min_str, max_str, rate_str = match
                min_amount = int(min_str.replace(' ', ''))
                max_amount = int(max_str.replace(' ', '')) if max_str != '∞' else None
                rate = float(rate_str.replace(',', '.'))
                
                brackets.append({
                    "min": min_amount,
                    "max": max_amount,
                    "rate": rate
                })
            except ValueError:
                continue
        
        return brackets[:5]  # Limit to reasonable number
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does but doesn't describe traits like whether it's read-only, requires authentication, has rate limits, or what the output format is. The description is minimal and fails to compensate for the lack of annotations, leaving key behavioral aspects unspecified.

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 a single, efficient sentence with zero waste. It's front-loaded with the core action and resource, making it easy to parse. Every word earns its place, and there's no redundant or verbose phrasing.

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 low complexity (1 optional parameter) and the presence of an output schema, the description is adequate but minimal. It covers the basic purpose but lacks details on behavior, usage context, and parameter nuances. The output schema likely handles return values, so the description doesn't need to explain those, but it should do more to guide the agent effectively.

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 mentions 'for a specific year', which aligns with the 'year' parameter in the input schema. However, schema description coverage is 0%, so the schema provides no details about the parameter. The description adds minimal semantics by indicating the parameter's purpose but doesn't explain format, constraints, or the null default. It partially compensates but not fully 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 the resource 'income tax brackets (tranches d'imposition)' with the scope 'for a specific year'. It distinguishes from siblings like 'calculate_income_tax' (which computes tax amounts) and 'get_tax_info_from_web' (which fetches broader information), but doesn't explicitly differentiate them. The purpose is specific and actionable, though not fully contrasted with alternatives.

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 bracket data by year, but lacks explicit when/when-not instructions or prerequisites. This leaves the agent to infer context without clear direction.

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