Skip to main content
Glama

Custom IGDB Query

custom_query

Execute custom Apicalypse queries to retrieve specific video game data from IGDB endpoints like games, companies, or platforms.

Instructions

Run a custom Apicalypse query against any IGDB API endpoint

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointYesThe API endpoint to query (e.g., 'games', 'companies', 'platforms', 'people', 'characters')
queryYesThe Apicalypse query string

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that executes the custom_query tool. It accepts an endpoint and Apicalypse query, retrieves the IGDB client, and performs the API request.
    async def custom_query(
        endpoint: Annotated[
            str,
            Field(
                description="The API endpoint to query (e.g., 'games', 'companies', 'platforms', 'people', 'characters')"
            ),
        ],
        query: Annotated[str, Field(description="The Apicalypse query string")],
        ctx: Context,
    ) -> List[Dict[str, Any]]:
        """
        Execute a custom IGDB API query.
    
        This allows advanced users to write their own IGDB queries using the Apicalypse query language.
        See https://api-docs.igdb.com/#apicalypse for query syntax.
    
        Args:
            endpoint: The API endpoint to query (e.g., "games", "companies", "platforms")
            query: The Apicalypse query string
            ctx: Context for accessing session configuration
    
        Returns:
            Raw response from the IGDB API
    
        Example:
            endpoint: "games"
            query: "fields name,rating; where rating > 90; sort rating desc; limit 5;"
        """
        igdb_client = get_igdb_client(ctx)
    
        return await igdb_client.make_request(endpoint, query)
  • The @mcp.tool decorator that registers the custom_query tool with the FastMCP server.
    @mcp.tool(
        name="custom_query",
        title="Custom IGDB Query",
        description="Run a custom Apicalypse query against any IGDB API endpoint"
    )
  • Pydantic schema definitions for the input parameters of the custom_query tool using Annotated and Field.
        endpoint: Annotated[
            str,
            Field(
                description="The API endpoint to query (e.g., 'games', 'companies', 'platforms', 'people', 'characters')"
            ),
        ],
        query: Annotated[str, Field(description="The Apicalypse query string")],
        ctx: Context,
    ) -> List[Dict[str, Any]]:
  • The IGDBClient.make_request method used by custom_query to perform the actual API call.
    async def make_request(self, endpoint: str, query: str) -> List[Dict[str, Any]]:
        """Make a request to the IGDB API."""
        token = await self.get_access_token()
    
        response = await self.http_client.post(
            f"{IGDB_BASE_URL}/{endpoint}",
            headers={
                "Client-ID": self.client_id,
                "Authorization": f"Bearer {token}",
                "Accept": "application/json",
            },
            content=query,
            timeout=30.0,
        )
        response.raise_for_status()
    
        data = response.json()
        if isinstance(data, list):
            return data
        return [data]
  • Helper function to get or initialize the IGDBClient instance, called by custom_query.
    def get_igdb_client(ctx: Optional[Context] = None) -> IGDBClient:
        """Get or create the IGDB client singleton."""
        global _igdb_client
    
        if "_igdb_client" not in globals():
            # Get credentials from environment variables or Smithery settings
            # Check if context has session_config (Smithery mode)
            settings = getattr(ctx, 'session_config', None) if ctx else None
    
            client_id = os.getenv("IGDB_CLIENT_ID") or (settings.IGDB_CLIENT_ID if settings else None)
            client_secret = os.getenv("IGDB_CLIENT_SECRET") or (settings.IGDB_CLIENT_SECRET if settings else None)
    
            if not client_id or not client_secret:
                raise ValueError(
                    "Please set IGDB_CLIENT_ID and IGDB_CLIENT_SECRET. "
                    "You can either set them as environment variables or configure them in Smithery. "
                    "You can obtain these from https://api-docs.igdb.com/#account-creation"
                )
    
            _igdb_client = IGDBClient(client_id, client_secret)
    
        return _igdb_client
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. While it mentions 'Apicalypse query' (implying a specific query language/syntax), it doesn't address authentication requirements, rate limits, error handling, response format, or whether this is a read-only vs. mutation operation. The description provides minimal behavioral context beyond the basic action.

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 a single, efficient sentence that communicates the core functionality without any wasted words. It's appropriately sized for a tool with two parameters and good schema documentation, and the information is front-loaded with the essential action and target.

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 tool has an output schema (which handles return values), 100% parameter schema coverage, and no complex nested objects, the description is minimally adequate. However, for a flexible query tool with no annotations and specialized sibling tools, it should provide more guidance about when to use it versus the alternatives and more context about the Apicalypse query language.

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?

With 100% schema description coverage, the input schema already fully documents both parameters (endpoint and query). The description doesn't add meaningful semantic context beyond what's in the schema descriptions, such as explaining Apicalypse syntax in more detail or providing endpoint usage patterns. The baseline of 3 is appropriate when the schema does the heavy lifting.

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 ('Run a custom Apicalypse query') and target resource ('against any IGDB API endpoint'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate from sibling tools like 'search_games' or explain when to use this more flexible tool versus the specialized ones.

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 about when to use this tool versus the sibling tools (get_game_details, get_most_anticipated_games, search_games). There's no mention of prerequisites, alternatives, or specific scenarios where this custom query approach is preferable to the more specialized tools.

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/bielacki/igdb-mcp-server'

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