[Bug]: Cursor provider (V2 SDK) ignores existing Cursor CLI/SDK login and forces T3 sign-in or CURSOR_API_KEY #15781
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Summary#
Since the orchestration V2 switch (#2829), the Cursor provider only accepts two credential sources: a T3-owned browser sign-in, or CURSOR_API_KEY in the provider/server environment. Credentials that already exist outside T3 are ignored:
- the Cursor CLI login (
cursor-agent login, stored in the macOS Keychain ascursor-access-token/cursor-user), and - the Cursor SDK's standard login file (
~/.cursor/sdk/auth.json, the default store ofCursor.auth.login()).
As a result, T3 marks Cursor as unauthenticated and blocks sending until the user signs in again through T3 or pastes an API key. This is a regression for setups where the Cursor environment is provisioned through config files and the existing CLI login. For example, some managed or corporate launchers configure Cursor only by writing ~/.cursor/mcp.json / ~/.cursor/cli-config.json and depend on the user's existing cursor-agent login; they don't put an API key in T3's environment. V1 worked in that setup because it asked the CLI itself.
Steps to reproduce#
- On macOS, sign in with the Cursor CLI:
cursor-agent login. Confirm thatcursor-agent aboutreports your email. - Don't set
CURSOR_API_KEYanywhere, and don't sign in through T3. - Optionally, provision Cursor config through files only (e.g. MCP servers in
~/.cursor/mcp.json). - Enable the Cursor provider in T3 Code (nightly
0.0.46-nightly.20261004.2648,main@efecd3c).
Expected behavior#
T3 reuses the credential the user already has, or at least offers that option, the same way V1 did through agent about and the way the Claude and Codex providers reuse their CLI logins and config files. Cursor should show as authenticated and threads should start without a second, T3-specific sign-in. (Once auth passes, user config such as ~/.cursor/mcp.json is already loaded through settingSources.)
Actual behavior#
- The provider status is
error/unauthenticatedwith the messageSign in with Cursor or add CURSOR_API_KEY in provider settings. - The only remedies offered are T3's browser sign-in, which mints a separate
T3 Code - <name>API key into T3's own secret store, or manually addingCURSOR_API_KEY. - Sessions and text generation fail with the same
ProviderSetupErroruntil one of those is done.
Root cause#
All Cursor auth goes through CursorAuth, which only resolves two sources:
CURSOR_API_KEYfrom the merged provider environment (process.envplus instance env): https://github.com/pingdotgg/t3code/blob/efecd3cf8bcec3d1891b5f5a27dc2f6d797c6448/apps/server/src/provider/Drivers/CursorDriver.ts#L118-L123- A T3-owned per-instance credential (
ServerSecretStore, keycursor:<instanceId>), filled only by T3's ownCursor.auth.login()flow: https://github.com/pingdotgg/t3code/blob/efecd3cf8bcec3d1891b5f5a27dc2f6d797c6448/apps/server/src/provider/CursorAuth.ts#L76-L112
Every entry point is gated on that result:
- Status probe:
checkCursorProviderStatusreturnsunauthenticatedas soon as no key is resolved, without trying anything else: https://github.com/pingdotgg/t3code/blob/efecd3cf8bcec3d1891b5f5a27dc2f6d797c6448/apps/server/src/provider/Layers/CursorProvider.ts#L273-L288 - Sessions:
sdkRunner.openis wrapped inauth.requireApiKey, which fails before the SDK is called: https://github.com/pingdotgg/t3code/blob/efecd3cf8bcec3d1891b5f5a27dc2f6d797c6448/apps/server/src/provider/Drivers/CursorDriver.ts#L158-L183 - Text generation: same
requireApiKeygate: https://github.com/pingdotgg/t3code/blob/efecd3cf8bcec3d1891b5f5a27dc2f6d797c6448/apps/server/src/textGeneration/CursorTextGeneration.ts#L85-L104
Because T3 always passes an explicit apiKey, the SDK's own credential precedence (explicit apiKey, then CURSOR_API_KEY, then the stored Cursor.auth.login() key in ~/.cursor/sdk/auth.json) never applies, so a user-level SDK login is never seen.
The CLI login is also not considered for auth, even though T3 already knows how to read it. readMacCursorAccessToken reads the CLI's Keychain entry, but it's used only for the opt-in usage/limits feature (cursorKeychainUsageEnabled):
https://github.com/pingdotgg/t3code/blob/efecd3cf8bcec3d1891b5f5a27dc2f6d797c6448/apps/server/src/provider/cursorKeychainToken.ts#L51-L55
For comparison, V1 (before #2829) ran agent about with the configured binaryPath, so any login the CLI itself recognized counted as authenticated:
https://github.com/pingdotgg/t3code/blob/e5a46d6c5d00b89afba5274a94d42428c8d79763/apps/server/src/provider/Layers/CursorProvider.ts#L1023-L1100
binaryPath and apiEndpoint are still kept in CursorSettings but are documented as unused by V2:
https://github.com/pingdotgg/t3code/blob/efecd3cf8bcec3d1891b5f5a27dc2f6d797c6448/packages/contracts/src/settings.ts#L703-L726
Background / constraints#
@cursor/sdk(1.0.31) only accepts user API keys. ItsStoredSdkCredentialsdoc says the minted API key "is the only credential the SDK's surfaces accept". So the CLI's Keychain session token can't be passed toAgent.create({ apiKey })as-is.FileCredentialStoreandgetDefaultSdkAuthPath()are public SDK exports, so the standard~/.cursor/sdk/auth.jsonlogin can be read directly.- The SDK mints a key from a login session internally (
mintUserApiKey,DashboardService/CreateUserApiKey), but that isn't a public export today.
Possible fixes#
- Fall back to the SDK's default credential chain. When neither
CURSOR_API_KEYnor a T3-owned credential exists, readnew FileCredentialStore()(~/.cursor/sdk/auth.json), or pass noapiKeyand let the SDK resolve it. Report the result as authenticated with a distinct type/label such as "Cursor SDK login (shared)". KeepcanLogout: falsefor this source so T3 doesn't delete a credential it doesn't own. - Optionally reuse the Cursor CLI login. With explicit consent (same pattern as
cursorKeychainUsageEnabled), use the CLI's Keychain session to mint a named, expiring T3 API key without a browser round trip. This probably needs Cursor to expose a public mint API, or a CLI command that prints or mints an SDK key. - Make the credential source explicit in provider settings, for example "T3 sign-in" / "Use existing Cursor login" / "API key from environment". Instances provisioned by config files then work without interactive auth.
- At minimum, when no T3-owned key is found but a CLI or SDK login exists, the status message should say so and explain why it isn't used. Today it suggests the user has never signed in.
Impact#
Blocks work completely for setups that rely on an existing Cursor CLI/SDK login or file-based provisioning, unless the user creates a second credential just for T3.
Version or commit#
main @ efecd3cf8bcec3d1891b5f5a27dc2f6d797c6448; T3 Code (Nightly) 0.0.46-nightly.20261004.2648
Environment#
macOS 26.6.2, Cursor CLI 2026.10.01-e373342, @cursor/sdk 1.0.31
Related#
- #7244: V1 counterpart (CLI
CURSOR_API_KEYtreated as logged out), closed by #2829 - #15268: Cursor threads losing user/plugin/project MCP servers. A separate bug, but it hits the same config-file-provisioned setups.
Workaround#
Export CURSOR_API_KEY in the environment T3's server inherits, or add it to the Cursor provider's environment. Alternatively, complete T3's own "Sign in with Cursor" flow, which creates an additional API key.
juliusmarminge added labelsenhancement
juliusmarminge added labelsvia-triage
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Triage#
Thanks @mats16 for the detailed write-up and for comparing it against V1. It made this easy to trace.
What I found#
CURSOR_API_KEYfrom the provider environment, and then the per-instance credential saved by T3's own Sign in with Cursor flow (cursor:<instanceId>). This happens inmakeCursorAuthinapps/server/src/provider/CursorAuth.ts.CursorDriver.ts/Layers/CursorProvider.tsthen always pass that key to the SDK.docs/user/cursor.mdcurrently describes the editor and CLI logins as separate from T3's. #12948 noticed the same CLI and editor gap and added T3's own browser sign-in instead of reusing the CLI credential.~/.cursor/sdk/auth.json: In@cursor/sdk1.0.31, leaving outapiKeymakes the SDK fall back toCURSOR_API_KEYand then this file, as long as the stored key hasn't expired and was minted for the same backend.FileCredentialStoreandgetDefaultSdkAuthPath()are public. T3 never gets to that fallback because it requires its own key first. Passing an explicit key, even an empty string, skips the fallback.cursor-access-token/cursor-user): This is a session token, not the minted user API key that the SDK's agent features accept.mintUserApiKeyexists inside the package, but the public entry point doesn't export it. Also, a Keychain prompt would show up on the server's screen, where a remote client can't answer it.Likely fix area#
Some options for a maintainer to weigh:
~/.cursor/sdk/auth.jsonas a third, read-only source inCursorAuth.ts. It would usecanLogout: false, so signing out of T3 never deletes a login T3 doesn't own. The status probe would need to recognize this source too, not justAgent.create, or the provider would still look unauthenticated.apiKeywhen T3 has no key of its own, so the SDK's built-in fallback runs. The status probe would need the same change.cursorKeychainUsageEnabledsetting.In the meantime, setting
CURSOR_API_KEYon the server or finishing T3's Sign in with Cursor flow still works.A maintainer will decide on the fix direction.