packages/twenty-codex-plugin/references/use-twenty-mcp/setup.md
Use this reference to configure a workspace-specific Twenty MCP endpoint. The plugin must not assume a fixed workspace domain; collect the user's workspace URL first, normalize it to an MCP URL, then configure and authenticate the MCP client.
Ask for the workspace URL or host if it is missing. Do not invent or reuse a private default domain.
Accept any of these forms:
myworkspace.twenty.com
myworkspace.customdomain.com
myworkspace.localhost:3001
https://myworkspace.twenty.com
https://myworkspace.customdomain.com/mcp
http://myworkspace.localhost:3001/mcp
Optional inputs:
twenty-<host-without-tld>, for example acme.example.com becomes twenty-acme-example.Important OAuth guard:
--login from Codex. It is deprecated.open <authorization-url> for an OAuth URL printed by codex mcp add unless the user confirms no browser tab opened. Opening the same authorization URL twice creates two callback tabs with the same state and different one-time code values.Normalize workspace input as follows:
http:// or https://, preserve that scheme.localhost, 127.x.x.x, [::1], *.localhost, or *.localhost:<port>, use http://.https://./mcp, append /mcp.Examples:
myworkspace.twenty.com -> https://myworkspace.twenty.com/mcp name: twenty-myworkspace
acme.example.com -> https://acme.example.com/mcp name: twenty-acme-example
myworkspace.customdomain.com -> https://myworkspace.customdomain.com/mcp name: twenty-myworkspace-customdomain
myworkspace.localhost:3001 -> http://myworkspace.localhost:3001/mcp name: twenty-myworkspace-localhost-3001
Use the bundled helper from the Twenty repo or plugin checkout:
bash packages/twenty-codex-plugin/scripts/setup-mcp.sh <workspace-url-or-mcp-url>
Use --name <server-name> when configuring multiple Twenty workspaces:
bash packages/twenty-codex-plugin/scripts/setup-mcp.sh --name twenty-prod acme.twenty.com
bash packages/twenty-codex-plugin/scripts/setup-mcp.sh --name twenty-local acme.localhost:3001
Use --force-login only when running from a normal terminal and Codex did not open OAuth automatically:
bash packages/twenty-codex-plugin/scripts/setup-mcp.sh --force-login acme.twenty.com
Use --print-url to preview normalization without changing client config:
bash packages/twenty-codex-plugin/scripts/setup-mcp.sh --print-url myworkspace.localhost:3001
The helper:
--name is provided.codex mcp add <name> --url <normalized-url>.codex mcp login <name> only when --force-login is provided outside a Codex-managed shell.If the helper is unavailable, configure Codex manually:
codex mcp add twenty-myworkspace --url https://myworkspace.twenty.com/mcp
codex mcp login twenty-myworkspace
For local development:
codex mcp add twenty-local --url http://myworkspace.localhost:3001/mcp
codex mcp login twenty-local
After setup, verify the MCP server is available:
codex mcp get <server-name>
When connected, use the Twenty MCP discovery flow:
learn_tools -> execute_tool
Use this workflow when the user reports missing tools, unexpected workspace data, authentication failures, or suspects Codex queried the wrong Twenty workspace.
bash packages/twenty-codex-plugin/scripts/setup-mcp.sh --print-url <workspace-url-or-mcp-url>
codex mcp list
codex mcp get <server-name>
bash packages/twenty-codex-plugin/scripts/setup-mcp.sh --name <server-name> <workspace-url-or-mcp-url>
Auth required, run OAuth for that exact server:codex mcp login <server-name>
codex exec query that loads the updated MCP config.SERVER_URL matches the public workspace origin. OAuth metadata and MCP URLs derive from that value.http:// explicitly or rely on the helper's localhost default.--name to keep multiple workspaces.