# set_environment

URL: https://codepanel.ai/docs/mcp-server/set_environment

The CodePanel MCP tool that configures a repository's setup command, verify commands, startup services, and default local or cloud host.

`set_environment` configures a repository's execution environment for both local runners and cloud sandboxes: `setupCommand`, `verifyCommands`, `startupServices`, and `defaultHost` (`local` or `cloud`). Needs the `tasks:write` scope.

## When to call it

- **When onboarding a repository for cloud or local agents**, or updating its install/test commands so every agent run uses the exact same reproducible setup.

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `repo` | string | yes | Repository as owner/name |
| `setupCommand` | string or null | no | Single-line setup command run after cloning, e.g. bun install --frozen-lockfile; null clears |
| `verifyCommands` | array of strings or null | no | Up to 10 verification commands run before pushing, e.g. ['bun run check']; null clears |
| `startupServices` | array of objects or null | no | Up to 5 background services started in the sandbox; null clears |
| `startupServices[].name` | string | yes | Short service identifier, e.g. dev or db |
| `startupServices[].command` | string | yes | Single-line shell command to start the service |
| `startupServices[].readyUrl` | string | no | Optional http(s) health-check URL |
| `defaultHost` | `local` or `cloud` or null | no | Default execution host for this repository: local or cloud; null resets to local |

It writes: the server marks it `readOnlyHint: false` and `destructiveHint: true` (it can change what is already there), so a client that asks before writes asks here.

## What it returns

`{ environment }`, matching [`get_environment`](/docs/mcp-server/get_environment). Passing `null` for a field clears it (resetting `defaultHost` to `local`).

## The same step without MCP

| Surface | Form |
| --- | --- |
| HTTP API | `POST /autopilot/environments` with `tasks:write` scope |
| CLI | `codepanel env set owner/name --setup "bun install" --verify "bun run check" --default-host cloud` |
| Dashboard | Repository → Settings → Environment & Zero-Trust Secrets |

## What the server tells your agent

The description your agent reads when it lists the tools:

> Use it to configure a repository's setup command, verification commands, startup services, and default execution host (local or cloud) for local runners and cloud sandboxes. Needs the tasks:write scope. Returns { environment }.

## Related

- [`get_environment`](/docs/mcp-server/get_environment): read the current environment and secret names.
- [`list_secrets`](/docs/mcp-server/list_secrets): list available Zero-Trust secret names.
- [MCP server](/docs/mcp-server): install, sign-in and every other tool.
