Skip to main content
Glama
saidsurucu

Mevzuat MCP

by saidsurucu

search_cbbaskankarar

Search Turkish Presidential Decisions by title or content using Boolean operators, exact phrases, and date filters to find executive decisions issued by Turkey's President.

Instructions

Search for Turkish Presidential Decisions (Cumhurbaşkanı Kararı) in both titles and content.

This tool searches in Presidential Decision titles and full text content. Presidential Decisions are executive decisions issued by the President of Turkey (different from Presidential Decrees/Kararnamesi).

Query Syntax:

  • Simple keyword: atama

  • Boolean AND: atama AND tayin (both terms)

  • Boolean OR: atama OR görevden (at least one term)

  • Boolean NOT: atama NOT görevden (first yes, second no)

  • Required term: +atama +tayin (similar to AND)

  • Grouping: (atama OR tayin) AND görev

  • Exact phrase: "görevden alma" (or use tam_cumle=true)

  • Empty search: List all decisions (use date filters)

Returns:

  • Decision number, title, and publication date

  • Official Gazette publication date and issue number

  • URLs for viewing online (PDF format)

Example queries:

  • "atama tayin" - Find decisions about appointments

  • Leave empty with dates to list all decisions from a period

  • "görevden AND alma" - Decisions about dismissals

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
aranacak_ifadeNoSearch query with optional Boolean operators: simple word (organize), AND (organize AND suç), OR (suç OR ceza), NOT (organize NOT terör), + for required (+term), grouping with (), exact phrase with quotes ("organize suç"). Leave empty to list all decrees.
tam_cumleNoExact phrase match (true) or any word match (false, default). Set to true when searching for exact phrases.
baslangic_tarihiNoStart year for filtering results (format: YYYY, e.g., '2018')
bitis_tarihiNoEnd year for filtering results (format: YYYY, e.g., '2024')
page_numberNoPage number for pagination (starts at 1)
page_sizeNoNumber of results per page (1-100)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
documentsYes
page_sizeYes
query_usedYes
total_pagesYes
current_pageYes
error_messageNo
total_resultsYes

