Build a connector

Build an app that signs users in to the Dovetail MCP server with OAuth and a Client ID Metadata Document.

Overview

This guide is for partners and developers who build an AI app, agent platform, or MCP client that connects to Dovetail workspaces. Your users sign in to Dovetail with OAuth. Your app then calls the Dovetail MCP server on their behalf.

Dovetail uses a Client ID Metadata Document (CIMD) to identify your app. You publish a small JSON file at an HTTPS address that you control. That address is your OAuth client ID. When a user connects your app, Dovetail's login service reads the file. You do not register your app with Dovetail first, and you do not receive a client secret.

For the full CIMD specification, see OAuth Client ID Metadata Document. For how MCP clients use it, see the MCP authorization specification.

Note: A workspace admin must allow third-party apps before your app can connect to that workspace. See Allow third-party apps to connect. Until an admin does this, Dovetail refuses requests from your app.

Other ways to connect

CIMD is not the only option. Choose the one that fits your case:

OptionUse it when
CIMD (this guide)You build a product that many Dovetail customers connect to, and you can host a public metadata file.
Built-in integrationYou want your app to appear in Dovetail without admins turning on a setting. Email [email protected] to discuss a partnership.
API tokenA person connects one tool for themselves and can set a custom Authorization header.

What you need

  • A public HTTPS address where you can host the metadata file.
  • One or more redirect URIs that your app can receive the authorization code on.
  • An MCP client that supports Streamable HTTP, OAuth server discovery, and PKCE.
  • A Dovetail workspace where an admin has turned on Allow apps that connect with CIMD, for testing.

Step 1: Publish your metadata document

Host a JSON file at an address that you control. Example:

{
  "client_id": "https://example.com/oauth/dovetail-client.json",
  "client_name": "Example AI",
  "client_uri": "https://example.com",
  "logo_uri": "https://example.com/logo.png",
  "redirect_uris": ["https://example.com/oauth/callback"],
  "grant_types": ["authorization_code", "refresh_token"],
  "response_types": ["code"],
  "token_endpoint_auth_method": "none"
}
FieldRequiredDescription
client_idYesThe exact address of this file. It must match the address that Dovetail uses to fetch the file.
redirect_urisYesThe addresses where Dovetail can send the authorization code. Each address that your app uses must be in this list exactly.
client_nameRecommendedThe app name that users see when they sign in. Use your product name.
client_uriRecommendedThe address of your website.
logo_uriRecommendedThe address of your logo.
grant_typesRecommendedUse authorization_code and refresh_token.
response_typesRecommendedUse code.
token_endpoint_auth_methodRecommendedUse none. Your app is a public client and uses PKCE instead of a secret.

