Skip to main content
Glama
cornelcroi

French Tax MCP Server

by cornelcroi

get_tax_info_from_web

Retrieve official French tax information from government websites like impots.gouv.fr for specific tax topics and years.

Instructions

Get tax information from official French government websites like impots.gouv.fr, service-public.fr, or legifrance.gouv.fr

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tax_topicYes
yearNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Registration of the 'get_tax_info_from_web' tool using the @mcp.tool decorator.
    @mcp.tool(
        name="get_tax_info_from_web",
        description="Get tax information from official French government websites like impots.gouv.fr, service-public.fr, or legifrance.gouv.fr",
    )
  • The primary handler function that executes the tool logic. It maps the tax topic to specific scrapers (currently only tax_brackets) or returns an error for unimplemented topics.
    async def get_tax_info_from_web(tax_topic: str, ctx: Context, year: Optional[int] = None) -> Optional[Dict]:
        """Get tax information from official French government websites.
    
        Args:
            tax_topic: The tax topic to search for (e.g., 'tranches_impot', 'pinel', 'lmnp')
            year: Optional tax year (defaults to current year if not specified)
            ctx: MCP context for logging and state management
    
        Returns:
            Dict: Dictionary containing the tax information retrieved from the website
        """
        try:
            # This is a placeholder implementation
            # The actual implementation will be more complex and will use specialized scrapers
    
            # Set default year to current year if not specified
            if year is None:
                year = datetime.now().year
    
            await ctx.info(f"Retrieving information about {tax_topic} for year {year}")
    
            # Map topic to appropriate scraper
            if tax_topic.lower() in ["tranches_impot", "baremes", "tax_brackets"]:
                # Use tax brackets scraper (lazy import)
                from french_tax_mcp.scrapers.impots_scraper import get_tax_brackets
                result = await get_tax_brackets(year)
                return result
            else:
                # Generic response for now
                return {
                    "status": "error",
                    "message": f"Information for {tax_topic} not yet implemented",
                    "year": year,
                }
    
        except Exception as e:
            await ctx.error(f"Failed to get tax information from web: {e}")
            return {
                "status": "error",
                "message": f"Error retrieving information: {str(e)}",
                "topic": tax_topic,
                "year": year,
            }
  • Supporting function imported and called by the handler for 'tranches_impot' topics. Uses MarkItDown scraper with fallback to hardcoded data.
    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)
    
    
    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
    
    
    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)"
        }
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 implies a read-only operation by using 'Get', but doesn't specify whether it involves web scraping, API calls, rate limits, authentication needs, or potential delays. This leaves critical behavioral traits undocumented for a tool interacting with external websites.

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 wasted words. It's appropriately sized for a simple tool and front-loads the core purpose without unnecessary elaboration, making it easy to parse quickly.

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 complexity (interacting with external websites), lack of annotations, and 0% schema coverage, the description is incomplete. While an output schema exists (which reduces the need to explain return values), the description doesn't cover behavioral aspects like data freshness, error handling, or usage constraints, leaving gaps for effective tool selection.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate for undocumented parameters. It mentions 'tax information' and 'official French government websites', which loosely relates to 'tax_topic', but provides no details on format, examples, or constraints for either parameter. The 'year' parameter isn't addressed at all, failing to add meaningful semantics beyond the bare schema.

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 action ('Get') and resource ('tax information') with specific sources ('official French government websites'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_tax_article' or 'get_cached_tax_info', which might retrieve similar information through different means.

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. It doesn't mention when to prefer it over siblings like 'get_cached_tax_info' (for cached data) or 'get_tax_article' (for specific articles), nor does it specify prerequisites or exclusions, leaving usage context unclear.

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