Skip to content

tools

tools

Marianne MCP tools for conductor records, controls, and artifacts.

This module implements MCP tools that expose conductor-managed Marianne score execution to external AI agents. Tools are organized by category:

  • JobTools: submitted-score lifecycle management (list, get, start)
  • ControlTools: conductor control operations (pause, resume, cancel)
  • ArtifactTools: Workspace and artifact management

Each tool follows the MCP specification for parameter schemas and return values. Tools leverage the existing JobControlService for consistent behavior with the dashboard.

Classes

JobTools

JobTools(state_backend, workspace_root)

Marianne submitted-score lifecycle management tools.

Provides MCP tools for running, monitoring, and querying submitted scores. Tools require explicit user consent due to file system and process execution.

Routes through the conductor for all operations.

Source code in src/marianne/mcp/tools.py
def __init__(self, state_backend: StateBackend, workspace_root: Path):
    self.state_backend = state_backend
    self._daemon_client = DaemonClient(_resolve_socket_path(None))
    self.job_control = JobControlService(self._daemon_client)
Methods:
list_tools async
list_tools()

List all submitted-score management tools.

Source code in src/marianne/mcp/tools.py
async def list_tools(self) -> list[dict[str, Any]]:
    """List all submitted-score management tools."""
    return [
        {
            "name": "list_jobs",
            "description": (
                "List conductor records for submitted Marianne scores with current status"
            ),
            "inputSchema": {
                "type": "object",
                "properties": {
                    "status_filter": {
                        "type": "string",
                        "description": (
                            "Filter submitted scores by status "
                            "(running, paused, completed, failed, cancelled)"
                        ),
                        "enum": ["running", "paused", "completed", "failed", "cancelled"],
                    },
                    "limit": {
                        "type": "integer",
                        "description": "Maximum number of jobs to return",
                        "default": 50,
                        "minimum": 1,
                        "maximum": 500,
                    },
                },
                "required": [],
            },
        },
        {
            "name": "get_job",
            "description": (
                "Get detailed conductor state for a submitted Marianne score"
            ),
            "inputSchema": {
                "type": "object",
                "properties": {
                    "job_id": {
                        "type": "string",
                        "description": (
                            "Conductor runtime identifier for the submitted score"
                        ),
                    }
                },
                "required": ["job_id"],
            },
        },
        {
            "name": "start_job",
            "description": (
                "Submit a Marianne score YAML file to the conductor. "
                "Set confirm_fresh=true when fresh=true because fresh clears "
                "existing score state."
            ),
            "inputSchema": {
                "type": "object",
                "properties": {
                    "config_path": {
                        "type": "string",
                        "description": "Path to the Marianne score YAML file (.yaml/.yml)",
                    },
                    "workspace": {
                        "type": "string",
                        "description": "Workspace directory for score execution (optional)",
                    },
                    "client_cwd": {
                        "type": "string",
                        "description": (
                            "Client working directory for resolving relative score paths"
                        ),
                    },
                    "start_sheet": {
                        "type": "integer",
                        "description": "Sheet number to start from (1-indexed)",
                        "default": 1,
                        "minimum": 1,
                    },
                    "self_healing": {
                        "type": "boolean",
                        "description": "Enable self-healing mode for automatic error recovery",
                        "default": False,
                    },
                    "self_healing_auto_confirm": {
                        "type": "boolean",
                        "description": "Auto-confirm self-healing fixes",
                        "default": False,
                    },
                    "escalation": {
                        "type": "boolean",
                        "description": "Pause for composer decision on exhaustion",
                        "default": False,
                    },
                    "dry_run": {
                        "type": "boolean",
                        "description": "Validate without executing when supported",
                        "default": False,
                    },
                    "fresh": {
                        "type": "boolean",
                        "description": "Clear existing score state before submitting",
                        "default": False,
                    },
                    "confirm_fresh": {
                        "type": "boolean",
                        "description": "Required when fresh is true",
                        "default": False,
                    },
                    "chain_depth": {
                        "type": "integer",
                        "description": "Concert chain depth for chained submissions",
                        "minimum": 0,
                    },
                    "runtime_variables": {
                        "type": "object",
                        "description": "Per-invocation template variables",
                        "additionalProperties": {"type": "string"},
                    },
                },
                "required": ["config_path"],
            },
        },
    ]
call_tool async
call_tool(name, arguments)

Execute a job management tool.

Source code in src/marianne/mcp/tools.py
async def call_tool(self, name: str, arguments: dict[str, Any]) -> dict[str, Any]:
    """Execute a job management tool."""
    try:
        if name == "list_jobs":
            return await self._list_jobs(arguments)
        elif name == "get_job":
            return await self._get_job(arguments)
        elif name == "start_job":
            return await self._start_job(arguments)
        else:
            raise ValueError(f"Unknown job tool: {name}")

    except (
        DaemonError,
        KeyError,
        ValueError,
        FileNotFoundError,
        RuntimeError,
        OSError,
        ConnectionError,
    ) as e:
        logger.exception("mcp.tool_error", tool=name)
        return _make_error_response(e)
