Skip to main content
Glama

get_more_search_results

Retrieve additional search results using offset-based pagination to access specific ranges or tail results from ongoing searches.

Instructions

                    Get more results from an active search with offset-based pagination.
                    
                    Supports partial result reading with:
                    - 'offset' (start result index, default: 0)
                      * Positive: Start from result N (0-based indexing)
                      * Negative: Read last N results from end (tail behavior)
                    - 'length' (max results to read, default: 100)
                      * Used with positive offsets for range reading
                      * Ignored when offset is negative (reads all requested tail results)
                    
                    Examples:
                    - offset: 0, length: 100     → First 100 results
                    - offset: 200, length: 50    → Results 200-249
                    - offset: -20                → Last 20 results
                    - offset: -5, length: 10     → Last 5 results (length ignored)
                    
                    Returns only results in the specified range, along with search status.
                    Works like read_process_output - call this repeatedly to get progressive
                    results from a search started with start_search.
                    
                    This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYes
offsetNo
lengthNo

Implementation Reference

  • Main handler function executing the tool logic: validates input with schema, reads search results from searchManager, formats paginated output with status and hints.
    export async function handleGetMoreSearchResults(args: unknown): Promise<ServerResult> {
      const parsed = GetMoreSearchResultsArgsSchema.safeParse(args);
      if (!parsed.success) {
        return {
          content: [{ type: "text", text: `Invalid arguments for get_more_search_results: ${parsed.error}` }],
          isError: true,
        };
      }
    
      try {
        const results = searchManager.readSearchResults(
          parsed.data.sessionId,
          parsed.data.offset,
          parsed.data.length
        );
        
        // Only return error if we have no results AND there's an actual error
        // Permission errors should not block returning found results
        if (results.isError && results.totalResults === 0 && results.error?.trim()) {
          return {
            content: [{
              type: "text",
              text: `Search session ${parsed.data.sessionId} encountered an error: ${results.error}`
            }],
            isError: true,
          };
        }
    
        // Format results for display
        let output = `Search session: ${parsed.data.sessionId}\n`;
        output += `Status: ${results.isComplete ? 'COMPLETED' : 'IN PROGRESS'}\n`;
        output += `Runtime: ${Math.round(results.runtime / 1000)}s\n`;
        output += `Total results found: ${results.totalResults} (${results.totalMatches} matches)\n`;
        
        const offset = parsed.data.offset;
        
        if (offset < 0) {
          // Negative offset - tail behavior
          output += `Showing last ${results.returnedCount} results\n\n`;
        } else {
          // Positive offset - range behavior
          const startPos = offset;
          const endPos = startPos + results.returnedCount - 1;
          output += `Showing results ${startPos}-${endPos}\n\n`;
        }
    
        if (results.results.length === 0) {
          if (results.isComplete) {
            output += results.totalResults === 0 ? "No matches found." : "No results in this range.";
          } else {
            output += "No results yet, search is still running...";
          }
        } else {
          output += "Results:\n";
          
          for (const result of results.results) {
            if (result.type === 'content') {
              output += `📄 ${result.file}:${result.line} - ${result.match?.substring(0, 100)}${result.match && result.match.length > 100 ? '...' : ''}\n`;
            } else {
              output += `📁 ${result.file}\n`;
            }
          }
        }
    
        // Add pagination hints
        if (offset >= 0 && results.hasMoreResults) {
          const nextOffset = offset + results.returnedCount;
          output += `\n📖 More results available. Use get_more_search_results with offset: ${nextOffset}`;
        }
    
        if (results.isComplete) {
          output += `\n✅ Search completed.`;
          
          // Warn users if search was incomplete due to permission issues
          if (results.wasIncomplete) {
            output += `\n⚠️  Warning: Some files were inaccessible due to permissions. Results may be incomplete.`;
          }
        }
    
        return {
          content: [{ type: "text", text: output }],
        };
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        
        return {
          content: [{ type: "text", text: `Error reading search results: ${errorMessage}` }],
          isError: true,
        };
      }
    }
  • src/server.ts:581-609 (registration)
    Tool specification registration in the allTools array: defines name, description, input schema from GetMoreSearchResultsArgsSchema, and annotations for the MCP tools/list response.
        name: "get_more_search_results",
        description: `
                Get more results from an active search with offset-based pagination.
                
                Supports partial result reading with:
                - 'offset' (start result index, default: 0)
                  * Positive: Start from result N (0-based indexing)
                  * Negative: Read last N results from end (tail behavior)
                - 'length' (max results to read, default: 100)
                  * Used with positive offsets for range reading
                  * Ignored when offset is negative (reads all requested tail results)
                
                Examples:
                - offset: 0, length: 100     → First 100 results
                - offset: 200, length: 50    → Results 200-249
                - offset: -20                → Last 20 results
                - offset: -5, length: 10     → Last 5 results (length ignored)
                
                Returns only results in the specified range, along with search status.
                Works like read_process_output - call this repeatedly to get progressive
                results from a search started with start_search.
                
                ${CMD_PREFIX_DESCRIPTION}`,
        inputSchema: zodToJsonSchema(GetMoreSearchResultsArgsSchema),
        annotations: {
            title: "Get Search Results",
            readOnlyHint: true,
        },
    },
  • Dispatch registration in CallToolRequest handler switch: routes calls to 'get_more_search_results' to the handleGetMoreSearchResults function imported via handlers/index.js
    case "get_more_search_results":
        result = await handlers.handleGetMoreSearchResults(args);
        break;
  • Zod schema defining input parameters: sessionId (required), offset and length (optional with defaults). Used for validation in handler and JSON schema in tool registration.
    export const GetMoreSearchResultsArgsSchema = z.object({
      sessionId: z.string(),
      offset: z.number().optional().default(0),    // Same as file reading
      length: z.number().optional().default(100),  // Same as file reading (but smaller default)
    });

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/wonderwhy-er/ClaudeComputerCommander'

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