Skip to main content
Glama
saidsurucu

İhale MCP

by saidsurucu

search_direct_procurement_authorities

Find Turkish procurement authorities by name or location to identify valid entities for direct procurement processes in EKAP system.

Instructions

Search authorities (İdare) for Direct Procurement (idareAra). Use returned 'token' as idareId.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cookiesNoCookie header (Çerez) for EKAP session (optional)
search_termNoAuthority search term (İdare arama), e.g., 'antalya' or institution name

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Core implementation of the search_direct_procurement_authorities tool in EKAPClient class. Makes HTTP GET request to legacy EKAP endpoint (metot=idareAra), parses response, extracts token and name for each authority, handles errors.
    async def search_direct_procurement_authorities(
        self,
        search_term: str,
        cookies: Optional[Any] = None,
    ) -> Dict[str, Any]:
        """Search authorities for Direct Procurement filter (legacy idareAra).
    
        Returns list of { token, name } where token is the encrypted idareId (A) and name is D.
        """
        params = {
            "metot": "idareAra",
            "aranan": search_term or "",
            "ES": "",
            "ihaleidListesi": "",
        }
        try:
            data = await self._make_get_request_full_url(
                self.direct_procurement_url,
                params=params,
                cookies=cookies,
            )
            items = data.get("idareAramaResultList", [])
            results = []
            for it in items:
                results.append({
                    "token": it.get("A"),
                    "name": it.get("D"),
                })
            return {
                "authorities": results,
                "returned_count": len(results),
                "search_term": search_term,
            }
        except httpx.HTTPStatusError as e:
            return {
                "error": f"Authority search failed with status {e.response.status_code}",
                "message": str(e)
            }
        except Exception as e:
            return {
                "error": "Authority search failed",
                "message": str(e)
            }
  • ihale_mcp.py:423-434 (registration)
    MCP tool registration via @mcp.tool decorator. Defines input schema via Annotated parameters and thin wrapper delegating to EKAPClient instance.
    @mcp.tool
    async def search_direct_procurement_authorities(
        search_term: Annotated[str, "Authority search term (İdare arama), e.g., 'antalya' or institution name"] = "",
        cookies: Annotated[Optional[str], "Cookie header (Çerez) for EKAP session (optional)"] = None,
    ) -> Dict[str, Any]:
        """
        Search authorities (İdare) for Direct Procurement (idareAra). Use returned 'token' as idareId.
        """
        return await ekap_client.search_direct_procurement_authorities(
            search_term=search_term,
            cookies=cookies,
        )
  • Helper method used by the handler to make authenticated GET requests to legacy EKAP endpoints, handles cookies, SSL, session warmup for redirects, and error handling.
    async def _make_get_request_full_url(
        self,
        url: str,
        params: dict,
        headers: Optional[Dict[str, str]] = None,
        cookies: Optional[Any] = None,
    ) -> dict:
        """Make a GET request to a full URL (used for legacy EKAP endpoints).
    
        cookies: can be a cookie header string or a dict suitable for httpx.
        """
        ssl_context = self._create_ssl_context()
        req_headers = {
            'Accept': 'application/json, text/plain, */*',
            'Accept-Encoding': 'identity',
            'Connection': 'keep-alive',
            'Referer': 'https://ekap.kik.gov.tr/EKAP/YeniIhaleArama.aspx',
            'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36',
            'sec-ch-ua': '"Chromium";v="140", "Not=A?Brand";v="24", "Google Chrome";v="140"',
            'sec-ch-ua-mobile': '?0',
            'sec-ch-ua-platform': '"macOS"'
        }
        if headers:
            req_headers.update(headers)
        async with httpx.AsyncClient(
            timeout=30.0,
            verify=ssl_context,
            http2=False,
            limits=httpx.Limits(max_keepalive_connections=5, max_connections=10)
        ) as client:
            # If cookies is a string, set Cookie header; if dict, pass to client
            request_headers = dict(req_headers)
            httpx_cookies = None
            if isinstance(cookies, str) and cookies.strip():
                request_headers['Cookie'] = cookies
            elif isinstance(cookies, dict):
                httpx_cookies = cookies
            # First attempt
            response = await client.get(url, params=params, headers=request_headers, cookies=httpx_cookies, follow_redirects=False)
            # If redirected to error page, try warming up to obtain cookies and retry once
            if response.status_code == 302 and '/EKAP/error_page.html' in response.headers.get('location', '') and not cookies:
                await self._warmup_legacy_ekap(client)
                response = await client.get(url, params=params, headers=req_headers, follow_redirects=False)
            response.raise_for_status()
            return response.json()
  • Initialization of the EKAPClient instance used by all EKAP-related tools including search_direct_procurement_authorities.
    ekap_client = EKAPClient()
    ilan_client = IlanClient()
Behavior2/5

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

With no annotations provided, the description carries full burden. It mentions the output token usage but doesn't disclose behavioral aspects like authentication needs (cookies parameter is optional but not explained), rate limits, error conditions, or what 'searching' entails (e.g., partial matches, case sensitivity).

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 brief and front-loaded with the core purpose. The second sentence about token usage is relevant but could be integrated more smoothly. No wasted words, though slightly terse.

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 cover return values), the description adequately states the tool's purpose. However, for a search tool with no annotations, it lacks context on authentication, session handling, or result formatting, leaving gaps in operational understanding.

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 good documentation for both parameters. The description adds no parameter-specific information beyond what's in the schema, so it meets the baseline of 3 without compensating or adding extra 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 action ('Search authorities') and the resource ('for Direct Procurement'), with the specific operation 'idareAra' mentioned. It distinguishes from general 'search_authorities' by specifying 'Direct Procurement' context, though it doesn't explicitly contrast with 'search_direct_procurement_parent_authorities'.

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 like 'search_authorities' or 'search_direct_procurement_parent_authorities'. It mentions using the returned 'token' as idareId, which is a usage instruction but not comparative 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/ihale-mcp'

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