Skip to main content
Glama

advanced_search

Search UniProt protein data using multiple filters like organism, sequence length, molecular mass, and keywords to find specific proteins.

Instructions

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

Input Schema

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

Implementation Reference

  • The main handler function for the 'advanced_search' tool. It validates input, constructs a complex UniProt search query using filters like length, mass, organism, keywords, executes the API call, and returns the 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 definition for the 'advanced_search' tool, specifying parameters like query, organism filters, length/mass ranges, keywords, and result size.
    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:621-637 (registration)
    Registration of the 'advanced_search' tool in the ListToolsRequestSchema handler's tools array.
      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 handler dispatch in the CallToolRequestSchema switch statement.
    case 'advanced_search':
      return this.handleAdvancedSearch(args);
  • Type guard function for validating input arguments to the 'advanced_search' tool.
    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))
      );
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It mentions 'complex queries' but doesn't disclose important behavioral traits like whether this is a read-only operation, performance characteristics, rate limits, authentication requirements, or what happens when multiple filters conflict. The description is insufficient for a tool with 8 parameters and no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise (one phrase) and front-loaded with the core purpose. However, it's arguably too brief for a tool with 8 parameters and complex functionality - it could benefit from slightly more context without becoming verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex search tool with 8 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what type of data is being searched (proteins based on sibling context), what the output format looks like, how filters combine, or any error conditions. The description leaves too many open questions for effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 8 parameters thoroughly. The description mentions filter types (length, mass, organism, function) which maps to some parameters, but doesn't add meaningful semantic context beyond what's in the schema descriptions. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool performs 'complex queries with multiple filters' which gives a general purpose, but it's vague about what exactly is being searched (proteins, sequences, etc.) and doesn't clearly distinguish it from sibling tools like 'search_proteins' or 'search_by_function'. It mentions filter types but not the resource being queried.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided about when to use this tool versus alternatives. With many sibling search tools (search_proteins, search_by_function, search_by_taxonomy, etc.), the description doesn't explain what makes 'advanced_search' different or when it should be preferred over simpler search tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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