@transcend-io/mcp-server-preferences 0.6.6 → 0.7.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.
- package/README.md +4 -1
- package/dist/cli.mjs +2 -2
- package/dist/index.d.mts +108 -46
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/scopes-CFVgjKbp.mjs +369 -0
- package/dist/scopes-CFVgjKbp.mjs.map +1 -0
- package/package.json +4 -3
- package/dist/scopes-DoJ9OoBH.mjs +0 -250
- package/dist/scopes-DoJ9OoBH.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ OAuth stdio is the recommended path for MCP clients (Cursor, Claude Desktop). Re
|
|
|
40
40
|
|
|
41
41
|
At startup the server verifies client ID, secret, and redirect URI. On first tool call it opens a browser for login. Tokens are session-only (in-memory).
|
|
42
42
|
|
|
43
|
-
**OAuth scopes:** `
|
|
43
|
+
**OAuth scopes:** `ViewManagedConsentDatabaseAdminApi`, `ManageStoredPreferences`, `ViewConsentManager`. The signed-in user must hold these permissions. See [`src/scopes.ts`](./src/scopes.ts). Existing OAuth clients created before `ViewConsentManager` was added must re-grant that scope (re-auth / update the client).
|
|
44
44
|
|
|
45
45
|
Full setup, troubleshooting, and multi-server guidance: [MCP root README](../README.md#oauth-client-setup).
|
|
46
46
|
|
|
@@ -102,6 +102,9 @@ See [CONTRIBUTING.md](../../../CONTRIBUTING.md#mcp-servers) for workspace layout
|
|
|
102
102
|
|
|
103
103
|
## Tools
|
|
104
104
|
|
|
105
|
+
Call `preferences_list_partitions` first to discover valid Preference Store partition keys, then pass a returned `partition` value into the other tools (prefer `effectivePartition` / the row with `isEffectiveForConsentManager` unless the user named another partition). Do not use the organization id as `partition`.
|
|
106
|
+
|
|
107
|
+
- `preferences_list_partitions` — List Preference Store partitions (default airgap bundle + custom)
|
|
105
108
|
- `preferences_query` — Query preference records
|
|
106
109
|
- `preferences_upsert` — Create or update a preference record
|
|
107
110
|
- `preferences_delete` — Delete a preference record
|
package/dist/cli.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as getPreferenceTools, t as PREFERENCE_OAUTH_SCOPES } from "./scopes-
|
|
2
|
+
import { n as getPreferenceTools, t as PREFERENCE_OAUTH_SCOPES } from "./scopes-CFVgjKbp.mjs";
|
|
3
3
|
import { TranscendGraphQLBase, createMCPServer, createTranscendRestClient } from "@transcend-io/mcp-server-base";
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/cli.ts
|
|
6
6
|
createMCPServer({
|
|
7
7
|
name: "transcend-mcp-preferences",
|
|
8
|
-
version: "0.
|
|
8
|
+
version: "0.7.0",
|
|
9
9
|
oauthScopes: PREFERENCE_OAUTH_SCOPES,
|
|
10
10
|
getTools: getPreferenceTools,
|
|
11
11
|
createClients: ({ auth, sombraUrl, sombraCustomerKey, graphqlUrl, dashboardUrl }) => {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,64 +1,103 @@
|
|
|
1
1
|
import { ToolClients, ToolDefinition, z } from "@transcend-io/mcp-server-base";
|
|
2
2
|
import { ScopeName } from "@transcend-io/privacy-types";
|
|
3
|
+
import * as _$zod_v4_core0 from "zod/v4/core";
|
|
4
|
+
import * as _$zod from "zod";
|
|
3
5
|
|
|
4
6
|
//#region src/tools/index.d.ts
|
|
5
7
|
declare function getPreferenceTools(clients: ToolClients): ToolDefinition[];
|
|
6
8
|
//#endregion
|
|
7
9
|
//#region src/scopes.d.ts
|
|
8
10
|
/** OAuth scopes required for Preference MCP tools (offline_access added by base). */
|
|
9
|
-
declare const PREFERENCE_OAUTH_SCOPES: readonly [ScopeName.
|
|
11
|
+
declare const PREFERENCE_OAUTH_SCOPES: readonly [ScopeName.ViewManagedConsentDatabaseAdminApi, ScopeName.ManageStoredPreferences, ScopeName.ViewConsentManager];
|
|
10
12
|
//#endregion
|
|
11
|
-
//#region src/tools/
|
|
13
|
+
//#region src/tools/preferences_list_partitions.d.ts
|
|
14
|
+
declare const ListPartitionsSchema: _$zod.ZodObject<{}, _$zod_v4_core0.$strip>;
|
|
15
|
+
type ListPartitionsInput = Record<string, never>;
|
|
16
|
+
/** A Preference Store partition key agents can pass to preferences_* tools */
|
|
17
|
+
interface PreferencePartitionRow {
|
|
18
|
+
/** Value to pass as `partition` on preferences_* Sombra tools */
|
|
19
|
+
partition: string;
|
|
20
|
+
/** Human label; for the default row uses "Default (airgap bundle)" */
|
|
21
|
+
name: string;
|
|
22
|
+
/** "default" = bundle id path; "custom" = airgapPartitions row */
|
|
23
|
+
type: 'default' | 'custom';
|
|
24
|
+
/** True when this is consentManager.partition?.partition ?? consentManager.id */
|
|
25
|
+
isEffectiveForConsentManager: boolean;
|
|
26
|
+
/** Present only for custom rows — airgapPartition DB id (not the path key) */
|
|
27
|
+
airgapPartitionId?: string;
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/tools/preference-schemas.d.ts
|
|
31
|
+
/** Shared describe for Preference Store `partition` inputs on preferences_* tools */
|
|
32
|
+
declare const PARTITION_DESCRIBE: string;
|
|
12
33
|
declare const IdentifierSchema: z.ZodObject<{
|
|
34
|
+
name: z.ZodString;
|
|
13
35
|
value: z.ZodString;
|
|
14
|
-
type: z.ZodOptional<z.ZodString>;
|
|
15
36
|
}, z.core.$strip>;
|
|
16
37
|
type IdentifierInput = z.infer<typeof IdentifierSchema>;
|
|
38
|
+
declare const UpsertPurposeSchema: z.ZodObject<{
|
|
39
|
+
purpose: z.ZodString;
|
|
40
|
+
enabled: z.ZodBoolean;
|
|
41
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
declare const UpsertRecordSchema: z.ZodObject<{
|
|
44
|
+
partition: z.ZodString;
|
|
45
|
+
timestamp: z.ZodString;
|
|
46
|
+
confirmed: z.ZodOptional<z.ZodBoolean>;
|
|
47
|
+
identifiers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
value: z.ZodString;
|
|
50
|
+
}, z.core.$strip>>>;
|
|
51
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
52
|
+
purposes: z.ZodArray<z.ZodObject<{
|
|
53
|
+
purpose: z.ZodString;
|
|
54
|
+
enabled: z.ZodBoolean;
|
|
55
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strip>>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/tools/preferences_query.d.ts
|
|
17
60
|
declare const QueryPreferencesSchema: z.ZodObject<{
|
|
18
61
|
partition: z.ZodString;
|
|
19
62
|
identifiers: z.ZodArray<z.ZodObject<{
|
|
63
|
+
name: z.ZodString;
|
|
20
64
|
value: z.ZodString;
|
|
21
|
-
type: z.ZodOptional<z.ZodString>;
|
|
22
65
|
}, z.core.$strip>>;
|
|
66
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
23
68
|
}, z.core.$strip>;
|
|
24
69
|
type QueryPreferencesInput = z.infer<typeof QueryPreferencesSchema>;
|
|
25
70
|
//#endregion
|
|
26
71
|
//#region src/tools/preferences_upsert.d.ts
|
|
27
|
-
declare const UpsertPreferencesPurposeSchema: z.ZodObject<{
|
|
28
|
-
purpose: z.ZodString;
|
|
29
|
-
enabled: z.ZodBoolean;
|
|
30
|
-
}, z.core.$strip>;
|
|
31
|
-
type UpsertPreferencesPurposeInput = z.infer<typeof UpsertPreferencesPurposeSchema>;
|
|
32
|
-
declare const UpsertPreferencesRecordSchema: z.ZodObject<{
|
|
33
|
-
identifier: z.ZodString;
|
|
34
|
-
identifierType: z.ZodOptional<z.ZodString>;
|
|
35
|
-
purposes: z.ZodArray<z.ZodObject<{
|
|
36
|
-
purpose: z.ZodString;
|
|
37
|
-
enabled: z.ZodBoolean;
|
|
38
|
-
}, z.core.$strip>>;
|
|
39
|
-
confirmed: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
|
-
type UpsertPreferencesRecordInput = z.infer<typeof UpsertPreferencesRecordSchema>;
|
|
42
72
|
declare const UpsertPreferencesSchema: z.ZodObject<{
|
|
43
|
-
partition: z.ZodString;
|
|
44
73
|
records: z.ZodArray<z.ZodObject<{
|
|
45
|
-
|
|
46
|
-
|
|
74
|
+
partition: z.ZodString;
|
|
75
|
+
timestamp: z.ZodString;
|
|
76
|
+
confirmed: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
identifiers: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
value: z.ZodString;
|
|
80
|
+
}, z.core.$strip>>>;
|
|
81
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
47
82
|
purposes: z.ZodArray<z.ZodObject<{
|
|
48
83
|
purpose: z.ZodString;
|
|
49
84
|
enabled: z.ZodBoolean;
|
|
85
|
+
timestamp: z.ZodOptional<z.ZodString>;
|
|
50
86
|
}, z.core.$strip>>;
|
|
51
|
-
confirmed: z.ZodOptional<z.ZodBoolean>;
|
|
52
87
|
}, z.core.$strip>>;
|
|
88
|
+
skipWorkflowTriggers: z.ZodOptional<z.ZodBoolean>;
|
|
53
89
|
}, z.core.$strip>;
|
|
54
90
|
type UpsertPreferencesInput = z.infer<typeof UpsertPreferencesSchema>;
|
|
55
91
|
//#endregion
|
|
56
92
|
//#region src/tools/preferences_delete.d.ts
|
|
57
93
|
declare const DeletePreferencesSchema: z.ZodObject<{
|
|
58
94
|
partition: z.ZodString;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
95
|
+
records: z.ZodArray<z.ZodObject<{
|
|
96
|
+
anchorIdentifier: z.ZodObject<{
|
|
97
|
+
name: z.ZodString;
|
|
98
|
+
value: z.ZodString;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
timestamp: z.ZodString;
|
|
62
101
|
}, z.core.$strip>>;
|
|
63
102
|
}, z.core.$strip>;
|
|
64
103
|
type DeletePreferencesInput = z.infer<typeof DeletePreferencesSchema>;
|
|
@@ -66,28 +105,42 @@ type DeletePreferencesInput = z.infer<typeof DeletePreferencesSchema>;
|
|
|
66
105
|
//#region src/tools/preferences_append_identifiers.d.ts
|
|
67
106
|
declare const AppendIdentifiersSchema: z.ZodObject<{
|
|
68
107
|
partition: z.ZodString;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
108
|
+
records: z.ZodArray<z.ZodObject<{
|
|
109
|
+
anchorIdentifier: z.ZodObject<{
|
|
110
|
+
name: z.ZodString;
|
|
111
|
+
value: z.ZodString;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
append: z.ZodObject<{
|
|
114
|
+
name: z.ZodString;
|
|
115
|
+
value: z.ZodString;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
timestamp: z.ZodString;
|
|
118
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
119
|
+
mergeRecordsOnConflict: z.ZodOptional<z.ZodBoolean>;
|
|
120
|
+
returnIdentifiers: z.ZodOptional<z.ZodBoolean>;
|
|
121
|
+
}, z.core.$strip>>;
|
|
73
122
|
}, z.core.$strip>>;
|
|
74
123
|
}, z.core.$strip>;
|
|
75
124
|
type AppendIdentifiersInput = z.infer<typeof AppendIdentifiersSchema>;
|
|
76
125
|
//#endregion
|
|
77
126
|
//#region src/tools/preferences_update_identifiers.d.ts
|
|
78
|
-
declare const UpdateIdentifiersItemSchema: z.ZodObject<{
|
|
79
|
-
oldValue: z.ZodString;
|
|
80
|
-
newValue: z.ZodString;
|
|
81
|
-
type: z.ZodOptional<z.ZodString>;
|
|
82
|
-
}, z.core.$strip>;
|
|
83
|
-
type UpdateIdentifiersItemInput = z.infer<typeof UpdateIdentifiersItemSchema>;
|
|
84
127
|
declare const UpdateIdentifiersSchema: z.ZodObject<{
|
|
85
128
|
partition: z.ZodString;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
129
|
+
records: z.ZodArray<z.ZodObject<{
|
|
130
|
+
anchorIdentifier: z.ZodObject<{
|
|
131
|
+
name: z.ZodString;
|
|
132
|
+
value: z.ZodString;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
update: z.ZodObject<{
|
|
135
|
+
name: z.ZodString;
|
|
136
|
+
oldValue: z.ZodString;
|
|
137
|
+
newValue: z.ZodString;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
timestamp: z.ZodString;
|
|
140
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
141
|
+
mergeRecordsOnConflict: z.ZodOptional<z.ZodBoolean>;
|
|
142
|
+
returnIdentifiers: z.ZodOptional<z.ZodBoolean>;
|
|
143
|
+
}, z.core.$strip>>;
|
|
91
144
|
}, z.core.$strip>>;
|
|
92
145
|
}, z.core.$strip>;
|
|
93
146
|
type UpdateIdentifiersInput = z.infer<typeof UpdateIdentifiersSchema>;
|
|
@@ -95,13 +148,22 @@ type UpdateIdentifiersInput = z.infer<typeof UpdateIdentifiersSchema>;
|
|
|
95
148
|
//#region src/tools/preferences_delete_identifiers.d.ts
|
|
96
149
|
declare const DeleteIdentifiersSchema: z.ZodObject<{
|
|
97
150
|
partition: z.ZodString;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
151
|
+
records: z.ZodArray<z.ZodObject<{
|
|
152
|
+
anchorIdentifier: z.ZodObject<{
|
|
153
|
+
name: z.ZodString;
|
|
154
|
+
value: z.ZodString;
|
|
155
|
+
}, z.core.$strip>;
|
|
156
|
+
delete: z.ZodObject<{
|
|
157
|
+
name: z.ZodString;
|
|
158
|
+
value: z.ZodString;
|
|
159
|
+
}, z.core.$strip>;
|
|
160
|
+
timestamp: z.ZodString;
|
|
161
|
+
options: z.ZodOptional<z.ZodObject<{
|
|
162
|
+
returnIdentifiers: z.ZodOptional<z.ZodBoolean>;
|
|
163
|
+
}, z.core.$strip>>;
|
|
102
164
|
}, z.core.$strip>>;
|
|
103
165
|
}, z.core.$strip>;
|
|
104
166
|
type DeleteIdentifiersInput = z.infer<typeof DeleteIdentifiersSchema>;
|
|
105
167
|
//#endregion
|
|
106
|
-
export { type AppendIdentifiersInput, AppendIdentifiersSchema, type DeleteIdentifiersInput, DeleteIdentifiersSchema, type DeletePreferencesInput, DeletePreferencesSchema, type IdentifierInput, IdentifierSchema,
|
|
168
|
+
export { type AppendIdentifiersInput, AppendIdentifiersSchema, type DeleteIdentifiersInput, DeleteIdentifiersSchema, type DeletePreferencesInput, DeletePreferencesSchema, type IdentifierInput, IdentifierSchema, type ListPartitionsInput, ListPartitionsSchema, PARTITION_DESCRIBE, PREFERENCE_OAUTH_SCOPES, type PreferencePartitionRow, type QueryPreferencesInput, QueryPreferencesSchema, type UpdateIdentifiersInput, UpdateIdentifiersSchema, type UpsertPreferencesInput, UpsertPreferencesSchema, UpsertPurposeSchema, UpsertRecordSchema, getPreferenceTools };
|
|
107
169
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/tools/index.ts","../src/scopes.ts","../src/tools/preferences_query.ts","../src/tools/preferences_upsert.ts","../src/tools/preferences_delete.ts","../src/tools/preferences_append_identifiers.ts","../src/tools/preferences_update_identifiers.ts","../src/tools/preferences_delete_identifiers.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/tools/index.ts","../src/scopes.ts","../src/tools/preferences_list_partitions.ts","../src/tools/preference-schemas.ts","../src/tools/preferences_query.ts","../src/tools/preferences_upsert.ts","../src/tools/preferences_delete.ts","../src/tools/preferences_append_identifiers.ts","../src/tools/preferences_update_identifiers.ts","../src/tools/preferences_delete_identifiers.ts"],"mappings":";;;;;;iBAUgB,kBAAA,CAAmB,OAAA,EAAS,WAAA,G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
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { AppendIdentifiersSchema, DeleteIdentifiersSchema, DeletePreferencesSchema, IdentifierSchema, PREFERENCE_OAUTH_SCOPES, QueryPreferencesSchema,
|
|
1
|
+
import { a as QueryPreferencesSchema, c as DeletePreferencesSchema, d as PARTITION_DESCRIBE, f as UpsertPurposeSchema, i as UpdateIdentifiersSchema, l as AppendIdentifiersSchema, n as getPreferenceTools, o as ListPartitionsSchema, p as UpsertRecordSchema, r as UpsertPreferencesSchema, s as DeleteIdentifiersSchema, t as PREFERENCE_OAUTH_SCOPES, u as IdentifierSchema } from "./scopes-CFVgjKbp.mjs";
|
|
2
|
+
export { AppendIdentifiersSchema, DeleteIdentifiersSchema, DeletePreferencesSchema, IdentifierSchema, ListPartitionsSchema, PARTITION_DESCRIBE, PREFERENCE_OAUTH_SCOPES, QueryPreferencesSchema, UpdateIdentifiersSchema, UpsertPreferencesSchema, UpsertPurposeSchema, UpsertRecordSchema, getPreferenceTools };
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { EmptySchema, createListResult, createToolResult, defineTool, z } from "@transcend-io/mcp-server-base";
|
|
2
|
+
import { CONSENT_PARTITIONS, FETCH_CONSENT_MANAGER } from "@transcend-io/sdk";
|
|
3
|
+
import { ScopeName } from "@transcend-io/privacy-types";
|
|
4
|
+
//#region src/tools/mutation-success.ts
|
|
5
|
+
/**
|
|
6
|
+
* Whether a Preference Store mutation response should be treated as MCP success.
|
|
7
|
+
* HTTP 200 can still include partial failures in `failures`, `errors`, or per-record flags.
|
|
8
|
+
*/
|
|
9
|
+
function isPreferenceMutationSuccessful(result) {
|
|
10
|
+
if (result.success === false) return false;
|
|
11
|
+
if ((result.failures?.length ?? 0) > 0) return false;
|
|
12
|
+
if ((result.errors?.length ?? 0) > 0) return false;
|
|
13
|
+
if (result.records?.some((record) => record.success === false)) return false;
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
/** Count of failed records for error messaging. */
|
|
17
|
+
function preferenceMutationFailureCount(result) {
|
|
18
|
+
if ((result.failures?.length ?? 0) > 0) return result.failures.length;
|
|
19
|
+
if ((result.errors?.length ?? 0) > 0) return result.errors.length;
|
|
20
|
+
return result.records?.filter((record) => record.success === false).length ?? 0;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build a tool result that reports Preference Store partial failures as MCP failure,
|
|
24
|
+
* while still returning the API payload (in `data` on success, `details` on failure).
|
|
25
|
+
*/
|
|
26
|
+
function preferenceMutationToolResult(createToolResult, ok, data, failureMessage) {
|
|
27
|
+
if (ok) return createToolResult(true, data);
|
|
28
|
+
return createToolResult(false, void 0, failureMessage, { details: data });
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/tools/preference-schemas.ts
|
|
32
|
+
/** Shared describe for Preference Store `partition` inputs on preferences_* tools */
|
|
33
|
+
const PARTITION_DESCRIBE = "Preference Store partition key for the Sombra path. Call preferences_list_partitions first; use the returned partition string (bundle UUID or custom slug), not the organization id. Prefer the row with isEffectiveForConsentManager unless the user named another partition.";
|
|
34
|
+
const IdentifierSchema = z.object({
|
|
35
|
+
name: z.string().describe("Identifier name (e.g. email, phone)"),
|
|
36
|
+
value: z.string().describe("Identifier value. For name \"phone\", use E.164 (e.g. +14155550101), not national formats like +1-555-0101.")
|
|
37
|
+
});
|
|
38
|
+
const IdentifierOptionsSchema = z.object({
|
|
39
|
+
mergeRecordsOnConflict: z.boolean().optional().describe("Merge records when an identifier value conflicts"),
|
|
40
|
+
returnIdentifiers: z.boolean().optional().describe("Return remaining identifiers in the response")
|
|
41
|
+
}).describe("Optional flags for identifier mutation operations");
|
|
42
|
+
const DeleteIdentifierOptionsSchema = z.object({ returnIdentifiers: z.boolean().optional().describe("Return remaining identifiers in the response") }).describe("Optional flags for identifier deletion operations");
|
|
43
|
+
const UpsertPurposeSchema = z.object({
|
|
44
|
+
purpose: z.string().describe("Purpose slug"),
|
|
45
|
+
enabled: z.boolean().describe("Whether the purpose is enabled (Preference Store PUT /v1/preferences field name). Do not send \"consent\" — the API expects enabled: boolean."),
|
|
46
|
+
timestamp: z.string().optional().describe("ISO 8601 timestamp for this purpose")
|
|
47
|
+
});
|
|
48
|
+
const UpsertRecordSchema = z.object({
|
|
49
|
+
partition: z.string().describe(PARTITION_DESCRIBE),
|
|
50
|
+
timestamp: z.string().describe("ISO 8601 timestamp for the consent update"),
|
|
51
|
+
confirmed: z.boolean().optional().describe("Whether consent was explicitly confirmed"),
|
|
52
|
+
identifiers: z.array(IdentifierSchema).optional().describe("User identifiers"),
|
|
53
|
+
userId: z.string().optional().describe("Legacy user ID (prefer identifiers)"),
|
|
54
|
+
purposes: z.array(UpsertPurposeSchema).describe("Purpose consent updates")
|
|
55
|
+
});
|
|
56
|
+
const DeleteRecordSchema = z.object({
|
|
57
|
+
anchorIdentifier: IdentifierSchema.describe("Anchor identifier locating the record"),
|
|
58
|
+
timestamp: z.string().describe("ISO 8601 timestamp for the deletion")
|
|
59
|
+
});
|
|
60
|
+
const AppendRecordSchema = z.object({
|
|
61
|
+
anchorIdentifier: IdentifierSchema.describe("Anchor identifier locating the record"),
|
|
62
|
+
append: IdentifierSchema.describe("Identifier to append"),
|
|
63
|
+
timestamp: z.string().describe("ISO 8601 timestamp for the update"),
|
|
64
|
+
options: IdentifierOptionsSchema.optional()
|
|
65
|
+
});
|
|
66
|
+
const UpdateRecordSchema = z.object({
|
|
67
|
+
anchorIdentifier: IdentifierSchema.describe("Anchor identifier locating the record"),
|
|
68
|
+
update: z.object({
|
|
69
|
+
name: z.string().describe("Identifier name"),
|
|
70
|
+
oldValue: z.string().describe("Current identifier value"),
|
|
71
|
+
newValue: z.string().describe("New identifier value")
|
|
72
|
+
}).describe("Identifier update details"),
|
|
73
|
+
timestamp: z.string().describe("ISO 8601 timestamp for the update"),
|
|
74
|
+
options: IdentifierOptionsSchema.optional()
|
|
75
|
+
});
|
|
76
|
+
const DeleteIdentifierRecordSchema = z.object({
|
|
77
|
+
anchorIdentifier: IdentifierSchema.describe("Anchor identifier locating the record"),
|
|
78
|
+
delete: IdentifierSchema.describe("Identifier to delete"),
|
|
79
|
+
timestamp: z.string().describe("ISO 8601 timestamp for the update"),
|
|
80
|
+
options: DeleteIdentifierOptionsSchema.optional()
|
|
81
|
+
});
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/tools/preferences_append_identifiers.ts
|
|
84
|
+
const AppendIdentifiersSchema = z.object({
|
|
85
|
+
partition: z.string().describe(PARTITION_DESCRIBE),
|
|
86
|
+
records: z.array(AppendRecordSchema).min(1).describe("Identifier append operations to perform")
|
|
87
|
+
});
|
|
88
|
+
function createPreferencesAppendIdentifiersTool(clients) {
|
|
89
|
+
const { rest } = clients;
|
|
90
|
+
return defineTool({
|
|
91
|
+
name: "preferences_append_identifiers",
|
|
92
|
+
description: "Add another identifier that resolves to an existing preference record. Leaves current identifiers and their consent history intact.",
|
|
93
|
+
category: "Preference Management",
|
|
94
|
+
readOnly: false,
|
|
95
|
+
confirmation: { hint: "Links additional identifiers to an existing preference record, widening how that user's consent can be looked up. Check userId and identifiers in the call arguments before agreeing." },
|
|
96
|
+
annotations: {
|
|
97
|
+
readOnlyHint: false,
|
|
98
|
+
destructiveHint: false,
|
|
99
|
+
idempotentHint: false
|
|
100
|
+
},
|
|
101
|
+
requireSombra: true,
|
|
102
|
+
zodSchema: AppendIdentifiersSchema,
|
|
103
|
+
handler: async ({ partition, records }) => {
|
|
104
|
+
const result = await rest.appendIdentifiers(partition, records);
|
|
105
|
+
const ok = isPreferenceMutationSuccessful(result);
|
|
106
|
+
const failureCount = preferenceMutationFailureCount(result);
|
|
107
|
+
return preferenceMutationToolResult(createToolResult, ok, {
|
|
108
|
+
...result,
|
|
109
|
+
recordsProcessed: records.length,
|
|
110
|
+
message: ok ? "Identifiers appended successfully" : `Identifier append completed with ${failureCount} failure(s)`
|
|
111
|
+
}, `Identifier append failed for ${failureCount} record(s)`);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/tools/preferences_delete.ts
|
|
117
|
+
const DeletePreferencesSchema = z.object({
|
|
118
|
+
partition: z.string().describe(PARTITION_DESCRIBE),
|
|
119
|
+
records: z.array(DeleteRecordSchema).min(1).describe("Preference records to delete")
|
|
120
|
+
});
|
|
121
|
+
function createPreferencesDeleteTool(clients) {
|
|
122
|
+
const { rest } = clients;
|
|
123
|
+
return defineTool({
|
|
124
|
+
name: "preferences_delete",
|
|
125
|
+
description: "Delete consent preferences for specified users",
|
|
126
|
+
category: "Preference Management",
|
|
127
|
+
readOnly: false,
|
|
128
|
+
confirmation: { hint: "Permanently deletes stored consent preferences for these identifiers. The previous consent state cannot be recovered, and the people affected fall back to default consent. Check the identifiers in the call arguments before agreeing." },
|
|
129
|
+
annotations: {
|
|
130
|
+
readOnlyHint: false,
|
|
131
|
+
destructiveHint: true,
|
|
132
|
+
idempotentHint: false
|
|
133
|
+
},
|
|
134
|
+
requireSombra: true,
|
|
135
|
+
zodSchema: DeletePreferencesSchema,
|
|
136
|
+
handler: async ({ partition, records }) => {
|
|
137
|
+
const result = await rest.deletePreferences(partition, records);
|
|
138
|
+
const ok = isPreferenceMutationSuccessful(result);
|
|
139
|
+
const failureCount = preferenceMutationFailureCount(result);
|
|
140
|
+
return preferenceMutationToolResult(createToolResult, ok, {
|
|
141
|
+
...result,
|
|
142
|
+
recordsProcessed: records.length,
|
|
143
|
+
message: ok ? `Processed deletion for ${records.length} preference record(s)` : `Preference delete completed with ${failureCount} failure(s)`
|
|
144
|
+
}, `Preference delete failed for ${failureCount} record(s)`);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/tools/preferences_delete_identifiers.ts
|
|
150
|
+
const DeleteIdentifiersSchema = z.object({
|
|
151
|
+
partition: z.string().describe(PARTITION_DESCRIBE),
|
|
152
|
+
records: z.array(DeleteIdentifierRecordSchema).min(1).describe("Identifier delete operations to perform")
|
|
153
|
+
});
|
|
154
|
+
function createPreferencesDeleteIdentifiersTool(clients) {
|
|
155
|
+
const { rest } = clients;
|
|
156
|
+
return defineTool({
|
|
157
|
+
name: "preferences_delete_identifiers",
|
|
158
|
+
description: "Remove one identifier from a preference record, keeping the record and its remaining identifiers. Use preferences_delete to remove the whole record.",
|
|
159
|
+
category: "Preference Management",
|
|
160
|
+
readOnly: false,
|
|
161
|
+
confirmation: { hint: "Permanently removes these identifiers from a user's preference record. Consent recorded against a removed identifier can no longer be looked up by it. Check the identifiers in the call arguments before agreeing." },
|
|
162
|
+
annotations: {
|
|
163
|
+
readOnlyHint: false,
|
|
164
|
+
destructiveHint: true,
|
|
165
|
+
idempotentHint: false
|
|
166
|
+
},
|
|
167
|
+
requireSombra: true,
|
|
168
|
+
zodSchema: DeleteIdentifiersSchema,
|
|
169
|
+
handler: async ({ partition, records }) => {
|
|
170
|
+
const result = await rest.deleteIdentifiers(partition, records);
|
|
171
|
+
const ok = isPreferenceMutationSuccessful(result);
|
|
172
|
+
const failureCount = preferenceMutationFailureCount(result);
|
|
173
|
+
return preferenceMutationToolResult(createToolResult, ok, {
|
|
174
|
+
...result,
|
|
175
|
+
recordsProcessed: records.length,
|
|
176
|
+
message: ok ? "Identifiers deleted successfully" : `Identifier delete completed with ${failureCount} failure(s)`
|
|
177
|
+
}, `Identifier delete failed for ${failureCount} record(s)`);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/tools/preferences_list_partitions.ts
|
|
183
|
+
const ListPartitionsSchema = EmptySchema;
|
|
184
|
+
const PAGE_SIZE = 50;
|
|
185
|
+
async function fetchAllConsentPartitions(graphql) {
|
|
186
|
+
const partitions = [];
|
|
187
|
+
let offset = 0;
|
|
188
|
+
let shouldContinue = false;
|
|
189
|
+
do {
|
|
190
|
+
const { nodes } = (await graphql.makeRequest(CONSENT_PARTITIONS, {
|
|
191
|
+
first: PAGE_SIZE,
|
|
192
|
+
offset
|
|
193
|
+
})).consentPartitions;
|
|
194
|
+
partitions.push(...nodes);
|
|
195
|
+
offset += PAGE_SIZE;
|
|
196
|
+
shouldContinue = nodes.length === PAGE_SIZE;
|
|
197
|
+
} while (shouldContinue);
|
|
198
|
+
return partitions;
|
|
199
|
+
}
|
|
200
|
+
function createPreferencesListPartitionsTool(clients) {
|
|
201
|
+
return defineTool({
|
|
202
|
+
name: "preferences_list_partitions",
|
|
203
|
+
description: "List Preference Store partition keys for this organization: the default airgap-bundle partition plus any custom consent partitions. partitions[].partition is the string to pass as `partition` on preferences_* tools — not the organization id. effectivePartition is the partition the consent manager currently uses; prefer the row with isEffectiveForConsentManager unless the user named another partition.",
|
|
204
|
+
category: "Preference Management",
|
|
205
|
+
readOnly: true,
|
|
206
|
+
annotations: {
|
|
207
|
+
readOnlyHint: true,
|
|
208
|
+
destructiveHint: false,
|
|
209
|
+
idempotentHint: true
|
|
210
|
+
},
|
|
211
|
+
zodSchema: ListPartitionsSchema,
|
|
212
|
+
handler: async (_args) => {
|
|
213
|
+
const manager = (await clients.graphql.makeRequest(FETCH_CONSENT_MANAGER, {})).consentManager.consentManager;
|
|
214
|
+
const effectivePartition = manager.partition?.partition ?? manager.id;
|
|
215
|
+
const customNodes = await fetchAllConsentPartitions(clients.graphql);
|
|
216
|
+
const partitions = [{
|
|
217
|
+
partition: manager.id,
|
|
218
|
+
name: "Default (airgap bundle)",
|
|
219
|
+
type: "default",
|
|
220
|
+
isEffectiveForConsentManager: manager.id === effectivePartition
|
|
221
|
+
}];
|
|
222
|
+
for (const node of customNodes) {
|
|
223
|
+
if (node.partition === manager.id) continue;
|
|
224
|
+
partitions.push({
|
|
225
|
+
partition: node.partition,
|
|
226
|
+
name: node.name,
|
|
227
|
+
type: "custom",
|
|
228
|
+
isEffectiveForConsentManager: node.partition === effectivePartition,
|
|
229
|
+
airgapPartitionId: node.id
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
return createToolResult(true, {
|
|
233
|
+
effectivePartition,
|
|
234
|
+
partitions
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/tools/preferences_query.ts
|
|
241
|
+
const QueryPreferencesSchema = z.object({
|
|
242
|
+
partition: z.string().describe(PARTITION_DESCRIBE),
|
|
243
|
+
identifiers: z.array(IdentifierSchema).describe("Identifiers to query"),
|
|
244
|
+
limit: z.number().min(1).max(50).optional().describe("Max records to return (1–50, defaults to identifier count)"),
|
|
245
|
+
cursor: z.string().optional().describe("Pagination cursor from a previous query")
|
|
246
|
+
});
|
|
247
|
+
function createPreferencesQueryTool(clients) {
|
|
248
|
+
const { rest } = clients;
|
|
249
|
+
return defineTool({
|
|
250
|
+
name: "preferences_query",
|
|
251
|
+
description: "Query consent preferences for multiple users by their identifiers",
|
|
252
|
+
category: "Preference Management",
|
|
253
|
+
readOnly: true,
|
|
254
|
+
annotations: {
|
|
255
|
+
readOnlyHint: true,
|
|
256
|
+
destructiveHint: false,
|
|
257
|
+
idempotentHint: true
|
|
258
|
+
},
|
|
259
|
+
requireSombra: true,
|
|
260
|
+
zodSchema: QueryPreferencesSchema,
|
|
261
|
+
handler: async ({ partition, identifiers, limit, cursor }) => {
|
|
262
|
+
const result = await rest.queryPreferences({
|
|
263
|
+
partition,
|
|
264
|
+
identifiers,
|
|
265
|
+
limit,
|
|
266
|
+
cursor
|
|
267
|
+
});
|
|
268
|
+
return createListResult(result.nodes, {
|
|
269
|
+
totalCount: result.nodes.length,
|
|
270
|
+
hasNextPage: Boolean(result.cursor),
|
|
271
|
+
cursor: result.cursor
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
//#endregion
|
|
277
|
+
//#region src/tools/preferences_update_identifiers.ts
|
|
278
|
+
const UpdateIdentifiersSchema = z.object({
|
|
279
|
+
partition: z.string().describe(PARTITION_DESCRIBE),
|
|
280
|
+
records: z.array(UpdateRecordSchema).min(1).describe("Identifier update operations to perform")
|
|
281
|
+
});
|
|
282
|
+
function createPreferencesUpdateIdentifiersTool(clients) {
|
|
283
|
+
const { rest } = clients;
|
|
284
|
+
return defineTool({
|
|
285
|
+
name: "preferences_update_identifiers",
|
|
286
|
+
description: "Rewrite an existing identifier value in place, moving its consent history onto the new value. The old value stops resolving.",
|
|
287
|
+
category: "Preference Management",
|
|
288
|
+
readOnly: false,
|
|
289
|
+
confirmation: { hint: "Rewrites identifier values in the preference store, moving the consent history attached to each old value onto the new one. The old values stop resolving. Check the old and new values in the call arguments before agreeing." },
|
|
290
|
+
annotations: {
|
|
291
|
+
readOnlyHint: false,
|
|
292
|
+
destructiveHint: true,
|
|
293
|
+
idempotentHint: true
|
|
294
|
+
},
|
|
295
|
+
requireSombra: true,
|
|
296
|
+
zodSchema: UpdateIdentifiersSchema,
|
|
297
|
+
handler: async ({ partition, records }) => {
|
|
298
|
+
const result = await rest.updateIdentifiers(partition, records);
|
|
299
|
+
const ok = isPreferenceMutationSuccessful(result);
|
|
300
|
+
const failureCount = preferenceMutationFailureCount(result);
|
|
301
|
+
return preferenceMutationToolResult(createToolResult, ok, {
|
|
302
|
+
...result,
|
|
303
|
+
recordsProcessed: records.length,
|
|
304
|
+
message: ok ? "Identifiers updated successfully" : `Identifier update completed with ${failureCount} failure(s)`
|
|
305
|
+
}, `Identifier update failed for ${failureCount} record(s)`);
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/tools/preferences_upsert.ts
|
|
311
|
+
const UpsertPreferencesSchema = z.object({
|
|
312
|
+
records: z.array(UpsertRecordSchema).min(1).describe("Preference records to upsert"),
|
|
313
|
+
skipWorkflowTriggers: z.boolean().optional().describe("When true, skip workflow triggers for these updates")
|
|
314
|
+
});
|
|
315
|
+
function createPreferencesUpsertTool(clients) {
|
|
316
|
+
const { rest } = clients;
|
|
317
|
+
return defineTool({
|
|
318
|
+
name: "preferences_upsert",
|
|
319
|
+
description: "Batch upsert consent preference records for multiple users. Call preferences_list_partitions first and pass purposes[].enabled (boolean) — Preference Store rejects a \"consent\" field.",
|
|
320
|
+
category: "Preference Management",
|
|
321
|
+
readOnly: false,
|
|
322
|
+
confirmation: { hint: "Records or overwrites stored consent preferences for these identifiers. Purpose settings take effect for compliance and downstream systems. Check partition, identifiers, and purpose values in the call arguments before agreeing." },
|
|
323
|
+
annotations: {
|
|
324
|
+
readOnlyHint: false,
|
|
325
|
+
destructiveHint: false,
|
|
326
|
+
idempotentHint: true
|
|
327
|
+
},
|
|
328
|
+
requireSombra: true,
|
|
329
|
+
zodSchema: UpsertPreferencesSchema,
|
|
330
|
+
handler: async ({ records, skipWorkflowTriggers }) => {
|
|
331
|
+
const result = await rest.upsertPreferences({
|
|
332
|
+
records,
|
|
333
|
+
skipWorkflowTriggers
|
|
334
|
+
});
|
|
335
|
+
const ok = isPreferenceMutationSuccessful(result);
|
|
336
|
+
const failureCount = preferenceMutationFailureCount(result);
|
|
337
|
+
return preferenceMutationToolResult(createToolResult, ok, {
|
|
338
|
+
...result,
|
|
339
|
+
recordsProcessed: records.length,
|
|
340
|
+
message: ok ? `Successfully upserted ${records.length} preference record(s)` : `Preference upsert completed with ${failureCount} failure(s)`
|
|
341
|
+
}, `Preference upsert failed for ${failureCount} record(s)`);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/tools/index.ts
|
|
347
|
+
function getPreferenceTools(clients) {
|
|
348
|
+
return [
|
|
349
|
+
createPreferencesListPartitionsTool(clients),
|
|
350
|
+
createPreferencesQueryTool(clients),
|
|
351
|
+
createPreferencesUpsertTool(clients),
|
|
352
|
+
createPreferencesDeleteTool(clients),
|
|
353
|
+
createPreferencesAppendIdentifiersTool(clients),
|
|
354
|
+
createPreferencesUpdateIdentifiersTool(clients),
|
|
355
|
+
createPreferencesDeleteIdentifiersTool(clients)
|
|
356
|
+
];
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/scopes.ts
|
|
360
|
+
/** OAuth scopes required for Preference MCP tools (offline_access added by base). */
|
|
361
|
+
const PREFERENCE_OAUTH_SCOPES = [
|
|
362
|
+
ScopeName.ViewManagedConsentDatabaseAdminApi,
|
|
363
|
+
ScopeName.ManageStoredPreferences,
|
|
364
|
+
ScopeName.ViewConsentManager
|
|
365
|
+
];
|
|
366
|
+
//#endregion
|
|
367
|
+
export { QueryPreferencesSchema as a, DeletePreferencesSchema as c, PARTITION_DESCRIBE as d, UpsertPurposeSchema as f, UpdateIdentifiersSchema as i, AppendIdentifiersSchema as l, getPreferenceTools as n, ListPartitionsSchema as o, UpsertRecordSchema as p, UpsertPreferencesSchema as r, DeleteIdentifiersSchema as s, PREFERENCE_OAUTH_SCOPES as t, IdentifierSchema as u };
|
|
368
|
+
|
|
369
|
+
//# sourceMappingURL=scopes-CFVgjKbp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scopes-CFVgjKbp.mjs","names":[],"sources":["../src/tools/mutation-success.ts","../src/tools/preference-schemas.ts","../src/tools/preferences_append_identifiers.ts","../src/tools/preferences_delete.ts","../src/tools/preferences_delete_identifiers.ts","../src/tools/preferences_list_partitions.ts","../src/tools/preferences_query.ts","../src/tools/preferences_update_identifiers.ts","../src/tools/preferences_upsert.ts","../src/tools/index.ts","../src/scopes.ts"],"mappings":";;;;;;;;AAIA,SAAgB,+BAA+B,QAMnC;AACV,KAAI,OAAO,YAAY,MACrB,QAAO;AAET,MAAK,OAAO,UAAU,UAAU,KAAK,EACnC,QAAO;AAET,MAAK,OAAO,QAAQ,UAAU,KAAK,EACjC,QAAO;AAET,KAAI,OAAO,SAAS,MAAM,WAAW,OAAO,YAAY,MAAM,CAC5D,QAAO;AAET,QAAO;;;AAIT,SAAgB,+BAA+B,QAIpC;AACT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A,IACA;IACE,GAAG;IACH,kBAAkB,QAAQ;IAC1B,SAAS,KACL,yBAAyB,QAAQ,OAAO,yBACxC,oCAAoC,aAAa;IACtD,EACD,gCAAgC,aAAa,YAC9C;;EAEJ,CAAC;;;;AC/CJ,SAAgB,mBAAmB,SAAwC;AACzE,QAAO;EACL,oCAAoC,QAAQ;EAC5C,2BAA2B,QAAQ;EACnC,4BAA4B,QAAQ;EACpC,4BAA4B,QAAQ;EACpC,uCAAuC,QAAQ;EAC/C,uCAAuC,QAAQ;EAC/C,uCAAuC,QAAQ;EAChD;;;;;AChBH,MAAa,0BAA0B;CACrC,UAAU;CACV,UAAU;CACV,UAAU;CACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transcend-io/mcp-server-preferences",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Transcend MCP Server — Preference Management tools.",
|
|
5
5
|
"homepage": "https://github.com/transcend-io/tools/tree/main/packages/mcp/mcp-server-preferences",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,8 +32,9 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
34
34
|
"zod": "^4.3.6",
|
|
35
|
-
"@transcend-io/mcp-server-base": "1.
|
|
36
|
-
"@transcend-io/privacy-types": "5.24.0"
|
|
35
|
+
"@transcend-io/mcp-server-base": "1.8.0",
|
|
36
|
+
"@transcend-io/privacy-types": "5.24.0",
|
|
37
|
+
"@transcend-io/sdk": "2.1.2"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@arethetypeswrong/cli": "^0.18.2",
|
package/dist/scopes-DoJ9OoBH.mjs
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { createListResult, createToolResult, defineTool, z } from "@transcend-io/mcp-server-base";
|
|
2
|
-
import { ScopeName } from "@transcend-io/privacy-types";
|
|
3
|
-
//#region src/tools/preferences_query.ts
|
|
4
|
-
const IdentifierSchema = z.object({
|
|
5
|
-
value: z.string().describe("Identifier value"),
|
|
6
|
-
type: z.string().optional().describe("Identifier type (optional)")
|
|
7
|
-
});
|
|
8
|
-
const QueryPreferencesSchema = z.object({
|
|
9
|
-
partition: z.string().describe("Partition/organization context"),
|
|
10
|
-
identifiers: z.array(IdentifierSchema).describe("Array of identifier objects to query")
|
|
11
|
-
});
|
|
12
|
-
function createPreferencesQueryTool(clients) {
|
|
13
|
-
const { rest } = clients;
|
|
14
|
-
return defineTool({
|
|
15
|
-
name: "preferences_query",
|
|
16
|
-
description: "Query consent preferences for multiple users by their identifiers",
|
|
17
|
-
category: "Preference Management",
|
|
18
|
-
readOnly: true,
|
|
19
|
-
annotations: {
|
|
20
|
-
readOnlyHint: true,
|
|
21
|
-
destructiveHint: false,
|
|
22
|
-
idempotentHint: true
|
|
23
|
-
},
|
|
24
|
-
requireSombra: true,
|
|
25
|
-
zodSchema: QueryPreferencesSchema,
|
|
26
|
-
handler: async ({ partition, identifiers }) => {
|
|
27
|
-
const result = await rest.queryPreferences({
|
|
28
|
-
partition,
|
|
29
|
-
identifiers: identifiers.map((id) => ({
|
|
30
|
-
value: id.value,
|
|
31
|
-
type: id.type
|
|
32
|
-
}))
|
|
33
|
-
});
|
|
34
|
-
return createListResult(result, { totalCount: result.length });
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/tools/preferences_append_identifiers.ts
|
|
40
|
-
const AppendIdentifiersSchema = z.object({
|
|
41
|
-
partition: z.string().describe("Partition/organization context"),
|
|
42
|
-
userId: z.string().describe("User ID to append identifiers to"),
|
|
43
|
-
identifiers: z.array(IdentifierSchema).describe("Array of identifier objects to append")
|
|
44
|
-
});
|
|
45
|
-
function createPreferencesAppendIdentifiersTool(clients) {
|
|
46
|
-
const { rest } = clients;
|
|
47
|
-
return defineTool({
|
|
48
|
-
name: "preferences_append_identifiers",
|
|
49
|
-
description: "Append additional identifiers to an existing user preference record",
|
|
50
|
-
category: "Preference Management",
|
|
51
|
-
readOnly: false,
|
|
52
|
-
confirmation: { hint: "Links additional identifiers to an existing preference record, widening how that user's consent can be looked up. Check userId and identifiers in the call arguments before agreeing." },
|
|
53
|
-
annotations: {
|
|
54
|
-
readOnlyHint: false,
|
|
55
|
-
destructiveHint: false,
|
|
56
|
-
idempotentHint: false
|
|
57
|
-
},
|
|
58
|
-
requireSombra: true,
|
|
59
|
-
zodSchema: AppendIdentifiersSchema,
|
|
60
|
-
handler: async ({ partition, userId, identifiers }) => {
|
|
61
|
-
return createToolResult(true, {
|
|
62
|
-
...await rest.appendIdentifiers(partition, userId, identifiers.map((id) => ({
|
|
63
|
-
value: id.value,
|
|
64
|
-
type: id.type
|
|
65
|
-
}))),
|
|
66
|
-
identifiersAdded: identifiers.length,
|
|
67
|
-
message: "Identifiers appended successfully"
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/tools/preferences_delete.ts
|
|
74
|
-
const DeletePreferencesSchema = z.object({
|
|
75
|
-
partition: z.string().describe("Partition/organization context"),
|
|
76
|
-
identifiers: z.array(IdentifierSchema).describe("Array of identifier objects to delete")
|
|
77
|
-
});
|
|
78
|
-
function createPreferencesDeleteTool(clients) {
|
|
79
|
-
const { rest } = clients;
|
|
80
|
-
return defineTool({
|
|
81
|
-
name: "preferences_delete",
|
|
82
|
-
description: "Delete consent preferences for specified users",
|
|
83
|
-
category: "Preference Management",
|
|
84
|
-
readOnly: false,
|
|
85
|
-
confirmation: { hint: "Permanently deletes stored consent preferences for these identifiers. The previous consent state cannot be recovered, and the people affected fall back to default consent. Check the identifiers in the call arguments before agreeing." },
|
|
86
|
-
annotations: {
|
|
87
|
-
readOnlyHint: false,
|
|
88
|
-
destructiveHint: true,
|
|
89
|
-
idempotentHint: false
|
|
90
|
-
},
|
|
91
|
-
requireSombra: true,
|
|
92
|
-
zodSchema: DeletePreferencesSchema,
|
|
93
|
-
handler: async ({ partition, identifiers }) => {
|
|
94
|
-
const result = await rest.deletePreferences(partition, identifiers.map((id) => ({
|
|
95
|
-
value: id.value,
|
|
96
|
-
type: id.type
|
|
97
|
-
})));
|
|
98
|
-
return createToolResult(true, {
|
|
99
|
-
...result,
|
|
100
|
-
message: `Successfully deleted ${result.count} preference records`
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region src/tools/preferences_delete_identifiers.ts
|
|
107
|
-
const DeleteIdentifiersSchema = z.object({
|
|
108
|
-
partition: z.string().describe("Partition/organization context"),
|
|
109
|
-
userId: z.string().describe("User ID to delete identifiers from"),
|
|
110
|
-
identifiers: z.array(IdentifierSchema).describe("Array of identifier objects to delete")
|
|
111
|
-
});
|
|
112
|
-
function createPreferencesDeleteIdentifiersTool(clients) {
|
|
113
|
-
const { rest } = clients;
|
|
114
|
-
return defineTool({
|
|
115
|
-
name: "preferences_delete_identifiers",
|
|
116
|
-
description: "Delete specific identifiers from a user preference record",
|
|
117
|
-
category: "Preference Management",
|
|
118
|
-
readOnly: false,
|
|
119
|
-
confirmation: { hint: "Permanently removes these identifiers from a user's preference record. Consent recorded against a removed identifier can no longer be looked up by it. Check the identifiers in the call arguments before agreeing." },
|
|
120
|
-
annotations: {
|
|
121
|
-
readOnlyHint: false,
|
|
122
|
-
destructiveHint: true,
|
|
123
|
-
idempotentHint: false
|
|
124
|
-
},
|
|
125
|
-
requireSombra: true,
|
|
126
|
-
zodSchema: DeleteIdentifiersSchema,
|
|
127
|
-
handler: async ({ partition, userId, identifiers }) => {
|
|
128
|
-
return createToolResult(true, {
|
|
129
|
-
...await rest.deleteIdentifiers(partition, userId, identifiers.map((id) => ({
|
|
130
|
-
value: id.value,
|
|
131
|
-
type: id.type
|
|
132
|
-
}))),
|
|
133
|
-
identifiersDeleted: identifiers.length,
|
|
134
|
-
message: "Identifiers deleted successfully"
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region src/tools/preferences_update_identifiers.ts
|
|
141
|
-
const UpdateIdentifiersItemSchema = z.object({
|
|
142
|
-
oldValue: z.string().describe("Old identifier value"),
|
|
143
|
-
newValue: z.string().describe("New identifier value"),
|
|
144
|
-
type: z.string().optional().describe("Identifier type (optional)")
|
|
145
|
-
});
|
|
146
|
-
const UpdateIdentifiersSchema = z.object({
|
|
147
|
-
partition: z.string().describe("Partition/organization context"),
|
|
148
|
-
userId: z.string().describe("User ID to update identifiers for"),
|
|
149
|
-
identifiers: z.array(UpdateIdentifiersItemSchema).describe("Array of identifier update objects with old and new values")
|
|
150
|
-
});
|
|
151
|
-
function createPreferencesUpdateIdentifiersTool(clients) {
|
|
152
|
-
const { rest } = clients;
|
|
153
|
-
return defineTool({
|
|
154
|
-
name: "preferences_update_identifiers",
|
|
155
|
-
description: "Update existing identifiers for a user (e.g., when email changes)",
|
|
156
|
-
category: "Preference Management",
|
|
157
|
-
readOnly: false,
|
|
158
|
-
confirmation: { hint: "Rewrites identifier values in the preference store, moving the consent history attached to each old value onto the new one. The old values stop resolving. Check the old and new values in the call arguments before agreeing." },
|
|
159
|
-
annotations: {
|
|
160
|
-
readOnlyHint: false,
|
|
161
|
-
destructiveHint: true,
|
|
162
|
-
idempotentHint: true
|
|
163
|
-
},
|
|
164
|
-
requireSombra: true,
|
|
165
|
-
zodSchema: UpdateIdentifiersSchema,
|
|
166
|
-
handler: async ({ partition, userId, identifiers }) => {
|
|
167
|
-
return createToolResult(true, {
|
|
168
|
-
...await rest.updateIdentifiers(partition, userId, identifiers.map((id) => ({
|
|
169
|
-
oldValue: id.oldValue,
|
|
170
|
-
newValue: id.newValue,
|
|
171
|
-
type: id.type
|
|
172
|
-
}))),
|
|
173
|
-
identifiersUpdated: identifiers.length,
|
|
174
|
-
message: "Identifiers updated successfully"
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/tools/preferences_upsert.ts
|
|
181
|
-
const UpsertPreferencesPurposeSchema = z.object({
|
|
182
|
-
purpose: z.string().describe("Purpose slug"),
|
|
183
|
-
enabled: z.boolean().describe("Whether consent is granted")
|
|
184
|
-
});
|
|
185
|
-
const UpsertPreferencesRecordSchema = z.object({
|
|
186
|
-
identifier: z.string().describe("User identifier"),
|
|
187
|
-
identifierType: z.string().optional().describe("Identifier type (optional)"),
|
|
188
|
-
purposes: z.array(UpsertPreferencesPurposeSchema).describe("Array of purpose consent settings"),
|
|
189
|
-
confirmed: z.boolean().optional().describe("Whether consent was explicitly confirmed")
|
|
190
|
-
});
|
|
191
|
-
const UpsertPreferencesSchema = z.object({
|
|
192
|
-
partition: z.string().describe("Partition/organization context"),
|
|
193
|
-
records: z.array(UpsertPreferencesRecordSchema).describe("Array of preference records to upsert")
|
|
194
|
-
});
|
|
195
|
-
function createPreferencesUpsertTool(clients) {
|
|
196
|
-
const { rest } = clients;
|
|
197
|
-
return defineTool({
|
|
198
|
-
name: "preferences_upsert",
|
|
199
|
-
description: "Batch upsert consent preference records for multiple users",
|
|
200
|
-
category: "Preference Management",
|
|
201
|
-
readOnly: false,
|
|
202
|
-
confirmation: { hint: "Records or overwrites stored consent preferences for these identifiers. Purpose settings take effect for compliance and downstream systems. Check partition, identifiers, and purpose values in the call arguments before agreeing." },
|
|
203
|
-
annotations: {
|
|
204
|
-
readOnlyHint: false,
|
|
205
|
-
destructiveHint: false,
|
|
206
|
-
idempotentHint: true
|
|
207
|
-
},
|
|
208
|
-
requireSombra: true,
|
|
209
|
-
zodSchema: UpsertPreferencesSchema,
|
|
210
|
-
handler: async ({ partition, records }) => {
|
|
211
|
-
const result = await rest.upsertPreferences({
|
|
212
|
-
partition,
|
|
213
|
-
records: records.map((record) => ({
|
|
214
|
-
identifier: record.identifier,
|
|
215
|
-
identifierType: record.identifierType,
|
|
216
|
-
purposes: record.purposes.map((p) => ({
|
|
217
|
-
purpose: p.purpose,
|
|
218
|
-
enabled: p.enabled
|
|
219
|
-
})),
|
|
220
|
-
confirmed: record.confirmed
|
|
221
|
-
}))
|
|
222
|
-
});
|
|
223
|
-
return createToolResult(true, {
|
|
224
|
-
...result,
|
|
225
|
-
recordsProcessed: records.length,
|
|
226
|
-
message: `Successfully upserted ${result.count} preference records`
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
//#endregion
|
|
232
|
-
//#region src/tools/index.ts
|
|
233
|
-
function getPreferenceTools(clients) {
|
|
234
|
-
return [
|
|
235
|
-
createPreferencesQueryTool(clients),
|
|
236
|
-
createPreferencesUpsertTool(clients),
|
|
237
|
-
createPreferencesDeleteTool(clients),
|
|
238
|
-
createPreferencesAppendIdentifiersTool(clients),
|
|
239
|
-
createPreferencesUpdateIdentifiersTool(clients),
|
|
240
|
-
createPreferencesDeleteIdentifiersTool(clients)
|
|
241
|
-
];
|
|
242
|
-
}
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/scopes.ts
|
|
245
|
-
/** OAuth scopes required for Preference MCP tools (offline_access added by base). */
|
|
246
|
-
const PREFERENCE_OAUTH_SCOPES = [ScopeName.ViewPrivacyCenter, ScopeName.ManagePrivacyCenter];
|
|
247
|
-
//#endregion
|
|
248
|
-
export { UpsertPreferencesSchema as a, DeleteIdentifiersSchema as c, IdentifierSchema as d, QueryPreferencesSchema as f, UpsertPreferencesRecordSchema as i, DeletePreferencesSchema as l, getPreferenceTools as n, UpdateIdentifiersItemSchema as o, UpsertPreferencesPurposeSchema as r, UpdateIdentifiersSchema as s, PREFERENCE_OAUTH_SCOPES as t, AppendIdentifiersSchema as u };
|
|
249
|
-
|
|
250
|
-
//# sourceMappingURL=scopes-DoJ9OoBH.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scopes-DoJ9OoBH.mjs","names":[],"sources":["../src/tools/preferences_query.ts","../src/tools/preferences_append_identifiers.ts","../src/tools/preferences_delete.ts","../src/tools/preferences_delete_identifiers.ts","../src/tools/preferences_update_identifiers.ts","../src/tools/preferences_upsert.ts","../src/tools/index.ts","../src/scopes.ts"],"mappings":";;;AAEA,MAAa,mBAAmB,EAAE,OAAO;CACvC,OAAO,EAAE,QAAQ,CAAC,SAAS,mBAAmB;CAC9C,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,6BAA6B;CACnE,CAAC;AAGF,MAAa,yBAAyB,EAAE,OAAO;CAC7C,WAAW,EAAE,QAAQ,CAAC,SAAS,iCAAiC;CAChE,aAAa,EAAE,MAAM,iBAAiB,CAAC,SAAS,uCAAuC;CACxF,CAAC;AAGF,SAAgB,2BAA2B,SAAsB;CAC/D,MAAM,EAAE,SAAS;AACjB,QAAO,WAAW;EAChB,MAAM;EACN,aAAa;EACb,UAAU;EACV,UAAU;EACV,aAAa;GAAE,cAAc;GAAM,iBAAiB;GAAO,gBAAgB;GAAM;EACjF,eAAe;EACf,WAAW;EACX,SAAS,OAAO,EAAE,WAAW,kBAAkB;GAC7C,MAAM,SAAS,MAAM,KAAK,iBAAiB;IACzC;IACA,aAAa,YAAY,KAAK,QAAQ;KACpC,OAAO,GAAG;KACV,MAAM,GAAG;KACV,EAAE;IACJ,CAAC;AAEF,UAAO,iBAAiB,QAAQ,EAC9B,YAAY,OAAO,QACpB,CAAC;;EAEL,CAAC;;;;ACjCJ,MAAa,0BAA0B,EAAE,OAAO;CAC9C,WAAW,EAAE,QAAQ,CAAC,SAAS,iCAAiC;CAChE,QAAQ,EAAE,QAAQ,CAAC,SAAS,mCAAmC;CAC/D,aAAa,EAAE,MAAM,iBAAiB,CAAC,SAAS,wCAAwC;CACzF,CAAC;AAGF,SAAgB,uCAAuC,SAAsB;CAC3E,MAAM,EAAE,SAAS;AACjB,QAAO,WAAW;EAChB,MAAM;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