@base44-preview/sdk 0.8.62-pr.379.c455058 → 0.8.62-pr.380.a0dcd66
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 +2 -0
- package/dist/client.types.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/modules/actors.types.d.ts +3 -3
- package/dist/modules/mcp.d.ts +11 -0
- package/dist/modules/mcp.js +24 -0
- package/dist/modules/mcp.types.d.ts +105 -0
- package/dist/modules/mcp.types.js +1 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -14,6 +14,7 @@ import { createAgentsModule } from "./modules/agents.js";
|
|
|
14
14
|
import { createAiGatewayModule } from "./modules/ai-gateway.js";
|
|
15
15
|
import { createAppLogsModule } from "./modules/app-logs.js";
|
|
16
16
|
import { createAppModule } from "./modules/app.js";
|
|
17
|
+
import { createMcpModule } from "./modules/mcp.js";
|
|
17
18
|
import { createUsersModule } from "./modules/users.js";
|
|
18
19
|
import { RoomsSocket } from "./utils/socket-utils.js";
|
|
19
20
|
import { createAnalyticsModule } from "./modules/analytics.js";
|
|
@@ -235,6 +236,7 @@ function buildClient(config, { sendBuildCommit }) {
|
|
|
235
236
|
}),
|
|
236
237
|
appLogs: createAppLogsModule(axiosClient, appId),
|
|
237
238
|
app: createAppModule(axiosClient, appId),
|
|
239
|
+
mcp: createMcpModule(axiosClient, appId),
|
|
238
240
|
users: createUsersModule(axiosClient, appId),
|
|
239
241
|
payments: createPaymentsModule(axiosClient, appId),
|
|
240
242
|
analytics: createAnalyticsModule({
|
package/dist/client.types.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { AgentsModule } from "./modules/agents.types.js";
|
|
|
11
11
|
import type { AiGatewayModule } from "./modules/ai-gateway.types.js";
|
|
12
12
|
import type { AppLogsModule } from "./modules/app-logs.types.js";
|
|
13
13
|
import type { AppModule } from "./modules/app.types.js";
|
|
14
|
+
import type { McpModule } from "./modules/mcp.types.js";
|
|
14
15
|
import type { AnalyticsModule } from "./modules/analytics.types.js";
|
|
15
16
|
import type { ActorsModule, ServiceRoleActorsModule } from "./modules/actors.types.js";
|
|
16
17
|
import type { FetchWithAuthInit } from "./utils/fetch-with-auth.js";
|
|
@@ -143,6 +144,8 @@ export interface Base44Client {
|
|
|
143
144
|
functions: FunctionsModule;
|
|
144
145
|
/** {@link IntegrationsModule | Integrations module} for calling pre-built integration endpoints. */
|
|
145
146
|
integrations: IntegrationsModule;
|
|
147
|
+
/** {@link McpModule | MCP module} for the consent step of connecting an AI client to the app's MCP server. */
|
|
148
|
+
mcp: McpModule;
|
|
146
149
|
/** {@link PaymentsModule | Payments module} for checkouts and purchases. */
|
|
147
150
|
payments: PaymentsModule;
|
|
148
151
|
/** Cleanup function to disconnect WebSocket connections. Call when you're done with the client. */
|
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, McpConsentAction, McpConsentInfo, McpConsentResponse, McpConsentTool, } from "./modules/mcp.types.js";
|
|
15
16
|
export type { ActorsModule, ActorClient, ActorRef, Connection, ActorSubscription, ActorConnectOptions, ActorNameRegistry, ActorRegistry, ActorConnectable, ActorMethods, ServiceRoleActorRef, ServiceRoleActorsModule, } from "./modules/actors.types.js";
|
|
16
17
|
export type { SsoModule, SsoAccessTokenResponse } from "./modules/sso.types.js";
|
|
17
18
|
export type { PaymentsModule, ServiceRolePaymentsModule, PaymentsErrorCode, PaymentsRecurringFrequency, CheckoutBuyer, CheckoutFreeTrial, CheckoutItem, CheckoutItemRecurring, CheckoutPresentation, CheckoutShipping, CheckoutElement, CheckoutMount, MountableCheckout, CreateCheckoutParams, CreateCheckoutResult, CompleteCheckoutResult, EmbeddedCheckout, PayPalCheckoutOnClick, PayPalEmbeddedCheckout, StripeEmbeddedCheckout, MountCheckoutOptions, ListPurchasesParams, ServiceRoleListPurchasesParams, ListPurchasesResult, Purchase, PurchaseItem, PurchaseStatus, RefundParams, ShippingAddress, RefundResult, CancelSubscriptionOptions, SubscriptionResult, } from "./modules/payments.types.js";
|
|
@@ -57,7 +57,7 @@ export type ActorMethods<N extends string> = N extends keyof ActorRegistry ? Act
|
|
|
57
57
|
[K in keyof M]: ActorMethodCall<M[K]>;
|
|
58
58
|
} : UntypedActorMethods : UntypedActorMethods;
|
|
59
59
|
/**
|
|
60
|
-
* Configures the connection that {@linkcode
|
|
60
|
+
* Configures the connection that {@linkcode ActorRef.connect | connect()} opens.
|
|
61
61
|
*/
|
|
62
62
|
export interface ActorConnectOptions {
|
|
63
63
|
/**
|
|
@@ -147,7 +147,7 @@ export interface Connection<N extends string = string> {
|
|
|
147
147
|
/**
|
|
148
148
|
* Represents a reference to an actor session, identified by actor name and session ID.
|
|
149
149
|
*
|
|
150
|
-
* Call {@linkcode
|
|
150
|
+
* Call {@linkcode ActorRef.connect | connect()} to open the WebSocket and get a [connection](/developers/backend/resources/actors/overview#connections),
|
|
151
151
|
* or call one of the actor's callable methods by name, such as `ref.kick({ userId })`: it runs
|
|
152
152
|
* the actor's method with your identity, even when no client is connected, and resolves to
|
|
153
153
|
* its return value. A refusal rejects with a `Base44Error` carrying the actor's status (404 for
|
|
@@ -233,7 +233,7 @@ export interface ActorClient<N extends string = string> {
|
|
|
233
233
|
*
|
|
234
234
|
* The actors module provides the functionality to:
|
|
235
235
|
*
|
|
236
|
-
* - Manage connections: {@link
|
|
236
|
+
* - Manage connections: {@link ActorRef.connect | Open} and {@link Connection.close | close} a WebSocket connection to a session.
|
|
237
237
|
* - Exchange messages: {@link Connection.send | Send} and {@link Connection.subscribe | listen} for messages to and from an actor.
|
|
238
238
|
* - Manage subscriptions: {@link Connection.subscribe | Subscribe} and {@link ActorSubscription.unsubscribe | unsubscribe} from actor messages without closing the connection.
|
|
239
239
|
* - Call methods: run one of an actor's callable methods on a session, without connecting.
|
|
@@ -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 step
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare function createMcpModule(axios: AxiosInstance, appId: string): McpModule;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 step
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export function createMcpModule(axios, appId) {
|
|
10
|
+
// A session may live only in the auth cookie, which axios leaves off
|
|
11
|
+
// cross-origin requests unless asked.
|
|
12
|
+
const config = { withCredentials: true };
|
|
13
|
+
return {
|
|
14
|
+
async getConsentInfo(ctx) {
|
|
15
|
+
return axios.get(`/apps/${appId}/mcp/consent-info`, {
|
|
16
|
+
...config,
|
|
17
|
+
params: { handle: ctx },
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
async respondToConsent(ctx, action) {
|
|
21
|
+
return axios.post(`/apps/${appId}/mcp/authorize-grant`, { ctx, action }, config);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tool an AI client is asking to use, as shown on the consent page.
|
|
3
|
+
*/
|
|
4
|
+
export interface McpConsentTool {
|
|
5
|
+
/** The tool's name. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** The tool's display title. */
|
|
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;
|
|
13
|
+
/** What the tool exposes: an entity operation, an agent, or a backend function. */
|
|
14
|
+
kind?: "entity" | "agent" | "function" | string;
|
|
15
|
+
/** The entity an `entity` tool operates on. */
|
|
16
|
+
entity?: string | null;
|
|
17
|
+
/** The operation an `entity` tool performs. */
|
|
18
|
+
operation?: "read" | "create" | "update" | "delete" | string | null;
|
|
19
|
+
/** The agent an `agent` tool talks to. */
|
|
20
|
+
agent?: string | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Display details of a pending authorization request for the app's MCP server.
|
|
24
|
+
*/
|
|
25
|
+
export interface McpConsentInfo {
|
|
26
|
+
/** The app's name. */
|
|
27
|
+
app_name: string;
|
|
28
|
+
/** The name of the AI client requesting access. */
|
|
29
|
+
client_name: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the request came from a signed-in user of this app.
|
|
32
|
+
*
|
|
33
|
+
* Use this to decide whether to send the user to login, not `auth.isAuthenticated()`: a session held only in a cookie counts here.
|
|
34
|
+
*/
|
|
35
|
+
authenticated: boolean;
|
|
36
|
+
/** The tools the AI client would get access to. Empty when `authenticated` is `false`. */
|
|
37
|
+
tools: McpConsentTool[];
|
|
38
|
+
/** The app's login route, to send a signed-out user to. */
|
|
39
|
+
login_path: string;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The user's decision on an authorization request.
|
|
43
|
+
*/
|
|
44
|
+
export type McpConsentAction = "approve" | "deny";
|
|
45
|
+
/**
|
|
46
|
+
* The result of responding to an authorization request.
|
|
47
|
+
*/
|
|
48
|
+
export interface McpConsentResponse {
|
|
49
|
+
/** The URL to send the browser to, which returns the user to the AI client. */
|
|
50
|
+
redirect_url: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* MCP module for the consent step of connecting an AI client to the app's MCP server.
|
|
54
|
+
*
|
|
55
|
+
* When an AI client connects to the app's MCP server, the platform sends the user to the app's consent page with an opaque `ctx` handle in the URL. Use this module on that page to:
|
|
56
|
+
* - Read what the AI client is asking for.
|
|
57
|
+
* - Send the user's decision to approve or deny it.
|
|
58
|
+
*
|
|
59
|
+
* Both methods send the user's session cookie along with the client's token, so they work for a user who is signed in with either. Call them from the app's own domain.
|
|
60
|
+
*
|
|
61
|
+
* ## Authentication modes
|
|
62
|
+
*
|
|
63
|
+
* This module is only available in user authentication mode (`base44.mcp`).
|
|
64
|
+
*/
|
|
65
|
+
export interface McpModule {
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves the display details of a pending authorization request.
|
|
68
|
+
*
|
|
69
|
+
* Rejects with a {@linkcode Base44Error} that has a `status` of `404` when the handle is unknown or has expired.
|
|
70
|
+
*
|
|
71
|
+
* @param ctx - The `ctx` handle from the consent page URL.
|
|
72
|
+
* @returns Promise resolving to the request's display details.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // Load the request, sending a signed-out user to login first
|
|
77
|
+
* const ctx = new URLSearchParams(window.location.search).get('ctx');
|
|
78
|
+
* const info = await base44.mcp.getConsentInfo(ctx);
|
|
79
|
+
* if (!info.authenticated) {
|
|
80
|
+
* const returnTo = encodeURIComponent(`${window.location.pathname}?ctx=${encodeURIComponent(ctx)}`);
|
|
81
|
+
* window.location.href = `${info.login_path}?returnTo=${returnTo}&from_url=${returnTo}`;
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
getConsentInfo(ctx: string): Promise<McpConsentInfo>;
|
|
86
|
+
/**
|
|
87
|
+
* Sends the user's decision on an authorization request.
|
|
88
|
+
*
|
|
89
|
+
* A handle can be used once. Rejects with a {@linkcode Base44Error} whose `status` tells you what to do next:
|
|
90
|
+
* - `401`: The user isn't signed in to this app. The handle is still valid, so send them to login and back.
|
|
91
|
+
* - `400`, `403`, `404`, `409`: The request can't be completed and the handle is spent. Ask the user to reconnect from their AI client.
|
|
92
|
+
*
|
|
93
|
+
* @param ctx - The `ctx` handle from the consent page URL.
|
|
94
|
+
* @param action - Whether the user approves or denies the request.
|
|
95
|
+
* @returns Promise resolving to the URL that returns the user to the AI client.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* // Approve the request and return to the AI client
|
|
100
|
+
* const { redirect_url } = await base44.mcp.respondToConsent(ctx, 'approve');
|
|
101
|
+
* window.location.href = redirect_url;
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
respondToConsent(ctx: string, action: McpConsentAction): Promise<McpConsentResponse>;
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|