Skip to main content
Glama
saidsurucu

İhale MCP

by saidsurucu

get_ilan_ad_detail

Retrieve comprehensive tender details from ilan.gov.tr including title, content, advertiser information, location, categories, and metadata for Turkish public procurement advertisements.

Instructions

Get detailed information for a specific advertisement from ilan.gov.tr.

Returns: title, content (HTML and Markdown), advertiser info, location, categories, filters, hit count, and other advertisement metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ad_idYesAdvertisement ID from ilan.gov.tr search results

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Primary MCP tool handler for get_ilan_ad_detail. Registered via @mcp.tool decorator. Defines input schema via Annotated parameter. Executes by calling IlanClient.get_ad_detail and returns the result.
    @mcp.tool
    async def get_ilan_ad_detail(
        ad_id: Annotated[str, "Advertisement ID from ilan.gov.tr search results"]
    ) -> Dict[str, Any]:
        """
        Get detailed information for a specific advertisement from ilan.gov.tr.
    
        Returns: title, content (HTML and Markdown), advertiser info, location,
        categories, filters, hit count, and other advertisement metadata.
        """
    
        # Use the client to get ad detail
        result = await ilan_client.get_ad_detail(ad_id)
    
        return result
  • Core implementation logic in IlanClient.get_ad_detail. Performs API request to https://www.ilan.gov.tr/api/api/services/app/AdDetail/GetAdDetail, handles SSL, converts HTML content to Markdown using MarkItDown, formats categories/filters/advertiser info, and structures the full response dictionary.
    async def get_ad_detail(
        self,
        ad_id: str
    ) -> Dict[str, Any]:
        """Get detailed information for a specific advertisement"""
    
        ssl_context = self._create_ssl_context()
    
        try:
            # Make GET request with query parameter
            async with httpx.AsyncClient(
                timeout=30.0,
                verify=ssl_context,
                http2=False,
                limits=httpx.Limits(max_keepalive_connections=5, max_connections=10)
            ) as client:
                response = await client.get(
                    f"{self.base_url}{self.detail_endpoint}",
                    params={"id": ad_id},
                    headers=self.headers
                )
                response.raise_for_status()
                response_data = response.json()
    
            # Check if successful
            if not response_data.get("success", False):
                return {
                    "error": "API returned unsuccessful response",
                    "message": response_data.get("error", "Unknown error")
                }
    
            # Extract result
            result = response_data.get("result", {})
    
            if not result:
                return {
                    "error": "No detail found",
                    "ad_id": ad_id
                }
    
            # Extract HTML content
            html_content = result.get("content", "")
    
            # Convert HTML to Markdown
            markdown_content = None
            if html_content:
                try:
                    # Initialize markdown converter
                    markitdown = MarkItDown()
                    # Create BytesIO from HTML content
                    html_bytes = BytesIO(html_content.encode('utf-8'))
                    conversion_result = markitdown.convert_stream(html_bytes, file_extension=".html")
                    markdown_content = conversion_result.text_content if conversion_result else None
                except Exception as e:
                    print(f"Warning: Failed to convert HTML to markdown: {e}")
                    markdown_content = None
    
            # Format categories
            categories = []
            for cat in result.get("categories", []):
                categories.append({
                    "id": cat.get("taxId"),
                    "name": cat.get("name"),
                    "slug": cat.get("slug")
                })
    
            # Format filters
            ad_type_filters = []
            for filter_item in result.get("adTypeFilters", []):
                ad_type_filters.append({
                    "key": filter_item.get("key"),
                    "value": filter_item.get("value")
                })
    
            # Build response
            return {
                "ad_detail": {
                    "id": result.get("id"),
                    "ad_no": result.get("adNo"),
                    "title": result.get("title"),
                    "content_html": html_content,
                    "content_markdown": markdown_content,
                    "city": result.get("addressCityName"),
                    "county": result.get("addressCountyName"),
                    "advertiser": {
                        "name": result.get("advertiserName"),
                        "code": result.get("advertiserCode"),
                        "logo": result.get("advertiserLogo")
                    },
                    "source": {
                        "name": result.get("adSourceName"),
                        "code": result.get("adSourceCode"),
                        "logo": result.get("adSourceLogoPath")
                    },
                    "url": result.get("urlStr"),
                    "full_url": f"https://www.ilan.gov.tr{result.get('urlStr', '')}",
                    "categories": categories,
                    "filters": ad_type_filters,
                    "statistics": {
                        "hit_count": result.get("hitCount", 0),
                        "is_archived": result.get("isArchived", False),
                        "is_bik": result.get("isBikAd", False)
                    }
                },
                "success": True
            }
    
        except httpx.HTTPStatusError as e:
            return {
                "error": f"API request failed with status {e.response.status_code}",
                "message": str(e),
                "ad_id": ad_id
            }
        except Exception as e:
            return {
                "error": "Request failed",
                "message": str(e),
                "ad_id": ad_id
            }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool returns detailed information but doesn't cover critical aspects like whether it's a read-only operation, requires authentication, has rate limits, or handles errors. This is a significant gap for a tool that likely queries an external API.

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 efficiently structured in two sentences: the first states the purpose, and the second enumerates the return values. Every sentence adds value without redundancy, making it easy to parse and understand quickly.

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

Completeness3/5

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

Given the presence of an output schema (which should detail return values), the description doesn't need to fully explain outputs. However, for a tool with no annotations and likely external API calls, it lacks context on behavioral traits like safety or constraints. The purpose is clear, but operational guidance is minimal.

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 has 100% description coverage, clearly documenting the single required 'ad_id' parameter. The description adds no additional parameter semantics beyond implying the ad_id comes from 'ilan.gov.tr search results', which is already covered in the schema. This meets the baseline for high schema coverage.

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 verb 'Get' and resource 'detailed information for a specific advertisement from ilan.gov.tr', making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'search_ilan_ads' or 'get_tender_details', which might handle similar advertisement data but with different scopes or sources.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an ad_id from search results), exclusions, or compare it to siblings like 'search_ilan_ads' for broader searches or 'get_tender_details' for tender-specific data, leaving the agent to infer usage context.

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

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