Model Context Protocol Tools

Every tool the once mcpModel Context Protocol server advertises in tools/list, with its input schema and a worked return example.

once_query_workspace#

Return the configured workspace root, root manifest state, graph loading state, and next calls.

Call this first when filesystem tools and the Once server may have different working directories. The result identifies the exact workspace every other Once tool uses, reports the target operating system, architecture, and ordered selection tokens, reports whether the root manifest exists, lists loaded packages and target count, preserves graph loading errors as data, and recommends the next discovery or validation call. The matching command-line operation is once query workspace --format json.

Input schema

json
{
"properties": {},
"type": "object"
}

Example return

json
{
"root": "/work/project",
"configuration": {
"os": "linux",
"arch": "aarch64",
"tokens": ["linux-arm64", "linux-aarch64", "linux", "arm64", "aarch64", "default"]
},
"root_manifest": { "path": "/work/project/once.toml", "exists": false },
"target_count": 0,
"packages": [],
"empty": true,
"suggested_calls": [
{ "tool": "once_list_target_kinds", "arguments": {}, "reason": "Discover a target kind and starter for this empty workspace." }
]
}

once_query_targets#

List every declared target in the workspace, optionally filtered by target kind.

Returns the same record shape as once query targets --format json: one entry per declared target with its canonical id, package, name, target kind, visibility rules, default dependencies, named dependency roles, and exposed capabilities. The optional kind argument narrows results to one target kind.

Input schema

json
{
"properties": {
"kind": {
"description": "Restrict results to a target kind discovered through `once_list_target_kinds`.",
"type": "string"
}
},
"type": "object"
}

Example return

json
[
{ "id": "packages/core/Core", "package": "packages/core", "name": "Core",
"kind": "library", "visibility": ["subtree:apps"], "deps": [],
"dependency_edges": {}, "capabilities": ["build"] },
{ "id": "apps/service/Service", "package": "apps/service", "name": "Service",
"kind": "application", "visibility": [], "deps": ["packages/core/Core"],
"dependency_edges": { "plugins": ["tools/compiler/Plugin"] },
"capabilities": ["build", "run"] }
]

once_query_capabilities#

Return the capabilities (build, lint, run, test) a target exposes, with their output groups and required inputs.

Returns the same record once query capabilities <target> --format json emits: the target's id and kind plus one entry per capability with its output groups (what running the capability produces) and required outputs (what it depends on having built).

Input schema

