Skip to main content
Glama
lroolle

OpenAI Agents MCP Server

by lroolle

web_search_agent

Find accurate, up-to-date information from the internet using an AI agent specialized in web searching. Provide a search query to get relevant online results.

Instructions

Use an AI agent specialized in web searching to find accurate, up-to-date information from the internet.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
locationNoOptional location context for location-specific searches (e.g., 'New York').
queryYesThe search query or question you want to find information about online.

Implementation Reference

  • The primary handler for the 'web_search_agent' MCP tool. It runs the web_search_agent (or a location-specific variant) using the Runner to execute web searches via WebSearchTool.
    @mcp.tool(
        name="web_search_agent",
        description="Use an AI agent specialized in web searching to find accurate, up-to-date information from the internet.",
    )
    async def web_search(
        query: str = Field(
            ..., description="The search query or question you want to find information about online."
        ),
        location: Optional[str] = Field(
            None,
            description="Optional location context for location-specific searches (e.g., 'New York').",
        ),
    ) -> AgentResponse:
        """Use a specialized web search agent powered by OpenAI to find information on the internet."""
        try:
            agent = web_search_agent
            if location:
                agent = Agent(
                    name="Web Search Assistant",
                    instructions=web_search_agent.instructions,
                    tools=[WebSearchTool(user_location={"type": "approximate", "city": location})],
                )
    
            with trace("Web search agent execution"):
                result = await Runner.run(agent, query)
    
            return AgentResponse(
                response=result.final_output,
                raw_response={"items": [str(item) for item in result.new_items]},
            )
    
        except Exception as e:
            print(f"Error running web search agent: {e}")
            return AgentResponse(
                response=f"An error occurred while searching the web: {str(e)}", raw_response=None
            )
  • Defines the core web_search_agent Agent instance with specialized instructions and WebSearchTool, used by the handler.
    web_search_agent = Agent(
        name="Web Search Assistant",
        instructions="""You are a web search assistant. Your primary goal is to search the web for accurate,
        up-to-date information based on the user's query.
    
        Guidelines:
        1. Always use the web search tool to find information
        2. Cite your sources when providing information
        3. If information seems outdated or contradictory, acknowledge this
        4. Summarize information in a clear, concise manner
        5. For complex topics, break down information into digestible parts
        """,
        tools=[WebSearchTool()],
    )
  • Pydantic schema for the output of the web_search_agent tool (and other agents).
    class AgentResponse(BaseModel):
        """Response from an OpenAI agent."""
    
        response: str = Field(..., description="The response from the agent")
        raw_response: Optional[Dict[str, Any]] = Field(
            None, description="The raw response data from the agent, if available"
        )
  • Secondary registration of web_search_agent as a sub-tool ('search_web') within the multi_tool_agent for orchestration.
    tools.append(
        web_search_agent.as_tool(
            tool_name="search_web", tool_description="Search the web for information"
        )
    )
  • Helper code to create a location-specific variant of the web_search_agent when location parameter is provided.
    if location:
        agent = Agent(
            name="Web Search Assistant",
            instructions=web_search_agent.instructions,
            tools=[WebSearchTool(user_location={"type": "approximate", "city": location})],
        )
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 the agent is 'specialized in web searching' and aims for 'accurate, up-to-date information,' which adds some context about quality and timeliness. However, it doesn't disclose critical behavioral traits such as rate limits, authentication needs, potential costs, or how results are returned (e.g., format, pagination). For a tool with no annotations, this leaves significant gaps in understanding its operation.

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 front-loads the core purpose: using an AI agent for web searching. Every word earns its place by specifying specialization ('specialized in web searching'), quality goals ('accurate, up-to-date'), and source ('from the internet'). There's no redundancy or unnecessary elaboration, making it appropriately sized for the tool's complexity.

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's moderate complexity (2 parameters, no output schema, no annotations), the description is partially complete. It covers the basic purpose and context but lacks details on behavioral aspects (e.g., how searches are performed, result handling) and doesn't compensate for the absence of an output schema. It's adequate as a starting point but leaves the agent with insufficient information for optimal tool invocation without further exploration.

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%, with both parameters ('query' and 'location') well-documented in the input schema. The description doesn't add any parameter-specific information beyond what the schema provides (e.g., it doesn't explain query formatting or location usage details). According to the rules, with high schema coverage (>80%), the baseline score is 3 even without param info in the description, which applies here.

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: 'Use an AI agent specialized in web searching to find accurate, up-to-date information from the internet.' It specifies the verb ('find') and resource ('information from the internet'), distinguishing it from sibling tools like 'file_search_agent' (local files) and 'computer_action_agent' (system actions). However, it doesn't explicitly differentiate from 'multi_tool_agent' in terms of web search specialization.

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 implies usage context by mentioning 'accurate, up-to-date information from the internet,' suggesting this tool is for online research. It doesn't provide explicit when-to-use vs. when-not-to-use guidance or name alternatives among siblings (e.g., use this for web searches vs. 'file_search_agent' for local files). The context is clear but lacks specific exclusions or comparative advice.

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/lroolle/openai-agents-mcp-server'

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