Skip to main content
Glama
saidsurucu

Yargı MCP

by saidsurucu

get_sayistay_document_unified

Read-onlyIdempotent

Retrieve full-text audit decisions from Sayıştay in clean Markdown format using decision ID and type for legal research and analysis.

Instructions

Use this when retrieving full text of a Sayıştay audit decision. Returns clean Markdown format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
decision_idYesDecision ID from search_sayistay_unified results
decision_typeYesDecision type: genel_kurul, temyiz_kurulu, or daire

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that provides unified access to Sayistay decision documents across all decision types (genel_kurul, temyiz_kurulu, daire) by calling the underlying client and returning structured Markdown output.
    async def get_document_unified(self, decision_id: str, decision_type: str) -> SayistayUnifiedDocumentMarkdown:
        """Unified document retrieval for all Sayıştay decision types."""
        
        # Use existing client method (decision_type is already a string)
        result = await self.client.get_document_as_markdown(decision_id, decision_type)
        
        return SayistayUnifiedDocumentMarkdown(
            decision_type=decision_type,
            decision_id=result.decision_id,
            source_url=result.source_url,
            document_data=result.model_dump(),
            markdown_content=result.markdown_content,
            error_message=result.error_message
        )
  • Core helper method in SayistayApiClient that performs the actual HTTP request to fetch decision document HTML, converts it to Markdown using MarkItDown, and handles session management, CSRF, and errors.
    async def get_document_as_markdown(self, decision_id: str, decision_type: str) -> SayistayDocumentMarkdown:
        """
        Retrieve full text of a Sayıştay decision and convert to Markdown.
        
        Args:
            decision_id: Unique decision identifier
            decision_type: Type of decision ('genel_kurul', 'temyiz_kurulu', 'daire')
            
        Returns:
            SayistayDocumentMarkdown with converted content
        """
        logger.info(f"Retrieving document for {decision_type} decision ID: {decision_id}")
        
        # Validate decision_id
        if not decision_id or not decision_id.strip():
            return SayistayDocumentMarkdown(
                decision_id=decision_id,
                decision_type=decision_type,
                source_url="",
                markdown_content=None,
                error_message="Decision ID cannot be empty"
            )
        
        # Map decision type to URL path
        url_path_mapping = {
            'genel_kurul': 'KararlarGenelKurul',
            'temyiz_kurulu': 'KararlarTemyiz',
            'daire': 'KararlarDaire'
        }
        
        if decision_type not in url_path_mapping:
            return SayistayDocumentMarkdown(
                decision_id=decision_id,
                decision_type=decision_type,
                source_url="",
                markdown_content=None,
                error_message=f"Invalid decision type: {decision_type}. Must be one of: {list(url_path_mapping.keys())}"
            )
        
        # Build document URL
        url_path = url_path_mapping[decision_type]
        document_url = f"{self.BASE_URL}/{url_path}/Detay/{decision_id}/"
        
        try:
            # Make HTTP GET request to document URL
            headers = {
                "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
                "Accept-Language": "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7",
                "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
                "Sec-Fetch-Dest": "document",
                "Sec-Fetch-Mode": "navigate",
                "Sec-Fetch-Site": "same-origin"
            }
            
            # Include session cookies if available
            if self.session_cookies:
                cookie_header = "; ".join([f"{k}={v}" for k, v in self.session_cookies.items()])
                headers["Cookie"] = cookie_header
            
            response = await self.http_client.get(document_url, headers=headers)
            response.raise_for_status()
            html_content = response.text
            
            if not html_content or not html_content.strip():
                logger.warning(f"Received empty HTML content from {document_url}")
                return SayistayDocumentMarkdown(
                    decision_id=decision_id,
                    decision_type=decision_type,
                    source_url=document_url,
                    markdown_content=None,
                    error_message="Document content is empty"
                )
            
            # Convert HTML to Markdown using existing method
            markdown_content = self._convert_html_to_markdown(html_content)
            
            if markdown_content and "Error converting HTML content" not in markdown_content:
                logger.info(f"Successfully retrieved and converted document {decision_id} to Markdown")
                return SayistayDocumentMarkdown(
                    decision_id=decision_id,
                    decision_type=decision_type,
                    source_url=document_url,
                    markdown_content=markdown_content,
                    retrieval_date=None  # Could add datetime.now().isoformat() if needed
                )
            else:
                return SayistayDocumentMarkdown(
                    decision_id=decision_id,
                    decision_type=decision_type,
                    source_url=document_url,
                    markdown_content=None,
                    error_message=f"Failed to convert HTML to Markdown: {markdown_content}"
                )
                
        except httpx.HTTPStatusError as e:
            error_msg = f"HTTP error {e.response.status_code} when fetching document: {e}"
            logger.error(f"HTTP error fetching document {decision_id}: {error_msg}")
            return SayistayDocumentMarkdown(
                decision_id=decision_id,
                decision_type=decision_type,
                source_url=document_url,
                markdown_content=None,
                error_message=error_msg
            )
        except httpx.RequestError as e:
            error_msg = f"Network error when fetching document: {e}"
            logger.error(f"Network error fetching document {decision_id}: {error_msg}")
            return SayistayDocumentMarkdown(
                decision_id=decision_id,
                decision_type=decision_type,
                source_url=document_url,
                markdown_content=None,
                error_message=error_msg
            )
        except Exception as e:
            error_msg = f"Unexpected error when fetching document: {e}"
            logger.error(f"Unexpected error fetching document {decision_id}: {error_msg}")
            return SayistayDocumentMarkdown(
                decision_id=decision_id,
                decision_type=decision_type,
                source_url=document_url,
                markdown_content=None,
                error_message=error_msg
            )
  • Pydantic schema for the output of the get_document_unified tool, defining the structure including decision metadata, source URL, Markdown content, and error handling.
    class SayistayUnifiedDocumentMarkdown(BaseModel):
        """Unified document model for all Sayıştay decision types."""
        decision_type: Literal["genel_kurul", "temyiz_kurulu", "daire"] = Field(..., description="Type of document")
        decision_id: str = Field(..., description="Decision ID")
        source_url: str = Field(..., description="Source URL of the document")
        document_data: Dict[str, Any] = Field(default_factory=dict, description="Document content and metadata")
        markdown_content: Optional[str] = Field(None, description="Markdown content")
        error_message: Optional[str] = Field(None, description="Error message if retrieval failed")
