Skip to main content
Glama
mohammadnajeeb

NCBI Gene MCP Server

search_genes

Search for genes in the NCBI database using gene names, symbols, or other identifiers to retrieve relevant gene information and metadata.

Instructions

Search for genes in NCBI database using a query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesSearch query (gene name, symbol, etc.)
max_resultsNoMaximum number of results to return (default: 20)

Implementation Reference

  • Core implementation of the search_genes tool using NCBI Entrez esearch API to search the gene database.
    def search_genes(self, query: str, max_results: int = 20) -> SearchResult:
        """
        Search for genes using NCBI Entrez.
        
        Args:
            query: Search query (gene name, symbol, etc.)
            max_results: Maximum number of results to return
            
        Returns:
            SearchResult object containing IDs and metadata
        """
        params = {
            "db": "gene",
            "term": query,
            "retmax": max_results
        }
        
        response = self._make_request("esearch", params)
        
        esearch_result = response.get("esearchresult", {})
        
        return SearchResult(
            count=int(esearch_result.get("count", 0)),
            ids=esearch_result.get("idlist", []),
            query_translation=esearch_result.get("querytranslation")
        )
  • Registration of the search_genes tool in the MCP server's tools/list, defining name, description, and input schema.
        "name": "search_genes",
        "description": "Search for genes in NCBI database using a query",
        "inputSchema": {
            "type": "object",
            "properties": {
                "query": {
                    "type": "string",
                    "description": "Search query (gene name, symbol, etc.)"
                },
                "max_results": {
                    "type": "integer",
                    "description": "Maximum number of results to return (default: 20)",
                    "default": 20
                }
            },
            "required": ["query"]
        }
    },
  • MCP server handler for tools/call requests to search_genes, extracting parameters and calling the bridge implementation.
    if name == "search_genes":
        query = arguments.get("query")
        max_results = arguments.get("max_results", 20)
        if not query:
            raise ValueError("query is required")
        
        result = self.bridge.search_genes(query, max_results)
        self.send_response({
            "content": [{
                "type": "text", 
                "text": f"Found {result.count} genes matching '{query}':\n\nGene IDs: {', '.join(result.ids[:10])}\n\nQuery translation: {result.query_translation or 'N/A'}"
            }]
        })
  • Pydantic model SearchResult used as return type for search_genes, defining structure of search results.
    class SearchResult(BaseModel):
        """Model for search results from NCBI Entrez."""
        
        count: int = Field(description="Total number of results")
        ids: List[str] = Field(description="List of IDs found")
        query_translation: Optional[str] = Field(default=None, description="Translated query")
  • Input schema definition for search_genes tool in MCP registration.
    "inputSchema": {
        "type": "object",
        "properties": {
            "query": {
                "type": "string",
                "description": "Search query (gene name, symbol, etc.)"
            },
            "max_results": {
                "type": "integer",
                "description": "Maximum number of results to return (default: 20)",
                "default": 20
            }
        },
        "required": ["query"]
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the basic function but doesn't mention important behavioral traits like whether this is a read-only operation, what authentication might be needed, rate limits, what happens with no results, or what format results come in. For a search tool with zero annotation coverage, this is inadequate.

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

Conciseness5/5

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

The description is a single, efficient sentence that states the core function without unnecessary words. It's appropriately sized for a simple search tool and front-loads the essential information. Every word earns its place.

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?

Given the lack of annotations and output schema, the description is insufficiently complete. For a search tool that likely returns structured gene data, the description should at minimum indicate what kind of information is returned (IDs, names, summaries?) and mention any important constraints. The current description leaves too much undefined for proper agent usage.

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 fully documents both parameters (query and max_results). The description doesn't add any parameter semantics beyond what's in the schema - it doesn't explain query syntax examples, what 'gene name, symbol, etc.' means practically, or how max_results affects performance. 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.

Purpose4/5

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

The description clearly states the action ('Search for genes') and the target resource ('NCBI database'), providing a specific verb+resource combination. However, it doesn't differentiate this tool from its siblings (fetch_gene_info, fetch_protein_info, search_by_gene_symbol), which likely have overlapping or related functionality.

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?

The description provides no guidance on when to use this tool versus its siblings. There's no mention of alternatives, exclusions, or specific contexts where this search tool is preferred over fetch_gene_info or search_by_gene_symbol. The agent must infer usage from tool names alone.

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/mohammadnajeeb/ncbi_gene_mcp_client'

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