Skip to main content
Glama

get_tax_deadlines

Retrieve official French tax deadlines for income tax filing and payment from service-public.fr to ensure timely compliance with tax obligations.

Instructions

Get tax deadlines from service-public.fr

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ctxNo
yearNo

Implementation Reference

  • Core handler implementation in ServicePublicScraper class: fetches the deadlines page, parses HTML, extracts deadlines using helper method, formats success/error response.
    async def get_tax_deadlines(self, year: Optional[int] = None) -> Dict: """Scrape tax deadlines from service-public.fr. Args: year: The tax year to retrieve deadlines for. Defaults to current year. Returns: Dictionary containing tax deadlines """ # Set default year to current year if not specified current_year = datetime.now().year tax_year = year or current_year logger.info(f"Scraping tax deadlines for year {tax_year}") try: # Get the page response = await self.get_page(DEADLINES_URL) # Parse HTML soup = self.parse_html(response.text) # Extract deadlines deadlines = self._extract_deadlines(soup, tax_year) return self.format_result( status="success", data={ "year": tax_year, "deadlines": deadlines, }, message=f"Successfully retrieved tax deadlines for {tax_year}", source_url=f"{BASE_URL}{DEADLINES_URL}", ) except Exception as e: logger.error(f"Error scraping tax deadlines: {e}") return self.format_result( status="error", message=f"Failed to retrieve tax deadlines: {str(e)}", data={"year": tax_year}, error=e, )
  • MCP tool registration via @mcp.tool decorator and wrapper function that handles context logging and delegates to the scraper implementation.
    @mcp.tool( name="get_tax_deadlines", description="Get tax deadlines from service-public.fr", ) async def get_tax_deadlines_wrapper( year: Optional[int] = None, ctx: Optional[Context] = None, ) -> Optional[Dict]: """Get tax deadlines from service-public.fr. Args: year: The tax year to retrieve deadlines for (defaults to current year) ctx: MCP context for logging Returns: Dict: Dictionary containing tax deadlines """ try: if ctx: await ctx.info(f"Getting tax deadlines for year {year or 'current'}") from french_tax_mcp.scrapers.service_public_scraper import get_tax_deadlines result = await get_tax_deadlines(year) return result except Exception as e: if ctx: await ctx.error(f"Failed to get tax deadlines: {e}") return { "status": "error", "message": f"Error getting tax deadlines: {str(e)}", }
  • Top-level helper function that delegates to the singleton ServicePublicScraper instance method.
    async def get_tax_deadlines(year: Optional[int] = None) -> Dict: """Scrape tax deadlines from service-public.fr. Args: year: The tax year to retrieve deadlines for. Defaults to current year. Returns: Dictionary containing tax deadlines """ return await service_public_scraper.get_tax_deadlines(year)
  • Key helper method that parses HTML tables and lists to extract deadline dates and descriptions for the specified year, handling French month names.
    def _extract_deadlines(self, soup: BeautifulSoup, year: int) -> List[Dict]: """Extract tax deadlines from HTML. Args: soup: BeautifulSoup object year: Tax year Returns: List of dictionaries containing deadline information """ deadlines = [] # Look for tables containing deadlines tables = soup.find_all("table") for table in tables: # Check if this table contains deadlines table_text = table.get_text().lower() if "date" in table_text and str(year) in table_text: rows = table.find_all("tr") # Skip header row for row in rows[1:]: cells = row.find_all("td") if len(cells) >= 2: # Extract deadline information date_cell = cells[0].get_text().strip() description_cell = cells[1].get_text().strip() # Parse date date_match = re.search(r"(\d{1,2})\s+(\w+)\s+(\d{4})", date_cell) if date_match: day = date_match.group(1) month = self._parse_french_month(date_match.group(2)) year = date_match.group(3) deadlines.append( { "date": f"{year}-{month:02d}-{int(day):02d}", "description": description_cell, } ) # If no deadlines found in tables, look for lists if not deadlines: for list_element in soup.find_all(["ul", "ol"]): list_text = list_element.get_text().lower() if "date" in list_text and str(year) in list_text: for item in list_element.find_all("li"): item_text = item.get_text().strip() # Look for date patterns date_match = re.search(r"(\d{1,2})\s+(\w+)\s+(\d{4})", item_text) if date_match: day = date_match.group(1) month = self._parse_french_month(date_match.group(2)) year = date_match.group(3) # Extract description (text after the date) description = item_text[date_match.end() :].strip() if not description: description = item_text deadlines.append( { "date": f"{year}-{month:02d}-{int(day):02d}", "description": description, } ) return deadlines
  • Helper utility to convert French month names to numeric months using FRENCH_MONTHS constant.
    def _parse_french_month(self, month_name: str) -> int: """Parse a French month name to a month number. Args: month_name: French month name Returns: Month number (1-12) """ month_name = month_name.lower() # Find the closest match for french_month, month_num in FRENCH_MONTHS.items(): if french_month in month_name: return month_num # Default to January if no match found return 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