Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langchain ai Langgraph Langgraph Dev Command

From Leeroopedia
Property Value
API `langgraph dev` CLI command
Type External Tool Doc
Source `libs/cli/langgraph_cli/cli.py`
Library langgraph-cli
Related Workflow CLI_Deployment

Overview

The `langgraph dev` command runs a local LangGraph API server in development mode with hot reloading and debugging support. It executes entirely in-process (no Docker required), loading graph definitions from the project configuration file and serving them via the LangGraph API. The command requires the `langgraph-cli[inmem]` extra to be installed, which provides the `langgraph_api` package containing the server runtime.

Description

Command Registration

The `dev` command is registered as a Click subcommand of the `cli` group at `libs/cli/langgraph_cli/cli.py:L680-768`. It is decorated with `@log_command` for analytics tracking.

Execution Flow

  1. Import check: Attempts to import `run_server` from `langgraph_api.cli`. If unavailable, raises a `UsageError` with installation instructions.
  2. Configuration loading: Calls `validate_config_file` on the specified configuration path to load and validate the configuration.
  3. Node.js check: Rejects configurations with `node_version` set (JS in-memory server is not supported in the Python CLI).
  4. Path setup: Adds the current working directory and all local dependency directories to `sys.path` for import resolution.
  5. Server startup: Calls `run_server` from `langgraph_api.cli` with the extracted configuration parameters.

Command Options

Option Type Default Description
`--host` `str` `127.0.0.1` Network interface to bind to
`--port` `int` `2024` Port number to bind to
`--no-reload` flag `False` Disable automatic code reloading
`--config` `Path` `langgraph.json` Path to configuration file
`--n-jobs-per-worker` `int` `None` (10) Maximum concurrent jobs per worker
`--no-browser` flag `False` Skip opening browser on startup
`--debug-port` `int` `None` Port for remote debugging via `debugpy`
`--wait-for-client` flag `False` Wait for debugger client before starting
`--studio-url` `str` `None` Custom LangGraph Studio URL
`--allow-blocking` flag `False` Suppress errors for synchronous I/O in async code
`--tunnel` flag `False` Expose local server via Cloudflare tunnel
`--server-log-level` `str` `WARNING` Log level for the API server

Parameters Passed to run_server

The `dev` command extracts the following from the validated configuration and passes them to `run_server`:

  • `graphs`: The graph registry dictionary.
  • `env`: Environment variables (dict or file path).
  • `store`: Store configuration for long-term memory.
  • `auth`: Authentication configuration.
  • `http`: HTTP server configuration.
  • `ui`: UI component definitions.
  • `ui_config`: UI configuration.
  • `webhooks`: Webhook configuration.

Code Reference

Source Location

Item File Line
`dev` function `libs/cli/langgraph_cli/cli.py` L685-768
Click options `libs/cli/langgraph_cli/cli.py` L609-683

Signature

@cli.command("dev", help="Run LangGraph API server in development mode with hot reloading and debugging support")
@log_command
def dev(
    host: str,
    port: int,
    no_reload: bool,
    config: str,
    n_jobs_per_worker: int | None,
    no_browser: bool,
    debug_port: int | None,
    wait_for_client: bool,
    studio_url: str | None,
    allow_blocking: bool,
    tunnel: bool,
    server_log_level: str,
):
    """CLI entrypoint for running the LangGraph API server."""
    ...

Import

This is a CLI command, not a Python import. It is invoked from the command line:

langgraph dev [OPTIONS]

The required package is installed with:

pip install -U "langgraph-cli[inmem]"

I/O Contract

Direction Name Type Description
Input CLI options various Command-line flags and arguments
Input config file JSON file `langgraph.json` (or specified via `--config`)
Output HTTP server network API server listening on `host:port`
Output Browser side effect Opens LangGraph Studio in default browser (unless `--no-browser`)
Raises `click.UsageError` If `langgraph-api` is not installed, configuration is invalid, or Node.js graphs are specified

Usage Examples

Basic Development Startup

# Start development server with defaults (localhost:2024)
langgraph dev

Custom Port and Config

# Serve on port 8000 with a custom config
langgraph dev --port 8000 --config ./my_project/langgraph.json

Remote Debugging with VS Code

# Start with debug port and wait for VS Code to attach
langgraph dev --debug-port 5678 --wait-for-client

Then in VS Code `launch.json`:

{
    "name": "Attach to LangGraph",
    "type": "debugpy",
    "request": "attach",
    "connect": {"host": "localhost", "port": 5678}
}

Tunnel for Remote Studio Access

# Expose local server via Cloudflare tunnel
langgraph dev --tunnel --no-browser

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment