Skip to main content
Glama
lroolle

OpenAI Agents MCP Server

by lroolle

file_search_agent

Search through files and documents using AI to find specific information based on your query, returning relevant results from specified vector stores.

Instructions

Use an AI agent specialized in searching through files and documents to find relevant information.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
max_resultsNoThe maximum number of document results to return.
queryYesThe search query or question to find in the documents.
vector_store_idsYesThe IDs of the vector stores to search in. This is required for file search to work.

Implementation Reference

  • Primary handler and registration for the 'file_search_agent' tool. Creates and runs an Agent instance equipped with FileSearchTool to execute file searches based on the provided query and vector store IDs.
    @mcp.tool(
        name="file_search_agent",
        description="Use an AI agent specialized in searching through files and documents to find relevant information.",
    )
    async def file_search(
        query: str = Field(..., description="The search query or question to find in the documents."),
        vector_store_ids: List[str] = Field(
            ...,
            description="The IDs of the vector stores to search in. This is required for file search to work.",
        ),
        max_results: int = Field(5, description="The maximum number of document results to return."),
    ) -> AgentResponse:
        """Use a specialized file search agent powered by OpenAI to find information in documents."""
        try:
            agent = Agent(
                name="File Search Assistant",
                instructions=file_search_instructions,
                tools=[FileSearchTool(max_num_results=max_results, vector_store_ids=vector_store_ids)],
            )
    
            with trace("File 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 file search agent: {e}")
            return AgentResponse(
                response=f"An error occurred while searching files: {str(e)}", raw_response=None
            )
  • Input schema definition using Pydantic Fields for the file_search_agent tool parameters.
        query: str = Field(..., description="The search query or question to find in the documents."),
        vector_store_ids: List[str] = Field(
            ...,
            description="The IDs of the vector stores to search in. This is required for file search to work.",
        ),
        max_results: int = Field(5, description="The maximum number of document results to return."),
    ) -> AgentResponse:
  • Helper string containing the instructions/prompt for the File Search Assistant Agent used in the tool.
    file_search_instructions = """You are a file search assistant. Your primary goal is to search through files and documents
    to find relevant information based on the user's query.
    
    Guidelines:
    1. Always use the file search tool to find documents
    2. Quote relevant sections from documents when appropriate
    3. Summarize document content clearly
    4. If multiple documents are found, compare and contrast their information
    5. If no relevant documents are found, clearly state this
    """
  • Output schema for agent responses, used by file_search_agent and other tools.
    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"
        )
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. It mentions the tool uses an 'AI agent specialized in searching' but doesn't describe how it works (e.g., semantic search vs keyword, ranking approach), what types of files it supports, whether it requires specific permissions, or what the output format looks like. The description is too vague about the actual behavior.

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 gets straight to the point without any wasted words. It's appropriately sized for a tool with good schema documentation and no complex behavioral nuances to explain.

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?

For a search tool with 3 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what constitutes a 'relevant' result, how results are ranked, what file formats are supported, or what the return structure looks like. The agent needs more context to understand what this tool actually delivers.

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 thoroughly. The description adds no parameter-specific information beyond what's in the schema. It mentions 'search query or question' and 'vector stores' indirectly but provides no additional context about parameter usage or relationships.

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: 'searching through files and documents to find relevant information' using an 'AI agent specialized' for this task. It specifies the verb (search) and resource (files/documents), but doesn't distinguish it from sibling tools like 'web_search_agent' which might search different content types.

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 on when to use this tool versus alternatives like 'web_search_agent' or 'multi_tool_agent'. It mentions the tool is 'specialized in searching through files and documents' but doesn't clarify when file/document search is appropriate versus web search or other approaches.

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