@base44-preview/sdk 0.8.52-pr.297.c6f2448 → 0.8.52-pr.299.9f7108e

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.
package/dist/client.js CHANGED
@@ -11,6 +11,7 @@ import { createAgentsModule } from "./modules/agents.js";
11
11
  import { createAiGatewayModule } from "./modules/ai-gateway.js";
12
12
  import { createAppLogsModule } from "./modules/app-logs.js";
13
13
  import { createAppModule } from "./modules/app.js";
14
+ import { createMcpModule } from "./modules/mcp.js";
14
15
  import { createUsersModule } from "./modules/users.js";
15
16
  import { RoomsSocket } from "./utils/socket-utils.js";
16
17
  import { createAnalyticsModule } from "./modules/analytics.js";
@@ -201,6 +202,7 @@ export function createClient(config) {
201
202
  }),
202
203
  appLogs: createAppLogsModule(axiosClient, appId),
203
204
  app: createAppModule(axiosClient, appId),
205
+ mcp: createMcpModule(axiosClient, appId),
204
206
  users: createUsersModule(axiosClient, appId),
205
207
  analytics: createAnalyticsModule({
206
208
  axiosClient,
@@ -8,6 +8,7 @@ import type { AgentsModule } from "./modules/agents.types.js";
8
8
  import type { AiGatewayModule } from "./modules/ai-gateway.types.js";
9
9
  import type { AppLogsModule } from "./modules/app-logs.types.js";
10
10
  import type { AppModule } from "./modules/app.types.js";
11
+ import type { McpModule } from "./modules/mcp.types.js";
11
12
  import type { AnalyticsModule } from "./modules/analytics.types.js";
12
13
  import type { ActorsModule } from "./modules/actors.types.js";
13
14
  import type { FetchWithAuthInit } from "./utils/fetch-with-auth.js";
@@ -138,6 +139,8 @@ export interface Base44Client {
138
139
  functions: FunctionsModule;
139
140
  /** {@link IntegrationsModule | Integrations module} for calling pre-built integration endpoints. */
140
141
  integrations: IntegrationsModule;
142
+ /** {@link McpModule | MCP module} for the app's MCP consent page. */
143
+ mcp: McpModule;
141
144
  /** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
142
145
  cleanup: () => void;
143
146
  /**
package/dist/index.d.ts CHANGED
@@ -12,6 +12,7 @@ export type { AgentsModule, AgentName, AgentNameRegistry, AgentConversation, Age
12
12
  export type { AiGatewayModule, AiGatewayConnection, AiGatewayConnectionOptions, } from "./modules/ai-gateway.types.js";
13
13
  export type { AppLogsModule } from "./modules/app-logs.types.js";
14
14
  export type { AppModule, AppPublicSettings, AppPublicSettingsResponse, } from "./modules/app.types.js";
15
+ export type { McpModule, McpConsentInfo, McpConsentTool, McpConsentAction, McpAuthorizeGrantResponse, } from "./modules/mcp.types.js";
15
16
  export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription, ActorConnectOptions, ActorNameRegistry, ActorRegistry, } from "./modules/actors.types.js";
16
17
  export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
17
18
  export { Actor, type Conn } from "./actor.js";
@@ -51,9 +51,9 @@ export interface AiGatewayModuleConfig {
51
51
  * against the provider directly, no separate account, API key, or billing
52
52
  * setup with the underlying model provider required.
53
53
  *
54
- * By default, `connection()` uses the OpenAI-compatible provider, which serves
55
- * chat, images, and videos. Pass `{ provider: "typesafe" }` for
56
- * structured evaluations.
54
+ * By default, `connection()` uses the OpenAI-compatible provider. Pass
55
+ * `{ provider: "typesafe" }` to connect to TypeSafe for structured evaluations
56
+ * with `@ai-sdk/typesafe-ai`.
57
57
  *
58
58
  * Call `connection()` from a backend function rather than the browser. This
59
59
  * keeps your instructions, tools, and business logic server-side, and lets
@@ -76,26 +76,6 @@ export interface AiGatewayModuleConfig {
76
76
  * `'gemini_3_1_flash_image'` or `'gpt_image_2'`. For request options, the
77
77
  * full model list, and limits, see [Generate images with the AI Gateway](/developers/references/sdk/getting-started/ai-gateway-images).
78
78
  *
79
- * ## Videos
80
- *
81
- * The gateway serves OpenAI's asynchronous video endpoints through the
82
- * `openai` SDK's `videos` client. `videos.create()` starts a job and returns
83
- * its `id` right away; call `videos.retrieve(id)` until `status` is
84
- * `completed` or `failed`. A completed job exposes the stored video at `url`.
85
- * A backend function is a bounded HTTP call, so don't poll inside one: return
86
- * the `id`, then retrieve it from a later call or scheduled run. Video
87
- * requests need a specific model, such as `'veo_3_1_fast'` or
88
- * `'seedance_2_fast'`; there's no `'automatic'` option.
89
- *
90
- * ## Structured evaluations
91
- *
92
- * The `typesafe` provider runs the `jev` evaluation model through
93
- * `@ai-sdk/typesafe-ai` and the `ai` package's `experimental_evaluate`. Give
94
- * it some app state and a set of questions, each a `choice`, `score`, or
95
- * `boolean`, and it returns each answer with its probabilities. Use it
96
- * to classify, score, or route records, then apply your own thresholds and
97
- * actions in code.
98
- *
99
79
  * ## Authentication Modes
100
80
  *
101
81
  * There's no permission difference between modes. Both just determine which
@@ -207,70 +187,6 @@ export interface AiGatewayModule {
207
187
  * const file = new File([image.uint8Array], "lighthouse.png", { type: image.mediaType });
208
188
  * const { file_url } = await base44.integrations.Core.UploadFile({ file });
209
189
  * ```
210
- *
211
- * @example
212
- * ```typescript
213
- * // Start a video job, then check on it from a later call
214
- * import { createClientFromRequest } from "@base44/sdk";
215
- * import OpenAI from "openai";
216
- *
217
- * // Runs inside a backend function
218
- * const base44 = createClientFromRequest(request);
219
- * const { baseURL, token, headers } = base44.aiGateway.connection();
220
- * const { videos } = new OpenAI({ baseURL, apiKey: token, defaultHeaders: headers });
221
- *
222
- * const { videoId } = await request.json();
223
- * if (!videoId) {
224
- * // Avoid automatic replays of billed requests
225
- * const job = await videos.create(
226
- * { model: "veo_3_1_fast", prompt: "A paper boat drifting down a rainy street", seconds: "4" },
227
- * { maxRetries: 0 },
228
- * );
229
- * return Response.json({ videoId: job.id, status: job.status }, { status: 202 });
230
- * }
231
- *
232
- * const video = await videos.retrieve(videoId);
233
- * // `queued` and `in_progress` mean unfinished; `url` is set once `completed`
234
- * return Response.json(video);
235
- * ```
236
- *
237
- * @example
238
- * ```typescript
239
- * // Route a support ticket with a structured evaluation
240
- * import { createClientFromRequest } from "@base44/sdk";
241
- * import { experimental_evaluate as evaluate } from "ai";
242
- * import { createTypeSafeAi } from "@ai-sdk/typesafe-ai";
243
- *
244
- * // Runs inside a backend function
245
- * const base44 = createClientFromRequest(request);
246
- * const { baseURL, token, headers } = base44.aiGateway.connection({ provider: "typesafe" });
247
- * const typesafe = createTypeSafeAi({ baseURL, apiKey: token, headers });
248
- *
249
- * const { answers } = await evaluate({
250
- * model: typesafe.evaluationModel("jev"),
251
- * maxRetries: 0,
252
- * state: { message: "Please refund today's duplicate charge." },
253
- * questions: {
254
- * department: {
255
- * type: "choice",
256
- * instructions: "Which team should handle this?",
257
- * criteria: { billing: "Payments and refunds", support: "Other requests" },
258
- * },
259
- * urgency: {
260
- * type: "score",
261
- * instructions: "How urgent is this?",
262
- * criteria: ["No deadline", "Requested today", "Immediate emergency"],
263
- * },
264
- * refund: { type: "boolean", instructions: "Is a refund explicitly requested?" },
265
- * },
266
- * });
267
- *
268
- * // answers.department → { type: "choice", choice: "billing", probabilities: { billing: 0.97, support: 0.03 } }
269
- * // answers.urgency → { type: "score", score: 1.2, probabilities: { 0: 0.1, 1: 0.6, 2: 0.3 } }
270
- * // answers.refund → { type: "boolean", probability: 0.99 }
271
- * // Pick your own thresholds and act on them in code
272
- * const autoRefund = answers.department.choice === "billing" && answers.refund.probability > 0.9;
273
- * ```
274
190
  */
275
191
  connection(options?: AiGatewayConnectionOptions): AiGatewayConnection;
276
192
  }
@@ -0,0 +1,11 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { McpModule } from "./mcp.types";
3
+ /**
4
+ * Creates the MCP module for the Base44 SDK.
5
+ *
6
+ * @param axios - Axios instance
7
+ * @param appId - Application ID
8
+ * @returns MCP module for the app's MCP consent page
9
+ * @internal
10
+ */
11
+ export declare function createMcpModule(axios: AxiosInstance, appId: string): McpModule;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Creates the MCP module for the Base44 SDK.
3
+ *
4
+ * @param axios - Axios instance
5
+ * @param appId - Application ID
6
+ * @returns MCP module for the app's MCP consent page
7
+ * @internal
8
+ */
9
+ export function createMcpModule(axios, appId) {
10
+ return {
11
+ async getConsentInfo(ctx) {
12
+ return axios.get(`/apps/${appId}/mcp/consent-info`, {
13
+ params: { handle: ctx },
14
+ });
15
+ },
16
+ async authorizeGrant(ctx, action) {
17
+ return axios.post(`/apps/${appId}/mcp/authorize-grant`, { ctx, action });
18
+ },
19
+ };
20
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * One tool shown on the MCP consent page.
3
+ */
4
+ export interface McpConsentTool {
5
+ /** The tool's MCP name. */
6
+ name: string;
7
+ /** Human-readable title, when the tool has one. */
8
+ title?: string | null;
9
+ /** What the tool does. */
10
+ description?: string | null;
11
+ /** Whether the tool only reads data. */
12
+ read_only_hint?: boolean | null;
13
+ }
14
+ /**
15
+ * Display details for a pending MCP authorization request, as returned by
16
+ * {@link McpModule.getConsentInfo}.
17
+ */
18
+ export interface McpConsentInfo {
19
+ /** The app's display name. */
20
+ app_name: string;
21
+ /** The name of the AI client asking for access. */
22
+ client_name: string;
23
+ /**
24
+ * Whether the request came from a signed-in user of this app. When `false`,
25
+ * send the user to `login_path` before showing approve and deny.
26
+ */
27
+ authenticated: boolean;
28
+ /** The tools the client will be able to use. Empty unless `authenticated` is `true`. */
29
+ tools: McpConsentTool[];
30
+ /** The app's login route for a signed-out user, such as `/login`. */
31
+ login_path: string;
32
+ }
33
+ /**
34
+ * The user's decision on an MCP authorization request.
35
+ */
36
+ export type McpConsentAction = "approve" | "deny";
37
+ /**
38
+ * Result of {@link McpModule.authorizeGrant}.
39
+ */
40
+ export interface McpAuthorizeGrantResponse {
41
+ /**
42
+ * Where to send the browser next: the AI client's redirect URI, carrying the
43
+ * authorization code on approve or an `access_denied` error on deny. It may
44
+ * use a custom scheme such as `cursor://`.
45
+ */
46
+ redirect_url: string;
47
+ }
48
+ /**
49
+ * MCP module for the app's MCP consent page.
50
+ *
51
+ * When an AI client connects to the app's MCP server, Base44 sends the user to
52
+ * the app's consent page with an opaque `ctx` query parameter. The page reads
53
+ * the request's details with {@link McpModule.getConsentInfo | getConsentInfo()}
54
+ * and records the user's decision with {@link McpModule.authorizeGrant | authorizeGrant()}.
55
+ *
56
+ * ## Authentication Modes
57
+ *
58
+ * This module is available to use with a client in user authentication mode. The
59
+ * signed-in user's token is sent when the client has one; otherwise the app's
60
+ * session cookie identifies the user.
61
+ */
62
+ export interface McpModule {
63
+ /**
64
+ * Gets the display details for a pending MCP authorization request.
65
+ *
66
+ * Rejects with a {@linkcode Base44Error} with `status` `404` when the `ctx`
67
+ * handle is unknown or expired.
68
+ *
69
+ * @param ctx - The `ctx` query parameter the consent page was opened with.
70
+ * @returns Promise resolving to the request's display details.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const ctx = new URLSearchParams(window.location.search).get('ctx');
75
+ * const info = await base44.mcp.getConsentInfo(ctx);
76
+ * if (!info.authenticated) {
77
+ * window.location.href = info.login_path;
78
+ * }
79
+ * ```
80
+ */
81
+ getConsentInfo(ctx: string): Promise<McpConsentInfo>;
82
+ /**
83
+ * Records the signed-in user's decision on an MCP authorization request.
84
+ *
85
+ * The `ctx` handle is single-use. Rejects with a {@linkcode Base44Error}:
86
+ * `status` `401` when the user must sign in again (the handle is still valid),
87
+ * and `400`, `403`, `404` or `409` when the request can no longer be
88
+ * completed and the user must reconnect from the AI client.
89
+ *
90
+ * @param ctx - The `ctx` query parameter the consent page was opened with.
91
+ * @param action - `"approve"` to grant access, `"deny"` to refuse it.
92
+ * @returns Promise resolving to the URL to send the browser to.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const { redirect_url } = await base44.mcp.authorizeGrant(ctx, 'approve');
97
+ * window.location.href = redirect_url;
98
+ * ```
99
+ */
100
+ authorizeGrant(ctx: string, action: McpConsentAction): Promise<McpAuthorizeGrantResponse>;
101
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/sdk",
3
- "version": "0.8.52-pr.297.c6f2448",
3
+ "version": "0.8.52-pr.299.9f7108e",
4
4
  "description": "JavaScript SDK for Base44 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",