Skip to main content
Glama

search_targets

Search for therapeutic targets using gene symbols, names, or descriptions to identify potential drug targets for disease research.

Instructions

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

Input Schema

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

Implementation Reference

  • The handler function that implements the core logic of the 'search_targets' tool: validates input, executes a GraphQL query to the Open Targets API to search for targets, limits results based on size parameter, and returns formatted JSON response.
    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, }; } }
  • JSON Schema defining the input parameters for the 'search_targets' tool, including required 'query' string and optional 'size' and 'format'.
    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)
    Registration of the 'search_targets' tool in the ListTools response, specifying 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)
    Switch case in CallToolRequest handler that dispatches calls to 'search_targets' to the handleSearchTargets method.
    case 'search_targets': return this.handleSearchTargets(args);
  • Type guard and validation helper function used by the handler to validate input arguments for 'search_targets'.
    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)) ); };

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