Skip to main content
Glama
adexltd

MCP Google Suite

by adexltd

drive_search_files

Find files in Google Drive by entering search queries to locate documents, spreadsheets, and other stored content.

Instructions

Search for files in Google Drive

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query
page_sizeNoNumber of results to return

Implementation Reference

  • MCP tool handler for drive_search_files that validates input and delegates to DriveService.search_files
    async def _handle_drive_search_files(
        self, context: GoogleWorkspaceContext, arguments: dict
    ) -> Dict[str, Any]:
        """Handle drive search files requests."""
        query = arguments.get("query")
        page_size = arguments.get("page_size", 10)
    
        if not query:
            raise ValueError("Search query is required")
    
        logger.debug(f"Drive search request - Query: {query}, Page Size: {page_size}")
        result = await context.drive.search_files(query=query, page_size=page_size)
        logger.debug(f"Drive search completed - Found {len(result.get('files', []))} files")
        return result
  • JSON schema defining the input parameters for the drive_search_files tool
    types.Tool(
        name="drive_search_files",
        description="Search for files in Google Drive",
        inputSchema={
            "type": "object",
            "properties": {
                "query": {"type": "string", "description": "Search query"},
                "page_size": {
                    "type": "integer",
                    "description": "Number of results to return",
                    "default": 10,
                },
            },
            "required": ["query"],
        },
    ),
  • Dynamic registration of the drive_search_files handler into the tool registry
    for tool in self._get_tools_list():
        handler_name = f"_handle_{tool.name}"
        if hasattr(self, handler_name):
            handler = getattr(self, handler_name)
            self._tool_registry[tool.name] = handler
            logger.debug(f"Registered handler for {tool.name}")
  • Core implementation using Google Drive API to search for files matching the query
    def search_files(self, query: str, page_size: int = 10) -> Dict[str, Any]:
        """Search for files in Google Drive."""
        try:
            results = (
                self.service.files()
                .list(q=query, pageSize=page_size, fields="files(id, name, mimeType, webViewLink)")
                .execute()
            )
    
            return {"success": True, "files": results.get("files", [])}
        except HttpError as error:
            return {"success": False, **self.handle_error(error)}

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Search for files' implies a read operation, but it doesn't disclose behavioral traits like whether it requires authentication, has rate limits, returns paginated results (despite having a page_size parameter), or what happens with empty results. The description adds minimal value 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 with zero waste. It's appropriately sized and front-loaded, directly stating the tool's purpose without unnecessary elaboration.

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?

Given the tool has 2 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the search returns (e.g., file metadata, IDs, or content), how results are structured, or error conditions. For a search tool with no structured output documentation, this 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?

Schema description coverage is 100%, so the schema already documents both parameters ('query' and 'page_size') adequately. The description doesn't add any meaning beyond what the schema provides, such as query syntax examples or context about result ordering. Baseline 3 is appropriate when 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 ('Search for files') and resource ('in Google Drive'), providing a specific verb+resource combination. However, it doesn't differentiate from potential sibling tools like 'drive_create_folder' that might also involve file operations, so it doesn't fully distinguish from alternatives.

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. With sibling tools like 'docs_create', 'sheets_get_values', and 'drive_create_folder' available, there's no indication of when searching files is appropriate versus creating or accessing other document types.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.