Skip to main content

surjection_core/adapters/
cursor.rs

1//! Grok Build, the desktop app formerly named Cursor (`cursor`): SPEC 7.3
2//! and 7.4. Cursor was renamed Grok Build on 2026-11-30; the desktop app
3//! still reads `.cursor/` (MCP config, rules, skills), so the client id
4//! and every path stay as they were. The terminal product is the separate
5//! `grok` client (Grok Build TUI).
6//!
7//! - User scope: `~/.cursor/mcp.json` (every OS).
8//! - Project scope: `<P>/.cursor/mcp.json`.
9//! - Entries: `mcpServers.<name>` without `type`: `{command, args, env,
10//!   envFile}` (stdio) or `{url, headers}` (a bare `url` is Streamable
11//!   HTTP). SSE entries carry `"type": "sse"`. `envFile` is a passthrough
12//!   field (`[client.cursor] envFile`).
13//! - Variables: Cursor expands `${env:NAME}` (and its own `${userHome}`,
14//!   `${workspaceFolder}`) in `command`, `args`, `env`, `url` and
15//!   `headers`; Surjection writes `${env:NAME}` for `env` delivery.
16//! - Project servers: Cursor lists each new server of a project file as
17//!   Disabled until it is enabled once in Customize > MCPs (gate V2 CUR-2);
18//!   that toggle is Cursor's own state, so plans and `effective` carry a
19//!   `client_enable_required` hint ([`TrustGate::ClientEnable`]).
20//! - Same-named entries: a user and a project entry both run, as separate
21//!   servers listed per source (gate V2 CUR-5, FB-17), so the layers are
22//!   [`ProjectSemantics::Coexist`]: `effective` lists one loaded row per
23//!   file with `duplicate_across_layers`, and a project cannot hide or
24//!   replace a user server (`cannot_suppress_in_project`).
25//!
26//! Verified at gate V2 (Windows Sandbox, Cursor 3.31; `docs/verify/cursor.md`):
27//! `"disabled": true` is ignored and the UI toggle lives in Cursor's own
28//! storage, so there is no native disable field (CUR-4); a project entry
29//! cannot hide a user server, and a same-named user and project entry both
30//! run as separate servers (CUR-5); `${env:NAME}` expands in command, args,
31//! env, url and headers (CUR-3); SSE with `"type": "sse"`, bare-url SSE and
32//! bare-url Streamable HTTP all load (CUR-6); dotted and spaced names load
33//! (CUR-7); plain `npx` starts without `cmd /c` (CUR-8); the per-user
34//! installer's uninstall entry is `Cursor (User)` (CUR-9).
35
36use crate::adapters::caps::{
37    Caps, EnvRefSyntax, FieldSet, ProjectSemantics, Source, TransportSet, TrustGate,
38};
39use crate::adapters::detect::Probe;
40use crate::adapters::location::Location;
41use crate::adapters::mapper::McpServersJson;
42use crate::adapters::spec::{AdapterSpec, ContainerPath, McpSpec, Tier, exact_names};
43use crate::env::Os;
44use crate::formats::Format;
45use crate::model::clients::passthrough_of;
46
47pub const ID: &str = "cursor";
48
49const CAPS: Caps = Caps {
50    transports: TransportSet::ALL,
51    env_ref: Some(EnvRefSyntax::DollarBraceEnv),
52    env_ref_fields: FieldSet::COMMAND
53        .union(FieldSet::ARGS)
54        .union(FieldSet::ENV)
55        .union(FieldSet::URL)
56        .union(FieldSet::HEADERS),
57    command_ref: None,
58    native_disable: None,
59    project_disable: None,
60    project_semantics: ProjectSemantics::Coexist,
61    // Only the order `effective` lists same-named entries in.
62    precedence: &[Source::Project, Source::User],
63    compat_reads: &[],
64    trust_gate: Some(TrustGate::ClientEnable("Grok Build > Customize > MCPs")),
65    rewrites_file_at_runtime: false,
66    restart_required: false,
67    tool_filter: None,
68    windows_shell_shim: false,
69    timeouts: &[],
70    passthrough_allowlist: passthrough_of(ID),
71};
72
73static MAPPER: McpServersJson = McpServersJson {
74    caps: &CAPS,
75    type_field: false,
76    remote_type: false,
77    cwd: false,
78    http_aliases: &[],
79    url_implies_http: true,
80    valid_name: |name| !name.is_empty(),
81};
82
83pub static SPEC: AdapterSpec = AdapterSpec {
84    id: ID,
85    display_name: "Grok Build",
86    tier: Tier::B,
87    detect: &[
88        Probe::Path(Location::Home(".cursor")),
89        Probe::Path(Location::AppData("Cursor")),
90        Probe::Executable("cursor"),
91        // The uninstall `DisplayName` of Cursor's installers: "Cursor (User)"
92        // for the per-user one (gate V2 CUR-9), "Cursor" machine-wide.
93        // `[verify]` whether a Grok Build installer keeps them; `~/.cursor`
94        // above detects the app either way.
95        Probe::UninstallEntry("Cursor"),
96        Probe::UninstallEntry("Cursor (User)"),
97    ],
98    mcp: Some(McpSpec {
99        oses: &[Os::Windows, Os::Linux, Os::MacOs],
100        read_only: false,
101        user: &[Location::Home(".cursor/mcp.json")],
102        user_files: None,
103        user_mirrors: &[],
104        profiles: None,
105        project: &[Location::Project(".cursor/mcp.json")],
106        project_local: &[],
107        format: Format::Json,
108        skeleton: "",
109        container: ContainerPath(&["mcpServers"]),
110        project_local_container: ContainerPath(&["mcpServers"]),
111        legacy_containers: &[],
112        same_name: exact_names,
113        replaced_by: &[],
114        mapper: &MAPPER,
115        caps: CAPS,
116        sign_in: crate::adapters::sign_in::SignIn::UNKNOWN,
117    }),
118};