get_act_relationships
Analyze legal relationships and references for Polish acts to identify amendments, citations, and connections between legal documents.
Instructions
Analyze legal relationships and references for an act. Shows which acts it amends, references, or is referenced by.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| publisher | Yes | Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski) | |
| year | Yes | Publication year | |
| num | Yes | Act number/position within the year |
Implementation Reference
- app.py:637-682 (handler)The handler function (named get_act_references) that implements the core logic for the 'get_act_relationships' tool. It fetches legal relationships and references from the Sejm API endpoint /eli/acts/{publisher}/{year}/{num}/references.def get_act_references( publisher: Annotated[str, "Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski)"], year: Annotated[int, "Publication year"], num: Annotated[Union[int, str], "Act number/position within the year"] ) -> dict: """Fetches references to/from a specific legal act (acts that reference this act or are referenced by this act). Analyzes the legal relationships and dependencies of a specific act, showing which acts it amends, references, or is referenced by. This helps understand the legal context and impact of the document within the broader legal framework. Args: publisher: Publication code (e.g., 'DU' for Dziennik Ustaw, 'MP' for Monitor Polski). year: Year of publication as integer. num: Act number/position within the year as integer or string. Returns: dict: Dictionary organized by reference types (e.g., 'Akty zmienione', 'Akty uchylone') with arrays of referenced acts and their relationship details. Returns empty dict if no references found or error occurs. Examples: User asks: "What acts reference DU/2020/1?": Parameters: publisher = 'DU', year = 2020, num = 1 Returns: {'Akty zmienione': [{'act': {'ELI': 'DU/2016/1498', ...}, 'date': '2020-01-17'}], ...} User asks: "Show me references for act MP/2023/25": Parameters: publisher = 'MP', year = 2023, num = 25 User asks: "What laws does DU/2019/50 reference?": Parameters: publisher = 'DU', year = 2019, num = 50 User asks: "Find acts that amended DU/2022/100": Parameters: publisher = 'DU', year = 2022, num = 100 User asks: "What is the legal basis for act DU/2021/75?": Parameters: publisher = 'DU', year = 2021, num = 75 """ logger.debug(f"get_act_references called with: publisher={publisher}, year={year}, num={num}") try: url = f"https://api.sejm.gov.pl/eli/acts/{publisher}/{year}/{num}/references" response = requests.get(url, headers={"Accept": "application/json"}) response.raise_for_status() data = response.json() logger.info(f"get_act_references retrieved references for act: {publisher}/{year}/{num}") return data except Exception as e: logger.error(f"Error: {e}") return {}
- app.py:632-636 (registration)The @app.tool decorator that registers the handler function as the MCP tool named 'get_act_relationships' with description and tags.@app.tool( name="get_act_relationships", description="Analyze legal relationships and references for an act. Shows which acts it amends, references, or is referenced by.", tags={"analysis", "references", "relationships", "legal-network"} )
- app.py:638-641 (schema)Input schema defined by type annotations with descriptions for publisher (str), year (int), num (Union[int,str]), output dict.publisher: Annotated[str, "Publisher code (DU for Dziennik Ustaw, MP for Monitor Polski)"], year: Annotated[int, "Publication year"], num: Annotated[Union[int, str], "Act number/position within the year"] ) -> dict: