Subchapter 2.45
references/cli/api/general.mdMarkdown5 KBView on GitHub
dg apiDagster Plus exposes the same resources two ways: the Dagster Plus MCP server and the dg api CLI. When both can do the job, prefer the MCP server — it returns structured data directly, needs no shell or , and avoids parsing CLI output.
dg plus loginDecide once, at the start of the task:
list_deployments may appear as mcp__dagster__list_deployments or similar. Look for the distinctive names (list_deployments, get_assets, launch_asset_run, get_alert_policies_as_document) rather than generic ones like get_run or list_runs, which another server could also define.dg api reference file names its MCP counterpart under an “MCP equivalent” heading.dg api commands documented here.A reference file with no “MCP equivalent” section is CLI-only, meaning the server exposes no tool for that command. Absence is the signal; there are no explicit “no equivalent” notes to look for.
Falling back is expected, not a failure. The server covers most read paths but leaves real gaps — compute logs, server-side event filtering, fetching a single Issue, asset events and evaluations, schedules, sensors, and secrets among them. Use the CLI whenever the operation you need has no tool, even in the middle of an otherwise MCP-based task.
What to avoid is switching paths for the same call: do not launch a run through MCP and then launch it again through the CLI, or page through one result set alternating between them.
When you do fall back, keep both paths pointed at the same place:
--deployment <name> explicitly, using the same deployment_name you gave the MCP tools. Otherwise the CLI targets whatever dg plus login configured, which may be a different deployment.list_deployments and dg api deployment list disagree, they are pointed at different organizations — say so rather than merging the two sets of results.dg api command if one exists; otherwise tell the user the Dagster Plus MCP server needs to be reconnected.DAGSTER_CLOUD_MCP_URL=https://mcp.agent.eu.dagster.cloud/mcp and reconnect; the US server has no record of an EU organization.deployment_name. Call list_deployments first if you don’t already know it.["warehouse", "orders"]), not the slash-separated strings the CLI uses (warehouse/orders).list_runs, get_assets, get_run_logs) return a cursor; pass it back to fetch the next page.All dg api subcommands support --json, --response-schema, --deployment, --organization, --api-token, and --view-graphql.
--response-schema — prints the JSON schema for the command’s response and exits. Run this before writing any parsing logic to get exact field names, types, and valid enum values.--view-graphql — prints GraphQL queries and responses to stderr, useful for debugging.For complex debugging/analysis workflows, ALWAYS use --json to get machine-readable output. Pipe into jq (recommended) or other tools for further processing.
Flags like --deployment/--organization/--api-token are typically not needed when authenticated via dg plus login. The exception is falling back from the MCP server mid-task: pass --deployment explicitly there, since the login default and the deployment you were querying through MCP need not be the same.