@rebasepro/server 0.28.0 → 0.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,9 +30,14 @@
30
30
  * - **Reach another project.** One platform key signs for every tenant, so the
31
31
  * audience is what binds a token to this one: `aud` must equal
32
32
  * `REBASE_PLATFORM_TOKEN_AUDIENCE`.
33
- * - **Act as a person of this app.** The caller is `platform:<sub>` with no
34
- * roles: row-level security sees nobody it knows, and every surface that
35
- * checks a scope other than the granted ones refuses it.
33
+ * - **Act as a person of this app.** The caller is `platform:<sub>`: row-level
34
+ * security sees nobody it knows by that uid, and every surface that checks a
35
+ * scope other than the granted ones refuses it. On the admin surfaces it
36
+ * holds no role. On the platform's MCP endpoint (`/api/admin/mcp`,
37
+ * `mcp/platform-mcp.ts`) — and nowhere else — a token holding `data:*` runs
38
+ * the app's MCP data tools with the `admin` role, under RLS: the reach the
39
+ * platform's own Studio has, which the platform grants only to the project's
40
+ * owners and admins.
36
41
  *
37
42
  * ## Wire format
38
43
  *
@@ -50,13 +55,22 @@ export declare const PLATFORM_TOKEN_PREFIX = "rpt_";
50
55
  /** The `iss` every platform token carries. */
51
56
  export declare const PLATFORM_TOKEN_ISSUER = "rebase-cloud";
52
57
  /**
53
- * Everything a platform token can be granted on this server.
58
+ * Everything a platform token can be granted on this server's admin surfaces.
54
59
  *
55
- * Read-only on purpose. Adding a scope here is a decision about what the
56
- * platform may do inside a customer's app on a person's behalf, and belongs in
57
- * its own change.
60
+ * Adding a scope here is a decision about what the platform may do inside a
61
+ * customer's app on a person's behalf, and belongs in its own change.
62
+ * `cron:write` (run a job, switch one on or off) was added with the hosted
63
+ * Rebase connector (docs/hosted-mcp-connector.md), whose `cron` tool takes a
64
+ * confirmed second call before it sends one.
58
65
  */
59
66
  export declare const PLATFORM_TOKEN_SCOPES: readonly AdminScope[];
67
+ /**
68
+ * What a platform token can be granted on the platform's MCP endpoint, and
69
+ * only there: the app's own MCP data tools. Never on `/api/data`, the socket,
70
+ * the public `/mcp`, or an admin surface. Added with the hosted connector, in
71
+ * the same review as `cron:write`.
72
+ */
73
+ export declare const PLATFORM_MCP_SCOPES: readonly string[];
60
74
  /** The longest `exp - iat` a platform token may declare. */
61
75
  export declare const PLATFORM_TOKEN_MAX_LIFETIME_SECONDS = 600;
62
76
  /** The environment variables a platform sets to turn platform tokens on. */
@@ -105,7 +119,9 @@ export declare function platformTokensFromEnv(env: Record<string, string | undef
105
119
  * Verify a presented platform token: signature, issuer, audience, lifetime, and
106
120
  * the scopes it may be granted here.
107
121
  */
108
- export declare function verifyPlatformToken(token: string, config: PlatformTokenConfig, nowSeconds?: number): Promise<PlatformCaller | PlatformTokenRefusal>;
122
+ export declare function verifyPlatformToken(token: string, config: PlatformTokenConfig, nowSeconds?: number,
123
+ /** The scopes this door grants: the admin surfaces' unless it says otherwise. */
124
+ grantable?: readonly string[]): Promise<PlatformCaller | PlatformTokenRefusal>;
109
125
  /**
110
126
  * Authenticate an `rpt_` bearer token ahead of an admin gate.
111
127
  *
@@ -21,6 +21,8 @@ import type { RlsAuditConfig } from "../rls-audit/index.js";
21
21
  import type { BackendStorageConfig, StorageController } from "../storage/index.js";
22
22
  import type { SchemaEditPolicy, RemoteRepositoryConfig } from "../schema-edit/schema-edit-permissions.js";
23
23
  import type { RuntimeOwnershipOptions, RuntimeSurfaceOptions } from "../init/surfaces.js";
24
+ import type { McpToolDefinition } from "../mcp/mcp-tools.js";
25
+ import type { McpScopeVocabulary } from "../mcp/oauth-metadata.js";
24
26
  /**
25
27
  * Who may change this project's schema through a running backend.
26
28
  *
@@ -856,6 +858,25 @@ export interface RebaseBackendOptions {
856
858
  * whole file.
857
859
  */
858
860
  maxBodySize?: number;
861
+ /**
862
+ * What `/mcp` serves, for a backend that brings its own tools instead of
863
+ * the data tools — the Rebase Cloud control plane serves its projects and
864
+ * their operations this way. The surface is still switched on by
865
+ * `REBASE_MCP_ENABLED` and `REBASE_PUBLIC_URL`; this only decides what is
866
+ * on it. Omitted, `/mcp` serves the data tools under `data:*` scopes.
867
+ *
868
+ * The OAuth server, its consent screen and its token checks are the same
869
+ * either way: a tool runs as the account that consented, with the scopes
870
+ * it consented to (`McpToolContext.caller`).
871
+ */
872
+ mcp?: {
873
+ /** The tools, in place of the data tools. Each is offered to a grant holding its `requiredScope`. */
874
+ tools: readonly McpToolDefinition[];
875
+ /** The scopes a grant may hold, with the consent screen's wording for each. */
876
+ scopes: McpScopeVocabulary;
877
+ /** What `initialize` tells the client about the tools. */
878
+ instructions: string;
879
+ };
859
880
  /**
860
881
  * Response compression for API routes. **Enabled by default.**
861
882
  *