Skip to main content
Glama

get_functional_enrichment

Identify biological functions and pathways enriched in a set of proteins using functional enrichment analysis. Supports custom species and background protein sets for precise results via STRING-db MCP Server.

Instructions

Perform functional enrichment analysis on a set of proteins

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
background_string_identifiersNoBackground protein set for enrichment (optional)
protein_idsYesList of protein identifiers
speciesNoSpecies name or NCBI taxonomy ID (default: 9606 for human)

Implementation Reference

  • Main handler function for get_functional_enrichment tool. Validates input, calls STRING API /tsv/enrichment, parses TSV data, groups results by category, and returns formatted JSON response.
    private async handleGetFunctionalEnrichment(args: any) { if (!isValidEnrichmentArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid enrichment arguments'); } try { const species = args.species || '9606'; const params: any = { identifiers: args.protein_ids.join('%0d'), species: species, caller_identity: 'string-mcp-server', }; if (args.background_string_identifiers) { params.background_string_identifiers = args.background_string_identifiers.join('%0d'); } const response = await this.apiClient.get('/tsv/enrichment', { params }); const enrichments = this.parseTsvData<EnrichmentTerm>(response.data); // Group by category const groupedEnrichments: Record<string, EnrichmentTerm[]> = {}; enrichments.forEach(term => { if (!groupedEnrichments[term.category]) { groupedEnrichments[term.category] = []; } groupedEnrichments[term.category].push(term); }); return { content: [ { type: 'text', text: JSON.stringify({ query_proteins: args.protein_ids, species: species, total_terms: enrichments.length, enrichment_categories: Object.keys(groupedEnrichments), enrichments: groupedEnrichments, significant_terms: enrichments.filter(term => term.pvalue_fdr < 0.05).length, }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error performing functional enrichment: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
  • JSON input schema defining parameters for the get_functional_enrichment tool: required protein_ids array, optional species and background_string_identifiers.
    inputSchema: { type: 'object', properties: { protein_ids: { type: 'array', items: { type: 'string' }, description: 'List of protein identifiers' }, species: { type: 'string', description: 'Species name or NCBI taxonomy ID (default: 9606 for human)' }, background_string_identifiers: { type: 'array', items: { type: 'string' }, description: 'Background protein set for enrichment (optional)' }, }, required: ['protein_ids'], },
  • src/index.ts:399-400 (registration)
    Tool registration in the switch statement that dispatches tool calls to the appropriate handler.
    case 'get_functional_enrichment': return this.handleGetFunctionalEnrichment(args);
  • Type guard function for validating input arguments matching the tool's schema before execution.
    const isValidEnrichmentArgs = ( args: any ): args is { protein_ids: string[]; species?: string; background_string_identifiers?: string[] } => { return ( typeof args === 'object' && args !== null && Array.isArray(args.protein_ids) && args.protein_ids.length > 0 && args.protein_ids.every((id: any) => typeof id === 'string') && (args.species === undefined || typeof args.species === 'string') && (args.background_string_identifiers === undefined || (Array.isArray(args.background_string_identifiers) && args.background_string_identifiers.every((id: any) => typeof id === 'string'))) ); };
  • Utility function to parse TSV responses from STRING API into typed objects, used in the handler to process enrichment results.
    private parseTsvData<T>(tsvData: string): T[] { const lines = tsvData.trim().split('\n'); if (lines.length < 2) return []; const headers = lines[0].split('\t'); const results: T[] = []; for (let i = 1; i < lines.length; i++) { const values = lines[i].split('\t'); const obj: any = {}; headers.forEach((header, index) => { const value = values[index] || ''; // Convert numeric fields if (['score', 'nscore', 'fscore', 'pscore', 'ascore', 'escore', 'dscore', 'tscore', 'ncbiTaxonId', 'protein_size', 'number_of_genes', 'number_of_genes_in_background', 'pvalue', 'pvalue_fdr'].includes(header)) { obj[header] = parseFloat(value) || 0; } else { obj[header] = value; } }); results.push(obj as T); } return results; }

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/STRING-db-MCP-Server'

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