Requirements for the file and its address:

  • The address uses https, has a path other than /, and has no fragment (#). Avoid a query string.
  • The server responds 200 OK with JSON at that exact address. Do not redirect.
  • Anyone on the internet can read the file. It needs no sign-in.
  • The file never contains a client secret or other private data.
  • The address stays the same over time. If you change it, Dovetail treats your app as a different app.

Step 2: Discover Dovetail's authorization server

Your client can find every address it needs from two documents. Do not hard-code these addresses if your client supports discovery.

  1. Fetch the MCP server's protected resource metadata:

    curl https://dovetail.com/.well-known/oauth-protected-resource/api/mcp

    The response lists the authorization server in authorization_servers (https://auth.dovetail.com/) and the permissions you can request in scopes_supported.

  2. Fetch the authorization server metadata:

    curl https://auth.dovetail.com/.well-known/oauth-authorization-server

    The response includes authorization_endpoint, token_endpoint, and client_id_metadata_document_supported: true. It does not include a registration_endpoint, so Dovetail does not offer Dynamic Client Registration. Use a metadata document instead.

If your client calls the MCP server without a token, it gets a 401 response. The WWW-Authenticate header in that response includes a resource_metadata value that points to the first document above:

WWW-Authenticate: Bearer realm="dovetail-mcp", error="invalid_request", error_description="Authentication required", resource="https://dovetail.com/api/mcp", resource_metadata="https://dovetail.com/.well-known/oauth-protected-resource/api/mcp"

Step 3: Send the user to authorize

Use the OAuth authorization code flow with PKCE. Send the user's browser to the authorization_endpoint, for example https://auth.dovetail.com/authorize, with these query parameters:

ParameterValue
response_typecode
client_idThe address of your metadata document.
redirect_uriOne of the redirect_uris in your document.
scopeA space-separated list of scopes, such as insight:read project:read offline_access.
stateA random value that your app checks when the user returns.
code_challengeThe PKCE challenge for your random code_verifier.
code_challenge_methodS256
audiencehttps://dovetail.com/api/mcp

Do not send an organization parameter. Dovetail asks the user to enter the subdomain of their workspace.

Choose scopes with these rules:

  • Request only scopes from scopes_supported. Scopes shows which tools each scope unlocks.
  • Request the fewest scopes that your app needs.
  • Add offline_access if your app needs a refresh token.
  • Do not request openid, profile, or email. These scopes are not in scopes_supported, and the MCP server does not need them.

What the user sees

  1. The user signs in to Dovetail.
  2. The user enters the subdomain of the workspace to connect.
  3. The user chooses the permissions to give your app: Full access, Read only, or Custom. The user can give fewer permissions than you asked for.

After this, Dovetail redirects the user to your redirect_uri with code and state. Check that state matches the value you sent.

Step 4: Exchange the code for tokens

Send a POST request to the token_endpoint, for example https://auth.dovetail.com/oauth/token. Do not send a client secret.

curl https://auth.dovetail.com/oauth/token \
  -d grant_type=authorization_code \
  -d client_id=https://example.com/oauth/dovetail-client.json \
  -d code=<CODE> \
  -d redirect_uri=https://example.com/oauth/callback \
  -d code_verifier=<CODE_VERIFIER>

The response includes access_token and expires_in. It also includes refresh_token if you requested offline_access.

The user can grant fewer permissions than you requested, so do not assume that every scope you asked for was granted. Handle a refused tool call as described in Handle errors.

Step 5: Call the MCP server

Send MCP requests to https://dovetail.com/api/mcp with the access token as a bearer token:

curl -X POST https://dovetail.com/api/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

The response lists only the tools that the granted permissions allow. For the tools and the permission each one needs, see Dovetail MCP server and Scopes.

Step 6: Refresh tokens

Access tokens are short-lived. Before an access token expires, or after a 401 response with error="invalid_token", use the refresh token to get a new one:

curl https://auth.dovetail.com/oauth/token \
  -d grant_type=refresh_token \
  -d client_id=https://example.com/oauth/dovetail-client.json \
  -d refresh_token=<REFRESH_TOKEN>

Refresh tokens rotate. Each refresh response includes a new refresh token, and the old one stops working. Store the new refresh token every time.

A refresh token expires after 15 days without use, and after 30 days in all cases, even if you use it often. After that, the user must sign in again. If a refresh fails, start the flow again from Step 3.

Handle errors

ResponseMeaningWhat your app does
401 with error="invalid_token"The access token is missing, invalid, or expired.Refresh the token. If that fails, send the user through the sign-in flow again.
403 with error="insufficient_scope"The user did not grant a permission that this tool needs.Read the scope value in the WWW-Authenticate header. If the user agrees, start the authorization flow again and ask for those scopes.
403 with error="forbidden" and the message "This app is not enabled for your Dovetail workspace"A workspace admin has not allowed third-party apps.Do not retry. Tell the user to ask a workspace admin to turn on Allow apps that connect with CIMD. See Allow third-party apps to connect.
403 with a message that external tool access is blockedThe workspace blocks API and MCP access from external tools.Do not retry. Tell the user to contact a workspace admin.
429The app made too many requests.Wait for the number of seconds in the Retry-After header, then retry.

Test your connector

  1. Ask an admin of a test workspace to turn on Allow apps that connect with CIMD. If you do not have a workspace, you can sign up for a free workspace to test with.
  2. Check that your metadata document loads without sign-in and that client_id matches its address.
  3. Complete the sign-in flow and exchange the code for tokens.
  4. Call tools/list, then call one tool that needs a permission you requested.
  5. Refresh the access token, and check that your app stores the new refresh token.
  6. Ask the admin to turn the setting off. Check that your app shows a clear message when it gets the 403 response.

Recommended practices

  • Use a clear product name and logo. Users see them when they approve your app.
  • Always use PKCE with S256, and always check state.
  • Register only the redirect URIs that your app uses.
  • Request the fewest scopes that your app needs. Ask for more only when a feature needs them.
  • Store access tokens and refresh tokens as secrets, and delete them when a user disconnects your app.
  • Keep the metadata document available at all times. Dovetail's login service cannot start a sign-in if it cannot read the file.

Get help

For questions about the connector flow or a partnership, email [email protected].


Did this page help you?