search_go_terms
Search Gene Ontology terms by keyword, name, or definition to find biological functions, processes, and cellular components for research and analysis.
Instructions
Search across Gene Ontology terms by keyword, name, or definition
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query (term name, keyword, or definition) | |
| ontology | No | GO ontology to search (default: all) | |
| size | No | Number of results to return (1-500, default: 25) | |
| exact | No | Exact match only (default: false) | |
| include_obsolete | No | Include obsolete terms (default: false) |
Implementation Reference
- src/index.ts:372-429 (handler)The private async handleSearchGoTerms function that executes the tool logic: validates input, constructs QuickGO API request for term search, processes results, and returns formatted JSON.private async handleSearchGoTerms(args: any) { if (!isValidSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid search arguments'); } try { const params: any = { query: args.query, limit: args.size || 25, page: 1, }; if (args.ontology && args.ontology !== 'all') { params.aspect = args.ontology === 'molecular_function' ? 'F' : args.ontology === 'biological_process' ? 'P' : 'C'; } if (args.include_obsolete === false) { params.obsolete = 'false'; } const response = await this.quickGoClient.get('/ontology/go/search', { params }); const searchResults = { query: args.query, totalResults: response.data.numberOfHits || 0, returnedResults: response.data.results?.length || 0, results: response.data.results?.map((term: any) => ({ id: term.id, name: term.name, definition: term.definition?.text || 'No definition available', namespace: term.aspect === 'F' ? 'molecular_function' : term.aspect === 'P' ? 'biological_process' : 'cellular_component', obsolete: term.isObsolete || false, url: `https://www.ebi.ac.uk/QuickGO/term/${term.id}` })) || [] }; return { content: [ { type: 'text', text: JSON.stringify(searchResults, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error searching GO terms: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
- src/index.ts:287-301 (schema)Input schema defining the parameters for search_go_terms tool: query (required), ontology, size, exact, include_obsolete.inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (term name, keyword, or definition)' }, ontology: { type: 'string', enum: ['molecular_function', 'biological_process', 'cellular_component', 'all'], description: 'GO ontology to search (default: all)' }, size: { type: 'number', description: 'Number of results to return (1-500, default: 25)', minimum: 1, maximum: 500 }, exact: { type: 'boolean', description: 'Exact match only (default: false)' }, include_obsolete: { type: 'boolean', description: 'Include obsolete terms (default: false)' }, }, required: ['query'], },
- src/index.ts:284-302 (registration)Registration of the search_go_terms tool in the ListToolsRequestSchema response, including name, description, and input schema.{ name: 'search_go_terms', description: 'Search across Gene Ontology terms by keyword, name, or definition', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Search query (term name, keyword, or definition)' }, ontology: { type: 'string', enum: ['molecular_function', 'biological_process', 'cellular_component', 'all'], description: 'GO ontology to search (default: all)' }, size: { type: 'number', description: 'Number of results to return (1-500, default: 25)', minimum: 1, maximum: 500 }, exact: { type: 'boolean', description: 'Exact match only (default: false)' }, include_obsolete: { type: 'boolean', description: 'Include obsolete terms (default: false)' }, }, required: ['query'], }, },
- src/index.ts:65-82 (helper)Type guard helper function used in handleSearchGoTerms to validate input arguments before processing.const isValidSearchArgs = (args: any): args is { query: string; ontology?: string; size?: number; exact?: boolean; include_obsolete?: boolean; } => { return ( typeof args === 'object' && args !== null && typeof args.query === 'string' && args.query.length > 0 && (args.ontology === undefined || ['molecular_function', 'biological_process', 'cellular_component', 'all'].includes(args.ontology)) && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 500)) && (args.exact === undefined || typeof args.exact === 'boolean') && (args.include_obsolete === undefined || typeof args.include_obsolete === 'boolean') ); };
- src/index.ts:343-344 (registration)Dispatch case in CallToolRequestSchema handler that routes search_go_terms calls to the handler function.case 'search_go_terms': return this.handleSearchGoTerms(args);