Behavior4/5

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

The description adds valuable behavioral context beyond annotations: it specifies the return format ('clean Markdown format'), which isn't covered by annotations. Annotations already indicate read-only, non-open world, and idempotent operations, so the bar is lower, and the description complements this with output details without contradiction.

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 highly concise and front-loaded: two sentences that directly state the tool's purpose and output format with zero wasted words. Every sentence earns its place by providing essential information efficiently.

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

Completeness4/5

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

Given the tool's complexity (simple retrieval with 2 required parameters), rich annotations (readOnlyHint, openWorldHint, idempotentHint), and the presence of an output schema (implied by context signals), the description is mostly complete. It covers purpose and output format, though it could better integrate with sibling tools for clearer usage context.

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?

Schema description coverage is 100%, providing full parameter documentation (decision_id and decision_type with descriptions and enum). The description doesn't add extra parameter semantics beyond what the schema already states, so it meets the baseline of 3 for high schema coverage without compensating value.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'retrieving full text of a Sayıştay audit decision' with a specific resource (audit decision) and verb (retrieving). It distinguishes from siblings by specifying the exact document type (Sayıştay audit decisions), though it doesn't explicitly contrast with similar document retrieval tools like get_anayasa_document_unified.

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

Usage Guidelines3/5

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

The description provides some usage guidance with 'Use this when retrieving full text of a Sayıştay audit decision,' which implies context. However, it doesn't specify when to use alternatives (e.g., search_sayistay_unified for finding decisions vs. this for retrieving text) or mention prerequisites like needing a decision_id from search results, which is only hinted at in the schema.

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/yargi-mcp'

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