Implementation Reference

  • The main handler and registration for the 'search_cbbaskankarar' tool using @app.tool(). It constructs a MevzuatSearchRequestNew with mevzuat_tur='Cumhurbaşkanı Kararı' and delegates the search to mevzuat_client.search_documents, handling errors and logging.
    async def search_cbbaskankarar(
        aranacak_ifade: Optional[str] = Field(
            None,
            description='Search query with optional Boolean operators: simple word (organize), AND (organize AND suç), OR (suç OR ceza), NOT (organize NOT terör), + for required (+term), grouping with (), exact phrase with quotes ("organize suç"). Leave empty to list all decrees.'
        ),
        tam_cumle: bool = Field(
            False,
            description="Exact phrase match (true) or any word match (false, default). Set to true when searching for exact phrases."
        ),
        baslangic_tarihi: Optional[str] = Field(
            None,
            description="Start year for filtering results (format: YYYY, e.g., '2018')"
        ),
        bitis_tarihi: Optional[str] = Field(
            None,
            description="End year for filtering results (format: YYYY, e.g., '2024')"
        ),
        page_number: int = Field(
            1,
            ge=1,
            description="Page number for pagination (starts at 1)"
        ),
        page_size: int = Field(
            25,
            ge=1,
            le=100,
            description="Number of results per page (1-100)"
        )
    ) -> MevzuatSearchResultNew:
        """
        Search for Turkish Presidential Decisions (Cumhurbaşkanı Kararı) in both titles and content.
    
        This tool searches in Presidential Decision titles and full text content.
        Presidential Decisions are executive decisions issued by the President of Turkey (different from Presidential Decrees/Kararnamesi).
    
        Query Syntax:
        - Simple keyword: atama
        - Boolean AND: atama AND tayin (both terms)
        - Boolean OR: atama OR görevden (at least one term)
        - Boolean NOT: atama NOT görevden (first yes, second no)
        - Required term: +atama +tayin (similar to AND)
        - Grouping: (atama OR tayin) AND görev
        - Exact phrase: "görevden alma" (or use tam_cumle=true)
        - Empty search: List all decisions (use date filters)
    
        Returns:
        - Decision number, title, and publication date
        - Official Gazette publication date and issue number
        - URLs for viewing online (PDF format)
    
        Example queries:
        - "atama tayin" - Find decisions about appointments
        - Leave empty with dates to list all decisions from a period
        - "görevden AND alma" - Decisions about dismissals
        """
        search_req = MevzuatSearchRequestNew(
            mevzuat_tur="Cumhurbaşkanı Kararı",
            aranacak_ifade=aranacak_ifade or "",
            aranacak_yer=1,  # Search in titles and content
            tam_cumle=tam_cumle,
            mevzuat_no=None,
            baslangic_tarihi=baslangic_tarihi,
            bitis_tarihi=bitis_tarihi,
            page_number=page_number,
            page_size=page_size
        )
    
        log_params = search_req.model_dump(exclude_defaults=True)
        logger.info(f"Tool 'search_cbbaskankarar' called with parameters: {log_params}")
    
        try:
            result = await mevzuat_client.search_documents(search_req)
    
            if not result.documents and not result.error_message:
                result.error_message = "No Presidential Decisions found matching the specified criteria."
    
            return result
    
        except Exception as e:
            logger.exception("Error in tool 'search_cbbaskankarar'")
            return MevzuatSearchResultNew(
                documents=[],
                total_results=0,
                current_page=page_number,
                page_size=page_size,
                total_pages=0,
                query_used=log_params,
                error_message=f"An unexpected error occurred: {str(e)}"
            )
  • Output schema: MevzuatSearchResultNew model defining the structure of search results returned by the tool.
    class MevzuatSearchResultNew(BaseModel):
        """Model for search results from mevzuat.gov.tr"""
    
        documents: List[MevzuatDocumentNew]
        total_results: int
        current_page: int
        page_size: int
        total_pages: int
        query_used: Dict[str, Any]
        error_message: Optional[str] = None
  • Input schema components: MevzuatSearchRequestNew model used internally by the tool for API requests. Tool parameters map directly to this model.
    class MevzuatSearchRequestNew(BaseModel):
        """Request model for searching legislation on mevzuat.gov.tr"""
    
        mevzuat_tur: MevzuatTurLiteral = Field(
            "Kanun",
            description="Type of legislation. Currently only 'Kanun' (laws) are fully supported for content extraction."
        )
    
        aranacak_ifade: Optional[str] = Field(
            None,
            description="Search term or phrase to look for in legislation"
        )
    
        aranacak_yer: int = Field(
            3,
            ge=1,
            le=3,
            description="Where to search: 1=Title only, 2=Article titles, 3=Full text (default)"
        )
    
        tam_cumle: bool = Field(
            False,
            description="Exact phrase match (true) or any word match (false, default)"
        )
    
        mevzuat_no: Optional[str] = Field(
            None,
            description="Specific legislation number to search for"
        )
    
        baslangic_tarihi: Optional[str] = Field(
            None,
            description="Start date for filtering (format: DD.MM.YYYY)"
        )
    
        bitis_tarihi: Optional[str] = Field(
            None,
            description="End date for filtering (format: DD.MM.YYYY)"
        )
    
        page_number: int = Field(
            1,
            ge=1,
            description="Page number of results"
        )
    
        page_size: int = Field(
            10,
            ge=1,
            le=100,
            description="Number of results per page"
        )
  • Core helper method implementing the search logic: search_documents in MevzuatApiClientNew. Makes authenticated POST request to mevzuat.gov.tr API, parses JSON response into documents.
    async def search_documents(self, request: MevzuatSearchRequestNew) -> MevzuatSearchResultNew:
        """Search for legislation documents using httpx with Playwright cookies."""
        # Get session/cookies with Playwright first
        await self._ensure_session()
    
        # If session establishment failed, fallback to full Playwright method
        if not self._antiforgery_token and not self._cookies:
            logger.warning("Session establishment failed, using full Playwright search method as fallback")
            return await self.search_documents_with_playwright(request)
    
        # Build DataTables compatible payload
        # Normalize mevzuat type for API
        mevzuat_tur_api = self._normalize_mevzuat_tur_for_api(request.mevzuat_tur)
    
        payload = {
            "draw": 1,
            "columns": [
                {"data": None, "name": "", "searchable": True, "orderable": False, "search": {"value": "", "regex": False}},
                {"data": None, "name": "", "searchable": True, "orderable": False, "search": {"value": "", "regex": False}},
                {"data": None, "name": "", "searchable": True, "orderable": False, "search": {"value": "", "regex": False}}
            ],
            "order": [],
            "start": (request.page_number - 1) * request.page_size,
            "length": request.page_size,
            "search": {"value": "", "regex": False},
            "parameters": {
                "MevzuatTur": mevzuat_tur_api,
                "YonetmelikMevzuatTur": "OsmanliKanunu",  # Required for all searches
                "AranacakIfade": request.aranacak_ifade or "",
                "TamCumle": "true" if request.tam_cumle else "false",
                "AranacakYer": str(request.aranacak_yer),
                "MevzuatNo": request.mevzuat_no or "",
                "KurumId": "0",
                "AltKurumId": "0",
                "BaslangicTarihi": request.baslangic_tarihi or "",
                "BitisTarihi": request.bitis_tarihi or "",
                "antiforgerytoken": self._antiforgery_token or ""
            }
        }
    
        try:
            # Log payload for debugging
            logger.debug(f"Search payload: {payload}")
    
            # Make request with cookies properly
            response = await self._http_client.post(
                self.SEARCH_ENDPOINT,
                json=payload,
                cookies=self._cookies if self._cookies else None
            )
    
            # Log response for debugging
            if response.status_code != 200:
                logger.error(f"Search API error {response.status_code}: {response.text[:500]}")
    
            response.raise_for_status()
            data = response.json()
    
            total_results = data.get("recordsTotal", 0)
            documents = []
    
            for item in data.get("data", []):
                doc = MevzuatDocumentNew(
                    mevzuat_no=item.get("mevzuatNo", ""),
                    mev_adi=item.get("mevAdi", ""),
                    kabul_tarih=item.get("kabulTarih", ""),
                    resmi_gazete_tarihi=item.get("resmiGazeteTarihi", ""),
                    resmi_gazete_sayisi=item.get("resmiGazeteSayisi", ""),
                    mevzuat_tertip=item.get("mevzuatTertip", ""),
                    mevzuat_tur=item.get("tur", 1),
                    url=item.get("url", "")
                )
                documents.append(doc)
    
            return MevzuatSearchResultNew(
                documents=documents,
                total_results=total_results,
                current_page=request.page_number,
                page_size=request.page_size,
                total_pages=(total_results + request.page_size - 1) // request.page_size if request.page_size > 0 else 0,
                query_used=request.model_dump()
            )
    
        except httpx.HTTPStatusError as e:
            logger.error(f"Search request failed: {e.response.status_code}")
            return MevzuatSearchResultNew(
                documents=[],
                total_results=0,
                current_page=request.page_number,
                page_size=request.page_size,
                total_pages=0,
                query_used=request.model_dump(),
                error_message=f"API request failed: {e.response.status_code}"
            )
        except Exception as e:
            logger.exception("Unexpected error during search")
            return MevzuatSearchResultNew(
                documents=[],
                total_results=0,
                current_page=request.page_number,
                page_size=request.page_size,
                total_pages=0,
                query_used=request.model_dump(),
                error_message=f"An unexpected error occurred: {e}"
            )
