@narrative.io/data-collaboration-sdk-ts 4.1.0 → 4.2.0
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.
|
@@ -6,7 +6,10 @@ import type { CreateMcpConnectionRequest, ListMcpConnectionsResponse, McpConnect
|
|
|
6
6
|
* can reference it by id via `mcp_servers[].connection_id`. Tokens are never returned by the API.
|
|
7
7
|
*
|
|
8
8
|
* The OAuth callback (`GET /mcp-connections/callback`) is a browser redirect, not an SDK call, so
|
|
9
|
-
* it is intentionally not wrapped here.
|
|
9
|
+
* it is intentionally not wrapped here. It only stores the authorization code and redirects; the
|
|
10
|
+
* app then calls {@link McpConnectionsApi.completeMcpConnection} to finish, authenticated as the
|
|
11
|
+
* user who began the flow. Because the callback is public, it is not allowed to complete anything
|
|
12
|
+
* itself — otherwise a `state` alone could turn another user's consent into a stored token.
|
|
10
13
|
*/
|
|
11
14
|
export declare class McpConnectionsApi extends BaseApi {
|
|
12
15
|
/**
|
|
@@ -21,6 +24,20 @@ export declare class McpConnectionsApi extends BaseApi {
|
|
|
21
24
|
* `authorization_url` the user must visit to consent.
|
|
22
25
|
*/
|
|
23
26
|
createMcpConnection(request: CreateMcpConnectionRequest): Promise<McpConnectionCreatedResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Completes a connection begun with {@link McpConnectionsApi.createMcpConnection}, once the user
|
|
29
|
+
* has consented and the OAuth callback has stored the authorization code. Exchanges that code and
|
|
30
|
+
* validates the connection with a `tools/list` call before storing the tokens.
|
|
31
|
+
*
|
|
32
|
+
* Must be called with the credentials of the user who began the flow — the `state` on its own is
|
|
33
|
+
* not enough.
|
|
34
|
+
* @param {string} state - The one-time `state` the OAuth callback forwarded to the app.
|
|
35
|
+
* @returns {Promise<McpConnectionSummary>} The connection's status view, normally `connected`.
|
|
36
|
+
* Rejects with 404 if the connection does not exist or belongs to another user; 400 if the
|
|
37
|
+
* `state` is unknown or expired, the authorization code has not arrived yet, or the token
|
|
38
|
+
* exchange or validation failed.
|
|
39
|
+
*/
|
|
40
|
+
completeMcpConnection(state: string): Promise<McpConnectionSummary>;
|
|
24
41
|
/**
|
|
25
42
|
* Fetches one of the calling user's connections.
|
|
26
43
|
* @param {string} connectionId - The connection id.
|
|
@@ -6,7 +6,10 @@ const resourceName = "mcp-connections";
|
|
|
6
6
|
* can reference it by id via `mcp_servers[].connection_id`. Tokens are never returned by the API.
|
|
7
7
|
*
|
|
8
8
|
* The OAuth callback (`GET /mcp-connections/callback`) is a browser redirect, not an SDK call, so
|
|
9
|
-
* it is intentionally not wrapped here.
|
|
9
|
+
* it is intentionally not wrapped here. It only stores the authorization code and redirects; the
|
|
10
|
+
* app then calls {@link McpConnectionsApi.completeMcpConnection} to finish, authenticated as the
|
|
11
|
+
* user who began the flow. Because the callback is public, it is not allowed to complete anything
|
|
12
|
+
* itself — otherwise a `state` alone could turn another user's consent into a stored token.
|
|
10
13
|
*/
|
|
11
14
|
export class McpConnectionsApi extends BaseApi {
|
|
12
15
|
/**
|
|
@@ -25,6 +28,22 @@ export class McpConnectionsApi extends BaseApi {
|
|
|
25
28
|
async createMcpConnection(request) {
|
|
26
29
|
return await this.post(resourceName, request);
|
|
27
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Completes a connection begun with {@link McpConnectionsApi.createMcpConnection}, once the user
|
|
33
|
+
* has consented and the OAuth callback has stored the authorization code. Exchanges that code and
|
|
34
|
+
* validates the connection with a `tools/list` call before storing the tokens.
|
|
35
|
+
*
|
|
36
|
+
* Must be called with the credentials of the user who began the flow — the `state` on its own is
|
|
37
|
+
* not enough.
|
|
38
|
+
* @param {string} state - The one-time `state` the OAuth callback forwarded to the app.
|
|
39
|
+
* @returns {Promise<McpConnectionSummary>} The connection's status view, normally `connected`.
|
|
40
|
+
* Rejects with 404 if the connection does not exist or belongs to another user; 400 if the
|
|
41
|
+
* `state` is unknown or expired, the authorization code has not arrived yet, or the token
|
|
42
|
+
* exchange or validation failed.
|
|
43
|
+
*/
|
|
44
|
+
async completeMcpConnection(state) {
|
|
45
|
+
return await this.post(`${resourceName}/complete`, { state });
|
|
46
|
+
}
|
|
28
47
|
/**
|
|
29
48
|
* Fetches one of the calling user's connections.
|
|
30
49
|
* @param {string} connectionId - The connection id.
|
|
@@ -7,6 +7,9 @@ export interface McpConnectionCreatedResponse {
|
|
|
7
7
|
connection_id: string;
|
|
8
8
|
authorization_url: string;
|
|
9
9
|
}
|
|
10
|
+
export interface CompleteMcpConnectionRequest {
|
|
11
|
+
state: string;
|
|
12
|
+
}
|
|
10
13
|
export interface McpConnectionSummary {
|
|
11
14
|
connection_id: string;
|
|
12
15
|
server_url: string;
|