# Artifacts and AI agents

> For AI agents: the complete documentation index is at https://buddy.works/llms.txt

Let an AI agent create artifacts, add versions, upload files and run pipelines with an artifact version through the Buddy MCP server, and what to check first.

AI agents can interact with artifacts through the [Buddy MCP server](https://buddy.works/docs/ai-agents/mcp.md). They can create artifacts and versions, upload files, and run pipelines with selected artifact versions. Access to artifacts is governed by the same permissions as in the UI, CLI, and REST API.

Artifact tools are not available when using a [category filter](https://buddy.works/docs/ai-agents/mcp.md). To access these tools, connect to the MCP server without a category filter. If the agent only needs to download artifact versions, use a token with the **Artifacts** scope at the **Read** level.

## Create an artifact and a version

The `create-artifact` tool creates a Bucket, Container Image, or NPM Package artifact at the Workspace or Project scope. The `create-artifact-version` tool creates an empty version of the artifact.

- **An artifact created over MCP uses Buddy Auth and gives pipelines no access.** The `pipelines_access_level` and `sandboxes_access_level` fields are set to `DENIED`. Before a pipeline can publish or download a version, someone has to set the level in the **Permissions** tab of the artifact ([Permissions and access](https://buddy.works/docs/artifacts/permissions-and-access.md)).
- **A new version is empty.** It has the `READY` status and a size of 0. You add files separately, one at a time (`upload-artifact-version-file`) or as a single ZIP archive (`publish-artifact-version`), which replaces the whole content of the version.

Version names must be unique within an artifact. Attempting to create a version with an existing name returns the `Artifact 'version' must be unique` error.

## Run a pipeline with an artifact version

The `run-pipeline` tool accepts the `artifact` and `artifactVersion` parameters. The `BUDDY_RUN_ARTIFACT_*` variables are available during the run, and the artifact version files are placed in the pipeline filesystem. This behavior is consistent with runs started from the **Run** window in the UI.

The artifact version is available to the run only if the pipeline configuration includes the `artifacts` context in YAML:

```yaml
- pipeline: deploy-build
  name: Deploy build
  artifacts:
  - my-app-build
  actions:
  - action: Show artifact version
    type: BUILD
    docker_image_name: library/ubuntu
    docker_image_tag: "24.04"
    commands: |-
      env | grep BUDDY_RUN_ARTIFACT
```

After the run, the agent should check whether the response contains the `artifact_version` field. If it is missing, the run started without a version. [Run a pipeline with an artifact version](https://buddy.works/docs/artifacts/run-with-version.md) describes the context and variables in detail.

Attempting to run a pipeline with a nonexistent artifact version returns the following error before the run starts:

```
Artifact version my-app-build:9.9.9 not found
```

## Artifact and version notes for AI agents

An artifact and each of its versions can have a note for agents (`agent_note`), for example "Broken migration, do not deploy." on a faulty version. The agent reads it with the `get-artifact` tool, because the `list-*` tools do not return notes. You set notes in the UI, through the API, with the `create-artifact` and `update-artifact` MCP tools, or with the `--agent-note` flag in `bdy artifact publish` and `bdy artifact update`.

> **Info**
>
> Set pipeline and sandbox permissions for the artifact in the **Permissions** tab in the UI. `get-artifact` returns them in its response, but `update-artifact` does not change them.

## Troubleshooting run failures without an error message

If `get-run` returns the `FAILED` status while the actions remain in the `ENQUEUED` status and `error_message` is empty, the run failed during setup, before the first action started. This can occur when an artifact trigger starts a pipeline that does not have access to the artifact. To view the error message, open the run details in the UI and expand the **Setup action** step. For common errors and troubleshooting instructions, see [Troubleshooting](https://buddy.works/docs/artifacts/troubleshooting.md).

See also:

- [MCP](https://buddy.works/docs/ai-agents/mcp.md) - connecting an agent to Buddy, authentication and tool filtering
- [Resource notes](https://buddy.works/docs/ai-agents/resource-notes.md) - notes for people and agents on artifacts and versions
- [Run a pipeline with an artifact version](https://buddy.works/docs/artifacts/run-with-version.md) - the `artifacts` context and the `BUDDY_RUN_ARTIFACT_*` variables
- [Artifacts in Sandboxes](https://buddy.works/docs/artifacts/sandboxes.md) - an agent in a sandbox with files from an artifact


---
Original source: https://buddy.works/docs/artifacts/ai-agents