---
title: "corestack_enterprise_repository_set"
url: https://docs.corefinity.com/mcp/tools/corestack_enterprise_repository_set
type: tool
last_updated: 2026-11-13
feature: enterprise-deployments
related:
  - https://docs.corefinity.com/guides/corestack-enterprise/deployments-and-pipelines.md
---
# corestack_enterprise_repository_set

**Set a CoreStack Enterprise repository.** Add a git repository and branch to a CoreStack Enterprise environment, or change one. Scope: write.

- Scope: `write`
- Runs as a task: no

## When to use it

Add a git repository and branch to a CoreStack Enterprise environment, or change one (`repository_id`): the Repositories
field's Save. The environment must deploy from git (`corestack_enterprise_deployment_settings_update`). Every field is
checked together and nothing is saved until all pass. The answer is the repository's row as
`corestack_enterprise_repositories_list` lists it.

The public API's `POST /api/environments/{environment}/repositories` and `PATCH .../repositories/{repository}` do the
same.

## Inputs

- `enterprise_env_id` (integer, ≥ 1, required)
- `repository_id` (integer, ≥ 1; leave out to add a repository)
- `connection_id` (integer, ≥ 1, required; one of the list's `connections`)
- `pipeline_id` (integer, ≥ 1, required; one of the environment's pipelines)
- `repo` (string, required; `owner/name` as the provider names it)
- `branch` (string, required; a valid branch name)
- `root_directory` (string, required; `/` for the repository root)

### Input schema

```json
{
  "additionalProperties": false,
  "properties": {
    "branch": {
      "maxLength": 255,
      "type": "string"
    },
    "connection_id": {
      "description": "A git account from corestack_enterprise_repositories_list connections.",
      "minimum": 1,
      "type": "integer"
    },
    "enterprise_env_id": {
      "description": "A CoreStack Enterprise environment's id; for CoreStack or CoreCluster use the corestack_deployment_* tools.",
      "minimum": 1,
      "type": "integer"
    },
    "pipeline_id": {
      "description": "The environment's pipeline the repository deploys with.",
      "minimum": 1,
      "type": "integer"
    },
    "repo": {
      "description": "owner/name as the provider names it.",
      "maxLength": 255,
      "type": "string"
    },
    "repository_id": {
      "description": "Change this repository; leave out to add one.",
      "minimum": 1,
      "type": "integer"
    },
    "root_directory": {
      "description": "/ for the repository root.",
      "maxLength": 255,
      "type": "string"
    }
  },
  "required": [
    "enterprise_env_id",
    "connection_id",
    "pipeline_id",
    "repo",
    "branch",
    "root_directory"
  ],
  "type": "object"
}
```

## Refusals

- `invalid_arguments`: a field is wrong (the pipeline is not the environment's, the repository path, branch or root
  directory grammar), or `connection_id` names no git account the person may use here ("The selected git account could
  not be found.").
- `forbidden`: the person's role lacks the Manage Deployment Repositories permission, or the environment's pushes deploy
  on their own (`deployment_source` git with `git_deploys` automatic) and it lacks the Create Deployments permission: the
  repository set here is what the next push deploys. The message names the permission and says an owner of the company
  can grant it in Roles; `details.permission` is `manageDeploymentRepositories` or `createDeployments`. Nothing is
  changed. With `git_deploys` manual nothing more is asked. Also `forbidden`: the repository was set up with a git
  account the person cannot use.
- `tenant_mismatch` (also for a `repository_id` that is not this environment's), `pin_refused`, and the refusals every
  tool can answer: `scope_required`, `rate_limited`, `temporarily_unavailable`, `internal_error`
  (corestack://guides/how-this-server-works).

## Example

```json
{
  "name": "corestack_enterprise_repository_set",
  "arguments": {
    "enterprise_env_id": 1530,
    "connection_id": 412,
    "pipeline_id": 2210,
    "repo": "example-org/storefront",
    "branch": "main",
    "root_directory": "/"
  }
}
```

## Prompt

```text
Using the Corefinity MCP server, call corestack_enterprise_repository_set with enterprise_env_id 1530, connection_id 412, pipeline_id 2210, repo example-org/storefront, branch main, root_directory /. (Set a CoreStack Enterprise repository.) Tell me what it returned.
```

## The same task elsewhere

- Guide: [Deployments and pipelines](https://docs.corefinity.com/guides/corestack-enterprise/deployments-and-pipelines.md)
