Skip to main content
Glama

discover_client

Locate and optionally launch an MCP client to facilitate communication between AI applications using the Model Context Protocol.

Instructions

Find and optionally start an MCP client

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
clientTypeYes
autoStartNo
timeoutNo

Implementation Reference

  • Main handler function implementing the discover_client tool: checks connected clients, discovers new ones, connects, or auto-starts clients based on input parameters.
    private async handleClientDiscovery(params: any): Promise<ClientDiscoveryResult> {
      const { clientType, autoStart = false, timeout = this.config.clientStartupTimeoutMs || 30000 } = params;
    
      this.logger.info(`Discovering client of type: ${clientType}, autoStart: ${autoStart}`);
    
      // Check if client is already connected
      const connectedClients = this.connectionManager.getConnectedClientsByType(clientType);
      if (connectedClients.length > 0) {
        this.logger.info(`Found connected client: ${connectedClients[0].id}`);
        return {
          found: true,
          client: connectedClients[0]
        };
      }
    
      // Try to find a discovered but not connected client
      const discoveredClients = this.discoveryManager.getClientsByType(clientType);
      if (discoveredClients.length > 0) {
        this.logger.info(`Found discovered client: ${discoveredClients[0].id}`);
    
        // Attempt to connect to the client
        this.connectionManager.handleRegistration(JSON.stringify(
          this.registrationProtocol.createRegisterMessage(
            clientType,
            {
              supportedMethods: ['tools/call'],
              supportedTransports: ['unix-socket'],
              targetType: clientType
            },
            'unix-socket',
            discoveredClients[0].id,
            discoveredClients[0].socketPath
          )
        ));
    
        return {
          found: true,
          client: discoveredClients[0]
        };
      }
    
      // If autoStart is true, attempt to start the client
      if (autoStart) {
        try {
          const startupOptions = this.getClientStartupOptions(clientType);
          if (!startupOptions) {
            this.logger.warn(`No startup configuration available for client type: ${clientType}`);
            return {
              found: false,
              error: `No startup configuration available for client type: ${clientType}`
            };
          }
    
          const client = await this.startClient(clientType, startupOptions, timeout);
          this.logger.info(`Started client: ${client.id}`);
          return {
            found: true,
            client,
            startupAttempted: true,
            startupSuccessful: true
          };
        } catch (error: unknown) {
          const errorMessage = error instanceof Error ? error.message : 'Unknown error';
          this.logger.error(`Failed to start client: ${errorMessage}`);
          return {
            found: false,
            error: `Failed to start client: ${errorMessage}`,
            startupAttempted: true,
            startupSuccessful: false
          };
        }
      }
    
      this.logger.warn(`No ${clientType} clients available`);
      return {
        found: false,
        error: `No ${clientType} clients available`
      };
    }
  • src/server.ts:71-82 (registration)
    Registration of the discover_client tool in MCP server capabilities, including description and input schema.
    'discover_client': {
      description: 'Find and optionally start an MCP client',
      inputSchema: {
        type: 'object',
        properties: {
          clientType: { type: 'string', enum: ['claude', 'cline'] },
          autoStart: { type: 'boolean' },
          timeout: { type: 'number' }
        },
        required: ['clientType']
      }
    },
  • Request handler dispatcher for tool calls, routing 'discover_client' to its implementation.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name === 'discover_client') {
        return this.handleClientDiscovery(request.params.arguments);
      }
      if (request.params.name === 'tools/call') {
        return this.handleToolCall(request.params.arguments);
      }
      throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`);
    });
  • Tool schema returned in ListToolsRequestSchema response.
      name: 'discover_client',
      description: 'Find and optionally start an MCP client',
      inputSchema: {
        type: 'object',
        properties: {
          clientType: { type: 'string', enum: ['claude', 'cline'] },
          autoStart: { type: 'boolean' },
          timeout: { type: 'number' }
        },
        required: ['clientType']
      }
    },
  • Helper function to start a client process, used when autoStart is true in discover_client.
    private async startClient(
      clientType: string,
      options: ClientStartupOptions,
      timeout: number
    ): Promise<ClientInfo> {
      return new Promise((resolve, reject) => {
        const timeoutId = setTimeout(() => {
          reject(new Error(`Client startup timed out after ${timeout}ms`));
        }, timeout);
    
        try {
          const childProcess = spawn(options.command!, options.args || [], {
            env: { ...process.env, ...options.env },
            cwd: options.cwd
          });
    
          const client: ClientInfo = {
            id: randomUUID(),
            type: clientType as 'claude' | 'cline',
            transport: 'stdio',
            connected: true,
            lastSeen: new Date(),
            state: ConnectionState.CONNECTING,
            processId: childProcess.pid
          };
    
          this.stateManager.registerClient(client);
    
          // Wait for initial connection
          childProcess.once('spawn', () => {
            clearTimeout(timeoutId);
            client.state = ConnectionState.CONNECTED;
            this.stateManager.updateClientState(client.id, ConnectionState.CONNECTED);
            resolve(client);
          });
    
          childProcess.on('error', (error: Error) => {
            clearTimeout(timeoutId);
            reject(error);
          });
    
          childProcess.on('exit', (code: number) => {
            if (code !== 0) {
              reject(new Error(`Client process exited with code ${code}`));
            }
          });
        } catch (error) {
          clearTimeout(timeoutId);
          reject(error);
        }
      });
    }
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. While it mentions the optional 'start' functionality, it doesn't describe what happens during discovery (e.g., scanning processes, checking ports), what 'autoStart' actually does (e.g., launches process, establishes connection), timeout behavior, error conditions, or what constitutes successful discovery. For a tool with 3 parameters and no annotation coverage, this is inadequate.

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 perfectly concise at 5 words, front-loading the core functionality ('Find and optionally start') immediately. Every word earns its place, with no redundant phrases or unnecessary elaboration. The structure efficiently communicates the essential action and target.

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's complexity (3 parameters, no annotations, no output schema), the description is insufficiently complete. It doesn't explain what the tool returns (client handle? status object?), what happens during discovery failures, or how the parameters interact. For a client management tool with multiple configuration options, more context about behavior and outcomes is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description provides no information about any of the 3 parameters. It doesn't explain what 'clientType' values represent, what 'autoStart' controls, or what 'timeout' affects. The description fails to compensate for the complete lack of parameter documentation in the schema, leaving all parameters semantically ambiguous.

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 with a specific verb ('Find and optionally start') and resource ('MCP client'), making it immediately understandable. It distinguishes itself from the sibling 'tools/call' by focusing on client discovery/startup rather than tool invocation. However, it doesn't specify what constitutes 'finding' a client (e.g., local discovery vs. network scanning).

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. There's no mention of prerequisites, typical use cases, or comparison with the sibling 'tools/call' tool. The agent receives no help in determining whether this is for initial client setup, runtime client management, or troubleshooting scenarios.

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/glassBead-tc/SubspaceDomain'

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