Requirements

Dependency declarations accepted by the clients’ send(requirements=...).

Usage

Source

Requirements()

add merges packages into the session declaration. get inspects it, set replaces it (emptying omitted fields), and reset restores startup defaults. Changed replacements of a live worker require control="restart", which also discards its variables. Python packages run in Console’s worker environment; installing a framework extra prepares the calling application.

Inspection normally returns JSON text, but can return a startup notice before the runtime is ready; check the response before parsing it. See the send reference for accepted package syntax, preparation policies, and complete replacement rules.

Attributes

action: Literal["get", "add", "set", "reset"]

get, add (the default), set, or reset.

python_version: list[str]

Python version constraints, such as [">=3.11"].

exclude_newer: str | None

Optional cutoff date for dependency resolution.

r: list[str]

R package requirements.

python: list[str]

Python package requirements.

duckdb: list[str]
DuckDB extensions.

Examples

Install with pip install 'mcp-console[client]'. Add NumPy to Console’s managed Python environment and use it in the same call:

from mcp_console import MCPConsole, Requirements

requirements: Requirements = {"python": ["numpy"]}
with MCPConsole() as console:
    print(
        console.send(
            requirements=requirements,
            python="import numpy as np; np.mean([12, 15, 18, 20, 25])",
        )
    )