apply_qc_filter
Set thresholds for minimum/maximum genes, minimum counts, and maximum mitochondrial percentage to filter the active dataset. The filtered subset replaces the data and remains revertible.
Instructions
Apply QC filters to the active dataset in MilliMap.
Replaces the active adata with the filtered subset and re-renders. The original can be restored via the in-app QC controls.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| min_genes | No | ||
| max_genes | No | ||
| min_counts | No | ||
| max_mito_pct | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/millimap_mcp/server.py:324-339 (handler)The MCP tool handler for 'apply_qc_filter'. It accepts min_genes, max_genes, min_counts, and max_mito_pct parameters with sensible defaults and delegates to the MilliMap desktop app via HTTP POST.
@mcp.tool() def apply_qc_filter( min_genes: int = 200, max_genes: int = 6000, min_counts: int = 500, max_mito_pct: float = 20.0, ) -> str: """Apply QC filters to the active dataset in MilliMap. Replaces the active adata with the filtered subset and re-renders. The original can be restored via the in-app QC controls. """ return _fmt_json(_post_tool("apply_qc_filter", { "min_genes": min_genes, "max_genes": max_genes, "min_counts": min_counts, "max_mito_pct": max_mito_pct, })) - src/millimap_mcp/server.py:33-58 (helper)_post_tool helper function that sends the tool name and arguments to the running MilliMap desktop app via HTTP POST to http://127.0.0.1:<port>/tool.
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}"} - src/millimap_mcp/server.py:77-78 (helper)_fmt_json helper that serializes the response to a pretty-printed JSON string for the MCP response.
def _fmt_json(payload: Any) -> str: return json.dumps(payload, indent=2, default=str) - src/millimap_mcp/server.py:324-324 (registration)The '@mcp.tool()' decorator registers 'apply_qc_filter' as an MCP tool with the FastMCP server instance on line 22.
@mcp.tool()