Skip to main content
Glama
saidsurucu

Mevzuat MCP

by saidsurucu

get_mevzuat_gerekce

Fetch the legislative rationale (gerekçe) for Turkish laws, including purpose, committee reports, and article justifications, using a gerekce ID from search results.

Instructions

Retrieve the law rationale (gerekçe / kanun gerekçesi) from bedesten.adalet.gov.tr.

The gerekçe contains:

  • Purpose and reasoning behind the law (kanunun amacı ve gerekçesi)

  • Parliamentary committee reports (komisyon raporları)

  • Article-by-article justifications (madde gerekçeleri)

Only available for KANUN type legislation that has a published rationale. Not all laws have a gerekçe — check if gerekceId is present in search_mevzuat results.

Workflow: search_mevzuat → check gerekceId in results → get_mevzuat_gerekce(gerekceId)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gerekce_idYesGerekçe ID from search_mevzuat results (gerekceId field, e.g., '2049'). Only available for laws (KANUN) that have a published rationale. Check if gerekceId exists in search_mevzuat results before calling.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The 'get_mevzuat_gerekce' tool handler function. This is the FastMCP tool registered with @app.tool() decorator. It takes gerekce_id as input, calls bedesten_client.get_gerekce_content(), strips HTML from the result, and returns plain text rationale content.
    @app.tool()
    async def get_mevzuat_gerekce(
        gerekce_id: str = Field(
            ...,
            description=(
                "Gerekçe ID from search_mevzuat results (gerekceId field, e.g., '2049'). "
                "Only available for laws (KANUN) that have a published rationale. "
                "Check if gerekceId exists in search_mevzuat results before calling."
            ),
        ),
    ) -> str:
        """
        Retrieve the law rationale (gerekçe / kanun gerekçesi) from bedesten.adalet.gov.tr.
    
        The gerekçe contains:
        - Purpose and reasoning behind the law (kanunun amacı ve gerekçesi)
        - Parliamentary committee reports (komisyon raporları)
        - Article-by-article justifications (madde gerekçeleri)
    
        Only available for KANUN type legislation that has a published rationale.
        Not all laws have a gerekçe — check if gerekceId is present in search_mevzuat results.
    
        Workflow: search_mevzuat → check gerekceId in results → get_mevzuat_gerekce(gerekceId)
        """
        try:
            result = await bedesten_client.get_gerekce_content(gerekce_id)
            if result.error_message:
                return f"Error fetching gerekçe: {result.error_message}"
            if not result.content:
                return f"Error: No gerekçe content found for gerekceId {gerekce_id}"
    
            plain = _strip_html(result.content)
            if not plain:
                return f"Error: Gerekçe content is empty for gerekceId {gerekce_id}"
    
            return plain
        except Exception as e:
            logger.exception("Error in get_mevzuat_gerekce")
            return f"An unexpected error occurred: {str(e)}"
  • The tool is registered via @app.tool() decorator on the get_mevzuat_gerekce async function. The schema/input definition is via Field() for the gerekce_id parameter.
    async def get_mevzuat_gerekce(
        gerekce_id: str = Field(
            ...,
            description=(
                "Gerekçe ID from search_mevzuat results (gerekceId field, e.g., '2049'). "
                "Only available for laws (KANUN) that have a published rationale. "
                "Check if gerekceId exists in search_mevzuat results before calling."
            ),
        ),
    ) -> str:
        """
        Retrieve the law rationale (gerekçe / kanun gerekçesi) from bedesten.adalet.gov.tr.
    
        The gerekçe contains:
        - Purpose and reasoning behind the law (kanunun amacı ve gerekçesi)
        - Parliamentary committee reports (komisyon raporları)
        - Article-by-article justifications (madde gerekçeleri)
    
        Only available for KANUN type legislation that has a published rationale.
        Not all laws have a gerekçe — check if gerekceId is present in search_mevzuat results.
    
        Workflow: search_mevzuat → check gerekceId in results → get_mevzuat_gerekce(gerekceId)
        """
  • The BedestenClient.get_gerekce_content() method that actually calls the bedesten.adalet.gov.tr API endpoint /getGerekceContent. It handles caching, base64 decoding, and returns BedGerekceContent.
    async def get_gerekce_content(
        self,
        gerekce_id: str,
    ) -> BedGerekceContent:
        """Fetch law rationale content."""
        cache_key = f"gerekce_{gerekce_id}"
        cached = self._get_cached(cache_key)
        if cached:
            return cached
    
        inner = {"gerekceId": gerekce_id}
        try:
            resp = await self._client.post("/getGerekceContent", json=_wrap(inner))
            resp.raise_for_status()
            body = resp.json()
    
            meta = body.get("metadata", {})
            if meta.get("FMTY") != "SUCCESS":
                return BedGerekceContent(error_message=meta.get("FMTE", "Unknown error"))
    
            data = body.get("data") or {}
            raw = data.get("content", "")
            mime = data.get("mimetype", data.get("mimeType", "text/html"))
            decoded = _decode_base64(raw)
    
            result = BedGerekceContent(
                gerekce_id=data.get("gerekceId"),
                mevzuat_id=data.get("mevzuatId"),
                content=decoded,
                mime_type=mime,
            )
            self._put_cached(cache_key, result)
            return result
        except Exception as e:
            logger.exception("bedesten get_gerekce_content error")
            return BedGerekceContent(error_message=str(e))
  • The BedGerekceContent model defining the response schema with fields: gerekce_id, mevzuat_id, content (decoded HTML/text), mime_type, error_message.
    class BedGerekceContent(BaseModel):
        """Law rationale (gerekçe) content."""
        gerekce_id: Optional[str] = None
        mevzuat_id: Optional[str] = None
        content: str = ""  # decoded HTML/text
        mime_type: Optional[str] = None
        error_message: Optional[str] = None
  • The BedMevzuatDocument model includes gerekce_id field (line 41) which indicates whether a law has a published rationale that can be retrieved via get_mevzuat_gerekce.
    class BedMevzuatDocument(BaseModel):
        """A legislation document from search results."""
        mevzuat_id: str = Field(..., alias="mevzuatId")
        mevzuat_no: Any = Field(..., alias="mevzuatNo")  # can be int or str
        mevzuat_adi: str = Field(..., alias="mevzuatAdi")
        mevzuat_tur: Optional[Any] = Field(None, alias="mevzuatTur")
        mevzuat_tertip: Optional[Any] = Field(None, alias="mevzuatTertip")
        gerekce_id: Optional[str] = Field(None, alias="gerekceId")
        ekler: Optional[List[str]] = None
        resmi_gazete_tarihi: Optional[str] = Field(None, alias="resmiGazeteTarihi")
        resmi_gazete_sayisi: Optional[str] = Field(None, alias="resmiGazeteSayisi")
        url: Optional[str] = None
        mukerrer: Optional[str] = None
    
        model_config = {"populate_by_name": True}
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description discloses the data source (bedesten.adalet.gov.tr), the content structure, and the condition that not all laws have a gerekçe. However, it does not mention network dependency, authentication needs, or read-only nature. Still, the provided information is useful and honest.

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 concise and well-structured: a clear action line, bullet points for content, and two lines for constraints. It front-loads the core purpose and uses efficient formatting without waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the single parameter and the presence of an output schema, the description covers all necessary context: what the tool does, what content it returns, prerequisite conditions, and the workflow. It is fully adequate for an agent to use correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema already has 100% coverage with a detailed description for gerekce_id. The tool description reiterates the prerequisite but does not add new semantic information beyond what the schema provides, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool retrieves law rationale (gerekçe) and lists specific content types (purpose, committee reports, article justifications). It distinguishes from siblings by limiting to KANUN type legislation and referencing search_mevzuat as a prerequisite.

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

Usage Guidelines5/5

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

The description explicitly states the tool is only for KANUN laws with published rationale, advises checking gerekceId in search_mevzuat results, and provides a clear workflow: search → check → call. This gives excellent when-to-use and when-not-to-use guidance.

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/saidsurucu/mevzuat-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server