cursus.mcp.tools.shared

Shared input resolvers for the cursus MCP tool handlers.

Several tool namespaces (compile, config, execdoc) each grew their own near-identical “turn the args into a PipelineDAG” helper, with subtly different accepted shapes. This module is the single canonical resolver so every DAG/config-taking tool advertises and accepts the same input contract:

DAG input — supply exactly one of:
  • dag_file: path to a serialized DAG JSON file (loaded via import_dag_from_json), or

  • dag: an inline object, either the flat form {"nodes": [...], "edges": [[s, d], ...]} or the serializer/wrapped form {"dag": {"nodes": [...], "edges": [...]}}.

Config input:
  • config_file: path to the pipeline configuration JSON.

Engine imports are lazy (inside the functions) so importing the tool modules stays cheap.

resolve_dag(args)[source]

Build a PipelineDAG from args, accepting exactly one of dag_file or inline dag (flat or wrapped). Raises ToolError on bad/ambiguous input.

This is the canonical superset of the former per-tool resolvers: it errors when both sources are supplied (rather than silently preferring one) and accepts the wrapped {"dag": {...}} form everywhere.

require_config_exists(config_file)[source]

Raise ToolError unless config_file is a path to an existing file.