json
{
"properties": {
"target": {
"description": "Canonical target id, such as `apps/service/Service`.",
"type": "string"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"id": "apps/service/Service",
"kind": "application",
"capabilities": [
{ "name": "build", "output_groups": ["default", "package"],
"requires_outputs": [] },
{ "name": "run", "output_groups": ["default"],
"requires_outputs": ["package"] }
]
}

once_query_schema#

Return the typed contract for a target kind: attributes, dep edges, providers, capabilities, source references, and runnable starters.

Returns the target kind schema (the typed contract a target of that kind must match) as once query schema <kind> --format json would. The record carries the target kind's documentation, attribute list with types and required, configurable, implemented, and allowed-value fields, expected dep providers, emitted providers, exposed capabilities, required tools, external source concepts that can guide partial adoption, and a lightweight list of runnable starter examples. Attributes marked implemented: false are discoverable compatibility fields that validation rejects until their target kind gives them behavior. Use once_materialize_example to create an unchanged starter without loading its contents into model context, or once_query_example when the caller needs to inspect and adapt the files.

Input schema

json
{
"properties": {
"kind": {
"description": "Target kind to introspect. Discover names with `once_list_target_kinds`.",
"type": "string"
}
},
"required": [
"kind"
],
"type": "object"
}

Example return

json
{
"kind": "library",
"docs": "Reusable library target...",
"attrs": [
{ "name": "mode", "ty": "string", "required": false,
"configurable": true, "implemented": true }
],
"capabilities": [ { "name": "build", "output_groups": ["default"], "requires_outputs": [] } ],
"providers": ["linkable", "module"],
"source_references": [
{ "system": "Example Build", "symbol": "example_library",
"url": "https://example.com/example_library", "use_when": "...",
"content_digest": "..." }
],
"examples": [
{
"slug": "library-minimal",
"name": "Minimal library",
"use_when": "..."
}
]
}

once_query_example#

Return the complete file bundle for one target kind starter example.

Returns the same record as once query example <kind> <slug> --format json: the selected example's slug, name, selection hint, and every file a caller can inspect or adapt. Text files use contents; binary files use contents_base64. Example descriptors are discovered through once_list_target_kinds or once_query_schema. For direct setup, prefer once_materialize_example, which writes the bundle without sending large dependency payloads through model context.

Input schema

json
{
"properties": {
"kind": {
"description": "Target kind that owns the example.",
"type": "string"
},
"slug": {
"description": "Example slug from the target kind schema.",
"type": "string"
}
},
"required": [
"kind",
"slug"
],
"type": "object"
}

Example return

json
{
"slug": "library-minimal",
"name": "Minimal library",
"use_when": "...",
"files": [
{ "path": "packages/core/once.toml", "contents": "[[target]]\nname = \"Core\"\nkind = \"library\"\n..." }
]
}

once_materialize_example#

Materialize a complete target kind starter directly inside the configured workspace.

This collision-safe setup tool is available only when the server starts with once mcp --allow-run. It copies the selected example without returning its file contents through model context. Existing files with identical contents are kept, making retries idempotent. If any path conflicts, Once reports every conflict and writes nothing. A successful result includes created and unchanged paths, canonical targets, complete-workspace validation, and exact suggested tool calls for targets of the requested kind. The matching command-line operation is once edit materialize-example <kind> <slug> --destination <dir>.

Input schema

json
{
"properties": {
"destination": {
"default": "",
"description": "Workspace-relative destination directory. Use an empty string for the workspace root.",
"type": "string"
},
"kind": {
"description": "Target kind that owns the example.",
"type": "string"
},
"slug": {
"description": "Example slug from `once_list_target_kinds` or `once_query_schema`.",
"type": "string"
}
},
"required": [
"kind",
"slug"
],
"type": "object"
}

Example return

json
{
"materialized": true,
"kind": "library",
"slug": "library-minimal",
"destination": "",
"created_files": ["packages/core/once.toml", "packages/core/src/core.txt"],
"unchanged_files": [],
"conflicts": [],
"targets": [
{ "id": "packages/core/Core", "kind": "library", "capabilities": ["build"] }
],
"workspace_validation": { "valid": true, "target_count": 1, "diagnostics": [] },
"suggested_calls": [
{ "tool": "once_validate_workspace", "arguments": {}, "reason": "Confirm the complete workspace after any customization." },
{ "tool": "once_build_target", "arguments": { "target": "packages/core/Core" }, "reason": "Build the materialized `library` target." }
]
}

once_list_target_kinds#

List target kinds with their docs, external source references, and example slugs, optionally filtered by ecosystem or intent.

Lightweight discovery entry point. Returns matching target kinds with documentation, external build-system concepts they can partially replace, and bundled starter examples. When the request names one or more ecosystems or runner families, include all of their names in the short query copied from the request. Once combines those specific matches while ignoring generic intent words, which lets a harness discover every native test integration in a mixed repository with one call. Omit the query when the intent is unknown. Call once_query_schema for the full contract of each chosen target kind. The matching command-line operation is once query target-kinds --query <text> --format json.

Input schema

json
{
"properties": {
"query": {
"description": "Short ecosystem, target-kind family, or intent text copied from the user's request.",
"type": "string"
}
},
"type": "object"
}

Example return

json
[
{
"kind": "library",
"docs": "Reusable library target...",
"source_references": [
{ "system": "Example Build", "symbol": "example_library",
"url": "https://example.com/example_library", "use_when": "...",
"content_digest": "..." }
],
"examples": [
{ "slug": "library-minimal", "name": "Minimal library", "use_when": "..." }
]
}
]

once_list_native_projects#

List native project declarations and the roots they currently recognize.

Returns each enabled native project's name, documentation, marker files, additional resolver inputs, seed target kind, and current package matches. Detection reads file names only and does not execute native project code. The matching command-line operation is once query native-projects --format json.

Input schema

json
{
"properties": {},
"type": "object"
}

Example return

json
{
"native_projects": [
{ "name": "native", "docs": "Recognize a native project.", "markers": ["project.native"], "target_kind": "native_workspace", "target_name": "native" }
],
"matches": [
{ "native_project": "native", "package": "", "markers": ["project.native"], "seed_target": "native" }
]
}

once_preview_native_project#

Preview the seed target and complete typed graph derived by one detected native project.

Runs the selected native project's ordinary target-kind resolver without writing a manifest, then returns its declaration, detection evidence, seed target, and expanded typed targets. Omit package when the native project has one match. Expanded dependency graphs can be very large. For a loaded project, prefer once_query_workspace, filtered once_query_targets, once_query_tests, and once_get_target when the complete graph is not needed. The matching command-line operation is once query native-project <name> [--package <path>] --format json.

Input schema

json
{
"properties": {
"name": {
"description": "Name discovered with `once_list_native_projects`.",
"type": "string"
},
"package": {
"description": "Package path from the native project match. Use an empty string for the workspace root.",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}

Example return

json
{
"native_project": { "name": "native", "target_kind": "native_workspace" },
"matched": { "native_project": "native", "package": "", "seed_target": "native" },
"seed": { "name": "native", "kind": "native_workspace" },
"targets": [ { "label": { "id": "native" }, "kind": "native_workspace" } ]
}

once_init_native_project#

Initialize Once from one detected native project.

This state-changing tool is available only when the server starts with once mcp --allow-run. It writes the native project's validated seed target through the manifest editor while preserving unrelated configuration and comments. Repeating an identical initialization is idempotent. A conflicting target with the same name is rejected. The matching command-line operation is once edit init-native-project <name> [--package <path>].

Input schema

json
{
"properties": {
"name": {
"description": "Name discovered with `once_list_native_projects`.",
"type": "string"
},
"package": {
"description": "Package path from the native project match. Use an empty string for the workspace root.",
"type": "string"
}
},
"required": [
"name"
],
"type": "object"
}

Example return

json
{
"initialized": true,
"changed": true,
"native_project": "native",
"package": "",
"seed_target": "native",
"path": "/work/project/once.toml"
}

once_query_module_contract#

Return the complete project-module authoring contract, primitives, invariants, capability starters, and normalized result examples.

Use this when no discovered target kind covers an external rule or plugin. The result contains the exact Starlark declaration helpers, schema invariants, implementation context fields, generic host-analysis and action primitives, module registration snippet, maintenance loop, and runnable generic, lint, and test starters with normalized result examples. A coding harness can use it to author and maintain a project-local target kind without waiting for a built-in integration. The matching command-line operation is once query module-contract --format json.

Input schema

json
{
"properties": {},
"type": "object"
}

Example return

json
{
"language": "Starlark",
"registration": "[modules]\npaths = [\"modules/*.star\"]\n",
"schema_invariants": ["attr.default is optional schema documentation and must be a string..."],
"context_fields": [
{ "signature": "ctx[\"attr\"]", "purpose": "Typed target attributes." }
],
"action_primitives": [
{ "signature": "write_path(path, content)", "purpose": "Declare a portable file-writing action." },
{ "signature": "materialize_host_file(source, destination)", "purpose": "Snapshot a content-verified absolute host toolchain file into a workspace output." },
{ "signature": "materialize_host_tree(source, destination)", "purpose": "Snapshot a content-verified absolute host directory into a workspace output." }
],
"starter": "def _generated_text_impl(ctx): ...",
"lint_starter": "def _scripted_lint_impl(ctx): ...",
"lint_target_starter": "[[target]]\nname = \"lint\"\nkind = \"scripted_lint\"\n...",
"lint_adapter_starter": "import argparse\nimport json\n...",
"normalized_lint_result_example": {
"schema": "once.lint_results.v1",
"status": "completed"
},
"test_starter": "def _scripted_test_impl(ctx): ..."
}

once_fetch_external_source#

Fetch bounded UTF-8 source code, metadata, or documentation from a public HTTPS address.

Fetches an authoritative external rule, plugin, registry record, or build-system reference for a coding harness to inspect before generating a local Once target kind. Only public HTTPS addresses are accepted, redirects are not followed, and response content is bounded to one mebibyte. The result includes the content, media type, digest, byte count, and truncation state. The matching command-line operation is once query external-source <url> --format json.

Input schema

json
{
"properties": {
"max_bytes": {
"default": 262144,
"description": "Maximum response bytes to return.",
"maximum": 1048576,
"minimum": 1,
"type": "integer"
},
"url": {
"description": "Public HTTPS address for external source code, metadata, or documentation.",
"type": "string"
}
},
"required": [
"url"
],
"type": "object"
}

Example return

json
{
"url": "https://example.com/rules/example.rule",
"content_type": "text/plain",
"content_digest": "...",
"byte_count": 4120,
"truncated": false,
"content": "rule implementation..."
}

once_validate_module#

Validate a project-local Starlark module and return its target kind contracts before registration or execution.

Reads one workspace-relative module file, evaluates it with the public Once declarations and generic primitives, and returns either its discovered target kind schemas or a structured repair diagnostic. Use it after a harness writes or updates an external-rule adaptation and before registering targets that depend on it. The matching command-line operation is once query validate-module <path> --format json.

Input schema

json
{
"properties": {
"path": {
"description": "Workspace-relative path to a Starlark module file.",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
}

Example return

json
{
"valid": true,
"path": "modules/generated_text.star",
"target_kinds": [
{ "kind": "generated_text", "providers": ["generated_file"], "capabilities": [ { "name": "build", "output_groups": ["default"] } ] }
],
"diagnostics": []
}

once_get_target#

Return one resolved target with its sources, dependency roles, typed attributes, capabilities, and providers.

Returns the same GraphTarget record once_query_targets emits, scoped to one target id. Includes default dependencies in deps, named roles in dependency_edges, typed attribute values, exposed capabilities, emitted providers, and manifest diagnostics. Use this before editing a target to learn its current shape.

Input schema

json
{
"properties": {
"target": {
"description": "Canonical target id, such as `packages/core/Core`.",
"type": "string"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"label": { "package": "packages/core", "name": "Core", "id": "packages/core/Core" },
"kind": "library",
"srcs": ["src/**/*.src"],
"visibility": ["subtree:apps"],
"deps": [],
"dependency_edges": { "plugins": ["tools/compiler/Plugin"] },
"attrs": {},
"capabilities": [ { "name": "build", "output_groups": ["default"], "requires_outputs": [] } ],
"providers": ["linkable", "module"]
}

once_query_tests#

List targets that expose Once's generic test capability.

Returns every target with a test capability, including its target kind, dependencies, runner type when the target kind exposes once_test_info, labels, and normalized result path. Use this as the agent test discovery entry point before running or filtering tests.

Input schema

json
{
"properties": {},
"type": "object"
}

Example return

json
[
{
"id": "tests/unit",
"kind": "test_suite",
"deps": [],
"runner": "unit",
"labels": ["fast"],
"results_path": ".once/out/tests/unit/test/test_results.json"
}
]

once_query_affected_tests#

Return test targets likely affected by a set of changed workspace paths.

Maps changed paths to test targets using graph relationships, declared inputs, and package ownership. A test is affected when a changed path belongs to the test target itself or to one of its declared dependencies. Declared source patterns are matched without requiring the changed file to still exist. An otherwise unowned path, including a package manifest, belongs to the nearest package and selects only that package's reverse dependency closure. The root manifest, configured graph modules, and paths outside every known package conservatively select every test. Selection does not depend on a particular test runner.

Input schema

json
{
"properties": {
"changed_paths": {
"description": "Workspace-relative changed paths. An empty list returns every test target.",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}

Example return

json
[
{
"id": "tests/unit",
"kind": "test_suite",
"reasons": ["changed test input `tests/unit/spec.src`"]
}
]

once_query_test_plan#

Create an immutable test plan without assigning work to runners.

Returns the selection policy, normalized changed paths, unmatched paths, selected tests, and stable execution batches. The plan deliberately contains no local worker, remote provider, or fixed-job assignment, so scheduling can change without changing test identity or invalidating reusable results. Before a target's first complete run, or when its discovery inputs change, the plan intentionally contains one whole-target batch. Run that target once with once_run_tests, inspect once_query_test_manifest, then query the plan again to see automatic file or case batches. Pass target with a test_unit from the manifest to create an exact unit-filtered plan. Planning rejects targets that do not declare exact filtering and units absent from the persisted whole-target manifest. The matching command-line operations are once query test-plan --changed-path <path> --format json and once query test-plan --target <target> --test-unit <unit> --format json.

Input schema

json
{
"properties": {
"changed_paths": {
"description": "Workspace-relative changed paths. An empty list creates a full test plan.",
"items": {
"type": "string"
},
"type": "array"
},
"target": {
"description": "Explicit canonical test target. When set, changed paths are ignored.",
"type": "string"
},
"test_unit": {
"description": "One stable unit identifier from once_query_test_manifest. Requires target.",
"type": "string"
}
},
"type": "object"
}

Example return

json
{
"schema": "once.test_plan.v1",
"id": "<stable digest>",
"selection": {
"schema": "once.test_selection.v1",
"policy": { "mode": "affected", "safety": "conservative", "evidence": "declared_graph_and_package_ownership" },
"changed_paths": ["src/lib.src"],
"unmatched_paths": [],
"tests": [{ "id": "tests/unit", "kind": "test_suite", "reasons": ["changed dependency `lib` input `src/lib.src`"] }]
},
"batches": [{ "id": "<stable digest>", "target": "tests/unit", "test_filters": [] }]
}

once_run_tests#

Run test targets by id, or run tests affected by changed workspace paths.

Creates the same immutable plan as once_query_test_plan, then pulls stable batches from a shared local queue. Batches with longer historical uncached durations are queued first, and idle workers dynamically take the next batch. Explicit target or targets produce an exact plan; otherwise changed_paths drive conservative graph selection. With exactly one target, test_unit runs a stable unit returned by once_query_test_manifest when the target kind declares filtering support. jobs caps workers without changing plan or batch identity. Set summary_only for compact normalized totals without case-level records. The result's plan is the work that just executed. Its next_plan is recomputed after complete runs refresh discovery, so use that field to assess file or case batching for the next run. The result also includes actual schedule attempts and normalized test results. Failed tests are returned as normal tool content with success: false rather than a tool protocol error, so agents can inspect failures and iterate. The matching command-line operations are once test --changed-path <path> --jobs <count> --format json and once test <target> --test-unit <unit> --format json.

Input schema

json
{
"properties": {
"changed_paths": {
"description": "Workspace-relative changed paths. Used only when no explicit target is supplied; an empty list runs every discovered test target.",
"items": {
"type": "string"
},
"type": "array"
},
"jobs": {
"description": "Maximum local workers. Defaults to available host parallelism and never changes plan or batch identity.",
"maximum": 256,
"minimum": 1,
"type": "integer"
},
"summary_only": {
"description": "Replace case-level normalized results with compact once.test_results_summary.v1 totals.",
"type": "boolean"
},
"target": {
"description": "Single canonical target id to run, such as `tests/unit`.",
"type": "string"
},
"targets": {
"description": "Canonical target ids to run. Used with `target`, this is deduplicated before execution.",
"items": {
"type": "string"
},
"type": "array"
},
"test_unit": {
"description": "Run one stable unit identifier returned by once_query_test_manifest. Requires exactly one explicit target.",
"type": "string"
}
},
"type": "object"
}

Example return

json
{
"plan": { "schema": "once.test_plan.v1", "id": "<executed plan digest>", "selection": {}, "batches": [] },
"next_plan": { "schema": "once.test_plan.v1", "id": "<next plan digest>", "selection": {}, "batches": [] },
"schedule": {
"schema": "once.test_schedule.v1",
"id": "<attempt-specific digest>",
"plan_id": "<executed plan digest>",
"strategy": "longest_estimated_duration_first_dynamic",
"workers": 2,
"attempts": [{ "batch_id": "<stable batch digest>", "placement": "local", "worker": "local-1", "status": "passed" }]
},
"runs": [
{
"batch_id": "<stable batch digest>",
"target": "tests/unit",
"exit_code": 0,
"success": true,
"record": { "target": "tests/unit", "capability": "test" },
"results": { "schema": "once.test_results.v1", "status": "passed" },
"stderr": ""
}
]
}

once_query_test_results#

Read normalized once.test_results.v1 results for a target.

Reads the normalized result file produced by the target's test capability. This is the stable agent-facing interface for pass or fail summaries, case-level failures, attempts, and artifacts. Set summary_only when exact totals are sufficient and a large case array would waste model context. The matching command-line operation is once query test-results <target> --summary-only --format json. Callers do not need to parse a runner's command output.

Input schema

json
{
"properties": {
"summary_only": {
"description": "Return once.test_results_summary.v1 status, totals, runner, and artifacts without case-level records.",
"type": "boolean"
},
"target": {
"description": "Canonical target id, such as `tests/unit`.",
"type": "string"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"schema": "once.test_results.v1",
"target": "tests/unit",
"runner": { "type": "native", "metadata": {} },
"status": "passed",
"summary": { "total": 1, "passed": 1, "failed": 0, "skipped": 0, "flaky": 0 },
"cases": [{ "id": "tests/unit::case_name", "name": "case_name", "suite": "tests/unit", "status": "passed", "attempts": [{ "status": "passed" }], "runner_metadata": {} }],
"artifacts": { "logs": [], "native_results": [] }
}

once_query_test_manifest#

List stable test units discovered in a target's normalized results.

Returns an immutable once.test_manifest.v1 projection of the target's current normalized test results and its target-kind-declared listing and filtering support. When no results exist, the manifest reports whole_target_fallback with no units; run the whole target once to refresh discovery. Unit identifiers can be passed to once_query_test_plan or once_run_tests only when case_filtering is runner_args. The matching command-line operation is once query test-manifest <target> --format json.

Input schema

json
{
"properties": {
"target": {
"description": "Canonical target identifier, such as `tests/unit`.",
"type": "string"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"schema": "once.test_manifest.v1",
"id": "<stable digest>",
"target": "tests/unit",
"runner": "native",
"source": "normalized_results",
"listing_supported": true,
"case_filtering": "runner_args",
"units": [{ "id": "tests/unit::case_name", "name": "case_name", "suite": "tests/unit" }]
}

once_query_test_attempts#

List persisted test batch attempts and measured durations.

Returns actual schedule attempts recorded by once_run_tests or once test --changed-path. Each record connects a stable plan and batch to its local worker, status, cache state, timestamps, measured duration, and the estimate used for ordering. Use target to inspect one test target and limit to bound history. The matching command-line operation is once query test-attempts --target <target> --limit <count> --format json.

Input schema

json
{
"properties": {
"limit": {
"default": 20,
"description": "Newest matching attempts to return.",
"maximum": 100,
"minimum": 1,
"type": "integer"
},
"target": {
"description": "Optional canonical test target id.",
"type": "string"
}
},
"type": "object"
}

Example return

json
[
{
"schema": "once.test_batch_attempt.v1",
"plan_id": "<stable plan digest>",
"batch_id": "<stable batch digest>",
"target": "tests/unit",
"placement": "local",
"worker": "local-1",
"duration_ms": 842,
"status": "passed",
"cache": "miss"
}
]

once_query_evidence#

List durable evidence records, optionally filtered by subject.

Returns the same record shape as once query evidence --format json: durable action evidence captured after once exec, once run, once build, once lint, or once test. Declared graph actions include an input fingerprint manifest whose categorized components explain which hashed source, dependency, toolchain, command, environment, or module input changed without exposing raw command or environment values. Other action types omit the optional manifest. Pass subject to filter to one command action, target, or target capability, such as cli or cli:test. The tool returns the newest five matching records by default; set limit from 1 through 100 when more or fewer are useful. The matching command-line option is once query evidence --limit <count>. Evidence is historical provenance, not proof that inputs remain unchanged; run the relevant capability when a current result is required.

Input schema

json
{
"properties": {
"limit": {
"default": 5,
"description": "Maximum number of newest matching records to return.",
"maximum": 100,
"minimum": 1,
"type": "integer"
},
"subject": {
"description": "Optional subject id or subject-capability pair, such as `cli` or `cli:test`.",
"type": "string"
}
},
"type": "object"
}

Example return

json
[
{
"schema": "once.evidence.v1",
"id": "8d65122cd9dcddc8d5d9a8458ff42a40fe3dd7acbd4e0563fd7f9e8fb19b0c44",
"kind": "action_result",
"subject": { "kind": "target", "id": "cli", "capability": "test" },
"status": "passed",
"action_digest": "0476bde2e7d8d1a64d9bd6f589ef5b443d0f60b71e2ad6f1c5bd7a2c4c41223f",
"input_digest": "8ed3f6ad685b959ead7022518e1af76cd816f8e8ec7ccd5f5814ccfb820e6a41",
"input_fingerprint": {
"schema": "once.input_fingerprint.v1",
"input_digest": "8ed3f6ad685b959ead7022518e1af76cd816f8e8ec7ccd5f5814ccfb820e6a41",
"components": [
{
"category": "source",
"label": "src/lib.rs",
"digest": "1111111111111111111111111111111111111111111111111111111111111111"
},
{
"category": "dependency",
"label": "core",
"digest": "2222222222222222222222222222222222222222222222222222222222222222"
}
]
},
"cache": "miss",
"exit_code": 0,
"stdout": "b439bb065d84034c2e7172c1709eb28797c9bd7f2c64c5d1a1d9c1118f6f9d7e",
"created_at_unix_ms": 1812345678901
}
]

once_query_graph_fingerprint#

Compute a deterministic, content-addressed digest of the whole graph.

Returns the same record as once query graph-fingerprint --format json: a single stable digest that folds in every target declaration, the resolved contents of every declared source file, the pinned Mise toolchain (mise.toml and mise.lock when present), and the root workspace manifest. The digest changes whenever any of those inputs change, so two identical checkouts on different machines produce the same digest. components lists the categorized (category, label, digest) triples behind the digest, mirroring per-action input fingerprints, so a caller can see which target, source, toolchain, or manifest input contributed. Categories default to all on; set include_sources, include_toolchain, or include_manifest to false to scope the digest, for example to compare only graph structure across checkouts. The matching command-line operation is once query graph-fingerprint [--no-sources --no-toolchain --no-manifest].

Input schema

json
{
"properties": {
"include_manifest": {
"default": true,
"description": "Fold the root `once.toml` manifest into the digest.",
"type": "boolean"
},
"include_sources": {
"default": true,
"description": "Fold resolved source file contents into the digest.",
"type": "boolean"
},
"include_toolchain": {
"default": true,
"description": "Fold the `mise.toml` and `mise.lock` declarations into the digest.",
"type": "boolean"
}
},
"type": "object"
}

Example return

json
{
"schema": "once.graph_fingerprint.v1",
"digest": "a046fc32a4c232b7320b4249d630ec5a4fef9ae8c3313a65754f33cc31375676",
"target_count": 2,
"source_count": 1,
"components": [
{ "category": "target", "label": "pkg/lib", "digest": "1111111111111111111111111111111111111111111111111111111111111111" },
{ "category": "source", "label": "pkg/lib.rs", "digest": "2222222222222222222222222222222222222222222221111111111111111111" },
{ "category": "toolchain", "label": "mise.toml", "digest": "3333333333333333333333333333333333333333333333333333333333333333" }
]
}

once_validate_script#

Parse and validate an annotated script's cache contract.

Reads a workspace-relative script, validates its shebang and once directives, and returns the parsed runtime, inputs, outputs, dependency scripts, fingerprints, environment names, working directory, remote policy, and output symlink policy. Put singular directives with quoted values directly after the shebang, for example # once input "input.txt" and # once output "output.txt". Plural names, colon syntax, and unquoted paths are invalid. Invalid contracts return { valid: false, diagnostics: [...] }, so callers can repair directive typos before execution. The matching command-line operation is once query script <path>.

Input schema

json
{
"properties": {
"path": {
"description": "Workspace-relative annotated script path.",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
}

Example return

json
{
"valid": true,
"path": "scripts/build.sh",
"contract": {
"path": "scripts/build.sh",
"runtime": "sh",
"runtime_args": [],
"inputs": ["src/**"],
"outputs": ["dist/**"],
"needs": [],
"fingerprints": [],
"env_vars": []
}
}

once_exec_script#

Execute a validated annotated script through Once's action cache.

Opt-in tool exposed only when the Model Context Protocol server starts with once mcp --allow-run. Validates the script contract before running the same path as once exec --script, materializes declared outputs, and returns captured streams, exit status, action digest, cache hit or miss state, and matching evidence. Invoke it twice with unchanged declared inputs to verify cache reuse.

Input schema

json
{
"properties": {
"args": {
"description": "Arguments passed to the script after its path.",
"items": {
"type": "string"
},
"type": "array"
},
"path": {
"description": "Workspace-relative annotated script path.",
"type": "string"
}
},
"required": [
"path"
],
"type": "object"
}

Example return

json
{
"path": "scripts/build.sh",
"success": true,
"exit_code": 0,
"stdout": "built\n",
"stderr": "",
"record": {
"action_digest": "0476bde2e7d8d1a64d9bd6f589ef5b443d0f60b71e2ad6f1c5bd7a2c4c41223f",
"cache": "hit",
"exit_code": 0
},
"evidence_subject": "0476bde2e7d8d1a64d9bd6f589ef5b443d0f60b71e2ad6f1c5bd7a2c4c41223f",
"evidence": []
}

once_build_target#

Build a target by running its generic build capability.

This tool is available only when the server starts with once mcp --allow-run. It behaves like once build <target> --format json, including dependency traversal, target actions, cache policy, and output groups. Because cache identity follows declared content rather than workspace history, a first build in a new workspace can reuse an equivalent action produced elsewhere. The result includes the exit status, command diagnostics under stderr, and bounded declared action logs under captured_stdout and captured_stderr. A captured field is null when the target did not declare that log. A failed build is returned as normal tool content with success: false so agents can inspect diagnostics.

Input schema

json
{
"properties": {
"target": {
"description": "Target id to build, such as `apps/service/Service` or `./Service`.",
"type": "string"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"target": "apps/service/Service",
"capability": "build",
"exit_code": 0,
"success": true,
"record": {
"target": "apps/service/Service",
"kind": "application",
"capability": "build",
"cache": "miss",
"outputs": [".once/out/apps/service/Service/package"]
},
"stderr": ""
}

once_lint_target#

Run a target's lint capability and return normalized findings.

This tool is available only when the server starts with once mcp --allow-run. It behaves like once lint <target> --format json: analyzer output is cached in Static Analysis Results Interchange Format, then projected into the tool-neutral once.lint_results.v1 record. The command reports failure when warning or error findings exist, while still returning the complete finding list for repair. Native analyzer configuration remains authoritative.

Input schema

json
{
"properties": {
"target": {
"description": "Target id whose lint capability should run.",
"type": "string"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"target": "quality/python/lint",
"capability": "lint",
"exit_code": 1,
"success": false,
"record": {
"schema": "once.lint_results.v1",
"target": "quality/python/lint",
"status": "completed",
"complete": true,
"summary": {"total": 1, "errors": 0, "warnings": 1, "notes": 0},
"findings": [{"analyzer": "ruff", "rule_id": "F401", "severity": "warning", "message": "imported but unused"}]
},
"stderr": ""
}

once_validate_actions#

Run scripted graph actions in a private validation sandbox.

Runs the same declared action analysis used by the graph, bypasses the action cache, inventories private and real-workspace filesystem changes, and returns structured input and output repairs. The matching command-line operation is once query validate-actions <target> --capability <name>. This tool requires once mcp --allow-run because it executes commands. Successful reads that leave no filesystem evidence remain a documented limitation of symlink-only validation.

Input schema

json
{
"properties": {
"action": {
"description": "Optional zero-based action index.",
"minimum": 0,
"type": "integer"
},
"capability": {
"default": "build",
"description": "Capability to validate.",
"type": "string"
},
"target": {
"description": "Canonical target id.",
"type": "string"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{"valid":false,"target":"pkg/tool","capability":"build","actions_run":1,"diagnostics":[{"code":"undeclared_write","target":"pkg/tool","attribute":"outputs","repairs":["Declare this path as an output or stop writing it"]}]}

once_run_target#

Run a target by executing its generic run capability.

This tool is available only when the server starts with once mcp --allow-run. It behaves like once run <target> --format json, including prerequisite build outputs declared by the target's run capability. Argument interpretation is target-kind-specific, so inspect the target-kind schema before supplying arguments. Set visible to request a visible interface when the target kind supports one. Uncacheable actions run again instead of replaying an action-cache hit. The result includes command diagnostics under stderr and up to 64 kibibytes of each declared stdout.log or stderr.log output under captured_stdout and captured_stderr, so an agent can verify ordinary command output without a separate filesystem read. A captured field is null when the target did not declare that log.

Input schema

json
{
"properties": {
"arguments": {
"description": "Target-kind-specific arguments supplied to the generic run capability. Inspect the target-kind schema before setting this field.",
"items": {
"type": "string"
},
"type": "array"
},
"target": {
"description": "Target id to run, such as `apps/service/Service` or `./Service`.",
"type": "string"
},
"visible": {
"description": "Request a visible runtime interface when the target kind supports one.",
"type": "boolean"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"target": "apps/service/Service",
"capability": "run",
"exit_code": 0,
"success": true,
"record": {
"target": "apps/service/Service",
"kind": "application",
"capability": "run",
"cache": "bypass",
"outputs": []
},
"stderr": ""
}

once_start_target#

Start a target in a persisted runtime session and return its session id.

This tool is available only when the server starts with once mcp --allow-run. It starts the target, saves its standard output and standard error under .once/runtime/<session_id>/, and returns immediately with the session record. Use the status, logs, and stop tools to follow the process.

Input schema

json
{
"properties": {
"target": {
"description": "Target id to start, such as `tools/demo/LaunchService` or `./LaunchService`.",
"type": "string"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"session_id": "tools-demo-LaunchService-123-1812345678901",
"target": "tools/demo/LaunchService",
"status": "starting",
"session_dir": ".once/runtime/tools-demo-LaunchService-123-1812345678901",
"stdout": ".once/runtime/tools-demo-LaunchService-123-1812345678901/stdout.log",
"stderr": ".once/runtime/tools-demo-LaunchService-123-1812345678901/stderr.log"
}

once_runtime_status#

Return the latest persisted status for a runtime session.

Reads .once/runtime/<session_id>/session.json and returns the latest status. Status values include starting, running, stopping, stopped, exited, and failed.

Input schema

json
{
"properties": {
"session_id": {
"description": "Session id returned by `once_start_target`.",
"type": "string"
}
},
"required": [
"session_id"
],
"type": "object"
}

Example return

json
{
"session_id": "tools-demo-LaunchService-123-1812345678901",
"target": "tools/demo/LaunchService",
"status": "running",
"pid": 4242
}

once_runtime_logs#

Read standard output or standard error records for a runtime session.

Reads persisted line-oriented standard output and standard error records from a runtime session. Pass source to restrict the result to stdout or stderr, and pass a previous cursor to read only newer records.

Input schema

json
{
"properties": {
"cursor": {
"description": "Cursor returned by a previous log record.",
"type": "string"
},
"limit": {
"description": "Maximum number of records to return.",
"type": "integer"
},
"session_id": {
"description": "Session id returned by `once_start_target`.",
"type": "string"
},
"source": {
"description": "`stdout` or `stderr`.",
"enum": [
"stdout",
"stderr"
],
"type": "string"
}
},
"required": [
"session_id"
],
"type": "object"
}

Example return

json
{
"session_id": "tools-demo-LaunchService-123-1812345678901",
"records": [
{ "cursor": "stdout:000000000000", "source": "stdout", "level": "info", "message": "ready" }
]
}

once_stop_runtime#

Request that a runtime session stop.

Requests that the process stop and updates the session status as the request is handled.

Input schema

json
{
"properties": {
"session_id": {
"description": "Session id returned by `once_start_target`.",
"type": "string"
}
},
"required": [
"session_id"
],
"type": "object"
}

Example return

json
{
"session_id": "tools-demo-LaunchService-123-1812345678901",
"target": "tools/demo/LaunchService",
"status": "stopping"
}

once_validate_workspace#

Validate the complete workspace graph before execution.

Loads every manifest and target kind schema, then checks target attributes, target-valued attribute references, duplicate target identifiers, missing dependencies, dependency visibility, dependency provider compatibility, source patterns, and dependency cycles. Returns stable diagnostics with target and attribute scope plus suggested repairs. Call this after materializing a starter or applying edits and before build, run, or test. The matching command-line operation is once query validate-workspace.

Input schema

json
{
"properties": {},
"type": "object"
}

Example return

json
{
"valid": false,
"target_count": 1,
"diagnostics": [
{
"code": "missing_dependency",
"message": "target `apps/service/Service` depends on missing target `packages/core/Core`",
"target": "apps/service/Service",
"attribute": "deps",
"repairs": ["Declare target `packages/core/Core` or remove it from `deps`"]
}
]
}

once_validate_target#

Validate a proposed [[target]] table against its target kind schema. Returns structured diagnostics instead of prose.

Schema-only validation: checks that the target declares a known target kind, every named dependency role is declared by that kind, every required attribute is present, every declared attribute is known and has the declared type, and the target name is well-formed. The check is local; it does not resolve dependency references or read other manifests. Returns { valid: true } on success or { valid: false, diagnostics: [...] } where each diagnostic carries a stable code, the offending target id, the offending attribute when applicable, and repairs an agent can apply.

Input schema

json
{
"properties": {
"target": {
"description": "Raw `[[target]]` table shape with `name`, `kind`, optional `deps`, `dependencies`, `srcs`, and `attrs`.",
"type": "object"
}
},
"required": [
"target"
],
"type": "object"
}

Example return

json
{
"valid": false,
"diagnostics": [
{
"code": "missing_required_attr",
"message": "target kind `library` requires attribute `visibility`",
"target": "Core",
"attribute": "visibility"
}
]
}

once_apply_edit#

Apply a batch of create / update / delete operations to one once.toml atomically.

Reads the manifest at <workspace>/<package>/once.toml and applies the operations only if every operation succeeds. Returns { applied: true, changed: <bool>, path: <manifest path> } on success. changed is false when the requested state already exists, in which case no manifest is written. Returns { applied: false, diagnostics: [...] } with the structured diagnostic shape used by once_validate_target when the edit is invalid. A failed batch leaves the original file unchanged.

Input schema

json
{
"properties": {
"operations": {
"description": "Ordered list of operations. Each is `{ op: \"create\", target: {...} }`, `{ op: \"update\", target_name: \"...\", set: {...} }`, or `{ op: \"delete\", target_name: \"...\" }`.",
"items": {
"type": "object"
},
"type": "array"
},
"package": {
"description": "Package directory relative to the workspace root, such as `packages/core`. Use `\"\"` for the root manifest.",
"type": "string"
}
},
"required": [
"package",
"operations"
],
"type": "object"
}

Example return

json
{
"applied": true,
"changed": true,
"path": "packages/core/once.toml"
}