Skip to main content
Glama

stream_answer

Query Exa's search API to receive streaming AI-generated answers, with support for custom system prompts and structured output schemas.

Instructions

Generate a streaming answer response using Exa.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe query to answer.
textNoWhether to include full text in the results.
system_promptNoA system prompt to guide the LLM's behavior.
modelNoThe model to use for answering.
output_schemaNoJSON schema for structured output.
user_locationNoTwo-letter ISO country code for user location.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for stream_answer. Defined with @mcp.tool() decorator, it accepts query, text, system_prompt, model, output_schema, and user_location parameters. It builds arguments dict and delegates to _call_mcp_tool with tool name 'exa_stream_answer' which calls the public Exa MCP endpoint at https://mcp.exa.ai/mcp via JSON-RPC.
    @mcp.tool()
    async def stream_answer(
        query: str,
        text: bool | None = None,
        system_prompt: str | None = None,
        model: Literal["exa"] | None = None,
        output_schema: JSONSchemaInput | None = None,
        user_location: str | None = None,
    ) -> list[dict[str, Any]]:
        """Generate a streaming answer response using Exa.
    
        Args:
            query: The query to answer.
            text: Whether to include full text in the results.
            system_prompt: A system prompt to guide the LLM's behavior.
            model: The model to use for answering.
            output_schema: JSON schema for structured output.
            user_location: Two-letter ISO country code for user location.
    
        Returns:
            List of dicts containing partial answers and citations.
    
        Example:
            >>> await stream_answer("What is the capital of France?")
            [{"content": "Paris", "citations": [...]}]
        """
        if not query:
            raise ValueError("Query cannot be empty")
    
        arguments: dict[str, Any] = {"query": query}
        if text is not None:
            arguments["text"] = text
        if system_prompt is not None:
            arguments["system_prompt"] = system_prompt
        if model is not None:
            arguments["model"] = model
        if output_schema is not None:
            arguments["output_schema"] = output_schema
        if user_location is not None:
            arguments["user_location"] = user_location
    
        try:
            result = await _call_mcp_tool("exa_stream_answer", arguments)
            return [result]
        except Exception as e:
            return [{"error": str(e)}]
  • Input schema for stream_answer tool: query (str, required), text (bool, optional), system_prompt (str, optional), model (Literal['exa'], optional), output_schema (dict, optional), user_location (str, optional). Returns list of dicts.
    async def stream_answer(
        query: str,
        text: bool | None = None,
        system_prompt: str | None = None,
        model: Literal["exa"] | None = None,
        output_schema: JSONSchemaInput | None = None,
        user_location: str | None = None,
    ) -> list[dict[str, Any]]:
  • The @mcp.tool() decorator registers stream_answer as an MCP tool on the FastMCP server instance 'mcp'.
    @mcp.tool()
  • Helper function _call_mcp_tool that makes JSON-RPC calls to the public Exa MCP server (https://mcp.exa.ai/mcp). It sends a tools/call request with the tool name and arguments, parses SSE-style responses, and extracts text content from the result.
    async def _call_mcp_tool(tool_name: str, arguments: dict[str, Any]) -> dict[str, Any]:
        """Call a tool on the public Exa MCP server."""
        request = {
            "jsonrpc": "2.0",
            "id": 1,
            "method": "tools/call",
            "params": {
                "name": tool_name,
                "arguments": arguments,
            },
        }
    
        async with httpx.AsyncClient(timeout=60.0) as client:
            response = await client.post(
                f"{BASE_URL}/mcp",
                json=request,
                headers={
                    "accept": "application/json, text/event-stream",
                    "content-type": "application/json",
                },
            )
            response.raise_for_status()
            response_text = response.text
    
            lines = response_text.split("\n")
            for line in lines:
                if line.startswith("data: "):
                    data = line[6:]
                    result = {"jsonrpc": "2.0", "id": 1, "result": {}}
                    try:
                        parsed = eval(data)
                    except Exception:
                        pass
                    else:
                        if "result" in parsed and parsed["result"].get("content"):
                            return {
                                "results": parsed["result"]["content"][0].get("text", "")
                            }
    
            return {"results": ""}
Behavior2/5

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

With no annotations provided, the description bears full burden for behavioral disclosure. It only mentions 'streaming' without explaining implications (e.g., chunked responses, early termination, connection handling). No information on side effects, authentication, rate limits, or reversibility is provided. The agent lacks critical awareness of how the tool behaves during execution.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence, which is concise but overly minimal. While brevity is valued, the content is insufficient to inform the agent about streaming behavior, usage, or parameters. It lacks front-loaded key details and structure, sacrificing completeness for conciseness.

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

Completeness2/5

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

The tool has 6 parameters, streaming behavior, an output schema, and several sibling tools. The description does not explain the streaming mechanism, the role of optional params (e.g., system_prompt, output_schema), or how it differs from 'answer'. Given the complexity, the description is incomplete and leaves significant gaps.

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 for all 6 parameters, so the schema already documents parameter meaning adequately. The description adds no additional semantic context beyond the schema. With full coverage, baseline is 3; the description does not degrade or enhance parameter understanding.

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

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states 'Generate a streaming answer response using Exa,' which indicates the tool produces streaming answers via Exa. However, it is somewhat vague and essentially restates the tool name without specifying what constitutes an 'answer response' or how it differs from a non-streaming version. The mention of 'streaming' provides minimal distinction from the sibling tool 'answer'.

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?

No explicit guidance on when to use this tool versus alternatives like 'answer'. The description does not specify contexts (e.g., real-time vs. batch, latency-sensitive tasks) or when streaming is beneficial. The agent receives no help in selecting the appropriate tool.

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/daedalus/mcp-exa'

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