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

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]]

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