Skip to main content
Glama
saidsurucu

İhale MCP

by saidsurucu

search_okas_codes

Find OKAS procurement classification codes for goods, services, or construction by searching Turkish descriptions to identify appropriate categories for public tenders.

Instructions

Search OKAS procurement classification codes.

Item types: 1=Goods, 2=Service, 3=Construction Search in Turkish descriptions for best results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kalem_turuNoFilter by item type: 1=Mal (Goods), 2=Hizmet (Service), 3=Yapım (Construction)
limitNoMaximum number of results to return (1-500)
search_termNoSearch term to find matching OKAS codes by description

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool handler for 'search_okas_codes'. Includes registration via @mcp.tool decorator and input schema via Annotated type hints. Delegates to EKAPClient for execution.
    @mcp.tool
    async def search_okas_codes(
        search_term: Annotated[str, "Search term to find matching OKAS codes by description"] = "",
        kalem_turu: Annotated[Optional[Literal[1, 2, 3]], "Filter by item type: 1=Mal (Goods), 2=Hizmet (Service), 3=Yapım (Construction)"] = None,
        limit: Annotated[int, "Maximum number of results to return (1-500)"] = 50
    ) -> Dict[str, Any]:
        """
        Search OKAS procurement classification codes.
        
        Item types: 1=Goods, 2=Service, 3=Construction
        Search in Turkish descriptions for best results.
        """
        
        # Use the client to search OKAS codes
        return await ekap_client.search_okas_codes(
            search_term=search_term,
            kalem_turu=kalem_turu,
            limit=limit
        )
  • Input schema defined by Annotated parameters in the tool handler function.
        search_term: Annotated[str, "Search term to find matching OKAS codes by description"] = "",
        kalem_turu: Annotated[Optional[Literal[1, 2, 3]], "Filter by item type: 1=Mal (Goods), 2=Hizmet (Service), 3=Yapım (Construction)"] = None,
        limit: Annotated[int, "Maximum number of results to return (1-500)"] = 50
    ) -> Dict[str, Any]:
  • Core helper method in EKAPClient class that implements the OKAS code search logic: builds DevExtreme loadOptions payload, calls EKAP API endpoint /b_ihalearama/api/IhtiyacKalemleri/GetAll, applies client-side filtering for kalem_turu, formats hierarchical OKAS codes with descriptions in Turkish/English, and structures the response.
    async def search_okas_codes(
        self,
        search_term: str = "",
        kalem_turu: Optional[Literal[1, 2, 3]] = None,
        limit: int = 50
    ) -> Dict[str, Any]:
        """Search OKAS (public procurement classification) codes"""
        
        # Validate limit
        if limit > 500:
            limit = 500
        elif limit < 1:
            limit = 1
        
        # Build API request payload for OKAS search
        okas_params = {
            "loadOptions": {
                "filter": {
                    "sort": [],
                    "group": [],
                    "filter": [],
                    "totalSummary": [],
                    "groupSummary": [],
                    "select": [],
                    "preSelect": [],
                    "primaryKey": []
                }
            }
        }
        
        # Add search filters if provided
        filters = []
        
        if search_term:
            # Search in both Turkish and English descriptions
            filters.extend([
                ["kalemAdi", "contains", search_term],
                "or",
                ["kalemAdiEng", "contains", search_term]
            ])
        
        # Note: kalem_turu filtering causes 500 errors on the API
        # We'll filter client-side after getting results
        
        if filters:
            okas_params["loadOptions"]["filter"]["filter"] = filters
        
        # Set take limit for API
        okas_params["loadOptions"]["take"] = limit
        
        try:
            # Make API request to OKAS endpoint
            response_data = await self._make_request(self.okas_endpoint, okas_params)
            
            # Parse and format the response
            okas_items = response_data.get("loadResult", {}).get("data", [])
            
            # Format each OKAS code for better readability
            results = []
            for item in okas_items:
                kalem_turu_desc = {
                    1: "Mal (Goods)",
                    2: "Hizmet (Service)", 
                    3: "Yapım (Construction)"
                }.get(item.get("kalemTuru"), "Unknown")
                
                # Client-side filtering by kalem_turu since API filtering causes 500 errors
                if kalem_turu is not None and item.get("kalemTuru") != kalem_turu:
                    continue
                
                results.append({
                    "id": item.get("id"),
                    "code": item.get("kod"),
                    "description_tr": item.get("kalemAdi"),
                    "description_en": item.get("kalemAdiEng"),
                    "item_type": {
                        "code": item.get("kalemTuru"),
                        "description": kalem_turu_desc
                    },
                    "code_level": item.get("kodLevel"),
                    "parent_id": item.get("parentId"),
                    "has_items": item.get("hasItem", False),
                    "child_count": item.get("childCount", 0)
                })
            
            # Apply limit after client-side filtering
            if len(results) > limit:
                results = results[:limit]
            
            return {
                "okas_codes": results,
                "total_found": len(results),
                "search_params": {
                    "search_term": search_term,
                    "kalem_turu": kalem_turu,
                    "limit": limit
                },
                "item_type_legend": {
                    "1": "Mal (Goods)",
                    "2": "Hizmet (Service)",
                    "3": "Yapım (Construction)"
                }
            }
            
        except httpx.HTTPStatusError as e:
            return {
                "error": f"API request failed with status {e.response.status_code}",
                "message": str(e)
            }
        except Exception as e:
            return {
                "error": "Request failed",
                "message": str(e)
            }
  • API endpoint constant used by search_okas_codes for fetching OKAS codes.
    self.okas_endpoint = "/b_ihalearama/api/IhtiyacKalemleri/GetAll"
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions searching 'in Turkish descriptions for best results,' which adds useful context about language optimization. However, it fails to disclose critical traits like whether this is a read-only operation, potential rate limits, authentication needs, or pagination behavior (beyond the 'limit' parameter in the schema). For a search tool with zero annotation coverage, this is a significant gap.

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 appropriately sized and front-loaded, with the core purpose stated first. Both sentences earn their place: the first defines the tool, and the second provides practical guidance (item types and language tip). There is zero waste or redundancy, making it highly efficient.

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 moderate complexity (search with filtering), 100% schema coverage, and the presence of an output schema (which means return values are documented elsewhere), the description is mostly complete. It covers purpose, item types, and a language tip. However, it lacks behavioral context (e.g., safety, performance), which is a minor gap since annotations are absent, but the output schema mitigates some of this.

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%, so the schema already documents all three parameters (kalem_turu, limit, search_term) with descriptions and defaults. The description adds minimal value by listing item type codes (1=Goods, etc.), which partially overlaps with the schema's enum description. It doesn't provide additional syntax, format details, or examples beyond what the schema offers, meeting the baseline for high 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 tool's purpose as 'Search OKAS procurement classification codes,' which is a specific verb+resource combination. It distinguishes itself from siblings by focusing on classification codes rather than tenders, authorities, or announcements. However, it doesn't explicitly contrast with sibling tools like 'search_tenders' or 'search_authorities' beyond the resource type.

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 implied usage guidance by mentioning 'Search in Turkish descriptions for best results,' which suggests a language preference. It also lists item type codes (1=Goods, etc.), hinting at when to filter by type. However, it lacks explicit when-to-use rules, alternatives (e.g., vs. other search tools), or exclusions, leaving some ambiguity for the agent.

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