shutdown async
shutdown()

Cleanup job tools.

Source code in src/marianne/mcp/tools.py
async def shutdown(self) -> None:
    """Cleanup job tools."""
    await self._daemon_client.close()

ControlTools

ControlTools(state_backend, workspace_root)

Marianne conductor control tools.

Provides MCP tools for controlling conductor records for submitted scores. These tools interact with running score processes and require user consent.

Routes through the conductor for all operations.

Source code in src/marianne/mcp/tools.py
def __init__(self, state_backend: StateBackend, workspace_root: Path):
    self.state_backend = state_backend
    self._daemon_client = DaemonClient(_resolve_socket_path(None))
    self.job_control = JobControlService(self._daemon_client)
Methods:
list_tools async
list_tools()

List all job control tools.

Source code in src/marianne/mcp/tools.py
async def list_tools(self) -> list[dict[str, Any]]:
    """List all job control tools."""
    return [
        {
            "name": "pause_job",
            "description": (
                "Pause a running Marianne score gracefully at a sheet boundary"
            ),
            "inputSchema": {
                "type": "object",
                "properties": {
                    "job_id": {
                        "type": "string",
                        "description": (
                            "Conductor runtime identifier for the submitted score"
                        ),
                    }
                },
                "required": ["job_id"],
            },
        },
        {
            "name": "resume_job",
            "description": "Resume a paused Marianne score",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "job_id": {
                        "type": "string",
                        "description": (
                            "Conductor runtime identifier for the submitted score"
                        ),
                    }
                },
                "required": ["job_id"],
            },
        },
        {
            "name": "cancel_job",
            "description": "Cancel a running Marianne score permanently",
            "inputSchema": {
                "type": "object",
                "properties": {
                    "job_id": {
                        "type": "string",
                        "description": (
                            "Conductor runtime identifier for the submitted score"
                        ),
                    }
                },
                "required": ["job_id"],
            },
        },
    ]
call_tool async
call_tool(name, arguments)

Execute a job control tool.

Source code in src/marianne/mcp/tools.py
async def call_tool(self, name: str, arguments: dict[str, Any]) -> dict[str, Any]:
    """Execute a job control tool."""
    try:
        if name == "pause_job":
            return await self._pause_job(arguments)
        elif name == "resume_job":
            return await self._resume_job(arguments)
        elif name == "cancel_job":
            return await self._cancel_job(arguments)
        else:
            raise ValueError(f"Unknown control tool: {name}")

    except (DaemonError, KeyError, ValueError, RuntimeError, OSError, ConnectionError) as e:
        logger.exception("mcp.control_tool_error", tool=name)
        return _make_error_response(e)
shutdown async
shutdown()

Cleanup control tools.

Source code in src/marianne/mcp/tools.py
async def shutdown(self) -> None:
    """Cleanup control tools."""
    await self._daemon_client.close()

ArtifactTools

ArtifactTools(workspace_root, state_backend=None)

Marianne artifact and workspace management tools.

Provides MCP tools for browsing workspace files and accessing job artifacts. File system access is restricted to designated workspace directories.

Source code in src/marianne/mcp/tools.py
def __init__(self, workspace_root: Path, state_backend: StateBackend | None = None):
    self.workspace_root = workspace_root
    self.state_backend = state_backend
    self._custom_level_cache: dict[str, re.Pattern[str]] = {}
Methods:
list_tools async
list_tools()

List all artifact management tools.

Source code in src/marianne/mcp/tools.py
async def list_tools(self) -> list[dict[str, Any]]:
    """List all artifact management tools."""
    return list(_ARTIFACT_TOOL_SCHEMAS)
call_tool async
call_tool(name, arguments)

Execute an artifact management tool.

Source code in src/marianne/mcp/tools.py
async def call_tool(self, name: str, arguments: dict[str, Any]) -> dict[str, Any]:
    """Execute an artifact management tool."""
    dispatch = {
        "marianne_artifact_list": self._list_files,
        "marianne_artifact_read": self._read_file,
        "marianne_artifact_get_logs": self._get_logs,
        "marianne_artifact_list_artifacts": self._list_artifacts,
        "marianne_artifact_get_artifact": self._get_artifact,
    }
    handler = dispatch.get(name)
    if handler is None:
        return {
            "content": [{"type": "text", "text": f"Error: Unknown artifact tool: {name}"}],
            "isError": True,
        }
    try:
        return await handler(arguments)
    except (
        KeyError,
        ValueError,
        FileNotFoundError,
        IsADirectoryError,
        NotADirectoryError,
        PermissionError,
        OSError,
    ) as e:
        logger.exception("mcp.artifact_tool_error", tool=name)
        return _make_error_response(e)
shutdown async
shutdown()

Cleanup artifact tools.

Source code in src/marianne/mcp/tools.py
async def shutdown(self) -> None:
    """Cleanup artifact tools."""
    pass

Functions: