Skip to main content
Glama

discover_api

Search and retrieve L402-enabled APIs with detailed endpoint information and pricing. Filter by category or keyword, and view affordable call counts based on your budget.

Instructions

Discover L402-enabled APIs. Use 'query' to search the registry for available APIs by keyword, or use 'url' to fetch a specific API's manifest with full endpoint details and pricing. Use 'category' to browse by category. With budget_aware=true, shows how many calls you can afford.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlNoBase URL of the L402-enabled API, or direct URL to the manifest JSON file. If omitted, searches the registry instead.
queryNoSearch the L402 API registry by keyword (e.g., 'weather', 'ai', 'geocoding').
categoryNoFilter registry results by category (e.g., 'ai', 'data', 'finance').
budget_awareNoIf true, annotate endpoints with affordable call counts based on remaining budget. Default: true.

Implementation Reference

  • The `discover_api` function is the main handler for the discover_api tool. It routes requests either to search the registry or to fetch a specific API manifest.
    async def discover_api(
        url: str | None = None,
        query: str | None = None,
        category: str | None = None,
        budget_aware: bool = True,
        budget_service: "BudgetService | None" = None,
    ) -> str:
        """
        Discover L402-enabled APIs.
    
        Use 'query' to search the registry for available APIs by keyword,
        or use 'url' to fetch a specific API's manifest with full endpoint
        details and pricing. Use 'category' to browse by category.
        With budget_aware=True, shows how many calls you can afford.
    
        Args:
            url: Base URL of the L402-enabled API, or direct URL to the manifest JSON file
            query: Search the L402 API registry by keyword (e.g., 'weather', 'ai', 'geocoding')
            category: Filter registry results by category (e.g., 'ai', 'data', 'finance')
            budget_aware: If True, annotate endpoints with affordable call counts. Default: True
            budget_service: BudgetService for budget annotations
    
        Returns:
            JSON with discovered APIs or manifest details
        """
        if httpx is None:
            return json.dumps({
                "success": False,
                "error": "httpx is required for discover_api. Install with: pip install httpx"
            })
    
        try:
            # Route: URL provided -> fetch manifest
            if url and url.strip():
                return await _fetch_and_format_manifest(
                    url.strip(), budget_aware, budget_service
                )
    
            # Route: query/category provided -> search registry
            if (query and query.strip()) or (category and category.strip()):
                return await _search_registry(
                    query, category, budget_aware, budget_service
                )
    
            # No params -> usage error
            return json.dumps({
                "success": False,
                "error": "Please provide either a 'url' to fetch an API manifest, or a 'query'/'category' to search the registry.",
                "examples": [
                    {"description": "Search for weather APIs", "call": 'discover_api(query="weather")'},
                    {"description": "Browse AI category", "call": 'discover_api(category="ai")'},
                    {"description": "Get full details for a specific API", "call": 'discover_api(url="https://api.example.com")'},
                ]
            }, indent=2)
    
        except Exception as e:
            return json.dumps({
                "success": False,
                "error": f"Error discovering API: {sanitize_error(str(e))}"
            })
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that the tool can show 'affordable call counts based on remaining budget' with budget_aware=true, which is useful behavioral context. However, it doesn't mention rate limits, authentication needs, or what happens when multiple parameters are provided simultaneously.

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 front-loaded with the core purpose, followed by specific usage instructions for each parameter. Every sentence earns its place by providing distinct guidance. It's appropriately sized for a tool with four parameters and no annotations.

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 (4 parameters, no output schema, no annotations), the description is mostly complete. It explains what the tool does, how to use different parameters, and a key behavioral feature (budget awareness). The main gap is lack of output format details, but with no output schema, this would be helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/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 parameters well. The description adds value by explaining the semantic relationship between parameters: url fetches a specific API, query searches by keyword, category filters by category, and budget_aware affects affordability display. This goes beyond the schema's individual parameter descriptions.

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

Purpose5/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: 'Discover L402-enabled APIs' with specific verbs (search, fetch, browse) and resources (APIs, manifests, endpoints, pricing). It distinguishes from siblings like 'access_l402_resource' (which likely accesses specific APIs) by focusing on discovery rather than usage.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use different parameters: 'Use 'query' to search...', 'use 'url' to fetch...', 'Use 'category' to browse...'. It also specifies 'If omitted, searches the registry instead' for the url parameter, offering clear alternatives.

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/refined-element/lightning-enable-mcp'

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