Branch Artifacts
Create or update the branch artifact that records a Git branch against a project repository
Overview
A branch artifact records a Git branch in Closedloop, so the branch can be linked to the document it implements. One tool writes it.
| Tool | Scope | Purpose |
|---|---|---|
create_branch_artifact | write | Create or update a branch artifact |
The tool name uses underscores, unlike the other Closedloop tools. It is offered only when your grant carries write.
The tool returns its result as JSON text. A failure comes back as a tool result with isError: true whose text carries a title, a description, any remediation steps, and the error code, message, and timestamp when the API supplied them.
To read the links a branch has once it exists, use list-artifact-links on Artifact Links.
Create Branch Artifact
Tool: create_branch_artifact
Scope: write
Underlying API: POST /artifact-links/branches
The repository is not a parameter. The API uses the project's primary repository, so the project must have one configured. Calling the tool again for the same branch updates the existing branch artifact rather than creating a second one.
| Name | Type | Required | Description |
|---|---|---|---|
projectId | string (UUID) | Yes | The project, by UUID. Slugs are not accepted here. |
branchName | string | Yes | The exact Git branch name. At least 1 character; the API trims it and allows at most 256. |
sourceArtifactId | string (UUID) | null | No | An artifact in your organization to link the branch to, by UUID. |
defaultBranch | string | null | No | Legacy assertion of the repository's default branch. Closedloop's own repository data decides eligibility. |
baseBranch | string | null | No | The branch this branch is based on, when known. |
baseBranchSource | string | null | No | Where baseBranch came from: pull_request_base, harness_input, mcp_input, migration_pr_base, or repository_default. The API uses repository_default when this is omitted. desktop_pull_request_base exists but is refused here, because only the Desktop sync may set it. |
headSha | string | null | No | The branch's head commit SHA, when known. |
headShaSource | string | null | No | Where headSha came from: push_webhook, pull_request_webhook, harness_input, mcp_input, explicit_sync, or migration_pr_head. |
Returns
Only the branch artifact's id:
{ "id": "b7a1c3e2-5d4f-4a6b-9c8d-0e1f2a3b4c5d" }Errors
| Status | Cause |
|---|---|
| — | A non-UUID projectId or sourceArtifactId, an empty string field, or baseBranchSource: "desktop_pull_request_base" (baseBranchSource is not client-assertable) is rejected by the tool schema. |
400 | Project has no primary repository configured. |
400 | Branch artifact input is invalid. |
400 | Source artifact is not eligible for the sourceArtifactId you passed. |
404 | The project is not in your organization, or the branch artifact could not be found. |
Example
create_branch_artifact(
projectId: "550e8400-e29b-41d4-a716-446655440000",
branchName: "feat/saved-carts",
sourceArtifactId: "9b2c4d6e-8f0a-4b1c-9d2e-3f4a5b6c7d8e",
baseBranch: "main",
baseBranchSource: "mcp_input"
)