Skip to main content
Glama

search_genes

Search for specific genes in the NCBI database by entering a gene name, symbol, or query. Retrieve relevant gene information quickly with customizable result limits.

Instructions

Search for genes in NCBI database using a query

Input Schema

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

Implementation Reference

  • Core handler implementation for the search_genes tool. Performs an ESearch query on the NCBI Gene database via Entrez API, returning a SearchResult with hit count, ID list, and query translation.
    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") )
  • MCP server dispatch handler for 'search_genes' tool calls. Extracts parameters, invokes the bridge implementation, and formats the SearchResult into MCP-standard text content response.
    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'}" }] })
  • Registration of the 'search_genes' tool in the MCP server's tools/list response, including tool name, description, and input schema definition.
    { "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"] } },
  • Pydantic model defining the structure of search results returned by the search_genes handler, used for type validation and serialization.
    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")

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

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