Skip to main content
Glama
cornelcroi

French Tax MCP Server

by cornelcroi

get_cached_tax_info

Retrieve French tax information from cached data when web scraping fails, providing reliable access to official tax brackets and calculations for residents.

Instructions

Get cached tax information when web scraping fails

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tax_topicYes
yearNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the get_cached_tax_info tool, including registration decorator. It handles caching logic for tax topics, primarily tax brackets, by instantiating ImpotsScraper and calling its fallback method.
    @mcp.tool(
        name="get_cached_tax_info",
        description="Get cached tax information when web scraping fails",
    )
    async def get_cached_tax_info(tax_topic: str, ctx: Context, year: Optional[int] = None) -> Optional[Dict]:
        """Get cached tax information when web scraping fails.
    
        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 cached tax information
        """
        try:
            # Set default year to current year if not specified
            if year is None:
                year = datetime.now().year
    
            await ctx.info(f"Retrieving cached information for {tax_topic} for year {year}")
    
            # Map topic to appropriate cached data
            if tax_topic.lower() in ["tranches_impot", "baremes", "tax_brackets"]:
                # Use tax brackets fallback data (lazy import)
                from french_tax_mcp.scrapers.impots_scraper import ImpotsScraper
    
                scraper = ImpotsScraper()
                brackets = scraper._get_fallback_brackets(year)
    
                return {
                    "status": "success",
                    "message": f"Retrieved cached tax brackets for {year}",
                    "data": {
                        "year": year,
                        "brackets": brackets,
                    },
                    "source": "cache",
                }
            else:
                # Generic response for now
                return {
                    "status": "error",
                    "message": f"Cached information for {tax_topic} not yet implemented",
                    "topic": tax_topic,
                    "year": year,
                    "source": "cache",
                }
    
        except Exception as e:
            await ctx.error(f"Failed to get cached tax information: {e}")
            return {
                "status": "error",
                "message": f"Error retrieving cached information: {str(e)}",
                "topic": tax_topic,
                "year": year,
            }
  • MCP tool registration for get_cached_tax_info.
    @mcp.tool(
        name="get_cached_tax_info",
        description="Get cached tax information when web scraping fails",
    )
  • Helper method in ImpotsScraper class that provides fallback tax bracket data from TAX_BRACKETS constant, selecting the closest available year.
    def _get_fallback_brackets(self, year: int) -> List[Dict]:
        """Get fallback tax brackets for a specific year.
    
        Args:
            year: Tax year
    
        Returns:
            List of dictionaries containing tax brackets
        """
        # Use the closest year we have data for
        available_years = sorted(TAX_BRACKETS.keys())
        if year in TAX_BRACKETS:
            return TAX_BRACKETS[year]
        elif year < available_years[0]:
            return TAX_BRACKETS[available_years[0]]
        else:
            return TAX_BRACKETS[available_years[-1]]
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 mentions the tool retrieves 'cached' data as a fallback, which implies read-only behavior and potential staleness, but doesn't detail what 'cached' entails (e.g., freshness, source, update frequency), error handling, or performance traits. For a tool with no annotation coverage, this leaves significant gaps in understanding its operational behavior.

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 that front-loads the core purpose and context without unnecessary words. Every part ('Get cached tax information when web scraping fails') earns its place by clarifying the tool's role and usage scenario.

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 has an output schema (which handles return values), no annotations, and low schema coverage, the description is minimally adequate. It explains the tool's purpose and fallback context but lacks details on parameters, caching behavior, and error cases. For a retrieval tool with output schema support, it meets a basic threshold but could be more informative.

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 schema provides no parameter details. The description adds no information about the parameters ('tax_topic' and 'year'), such as what constitutes a valid tax topic, how the year affects retrieval, or examples. With 2 parameters and zero coverage, the description fails to compensate, leaving semantics unclear.

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 tool's purpose: 'Get cached tax information when web scraping fails.' It specifies the verb ('Get'), resource ('cached tax information'), and context ('when web scraping fails'), which distinguishes it from siblings like 'get_tax_info_from_web' that likely fetch live data. However, it doesn't explicitly differentiate from other caching or retrieval tools beyond the context hint.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: 'when web scraping fails,' implying it's a fallback mechanism. This distinguishes it from 'get_tax_info_from_web' (for live scraping) and other tax info tools. However, it doesn't specify when NOT to use it (e.g., if cached data is stale) or name explicit alternatives beyond the implied sibling.

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