Skip to main content
Glama

stop_search

Stop active background searches in Desktop Commander MCP to conserve resources when results are found or processes take too long.

Instructions

                    Stop an active search.
                    
                    Stops the background search process gracefully. Use this when you've found
                    what you need or if a search is taking too long. Similar to force_terminate
                    for terminal processes.
                    
                    The search will still be available for reading final results until it's
                    automatically cleaned up after 5 minutes.
                    
                    This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sessionIdYes

Implementation Reference

  • The main handler function for the 'stop_search' tool. It validates input using StopSearchArgsSchema, then calls searchManager.terminateSearch(sessionId) to stop the search process, returning appropriate success or error messages.
    /**
     * Handle stop_search command
     */
    export async function handleStopSearch(args: unknown): Promise<ServerResult> {
      const parsed = StopSearchArgsSchema.safeParse(args);
      if (!parsed.success) {
        return {
          content: [{ type: "text", text: `Invalid arguments for stop_search: ${parsed.error}` }],
          isError: true,
        };
      }
    
      try {
        const success = searchManager.terminateSearch(parsed.data.sessionId);
        
        if (success) {
          return {
            content: [{
              type: "text",
              text: `Search session ${parsed.data.sessionId} terminated successfully.`
            }],
          };
        } else {
          return {
            content: [{
              type: "text",
              text: `Search session ${parsed.data.sessionId} not found or already completed.`
            }],
          };
        }
      } catch (error) {
        const errorMessage = error instanceof Error ? error.message : String(error);
        
        return {
          content: [{ type: "text", text: `Error terminating search session: ${errorMessage}` }],
          isError: true,
        };
      }
    }
  • Zod schema defining the input arguments for the stop_search tool: requires a 'sessionId' string.
    export const StopSearchArgsSchema = z.object({
      sessionId: z.string(),
    });
  • Core helper method in SearchManager that terminates the ChildProcess of the search session by sending SIGTERM, returns true if session existed.
    terminateSearch(sessionId: string): boolean {
      const session = this.sessions.get(sessionId);
      
      if (!session) {
        return false;
      }
    
      if (!session.process.killed) {
        session.process.kill('SIGTERM');
      }
    
      // Don't delete session immediately - let user read final results
      // It will be cleaned up by cleanup process
      
      return true;
    }

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