Skip to main content
Glama

search_tax_law

Search French tax law articles on legifrance.gouv.fr to find specific regulations and legal provisions for tax compliance.

Instructions

Search for tax law articles on legifrance.gouv.fr

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
ctxNo

Implementation Reference

  • Registration of the MCP tool named 'search_tax_law' using the @mcp.tool decorator.
    @mcp.tool( name="search_tax_law", description="Search for tax law articles on legifrance.gouv.fr", )
  • MCP tool handler wrapper for 'search_tax_law'. Logs the query using context and delegates execution to the imported 'search_tax_law' function from legal_scraper, handles exceptions.
    async def search_tax_law_wrapper( query: str, ctx: Optional[Context] = None, ) -> Optional[Dict]: """Search for tax law articles on legifrance.gouv.fr. Args: query: Search query ctx: MCP context for logging Returns: Dict: Dictionary containing search results """ try: if ctx: await ctx.info(f"Searching tax law for: {query}") result = await search_tax_law(query) return result except Exception as e: if ctx: await ctx.error(f"Failed to search tax law: {e}") return { "status": "error", "message": f"Error searching tax law: {str(e)}", }
  • Core handler implementation within LegalScraper class. Builds a comprehensive Legifrance search URL targeting French tax codes (CGI etc.), scrapes the page, extracts results using BeautifulSoup, formats success/error responses.
    async def search_tax_law(self, query: str) -> Dict: """Search for tax law articles on legifrance.gouv.fr. Args: query: Search query Returns: Dictionary containing search results """ logger.info(f"Searching for tax law articles with query: {query}") try: # Construct search URL with comprehensive parameters for tax code articles # This includes all article types (L, R, T, A, D, M, V, etc.) and specific tax codes # Build URL parameters base_params = ( f"query={query}&corpus=CODES&typePagination=DEFAUT&pageSize=10&page=1" "&tab_selection=code&searchField=ALL&searchType=ALL" ) # Article scope parameters (all types: L, R, T, A, D, M, V, etc.) article_scopes = [ "CODE_ARTICLE", "CODE_ARTICLE_C", "CODE_ARTICLE_L", "CODE_ARTICLE_R", "CODE_ARTICLE_T", "CODE_ARTICLE_A", "CODE_ARTICLE_D", "CODE_ARTICLE_M", "CODE_ARTICLE_V", "CODE_ARTICLE_LO", "CODE_ARTICLE_LP", "CODE_ARTICLE_LR", "CODE_ARTICLE_LD", "CODE_ARTICLE_LM", "CODE_ARTICLE_LV", "CODE_ARTICLE_RO", "CODE_ARTICLE_RP", "CODE_ARTICLE_RR", "CODE_ARTICLE_RD", "CODE_ARTICLE_RM", "CODE_ARTICLE_RV", "CODE_ARTICLE_TO", "CODE_ARTICLE_TP", "CODE_ARTICLE_TR", "CODE_ARTICLE_TD", "CODE_ARTICLE_TM", "CODE_ARTICLE_TV", "CODE_ARTICLE_AO", "CODE_ARTICLE_AP", "CODE_ARTICLE_AR", "CODE_ARTICLE_AD", "CODE_ARTICLE_AM", "CODE_ARTICLE_AV", "CODE_ARTICLE_DO", "CODE_ARTICLE_DP", "CODE_ARTICLE_DR", "CODE_ARTICLE_DD", "CODE_ARTICLE_DM", "CODE_ARTICLE_DV", "CODE_ARTICLE_MO", "CODE_ARTICLE_MP", "CODE_ARTICLE_MR", "CODE_ARTICLE_MD", "CODE_ARTICLE_MM", "CODE_ARTICLE_MV", "CODE_ARTICLE_VO", "CODE_ARTICLE_VP", "CODE_ARTICLE_VR", "CODE_ARTICLE_VD", "CODE_ARTICLE_VM", "CODE_ARTICLE_VV", ] scope_params = "&".join([f"searchScope={scope}" for scope in article_scopes]) # Code parameters codes = [ "CGIAN2", "CGIAN3", "CGIAN4", "CGICT", "CGILEGIARTI000006308740", "CGIPENAL", "CGISUBDIV", "CGITM", "LEGITEXT000006069577", ] code_params = "&".join([f"code={code}" for code in codes]) url = f"{SEARCH_URL}/code?{base_params}&{scope_params}&{code_params}" # Get the page response = await self.get_page(url) # Parse HTML soup = self.parse_html(response.text) # Extract search results search_results = self._extract_search_results(soup) return self.format_result( status="success", data={ "query": query, "results": search_results, }, message=f"Successfully searched for tax law articles with query: {query}", source_url=f"{BASE_URL}{url}", ) except Exception as e: logger.error(f"Error searching tax law: {e}") return self.format_result( status="error", message=f"Failed to search tax law: {str(e)}", data={"query": query}, error=e, )
  • Top-level helper function that delegates to the singleton LegalScraper instance's search_tax_law method. This is the entry point imported and called by the server.py wrapper.
    async def search_tax_law(query: str) -> Dict: """Search for tax law articles on legifrance.gouv.fr. Args: query: Search query Returns: Dictionary containing search results """ return await legal_scraper.search_tax_law(query)
  • Singleton instance of LegalScraper used by top-level helper functions.
    legal_scraper = LegalScraper()

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