search_proteins
Identify proteins by name or identifier across species. Specify a search query (protein or gene name) and optionally filter by species or limit results. Access data via the STRING-db MCP Server.
Instructions
Search for proteins by name or identifier across species
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results (default: 10) | |
| query | Yes | Search query (protein name, gene name, or identifier) | |
| species | No | Species name or NCBI taxonomy ID (optional) |
Implementation Reference
- src/index.ts:757-809 (handler)The handler function that executes the search_proteins tool: validates input, queries STRING API endpoint /tsv/get_string_ids, parses TSV data, formats and returns protein search results as JSON.private async handleSearchProteins(args: any) { if (!isValidSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid search arguments'); } try { const species = args.species || ''; const limit = args.limit || 10; const params: any = { identifiers: args.query, limit: limit, }; if (species) { params.species = species; } const response = await this.apiClient.get('/tsv/get_string_ids', { params }); const results = this.parseTsvData<ProteinAnnotation>(response.data); return { content: [ { type: 'text', text: JSON.stringify({ query: args.query, species_filter: species || 'all', total_results: results.length, proteins: results.map(protein => ({ string_id: protein.stringId, preferred_name: protein.preferredName, ncbi_taxon_id: protein.ncbiTaxonId, annotation: protein.annotation, protein_size: protein.protein_size, })) }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching proteins: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:378-386 (schema)Input schema definition for the search_proteins tool specifying required 'query' parameter and optional 'species' and 'limit'.inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (protein name, gene name, or identifier)' }, species: { type: 'string', description: 'Species name or NCBI taxonomy ID (optional)' }, limit: { type: 'number', description: 'Maximum number of results (default: 10)', minimum: 1, maximum: 100 }, }, required: ['query'], },
- src/index.ts:375-387 (registration)Tool registration in the MCP ListTools response, including name, description, and schema.{ name: 'search_proteins', description: 'Search for proteins by name or identifier across species', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (protein name, gene name, or identifier)' }, species: { type: 'string', description: 'Species name or NCBI taxonomy ID (optional)' }, limit: { type: 'number', description: 'Maximum number of results (default: 10)', minimum: 1, maximum: 100 }, }, required: ['query'], }, },
- src/index.ts:405-406 (registration)Dispatcher case in CallToolRequestSchema handler that routes search_proteins calls to the handler function.case 'search_proteins': return this.handleSearchProteins(args);
- src/index.ts:130-141 (helper)Validation helper function isValidSearchArgs used in the handler to check input parameters.const isValidSearchArgs = ( args: any ): args is { query: string; species?: string; limit?: number } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.species === undefined || typeof args.species === 'string') && (args.limit === undefined || (typeof args.limit === 'number' && args.limit > 0 && args.limit <= 100)) ); };