Skip to content

feat(ai): add Cursor as an AI provider (API key or CLI sign-in)#1624

Merged
datlechin merged 1 commit into
mainfrom
feat/cursor-ai-provider
Jun 8, 2026
Merged

feat(ai): add Cursor as an AI provider (API key or CLI sign-in)#1624
datlechin merged 1 commit into
mainfrom
feat/cursor-ai-provider

Conversation

@datlechin

Copy link
Copy Markdown
Member

Adds Cursor as an AI provider, so users can run AI chat and inline SQL suggestions on their Cursor subscription. Two ways to authenticate, both officially supported by Cursor:

  • API key — paste a key from the Cursor dashboard; stored in the macOS Keychain like other provider keys. Calls Cursor's Cloud Agents REST API (api.cursor.com).
  • Sign in with the Cursor CLI — leave the key blank and sign in through the browser. No key to paste. Drives the local agent command (agent login, agent -p --output-format stream-json).

The descriptor's makeProvider picks the REST provider when a key is set, otherwise the CLI provider. The settings UI is two grouped sections (API Key, Sign in with Cursor) with install/sign-in/sign-out states.

How it works

  • CursorProvider (REST): launches a no-repo agent, streams the run, maps assistant deltas to text.
  • CursorAgentProvider (CLI): spawns agent in an isolated empty temp workspace, parses the JSON-lines stream, yields only the incremental assistant deltas (the stream also emits a consolidated final message, which is skipped to avoid duplication).
  • CursorAgentCLI: locates the binary, runs login/status/logout, streams inference. stdin is /dev/null, PATH is widened, stderr is logged.
  • Models come from one curated list (Composer 2.5, Auto, Composer 2, Claude 4.5 Sonnet, Claude Opus 4.8, GPT-5.5, GPT-5.4, Gemini 3 Pro). The API-key path also fetches the live /v1/models list.

Limits (documented in-app and in docs)

Cursor runs as an agent, not a chat-completions endpoint: the AI cannot call TablePro's database tools (chat answers from the schema context TablePro sends; Edit and Agent modes do not run queries through Cursor), and responses can be slower than the other providers.

Security

  • The CLI is run with --trust (not -f/--yolo), so it trusts the isolated temp workspace without auto-approving arbitrary actions.
  • The prompt is passed after a literal -- so attacker-influenceable content (schema/data in the prompt) cannot smuggle CLI flags. Covered by a regression test.

Tests

Unit tests for the REST request encoding, the CLI argument building (including the -- guard and a flag-shaped prompt), JSON parsing, and registration (auth style, capabilities, key-vs-no-key provider selection, curated model set). Docs and CHANGELOG updated.

Built and verified against a real Cursor login: chat streams a single clean reply, the model list populates, and sign-in works.

@mintlify

mintlify Bot commented Jun 8, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
TablePro 🟢 Ready View Preview Jun 8, 2026, 10:04 AM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c250cff705

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +94 to +100
let reader = Task {
do {
for try await line in stdout.fileHandleForReading.bytes.lines {
if Task.isCancelled { break }
continuation.yield(line)
}
continuation.finish()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Surface non-zero Cursor CLI failures

When the CLI exits non-zero after launch (for example expired sign-in, invalid model, or quota/plan errors), Cursor's CLI output-format docs state failures write only to stderr and emit no well-formed JSON, but this reader ignores the termination status and finishes successfully as soon as stdout closes. In those cases CursorAgentProvider just sees no assistant JSON and TablePro shows an empty completed response instead of the actionable Cursor error.

Useful? React with 👍 / 👎.

Comment on lines +172 to +176
static func launchBody(prompt: String, model: String) -> [String: Any] {
var body: [String: Any] = ["prompt": ["text": prompt]]
if !model.isEmpty {
body["model"] = ["id": model]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Omit the model for Cursor Auto

When an API-key Cursor provider uses the curated auto option, this sends "model": {"id": "auto"} to the Cloud Agents API. Cursor's model docs describe Auto as the case where no model is supplied (and Cursor selects one), so selecting Auto will make the REST path fail with an invalid-model error instead of routing automatically.

Useful? React with 👍 / 👎.

@datlechin datlechin merged commit 2990cd2 into main Jun 8, 2026
5 checks passed
@datlechin datlechin deleted the feat/cursor-ai-provider branch June 8, 2026 12:03
datlechin added a commit that referenced this pull request Jun 8, 2026
…Cursor login, testable SSE parser, curated+fetched models) (#1627)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant