> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Deploy to an agent environment

> How the LangGraph and Managed Deep Agents CLIs bind a deployment to an agent and an environment, which values each flag takes, and which CLI versions accept them.

Deploying to an agent environment binds a [deployment](https://docs.langchain.com/langsmith/deploy-overview.md) to one [agent](https://docs.langchain.com/langsmith/agent-registry.md#agent) and one of that agent's [environments](https://docs.langchain.com/langsmith/agent-environments.md). Two flags carry the binding, and the LangGraph CLI and the `mda` CLI both accept them.

Use it to keep a staging build and a production build of the same agent apart, so each one reports into its own environment.

> [!NOTE]
>
> Agent-based workspaces are available on [LangSmith Cloud](https://docs.langchain.com/langsmith/cloud.md). They are not available on [self-hosted](https://docs.langchain.com/langsmith/self-hosted.md) LangSmith. To check whether your workspace is agent-based, look at the control at the top left. In an agent-based workspace, it is a workspace switcher that names your workspace. In a [project-based](https://docs.langchain.com/langsmith/observability-concepts.md#tracing-projects) workspace, it shows the LangSmith logo.

## Prerequisites

Both CLIs need the following:

* A [LangSmith API key](https://docs.langchain.com/langsmith/create-account-api-key.md) in `.env` or your shell environment.
* A project folder holding `langgraph.json`. Run the CLI from that folder.
* An agent-based workspace, because the flags require agent mode on the workspace.

An org-scoped API key also needs the workspace, and each CLI reads it from a different variable: `LANGSMITH_TENANT_ID` for the LangGraph CLI, and `LANGSMITH_WORKSPACE_ID` for the `mda` CLI. A workspace-scoped key needs neither. The LangGraph CLI prompts for the value when the key is org-scoped. In a script or CI job, set `LANGSMITH_TENANT_ID` ahead of time, and pass `--no-input` so the LangGraph CLI fails instead of waiting for input. Both the Python and the TypeScript LangGraph CLI accept `--no-input`.

## Addressing flags

Both CLIs take the same two flags:

* **`--agent-id`**: The agent to deploy to. The value is the agent's identifier, not its display name. For which value is which, see [Identifiers and display names](https://docs.langchain.com/langsmith/agent-registry.md#identifiers-and-display-names).
* **`--agent-environment`**: The environment the deployment reports into, and one of `development`, `staging`, or `production`. A deployment cannot take `local`. That environment [does not display on deployments](https://docs.langchain.com/langsmith/agent-environments.md#select-an-environment) at all, which is the one way this set differs from the four values the [agent variables](https://docs.langchain.com/langsmith/log-traces-to-agent.md#using-environment-variables) accept.

The flags name the same pair that agent addressing names on the tracing side. The LangGraph CLI also reads the flags from the same two variables, `LANGSMITH_AGENT_ID` and `LANGSMITH_AGENT_ENVIRONMENT`. The `mda` CLI does not read those variables, so pass the flags to it directly.

## Deploy with the LangGraph CLI

These flags require `langgraph-cli` v0.4.32 or later in Python, and `@langchain/langgraph-cli` 1.5.2-dev.0 in TypeScript. The TypeScript version is a prerelease build. Install it exactly, because the current stable release, 1.5.1, does not accept the flags. To deploy:

1. Install the CLI:

   ```bash Python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
   uv tool install --force "langgraph-cli>=0.4.32"
   ```

   ```bash TypeScript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
   npm install -g "@langchain/langgraph-cli@1.5.2-dev.0"
   ```

2. Deploy, naming the agent and the environment:

   ```bash Python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
   langgraph deploy --agent-id my-agent --agent-environment staging --remote
   ```

   ```bash TypeScript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
   langgraphjs deploy --agent-id my-agent --agent-environment staging --remote
   ```

Pass both flags or neither, because the CLI rejects either one on its own. Do not combine them with `--name` or an Agent Server ID flag. The Python CLI uses `--agent-server-id`, with `--deployment-id` accepted as a compatibility alias; older Python versions may require the legacy spelling. The TypeScript prerelease above uses `--deployment-id`. These flag names are separate from the version requirements for agent binding.

`--remote` forces a remote build. Without it, the CLI builds locally whenever Docker is available. For the rest of the flags, see [`langgraph deploy`](https://docs.langchain.com/langsmith/cli#deploy).

## Deploy with the mda CLI

These flags require `managed-deepagents` 0.7.5.dev4 in Python, or 0.7.5-dev.4 in TypeScript. Both are prerelease builds. Install that version exactly, because 0.8.0 and later do not accept the flags and a version range resolves to a build that rejects them. To deploy:

1. Install the CLI:

   ```bash Python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
   uv tool install --force --prerelease allow "managed-deepagents==0.7.5.dev4"
   uv add --prerelease allow "managed-deepagents==0.7.5.dev4"
   ```

   ```bash TypeScript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
   npm install "managed-deepagents@0.7.5-dev.4"
   ```

2. Deploy the project in the current folder:

   ```bash Python theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
   mda deploy . --agent-id my-agent --agent-environment staging
   ```

   ```bash TypeScript theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
   npx mda deploy . --agent-id my-agent --agent-environment staging
   ```

In Python, installing the CLI as a tool and pinning the same version as a project dependency keeps the global `mda` binary and the project's own dependency on one version. For the rest of the flags, see [Deploy projects](https://docs.langchain.com/langsmith/python/managed-deep-agents-cli.md#deploy-projects), and for deploying without the agent flags, see [Deploy a Managed Deep Agent](https://docs.langchain.com/langsmith/python/managed-deep-agents-deploy.md).

## Confirm the binding

Open the agent's [Overview](https://docs.langchain.com/langsmith/navigate-agents.md#read-the-agent-overview), then select **Agent Server** in the header. Check that the Agent Server appears in the intended environment. When active revisions are available, the header also shows revision information by environment.

If the Agent Server is missing from the intended environment, check the agent ID and environment passed to the CLI. The pinned `mda` versions above require explicit `--agent-id` and `--agent-environment` flags; they ignore `LANGSMITH_AGENT_ID` and `LANGSMITH_AGENT_ENVIRONMENT`.

## See also

* [Agent Registry](https://docs.langchain.com/langsmith/agent-registry.md)
* [Agent environments](https://docs.langchain.com/langsmith/agent-environments.md)
* [Log traces to an agent](https://docs.langchain.com/langsmith/log-traces-to-agent.md)

***

[Connect these docs](https://docs.langchain.com/use-these-docs.md) to your agent of choice via MCP for real-time answers.

[Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/langsmith/deploy-to-agent-environment.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
