Skip to main content

Connect to the MCP server with an access token

By default, MCP clients sign in to the remote MCP server with OAuth, so the assistant acts as your MotherDuck user. To connect as a service account, or from an agent that can't complete an OAuth sign-in, send a MotherDuck access token in the Authorization header instead:

Authorization: Bearer <your_motherduck_token>

The MCP server runs every tool call as the user who owns the token. A service account token gives the assistant that service account's databases, shares, and Duckling settings. A read scaling token works the same way and limits the assistant to read-only queries.

Use this when you want to:

  • Give a shared agent, bot, or automation its own identity instead of a person's account.
  • Run the MCP server from a headless environment, such as a CI job or a cloud agent, where no one can complete a browser sign-in.
  • Enforce read-only access with a read scaling token. See Restricting to read-only access.

Prerequisites​

Configure your client​

Most configurations read the token from the MOTHERDUCK_TOKEN environment variable, so the token stays out of the config file. Set it in the shell that starts your client:

export MOTHERDUCK_TOKEN='<your_motherduck_token>'

Then select your client:

On Claude web and Claude Desktop, add MotherDuck as a custom connector that sends the token as a request header.

note

Request header authentication is in beta for a limited set of Claude organizations. If you don't see Request headers in the Add custom connector dialog, use the Claude Desktop config below.

  1. Open the Add custom connector dialog:
    • On Free, Pro, and Max plans, go to Customize → Connectors and click Add custom connector.
    • On Team and Enterprise plans, an Owner goes to Organization settings → Connectors, clicks Add, and selects Custom.
  2. Enter https://api.motherduck.com/mcp as the server URL.
  3. Under Authentication, choose No sign-in.
  4. Under Request headers, select authorization as the header name and enter Bearer <your_motherduck_token> as the value. Claude sends the value exactly as entered, so include the Bearer prefix.
  5. Click Add.

Claude doesn't let you edit request headers after you add the connector. To rotate the token, remove the connector and add it again.

Claude Desktop config

If your organization doesn't have request headers, connect Claude Desktop through mcp-remote, which bridges the remote server into a local server and adds the header. Go to Settings → Developer → Edit Config and add:

{
"mcpServers": {
"MotherDuck": {
"command": "npx",
"args": [
"mcp-remote",
"https://api.motherduck.com/mcp",
"--header",
"Authorization:${AUTH_HEADER}"
],
"env": {
"AUTH_HEADER": "Bearer <your_motherduck_token>"
}
}
}
}

Keep the header argument without spaces. Claude Desktop on Windows doesn't escape spaces inside args, so the space after Bearer goes in the env value. Restart Claude Desktop after you save the file. This method requires Node.js for npx.

Verify the connection​

Start a new chat and ask "List all my databases on MotherDuck". The assistant should call a MotherDuck tool and return the databases of the token's owner. For a service account token, you see the service account's databases, not your own.

Troubleshooting​

ErrorCause and fix
Authentication required. Please authenticate using OAuth or provide a Bearer token.The client sent no token, or an empty one. Check that MOTHERDUCK_TOKEN is set in the environment that starts the client, then restart the client.
Invalid token format: not a valid JWTThe header value isn't a MotherDuck token. Check that the variable expanded and that the value is Bearer followed by the full token.
A message that starts with Invalid token:MotherDuck rejected the token. Check that you copied the full token and that it hasn't been revoked.