Connections
Experimental
Connections are experimental and off by default. Names, fields, and behavior may change in any release. Turn them on with experimental_connections: true.
A connection is one signed-in account at an OAuth 2.0 server or a remote MCP server. You sign in once, from the Web UI or the CLI, and steps then name the connection. The DAG holds no secret:
labels:
- workspace=ops
steps:
- id: open_issues
action: mcp.call
with:
connection: tracker
tool: list_issues
arguments: { state: open }Dagu stores the tokens encrypted, refreshes an access token when a step needs one, saves a rotated refresh token, and, over HTTP, sends a token only over HTTPS to the hosts the connection is bound to. An exported token and the tokens a coordinator hands to workers travel outside that rule, as Security and Workers explains. When a sign-in expires or is revoked, Dagu reports it once per notification channel and offers Reconnect.
These pages cover connections to any server:
- Connect an OAuth 2.0 Server: the
oauth2provider, with the authorization code or client credentials grant. - Connect Any MCP Server: the
mcpprovider, for a remote MCP server that follows the MCP authorization spec. - Use Connections in Steps:
mcp.call,http.request, token export, errors, and rate limits. - Security and Workers: what connections protect against, runs on workers, and the upgrade order.
Turn Connections On
Set the switch in config.yaml:
experimental_connections: trueOr set the environment variable:
export DAGU_EXPERIMENTAL_CONNECTIONS=trueSet it for every Dagu process that reads the configuration: the server, the scheduler, and the coordinator. Workers get tokens from the coordinator, so in distributed mode the coordinator needs it too.
While the switch is off:
- The Connections page, the connection API endpoints, the
dagu_readconnection targets, and the connection starter DAG do not exist. dagu connectionfails, saying the server does not serve connections.- A DAG that names a connection still loads, but its run fails before its first step:
connections are not enabled; set experimental_connections: true to use them. - Stored connections are kept. Turning the switch on again restores them.
OAuth Apps and Connections
| OAuth app | Connection | |
|---|---|---|
| What it is | A client registered at a provider: its endpoints, client ID, and optional secret | One authorized account at that provider, or for client credentials, the client itself |
| Scope | Server-wide. Many connections share one app | Belongs to one workspace. Steps use it by name |
| Managed by | Admins | Managers of the workspace |
| Holds | The client secret, encrypted | The refresh and access tokens, encrypted |
Register the client at the provider once, as an admin. Each connection then signs in its own account on that app, with its own consent and refresh token. An mcp connection can skip the admin step: Dagu finds or registers a client itself, as Connect Any MCP Server explains.
Names and Workspaces
- A name has 1 to 63 lowercase letters, digits, and hyphens, and starts with a letter or digit, such as
work-apiortracker-2. It never changes. - A name is unique within its workspace. Two workspaces may each have a connection of the same name, with separate sign-ins.
- A DAG's
connection: trackerresolves to the connectiontrackerof the run's workspace, taken from the DAG'sworkspacelabel, and to nothing else. - DAGs without a
workspacelabel use the connections the CLI and API callglobal. Unlike global secrets,globalconnections are not a fallback for other workspaces. - A connection is never shared or copied between workspaces. A workspace that needs the same account connects it again.
- A workspace that owns connections cannot be deleted or renamed. Remove its connections first.
Roles
| Action | Role |
|---|---|
| See connections: name, provider, account, status | viewer or above in the workspace |
| Test a connection, list its tools, call a tool with Try it | developer or above in the workspace |
| Create, sign in, reconnect, change, or remove a connection | manager or above in the workspace |
| Register, change, or delete an OAuth app | admin |
| Add a client credentials connection, or change its scopes or bound hosts | admin |
| Allow token export on a connection | admin |
| Name a connection in a DAG | Whoever may edit the DAG |
No role sees a token or client secret. Responses report only whether a secret or refresh token is configured. A manager who finds no fitting app sees what to ask an admin for: the client type and the redirect URI to register.
Add a Connection
In the Web UI, open Connections, click New connection, and pick a tile:
- Custom OAuth2 for any OAuth 2.0 server.
- Any MCP server for a remote MCP server.
From the CLI, run dagu connection add oauth2 or dagu connection add mcp. Both run the same connect flow as the UI, through the server's REST API.
The connection belongs to the workspace selected in the UI, or to the one --workspace names in the CLI. Every wizard warns that DAGs that run on the server, rather than on a worker, run as Dagu's user, so their authors can read the connection's tokens. See Security and Workers.
Sign In
Signing in runs a session:
- Dagu creates the authorization request, with PKCE and an encrypted
state, and opens the provider's consent page in a popup or a browser. - You consent at the provider. The provider redirects back with a code, which Dagu exchanges for tokens.
- Dagu shows the account that signed in. The tokens go live only when the user who started the session confirms it.
A session lasts 10 minutes. A session that fails, is cancelled, or expires changes nothing: a new connection stays pending, and a reconnected one keeps its previous tokens.
Before consent, the UI and the CLI show the exact redirect URI to register in the client, and the client ID.
Redirect Modes
| Mode | Used when | Redirect URI | Client type |
|---|---|---|---|
| Server callback | The server has a usable public URL | <public URL>/oauth/callback | web |
| Loopback | A desktop client, and the CLI runs where a browser can open | http://127.0.0.1:<port>/oauth/callback, on a random port the CLI listens on | desktop |
| Paste | A desktop client, without the CLI's listener | http://127.0.0.1:1/oauth/callback, which fails to load. You copy the address the browser lands on and paste it into the UI or the CLI | desktop |
The UI and the CLI pick the first mode that works for the server and the app's client type. Loopback needs the CLI. The UI uses server callback or paste. A web client on a server without a usable public URL has no mode, and cannot sign in. Loopback works only with a provider that accepts any port on a loopback redirect (RFC 8252, section 7.3).
The usable public URL is public_url from config.yaml, else the tunnel URL, else the origin of the request when it reaches Dagu at localhost or a loopback address, without a proxy. So the UI opened at http://localhost:8080, and the CLI on the local context, get a server callback on that origin, such as http://localhost:8080/oauth/callback, and a web client. A request through a proxy does not count, so a server behind a reverse proxy needs public_url.
In server callback mode, Copy sign-in link gives the authorization URL to the account's owner. The owner consents in their own browser without a Dagu login, and you confirm the account.
The Account
An OAuth 2.0 server names the account only in an OpenID Connect ID token, which it returns when the connection asks for the openid scope. Without one, the connection has no account, and you confirm the session as it is.
A second connection in the same workspace for the same account and client is created with a warning, not refused. Some providers limit how many refresh tokens one account holds per client. See Refresh Token Limits.
Status
| Status | Meaning | Steps that use it |
|---|---|---|
pending | Created, never signed in | Fail with reconnect_required, saying the connection was never connected |
connected | Holds live tokens | Run |
needs_reconnect | The provider refused the refresh token, as after a revocation or expiry | Fail with reconnect_required, without calling the provider |
broken | The token record is missing or cannot be decrypted, as after a create that stopped halfway | Fail. Remove the connection and add it again |
An app becomes invalid when the provider refuses its client, such as after the client secret was rotated or deleted at the provider. Every connection of the app then fails at once, without calling the provider, until an admin changes the app's client ID, client secret, token URL, or how the client sends its secret.
Only a confirmed reconnect clears needs_reconnect, and only an admin's change to the app clears invalid.
Reconnect
Click Reconnect on the connection page, or run:
dagu connection reconnect tracker --workspace opsA reconnect runs the same sign-in on the existing connection. The previous tokens stay live until you confirm. The CLI expects the account the connection holds. It confirms without asking only when the provider vouches for that account's email, in an ID token with email_verified, and the account ID matches. Without openid, or without a verified email, the CLI asks even for the same account. A different account always asks first.
Reconnect after the connection needs it, and after adding scopes, which take effect only at the next sign-in. A client credentials connection fetches a new token instead of signing in.
Test on the connection page, or dagu connection test, checks that an oauth2 or mcp connection can get a live token, refreshing it if needed. It does not call the API or the MCP server. To check the server, list its tools or call one, as Try It shows.
Badge and Notifications
The Connections navigation item shows a badge while any connection you can see needs reconnecting, or holds a refresh token that expires within two days or has expired. The badge is a warning dot when only an expiry causes it.
Two notification events report changes in a connection's status:
| Event | Sent when |
|---|---|
Connection needs attention (connection.needs_attention) | A connection becomes needs_reconnect, or its app becomes invalid |
Connection restored (connection.restored) | A connection goes from needs_reconnect to connected, or an app from invalid to ok |
- Each change sends one plain-text message per channel, however many runs fail on the broken connection.
- A connection's events follow its workspace's notification rules. An app's events follow the rules of each workspace with a connection on the app.
- The message holds a Reconnect link,
<public URL>/connections/<name>?workspace=<workspace>. Without a public URL, it names the Connections page anddagu connection reconnect <name>. - A channel that receives Connection needs attention does not also send the Failed message of a run whose only failures were steps on that broken connection. A channel that does not receive it sends every failure.
- New rules select both events. Existing rules keep their event lists until you add them.
A first sign-in from pending sends no event, and a step that fails on a pending connection still sends the run's failure message.
Expiry
Some providers report when a refresh token expires. Dagu then stores the date, and the Connections page and the connection page show the time left, as a warning within two days. Dagu sends no notification before the date: nothing checks on a timer. After the date, the next refresh fails, the connection becomes needs_reconnect, and Connection needs attention is sent.
Reconnect before the date to avoid the failure.
Remove
Click Remove on the connection page and confirm, or run:
dagu connection remove tracker --workspace opsRemove deletes the connection, its tokens, and its tool lists. Then Dagu revokes the refresh token at the provider's revocation endpoint, when the app names one.
- Dagu does not revoke while another connection on this server holds the same account on the same client, since a provider may end the account's whole grant to the client. That connection keeps working.
- Connections on other servers that use the same client may lose access. The confirmation says so.
- Revocation is best effort. A failure is logged and audited, and never fails the remove.
- A DAG that still names the connection fails when it starts, naming the connection.
- The CLI asks first. Without a terminal it needs
--yes.
Audit
With the audit log on, Dagu records app and connection changes, sign-ins, reconnects, removals, status changes, tool calls from Try it, a client credentials token fetched through the API, and a revocation. The tokens handed to steps are not audited, and no entry holds a secret.
CLI Reference
dagu connection is hidden from dagu --help while connections are experimental. dagu connection --help works. connections is an alias.
dagu connection providers
dagu connection add oauth2 [NAME] --scopes a,b --bound-host HOST [--grant client_credentials] \
[--app APP | --token-url URL [--authorize-url URL] [--revoke-url URL] --client-id ID \
[--client-secret-stdin] [--client-type web|desktop] [--no-pkce] [--token-auth basic|post]]
dagu connection add mcp [NAME] --url URL [--app APP | --client cimd|dcr] [--scopes a,b]
dagu connection list
dagu connection show NAME
dagu connection test NAME
dagu connection reconnect NAME
dagu connection remove NAME [--yes]
dagu connection tools NAME [--json]
dagu connection call NAME --tool TOOL [--args JSON] [--yes]
dagu connection apps list
dagu connection apps remove APP- Every command except
providersandappstakes--workspace. The default isglobal, the connections of DAGs without aworkspacelabel. addandreconnecttake--no-browser, which prints the sign-in URL instead of opening a browser, such as over SSH.addwithout enough flags asks for what is missing on a terminal, and reads secrets without echo. Without a terminal it fails, naming what is missing.- Every command calls the server's REST API. With a remote context it acts on that server. With the
localcontext it calls the server that this host's configuration describes, which must be running. With builtin or OIDC authentication, thelocalcontext has no credential: add a context with an API key. - No command prints a client secret, refresh token, or access token.

