Connect Any MCP Server
Experimental
Connections are experimental and off by default. Turn them on with experimental_connections: true in config.yaml, or DAGU_EXPERIMENTAL_CONNECTIONS=true. See Turn Connections On.
The mcp provider connects a remote MCP server that follows the MCP authorization spec. You give its URL. Dagu discovers its authorization server, picks or registers an OAuth client, and signs in. mcp.call then calls the server with connection alone:
labels:
- workspace=ops
steps:
- id: open_issues
action: mcp.call
with:
connection: tracker
tool: list_issues
arguments: { state: open }For a server that takes a static API key or token instead of OAuth, keep using mcp.call with headers.
Requirements
- The MCP server's URL is HTTPS, without a user name, password, fragment, or credential in its query. Dagu stores it in canonical form, with a lowercase host and without the default port.
- The server publishes protected resource metadata (RFC 9728), named in its
WWW-Authenticatechallenge or at the well-known path. - Its authorization server publishes metadata (RFC 8414) and supports PKCE with
S256. - The authorization server takes one of the clients in How Dagu Picks the Client.
A server or authorization server that lacks either metadata, or PKCE S256, is refused when the connection is created.
How Dagu Connects
When the connection is created, before it is stored, Dagu runs discovery once:
- It calls the MCP server without a token, and reads the protected resource metadata.
- It fetches the authorization server's metadata, and accepts it only when its
issuermatches the URL it came from. - It picks a client, as below.
- You sign in, as Sign In describes. The request carries PKCE and the server's URL as
resource(RFC 8707), and so does every refresh.
The connection's resource is the server's canonical URL. It never changes. To point at another URL, add another connection.
An mcp connection has no bound hosts to set: its token goes only to its MCP server's host, over HTTPS.
When the authorization server's metadata says it sends iss in its redirect (RFC 9207), a redirect whose iss is missing or names another issuer fails the sign-in before the code is exchanged.
How Dagu Picks the Client
| Client | Picked when | Who can use it |
|---|---|---|
| Client ID Metadata Document (CIMD) | The authorization server's metadata advertises CIMD, and this server has a public HTTPS URL | A manager |
| Dynamic client registration (DCR) | Otherwise, when the metadata names a registration endpoint (RFC 7591) | A manager |
| An MCP app an admin added | Only when you name it | A manager names it. An admin adds it |
Unless you choose, Dagu takes the first the authorization server advertises: CIMD, then DCR. It picks by the metadata, not by what works, and does not fall back: when the authorization server later fails to fetch the CIMD document at consent, the sign-in fails, and you add the connection again with DCR. When the metadata advertises neither, the create fails and asks for an admin's app.
CIMD. The client ID is the URL of this server's client metadata document, <public URL>/oauth/client-metadata.json, a public route that describes Dagu as a public client whose redirect URI is the server callback. The authorization server fetches it, so:
public_urlinconfig.yaml, or the tunnel URL, must be HTTPS.- The authorization server must reach that URL from the internet. A server on a private network, or behind a VPN, does not work. Choose DCR there.
One CIMD client serves every mcp connection to the same authorization server, and holds no secret.
DCR. Dagu registers a client for this connection alone. It is a public client with PKCE and no secret, unless the authorization server takes no public client. Its redirect URI is the server callback when the server has a usable public URL, and the paste redirect otherwise. Removing the connection deletes its client in Dagu, as a best effort. The client stays registered at the authorization server.
An MCP app an admin added. For an authorization server that takes neither, an admin registers a client there and adds it to Dagu as an mcp app. A connection on that app skips discovery, so give the scopes the server needs. When discovery finds no client it can use, the error names the redirect URI and endpoints to register. A web app signs in only on a server with a usable public URL. Without one, the error names the paste URI, http://127.0.0.1:1/oauth/callback, which needs a desktop app.
An admin adds an mcp app through the REST API:
curl -X POST "https://dagu.example.com/api/v1/oauth-apps" \
-H "Authorization: Bearer $DAGU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "tracker-client",
"provider": "mcp",
"clientId": "dagu",
"clientType": "web",
"endpoints": {
"authorizeUrl": "https://auth.example.com/authorize",
"tokenUrl": "https://auth.example.com/token"
}
}'Scopes
Without an app, the scopes default to those the server's challenge names, else those its protected resource metadata lists, with offline_access when the authorization server offers it. Name your own scopes to replace them. With an app, name the scopes yourself.
Network Limits
Discovery and registration fetch only HTTPS URLs:
- Discovery follows at most five redirects, each to HTTPS. Registration and token requests follow none.
- Each request takes at most 10 seconds, a whole discovery at most 30, and each response is read up to 1 MiB.
- Unless every address of the MCP server's host is private, loopback, or link-local, no discovery or registration request reaches such an address, and the token and revocation endpoints may not resolve to one when discovery checks them. Later token requests are not checked again.
- With a proxy configured, only the dial to the proxy skips that check, and the proxy resolves and reaches the target on its own, so the check does not cover requests through it. An internal MCP server is reached directly, never through the proxy.
From the Web UI
- Open Connections in the workspace that will own the connection, and click New connection.
- Pick Any MCP server.
- Enter the name and the MCP server URL.
- Optionally, open Advanced settings and choose the OAuth client: Automatic, Client ID Metadata Document (CIMD), Dynamic client registration (DCR), or An MCP app an admin added. Add scopes if the server needs others than it names.
- Create the connection, consent in the popup, and confirm the account.
When you chose CIMD and the create is refused, because the authorization server does not take CIMD or this server has no public HTTPS URL, the dialog offers Try again with DCR. A failed discovery offers no retry. When the authorization server refuses the CIMD client at sign-in, under any choice, the dialog offers Add again with DCR, which removes the connection that never signed in and adds it again with a DCR client.
The connection page shows the server URL, the client kind, the scopes, and the granted scopes.
From the CLI
dagu connection add mcp tracker --workspace ops --url https://mcp.example.com/mcp| Flag | Meaning |
|---|---|
--url | The MCP server's HTTPS URL. Required |
--client | cimd or dcr, in place of the automatic choice |
--app | An mcp app an admin added, by ID or name. Skips discovery |
--scopes | Scopes, comma-separated |
--no-browser | Print the sign-in URL instead of opening a browser |
For a public URL the authorization server cannot reach:
dagu connection add mcp tracker --workspace ops --url https://mcp.example.com/mcp --client dcrFor an authorization server that takes neither CIMD nor DCR:
dagu connection add mcp tracker --workspace ops --url https://mcp.example.com/mcp \
--app tracker-client --scopes read,offline_accessThen list the server's tools, and call one to check the connection:
dagu connection tools tracker --workspace ops
dagu connection call tracker --workspace ops --tool list_issues --args '{"state": "open"}'Next Steps
- Use Connections in Steps covers
mcp.callwithconnection, its errors, and the Tools panel. - The starter DAG calls one tool of the connection.

