get_analysis_card
Retrieve the full data of an analysis card, including its underlying DataFrame, to inspect numerical results such as differential expression tables, p-values, and z-scores.
Instructions
Fetch the full payload of one analysis result card, including its
underlying DataFrame (up to max_rows rows, default 50).
Use this to inspect the actual numbers behind a card — e.g. the differential expression table, spatial autocorrelation p-values, neighborhood enrichment z-scores — so you can reason over the result.
Args:
card_id: The id field from list_analysis_cards (a hex token).
max_rows: Max rows of the DataFrame to include (1–500, default 50).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| card_id | Yes | ||
| max_rows | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/millimap_mcp/server.py:237-252 (handler)The actual get_analysis_card tool handler. It accepts card_id and max_rows, then delegates to _post_tool('get_card_detail', ...) to fetch the full payload from the MilliMap desktop app via HTTP POST.
def get_analysis_card(card_id: str, max_rows: int = 50) -> str: """Fetch the full payload of one analysis result card, including its underlying DataFrame (up to ``max_rows`` rows, default 50). Use this to inspect the actual numbers behind a card — e.g. the differential expression table, spatial autocorrelation p-values, neighborhood enrichment z-scores — so you can reason over the result. Args: card_id: The ``id`` field from ``list_analysis_cards`` (a hex token). max_rows: Max rows of the DataFrame to include (1–500, default 50). """ return _fmt_json(_post_tool("get_card_detail", { "card_id": card_id, "max_rows": max_rows, })) - src/millimap_mcp/server.py:236-237 (registration)The @mcp.tool() decorator registers get_analysis_card as an MCP tool on the FastMCP server instance.
@mcp.tool() def get_analysis_card(card_id: str, max_rows: int = 50) -> str: - src/millimap_mcp/server.py:245-252 (schema)Input parameters: card_id (str, required) and max_rows (int, optional, default 50, range 1-500). Returns a JSON string via _fmt_json.
Args: card_id: The ``id`` field from ``list_analysis_cards`` (a hex token). max_rows: Max rows of the DataFrame to include (1–500, default 50). """ return _fmt_json(_post_tool("get_card_detail", { "card_id": card_id, "max_rows": max_rows, })) - src/millimap_mcp/server.py:33-58 (helper)_post_tool helper function that sends the tool call (including 'get_card_detail' used by get_analysis_card) via HTTP POST to the MilliMap desktop app's /tool endpoint.
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 used by get_analysis_card to serialize the response payload to a pretty-printed JSON string.
def _fmt_json(payload: Any) -> str: return json.dumps(payload, indent=2, default=str)