A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix(mcp-server): create dataclass wrapper for VariableValue to resolve Pydantic compatibility (#6265)
Joaquin Corominac7be32af39ad
diff --git a/marimo/_mcp/server/tools/cells.py b/marimo/_mcp/server/tools/cells.pyindex 305c6a5294..cfe4d00068 100644--- a/marimo/_mcp/server/tools/cells.py+++ b/marimo/_mcp/server/tools/cells.py@@ -11,7 +11,6 @@ from marimo._mcp.server.exceptions import ToolExecutionErrorfrom marimo._mcp.server.responses import (SuccessResult,)-from marimo._messaging.ops import VariableValuefrom marimo._server.api.deps import AppStateBasefrom marimo._types.ids import CellId_t, SessionId@@ -69,7 +68,14 @@ class CellRuntimeMetadata:execution_time: Optional[float]-CellVariables = dict[str, VariableValue]+@dataclass(kw_only=True)+class CellVariableValue:+ name: str+ value: Optional[str] = None+ datatype: Optional[str] = None+++CellVariables = dict[str, CellVariableValue]@dataclass(kw_only=True)@@ -407,6 +413,11 @@ def _get_cell_variables(for var_name in cell_defs:if var_name in all_variables:var_value = all_variables[var_name]- cell_variables[var_name] = var_value+ # Convert VariableValue to pydantic parsable dataclass+ cell_variables[var_name] = CellVariableValue(+ name=var_name,+ value=var_value.value,+ datatype=var_value.datatype,+ )return cell_variablesdiff --git a/tests/_mcp/server/tools/test_cells.py b/tests/_mcp/server/tools/test_cells.pyindex ffe61daffc..772ef48a7e 100644--- a/tests/_mcp/server/tools/test_cells.py+++ b/tests/_mcp/server/tools/test_cells.py@@ -12,6 +12,7 @@ from marimo._mcp.server.tools.cells import (CellErrors,CellRuntimeMetadata,CellVariables,+ CellVariableValue,SupportedCellType,_determine_cell_type,_get_cell_errors,@@ -241,7 +242,14 @@ def test_get_cell_variables_with_variables():result = _get_cell_variables(session, cell_data)- expected: CellVariables = {"x": var_x, "y": var_y}+ expected: CellVariables = {+ "x": CellVariableValue(+ name="x", value=var_x.value, datatype=var_x.datatype+ ),+ "y": CellVariableValue(+ name="y", value=var_y.value, datatype=var_y.datatype+ ),+ }assert result == expectedassert ("z" not in result@@ -262,5 +270,9 @@ def test_get_cell_variables_missing_variables():result = _get_cell_variables(session, cell_data)# Should only include variables that exist in session- expected: CellVariables = {"x": var_x}+ expected: CellVariables = {+ "x": CellVariableValue(+ name="x", value=var_x.value, datatype=var_x.datatype+ )+ }assert result == expected