Skip to main content
Glama

search_targets

Discover therapeutic targets by searching gene symbols, names, or descriptions using this tool. Specify query, result size, and output format for precise research insights.

Instructions

Search for therapeutic targets by gene symbol, name, or description

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOutput format (default: json)
queryYesSearch query (gene symbol, name, description)
sizeNoNumber of results to return (1-500, default: 25)

Implementation Reference

  • The primary handler function for the 'search_targets' tool. It validates the input arguments using isValidTargetSearchArgs, constructs and executes a GraphQL query to search for targets in the Open Targets API, limits the results based on the 'size' parameter, formats the response as JSON, and returns it as tool content. Handles errors by returning an error message.
    private async handleSearchTargets(args: any) { if (!isValidTargetSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid target search arguments'); } try { const query = ` query SearchTargets($queryString: String!) { search(queryString: $queryString, entityNames: ["target"]) { hits { id name description entity } } } `; const response = await this.graphqlClient.post('', { query, variables: { queryString: args.query } }); // Limit results on client side const hits = response.data.data?.search?.hits || []; const limitedHits = hits.slice(0, args.size || 25); const result = { ...response.data, data: { search: { hits: limitedHits, total: hits.length } } }; return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching targets: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
  • The input schema definition for the 'search_targets' tool, specifying the expected parameters: required 'query' string, optional 'size' number (1-500), and optional 'format' enum ['json', 'tsv']. Used in tool registration.
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (gene symbol, name, description)' }, size: { type: 'number', description: 'Number of results to return (1-500, default: 25)', minimum: 1, maximum: 500 }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, }, required: ['query'], },
  • src/index.ts:210-222 (registration)
    Tool registration entry in the ListToolsRequestSchema handler, defining the 'search_targets' tool with its name, description, and input schema.
    { name: 'search_targets', description: 'Search for therapeutic targets by gene symbol, name, or description', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (gene symbol, name, description)' }, size: { type: 'number', description: 'Number of results to return (1-500, default: 25)', minimum: 1, maximum: 500 }, format: { type: 'string', enum: ['json', 'tsv'], description: 'Output format (default: json)' }, }, required: ['query'], }, },
  • src/index.ts:292-293 (registration)
    Dispatch logic in the CallToolRequestSchema handler's switch statement, routing calls to 'search_targets' to the handleSearchTargets method.
    case 'search_targets': return this.handleSearchTargets(args);
  • Helper validation function (type guard) used by the handler to validate input arguments for the 'search_targets' tool, checking query is non-empty string, size is valid number, and format is json or tsv.
    const isValidTargetSearchArgs = (args: any): args is { query: string; size?: number; format?: string } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 500)) && (args.format === undefined || ['json', 'tsv'].includes(args.format)) ); };

Other Tools

Related 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/Augmented-Nature/OpenTargets-MCP-Server'

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