Skip to main content
Glama

advanced_search

Perform complex protein searches using multiple filters such as sequence length, molecular mass, organism, and function on the UniProt MCP Server. Refine results with keywords and customize output size.

Instructions

Complex queries with multiple filters (length, mass, organism, function)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
keywordsNoArray of keywords to include
maxLengthNoMaximum sequence length
maxMassNoMaximum molecular mass (Da)
minLengthNoMinimum sequence length
minMassNoMinimum molecular mass (Da)
organismNoOrganism name or taxonomy ID
queryNoBase search query
sizeNoNumber of results to return (1-500, default: 25)

Implementation Reference

  • The handler function that implements the advanced_search tool. It validates input, constructs a complex UniProt search query using filters (query, organism, length/mass ranges, keywords), queries the UniProt API, and returns JSON results.
    private async handleAdvancedSearch(args: any) { if (!isValidAdvancedSearchArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid advanced search arguments'); } try { let query = 'reviewed:true'; if (args.query) { query += ` AND (${args.query})`; } if (args.organism) { query += ` AND organism_name:"${args.organism}"`; } if (args.minLength || args.maxLength) { if (args.minLength && args.maxLength) { query += ` AND length:[${args.minLength} TO ${args.maxLength}]`; } else if (args.minLength) { query += ` AND length:[${args.minLength} TO *]`; } else if (args.maxLength) { query += ` AND length:[* TO ${args.maxLength}]`; } } if (args.minMass || args.maxMass) { if (args.minMass && args.maxMass) { query += ` AND mass:[${args.minMass} TO ${args.maxMass}]`; } else if (args.minMass) { query += ` AND mass:[${args.minMass} TO *]`; } else if (args.maxMass) { query += ` AND mass:[* TO ${args.maxMass}]`; } } if (args.keywords) { for (const keyword of args.keywords) { query += ` AND keyword:"${keyword}"`; } } const response = await this.apiClient.get('/uniprotkb/search', { params: { query: query, format: 'json', size: args.size || 25, }, }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error in advanced search: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
  • The input schema and metadata for the advanced_search tool as registered in the ListTools response.
    name: 'advanced_search', description: 'Complex queries with multiple filters (length, mass, organism, function)', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Base search query' }, organism: { type: 'string', description: 'Organism name or taxonomy ID' }, minLength: { type: 'number', description: 'Minimum sequence length', minimum: 1 }, maxLength: { type: 'number', description: 'Maximum sequence length' }, minMass: { type: 'number', description: 'Minimum molecular mass (Da)', minimum: 1 }, maxMass: { type: 'number', description: 'Maximum molecular mass (Da)' }, keywords: { type: 'array', items: { type: 'string' }, description: 'Array of keywords to include' }, size: { type: 'number', description: 'Number of results to return (1-500, default: 25)', minimum: 1, maximum: 500 }, }, required: [], }, },
  • src/index.ts:768-769 (registration)
    Registration of the advanced_search tool in the CallToolRequestSchema switch statement, dispatching to the handler.
    case 'advanced_search': return this.handleAdvancedSearch(args);
  • Type guard and validation function for advanced_search input arguments, ensuring correct types and ranges.
    const isValidAdvancedSearchArgs = ( args: any ): args is { query?: string; organism?: string; minLength?: number; maxLength?: number; minMass?: number; maxMass?: number; keywords?: string[]; size?: number } => { return ( typeof args === 'object' && args !== null && (args.query === undefined || typeof args.query === 'string') && (args.organism === undefined || typeof args.organism === 'string') && (args.minLength === undefined || (typeof args.minLength === 'number' && args.minLength > 0)) && (args.maxLength === undefined || (typeof args.maxLength === 'number' && args.maxLength > 0)) && (args.minMass === undefined || (typeof args.minMass === 'number' && args.minMass > 0)) && (args.maxMass === undefined || (typeof args.maxMass === 'number' && args.maxMass > 0)) && (args.keywords === undefined || (Array.isArray(args.keywords) && args.keywords.every((k: any) => typeof k === 'string'))) && (args.size === undefined || (typeof args.size === 'number' && args.size > 0 && args.size <= 500)) ); };

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

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