Skip to main content
Glama

get_data

Retrieve genomic data by automatically identifying query types for genes, proteins, regions, or evolutionary analysis.

Instructions

智能数据获取接口 - 统一处理所有查询类型

自动识别查询类型:

  • "TP53" → 基因信息查询

  • "P04637" → 蛋白质详细信息查询

  • "cancer" → 基因搜索

  • "protein kinase" → 蛋白质功能搜索

  • "chr17:7565097-7590856" → 区域搜索

  • "TP53, BRCA1" → 批量基因信息

  • "breast cancer genes" → 智能搜索

  • "TP53 homologs" → 同源基因查询

  • "evolutionary conservation" → 进化分析查询

Args: query: 查询内容(可以是基因ID、蛋白质ID、搜索词、区域、ID列表、进化相关查询) query_type: 查询类型(auto/info/search/region/protein/gene_protein/ortholog/evolution) data_type: 数据类型(gene/protein/gene_protein/ortholog/evolution) format: 返回格式(simple/detailed/raw) species: 物种(默认:human,支持9606/human/mouse/rat等) max_results: 最大结果数(默认:20)

Returns: 查询结果字典,包含基因和/或蛋白质信息

Examples: # 基因信息查询 get_data("TP53") get_data("TP53", format="detailed")

# 批量查询 get_data(["TP53", "BRCA1", "BRCA2"]) # 区域搜索 get_data("chr17:7565097-7590856") # 蛋白质查询 get_data("P04637", data_type="protein") # 基因-蛋白质整合查询 get_data("TP53", data_type="gene_protein") # 蛋白质功能搜索 get_data("tumor suppressor", data_type="protein")

Input Schema

NameRequiredDescriptionDefault
queryYes
query_typeNoauto
data_typeNogene
formatNosimple
speciesNohuman
max_resultsNo

Input Schema (JSON Schema)

{ "properties": { "data_type": { "default": "gene", "type": "string" }, "format": { "default": "simple", "type": "string" }, "max_results": { "default": 20, "type": "integer" }, "query": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ] }, "query_type": { "default": "auto", "type": "string" }, "species": { "default": "human", "type": "string" } }, "required": [ "query" ], "type": "object" }

Implementation Reference

  • The primary handler implementation for the 'get_data' MCP tool. This async function handles input validation, query parsing using QueryParser, execution via QueryExecutor, result formatting, and error handling.
    @mcp.tool() async def get_data( query: str | list[str], query_type: str = "auto", data_type: str = "gene", format: str = "simple", species: str = "human", max_results: int = 20, ) -> ToolResult: """ 智能数据获取接口 - 统一处理所有查询类型 自动识别查询类型: - "TP53" → 基因信息查询 - "P04637" → 蛋白质详细信息查询 - "cancer" → 基因搜索 - "protein kinase" → 蛋白质功能搜索 - "chr17:7565097-7590856" → 区域搜索 - "TP53, BRCA1" → 批量基因信息 - "breast cancer genes" → 智能搜索 - "TP53 homologs" → 同源基因查询 - "evolutionary conservation" → 进化分析查询 Args: query: 查询内容(可以是基因ID、蛋白质ID、搜索词、区域、ID列表、进化相关查询) query_type: 查询类型(auto/info/search/region/protein/gene_protein/ortholog/evolution) data_type: 数据类型(gene/protein/gene_protein/ortholog/evolution) format: 返回格式(simple/detailed/raw) species: 物种(默认:human,支持9606/human/mouse/rat等) max_results: 最大结果数(默认:20) Returns: 查询结果字典,包含基因和/或蛋白质信息 Examples: # 基因信息查询 get_data("TP53") get_data("TP53", format="detailed") # 批量查询 get_data(["TP53", "BRCA1", "BRCA2"]) # 区域搜索 get_data("chr17:7565097-7590856") # 蛋白质查询 get_data("P04637", data_type="protein") # 基因-蛋白质整合查询 get_data("TP53", data_type="gene_protein") # 蛋白质功能搜索 get_data("tumor suppressor", data_type="protein") """ try: # 验证通用参数 validated_max_results, validated_species, validated_query_type = ( validate_common_params( max_results=max_results, species=species, query_type=query_type ) ) # 根据data_type参数调整查询类型 if data_type == "protein" and validated_query_type == "auto": validated_query_type = "protein" elif data_type == "gene_protein" and validated_query_type == "auto": validated_query_type = "gene_protein" elif data_type == "ortholog" and validated_query_type == "auto": validated_query_type = "ortholog" elif data_type == "evolution" and validated_query_type == "auto": validated_query_type = "evolution" elif data_type == "gene" and validated_query_type == "auto": validated_query_type = "auto" # 保持原有的自动识别 # 解析查询意图 parsed = QueryParser.parse(query, validated_query_type) # 使用验证后的物种信息 if "organism" not in parsed.params: parsed.params["organism"] = validated_species # 执行查询 result = await _query_executor.execute( parsed, max_results=validated_max_results ) # 格式化结果 if format == "simple": return _format_simple_result(result) elif format == "detailed": return result else: return result except ValidationError as e: return format_simple_error(e, query=query, operation="get_data") except Exception as e: return format_simple_error(e, query=query, operation="get_data")
  • Top-level registration where create_mcp_tools is imported and invoked on the FastMCP instance, registering the get_data tool among others.
    from .core.tools import create_mcp_resources, create_mcp_tools # 创建MCP实例 mcp = FastMCP("Genome MCP", version="0.2.5") # 注册所有资源和工具 create_mcp_resources(mcp) create_mcp_tools(mcp)
  • The create_mcp_tools function defines and registers the get_data tool using the @mcp.tool() decorator.
    def create_mcp_tools(mcp: FastMCP) -> None: """创建并注册所有MCP工具"""

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/gqy20/genome-mcp'

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