score_gene_signature
Score a gene signature across all cells and add it as a new observation column. Apply published signatures like exhausted T cell markers or EMT genes to enable color-based visualization in MilliMap.
Instructions
Score a gene signature across all cells and add it as an obs column.
Use this to apply a published signature (e.g. exhausted T cell markers, EMT genes) to the dataset. The score becomes a colorable field in MilliMap.
Args: genes: List of gene symbols to score together. score_name: Name for the new obs column (default 'mcp_score').
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| genes | Yes | ||
| score_name | No | mcp_score |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/millimap_mcp/server.py:308-321 (handler)The `score_gene_signature` tool handler function decorated with `@mcp.tool()`. It accepts a list of gene symbols and an optional score_name, then proxies the call to the MilliMap desktop app via `_post_tool`.
@mcp.tool() def score_gene_signature(genes: list[str], score_name: str = "mcp_score") -> str: """Score a gene signature across all cells and add it as an obs column. Use this to apply a published signature (e.g. exhausted T cell markers, EMT genes) to the dataset. The score becomes a colorable field in MilliMap. Args: genes: List of gene symbols to score together. score_name: Name for the new obs column (default 'mcp_score'). """ return _fmt_json(_post_tool("score_gene_signature", { "genes": genes, "score_name": score_name, })) - src/millimap_mcp/server.py:308-321 (registration)The `@mcp.tool()` decorator on line 308 registers `score_gene_signature` as an MCP tool on the FastMCP server instance.
@mcp.tool() def score_gene_signature(genes: list[str], score_name: str = "mcp_score") -> str: """Score a gene signature across all cells and add it as an obs column. Use this to apply a published signature (e.g. exhausted T cell markers, EMT genes) to the dataset. The score becomes a colorable field in MilliMap. Args: genes: List of gene symbols to score together. score_name: Name for the new obs column (default 'mcp_score'). """ return _fmt_json(_post_tool("score_gene_signature", { "genes": genes, "score_name": score_name, })) - src/millimap_mcp/server.py:319-321 (helper)The `score_gene_signature` handler calls `_post_tool` (defined at line 33) to send a POST request to the MilliMap desktop app's /tool endpoint with the tool name and args.
return _fmt_json(_post_tool("score_gene_signature", { "genes": genes, "score_name": score_name, })) - src/millimap_mcp/server.py:33-58 (helper)The `_post_tool` helper function that sends the tool call to the MilliMap desktop HTTP server. It reads the control file for host/port, posts the tool name and args as JSON, and returns the response.
def _post_tool(name: str, args: dict, timeout: float = 600.0) -> dict: ctrl = _load_control() if not ctrl or not ctrl.get("port"): return { "ok": False, "error": ( f"MilliMap control endpoint not found at {CONTROL_PATH}. " "Make sure MilliMap is running with a dataset loaded." ), } host = ctrl.get("host", "127.0.0.1") port = int(ctrl["port"]) url = f"http://{host}:{port}/tool" data = json.dumps({"name": name, "args": args}).encode("utf-8") req = urllib.request.Request( url, data=data, headers={"Content-Type": "application/json"}, method="POST", ) try: with urllib.request.urlopen(req, timeout=timeout) as resp: return json.loads(resp.read().decode("utf-8")) except urllib.error.URLError as exc: return {"ok": False, "error": f"connection failed: {exc.reason}"} except Exception as exc: return {"ok": False, "error": f"HTTP call failed: {exc}"}