Behavior4/5

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

With no annotations provided, the description carries the full burden and does well by detailing the return format (decision number, title, publication date, Gazette info, URLs), pagination behavior (implied via page_number and page_size parameters), and search capabilities (Boolean operators, exact phrase matching). It also clarifies that results include PDF URLs, adding useful context beyond the input schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (purpose, syntax, returns, examples) and front-loaded key information. It is appropriately sized for a search tool with complex parameters, though it could be slightly more concise by integrating some details more tightly without losing clarity.

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 tool's complexity (6 parameters, no annotations, but with an output schema), the description is highly complete. It covers purpose, usage, behavioral details (returns, pagination), parameter semantics with examples, and contextualizes the tool within the domain. The presence of an output schema means the description doesn't need to detail return values, and it effectively compensates for the lack of annotations.

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

Parameters4/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds significant value by explaining query syntax with examples (e.g., Boolean operators, exact phrases), clarifying that an empty search lists all decisions with date filters, and providing example queries that illustrate parameter usage, enhancing understanding beyond the schema's technical descriptions.

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 searches for 'Turkish Presidential Decisions (Cumhurbaşkanı Kararı) in both titles and content,' specifying both the resource type and search scope. It distinguishes this from Presidential Decrees/Kararnamesi, helping differentiate it from sibling tools like search_cbk or search_khk that search different document types.

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

Usage Guidelines4/5

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

The description provides clear context by explaining what Presidential Decisions are and when to use this tool (for searching these specific documents). It mentions that leaving the search query empty with date filters lists all decisions, but it does not explicitly state when to choose this tool over alternatives like search_within_cbk or other sibling search tools for different document types.

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