@transcend-io/mcp-server-preferences 0.1.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 ADDED
@@ -0,0 +1,88 @@
1
+ # @transcend-io/mcp-server-preferences
2
+
3
+ > **Alpha** — this package is under active development and has not yet been published to npm. APIs may change without notice.
4
+
5
+ Transcend MCP Server for privacy preference management. Provides tools for querying, upserting, and deleting user privacy preference records and their identifiers.
6
+
7
+ Requires **Node.js ≥ 22.12** (see `engines` in `package.json`).
8
+
9
+ For local runs from this repository, copy [`secret.env.example`](../../../secret.env.example) to **`secret.env`** at the repo root (gitignored) and set your API key (see **Run from the monorepo**).
10
+
11
+ ## Install
12
+
13
+ When the package is available on npm, install the CLI globally:
14
+
15
+ ```bash
16
+ npm install -g @transcend-io/mcp-server-preferences
17
+ ```
18
+
19
+ Until then, run from a checkout of this repository (see **Run from the monorepo** below).
20
+
21
+ ## Usage
22
+
23
+ ```bash
24
+ # With TRANSCEND_API_KEY in the environment; from the monorepo use secret.env (see Run from the monorepo)
25
+ TRANSCEND_API_KEY=your-api-key transcend-mcp-preferences
26
+ ```
27
+
28
+ The process speaks MCP over **stdio** and is meant to be launched by an MCP client (for example Cursor or Claude Desktop), not used as an interactive shell.
29
+
30
+ ### MCP client configuration
31
+
32
+ `npx` runs the package’s `transcend-mcp-preferences` binary (see `bin` in `package.json`).
33
+
34
+ ```json
35
+ {
36
+ "mcpServers": {
37
+ "transcend-preferences": {
38
+ "command": "npx",
39
+ "args": ["-y", "@transcend-io/mcp-server-preferences"],
40
+ "env": {
41
+ "TRANSCEND_API_KEY": "your-api-key"
42
+ }
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ When developing in this repository, reuse the same variable names from root **`secret.env`** in the `env` block, or use your client’s env-file support if it has one.
49
+
50
+ ### Run from the monorepo
51
+
52
+ 1. **Credentials** — From the repository root, copy [`secret.env.example`](../../../secret.env.example) to **`secret.env`** and set `TRANSCEND_API_KEY` (and optional URL overrides).
53
+
54
+ 2. **Build and run** — `node ./dist/cli.mjs` matches the `transcend-mcp-preferences` `bin` (use `node` because `pnpm exec transcend-mcp-preferences` may not resolve this package’s own binary in a pnpm workspace):
55
+
56
+ ```bash
57
+ # from the repository root
58
+ pnpm exec turbo run build --filter="@transcend-io/mcp-server-preferences..."
59
+ set -a && source ./secret.env && set +a
60
+ pnpm -F @transcend-io/mcp-server-preferences exec node ./dist/cli.mjs
61
+ ```
62
+
63
+ **Alternative:** `./scripts/mcp-run.sh ./packages/mcp/mcp-server-preferences/dist/cli.mjs` (sources `secret.env` when present; run after build).
64
+
65
+ See [CONTRIBUTING.md](../../../CONTRIBUTING.md#mcp-servers) for workspace layout and `pnpm --filter` workflows.
66
+
67
+ ### Environment variables
68
+
69
+ | Variable | Required | Default | Description |
70
+ | ----------------------- | -------- | ------------------------------------------ | ----------------- |
71
+ | `TRANSCEND_API_KEY` | Yes | — | Transcend API key |
72
+ | `TRANSCEND_API_URL` | No | `https://multi-tenant.sombra.transcend.io` | Sombra API URL |
73
+ | `TRANSCEND_GRAPHQL_URL` | No | `https://api.transcend.io` | GraphQL API URL |
74
+
75
+ **Monorepo:** keep these in root **`secret.env`** (from [`secret.env.example`](../../../secret.env.example)); see **Run from the monorepo**.
76
+
77
+ ## Tools
78
+
79
+ - `preferences_query` — Query preference records
80
+ - `preferences_upsert` — Create or update a preference record
81
+ - `preferences_delete` — Delete a preference record
82
+ - `preferences_append_identifiers` — Append identifiers to a record
83
+ - `preferences_update_identifiers` — Update identifiers on a record
84
+ - `preferences_delete_identifiers` — Delete identifiers from a record
85
+
86
+ ## Related packages
87
+
88
+ Also available as part of the unified [`@transcend-io/mcp-server`](../mcp-server/README.md) which includes all domains. See the [root README](../../../README.md#mcp-servers) for the full list.
package/dist/cli.d.mts ADDED
@@ -0,0 +1 @@
1
+ export { };
package/dist/cli.mjs ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ import { t as getPreferenceTools } from "./tools-8p4M7SP7.mjs";
3
+ import { TranscendGraphQLBase, TranscendRestClient, createMCPServer } from "@transcend-io/mcp-server-core";
4
+ //#region src/cli.ts
5
+ createMCPServer({
6
+ name: "transcend-mcp-preferences",
7
+ version: "1.0.0",
8
+ getTools: getPreferenceTools,
9
+ createClients: (auth, sombraUrl, graphqlUrl) => ({
10
+ rest: new TranscendRestClient(auth, sombraUrl),
11
+ graphql: new TranscendGraphQLBase(auth, graphqlUrl)
12
+ })
13
+ });
14
+ //#endregion
15
+ export {};
16
+
17
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport {\n createMCPServer,\n TranscendGraphQLBase,\n TranscendRestClient,\n} from '@transcend-io/mcp-server-core';\n\nimport { getPreferenceTools } from './tools/index.js';\n\ncreateMCPServer({\n name: 'transcend-mcp-preferences',\n version: '1.0.0',\n getTools: getPreferenceTools,\n createClients: (auth, sombraUrl, graphqlUrl) => ({\n rest: new TranscendRestClient(auth, sombraUrl),\n graphql: new TranscendGraphQLBase(auth, graphqlUrl),\n }),\n});\n"],"mappings":";;;;AASA,gBAAgB;CACd,MAAM;CACN,SAAS;CACT,UAAU;CACV,gBAAgB,MAAM,WAAW,gBAAgB;EAC/C,MAAM,IAAI,oBAAoB,MAAM,UAAU;EAC9C,SAAS,IAAI,qBAAqB,MAAM,WAAW;EACpD;CACF,CAAC"}
@@ -0,0 +1,102 @@
1
+ import { ToolClients, ToolDefinition, z } from "@transcend-io/mcp-server-core";
2
+
3
+ //#region src/tools/index.d.ts
4
+ declare function getPreferenceTools(clients: ToolClients): ToolDefinition[];
5
+ //#endregion
6
+ //#region src/tools/preferences_query.d.ts
7
+ declare const IdentifierSchema: z.ZodObject<{
8
+ value: z.ZodString;
9
+ type: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>;
11
+ type IdentifierInput = z.infer<typeof IdentifierSchema>;
12
+ declare const QueryPreferencesSchema: z.ZodObject<{
13
+ partition: z.ZodString;
14
+ identifiers: z.ZodArray<z.ZodObject<{
15
+ value: z.ZodString;
16
+ type: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>>;
18
+ }, z.core.$strip>;
19
+ type QueryPreferencesInput = z.infer<typeof QueryPreferencesSchema>;
20
+ //#endregion
21
+ //#region src/tools/preferences_upsert.d.ts
22
+ declare const UpsertPreferencesPurposeSchema: z.ZodObject<{
23
+ purpose: z.ZodString;
24
+ enabled: z.ZodBoolean;
25
+ }, z.core.$strip>;
26
+ type UpsertPreferencesPurposeInput = z.infer<typeof UpsertPreferencesPurposeSchema>;
27
+ declare const UpsertPreferencesRecordSchema: z.ZodObject<{
28
+ identifier: z.ZodString;
29
+ identifierType: z.ZodOptional<z.ZodString>;
30
+ purposes: z.ZodArray<z.ZodObject<{
31
+ purpose: z.ZodString;
32
+ enabled: z.ZodBoolean;
33
+ }, z.core.$strip>>;
34
+ confirmed: z.ZodOptional<z.ZodBoolean>;
35
+ }, z.core.$strip>;
36
+ type UpsertPreferencesRecordInput = z.infer<typeof UpsertPreferencesRecordSchema>;
37
+ declare const UpsertPreferencesSchema: z.ZodObject<{
38
+ partition: z.ZodString;
39
+ records: z.ZodArray<z.ZodObject<{
40
+ identifier: z.ZodString;
41
+ identifierType: z.ZodOptional<z.ZodString>;
42
+ purposes: z.ZodArray<z.ZodObject<{
43
+ purpose: z.ZodString;
44
+ enabled: z.ZodBoolean;
45
+ }, z.core.$strip>>;
46
+ confirmed: z.ZodOptional<z.ZodBoolean>;
47
+ }, z.core.$strip>>;
48
+ }, z.core.$strip>;
49
+ type UpsertPreferencesInput = z.infer<typeof UpsertPreferencesSchema>;
50
+ //#endregion
51
+ //#region src/tools/preferences_delete.d.ts
52
+ declare const DeletePreferencesSchema: z.ZodObject<{
53
+ partition: z.ZodString;
54
+ identifiers: z.ZodArray<z.ZodObject<{
55
+ value: z.ZodString;
56
+ type: z.ZodOptional<z.ZodString>;
57
+ }, z.core.$strip>>;
58
+ }, z.core.$strip>;
59
+ type DeletePreferencesInput = z.infer<typeof DeletePreferencesSchema>;
60
+ //#endregion
61
+ //#region src/tools/preferences_append_identifiers.d.ts
62
+ declare const AppendIdentifiersSchema: z.ZodObject<{
63
+ partition: z.ZodString;
64
+ user_id: z.ZodString;
65
+ identifiers: z.ZodArray<z.ZodObject<{
66
+ value: z.ZodString;
67
+ type: z.ZodOptional<z.ZodString>;
68
+ }, z.core.$strip>>;
69
+ }, z.core.$strip>;
70
+ type AppendIdentifiersInput = z.infer<typeof AppendIdentifiersSchema>;
71
+ //#endregion
72
+ //#region src/tools/preferences_update_identifiers.d.ts
73
+ declare const UpdateIdentifiersItemSchema: z.ZodObject<{
74
+ oldValue: z.ZodString;
75
+ newValue: z.ZodString;
76
+ type: z.ZodOptional<z.ZodString>;
77
+ }, z.core.$strip>;
78
+ type UpdateIdentifiersItemInput = z.infer<typeof UpdateIdentifiersItemSchema>;
79
+ declare const UpdateIdentifiersSchema: z.ZodObject<{
80
+ partition: z.ZodString;
81
+ user_id: z.ZodString;
82
+ identifiers: z.ZodArray<z.ZodObject<{
83
+ oldValue: z.ZodString;
84
+ newValue: z.ZodString;
85
+ type: z.ZodOptional<z.ZodString>;
86
+ }, z.core.$strip>>;
87
+ }, z.core.$strip>;
88
+ type UpdateIdentifiersInput = z.infer<typeof UpdateIdentifiersSchema>;
89
+ //#endregion
90
+ //#region src/tools/preferences_delete_identifiers.d.ts
91
+ declare const DeleteIdentifiersSchema: z.ZodObject<{
92
+ partition: z.ZodString;
93
+ user_id: z.ZodString;
94
+ identifiers: z.ZodArray<z.ZodObject<{
95
+ value: z.ZodString;
96
+ type: z.ZodOptional<z.ZodString>;
97
+ }, z.core.$strip>>;
98
+ }, z.core.$strip>;
99
+ type DeleteIdentifiersInput = z.infer<typeof DeleteIdentifiersSchema>;
100
+ //#endregion
101
+ export { type AppendIdentifiersInput, AppendIdentifiersSchema, type DeleteIdentifiersInput, DeleteIdentifiersSchema, type DeletePreferencesInput, DeletePreferencesSchema, type IdentifierInput, IdentifierSchema, type QueryPreferencesInput, QueryPreferencesSchema, type UpdateIdentifiersInput, type UpdateIdentifiersItemInput, UpdateIdentifiersItemSchema, UpdateIdentifiersSchema, type UpsertPreferencesInput, type UpsertPreferencesPurposeInput, UpsertPreferencesPurposeSchema, type UpsertPreferencesRecordInput, UpsertPreferencesRecordSchema, UpsertPreferencesSchema, getPreferenceTools };
102
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/tools/index.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":";;;iBASgB,kBAAA,CAAmB,OAAA,EAAS,WAAA,GAAc,cAAA;;;cCP7C,gBAAA,EAAgB,CAAA,CAAA,SAAA;;;;KAIjB,eAAA,GAAkB,CAAA,CAAE,KAAA,QAAa,gBAAA;AAAA,cAEhC,sBAAA,EAAsB,CAAA,CAAA,SAAA;;;;;;;KAIvB,qBAAA,GAAwB,CAAA,CAAE,KAAA,QAAa,sBAAA;;;cCVtC,8BAAA,EAA8B,CAAA,CAAA,SAAA;;;;KAI/B,6BAAA,GAAgC,CAAA,CAAE,KAAA,QAAa,8BAAA;AAAA,cAE9C,6BAAA,EAA6B,CAAA,CAAA,SAAA;;;;;;;;;KAM9B,4BAAA,GAA+B,CAAA,CAAE,KAAA,QAAa,6BAAA;AAAA,cAE7C,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;;;;;KAIxB,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,uBAAA;;;cChBvC,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;KAIxB,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,uBAAA;;;cCJvC,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;KAKxB,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,uBAAA;;;cCPvC,2BAAA,EAA2B,CAAA,CAAA,SAAA;;;;;KAK5B,0BAAA,GAA6B,CAAA,CAAE,KAAA,QAAa,2BAAA;AAAA,cAE3C,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;;KAOxB,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,uBAAA;;;cCZvC,uBAAA,EAAuB,CAAA,CAAA,SAAA;;;;;;;;KAKxB,sBAAA,GAAyB,CAAA,CAAE,KAAA,QAAa,uBAAA"}
package/dist/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import { a as UpdateIdentifiersItemSchema, c as DeletePreferencesSchema, d as QueryPreferencesSchema, i as UpsertPreferencesSchema, l as AppendIdentifiersSchema, n as UpsertPreferencesPurposeSchema, o as UpdateIdentifiersSchema, r as UpsertPreferencesRecordSchema, s as DeleteIdentifiersSchema, t as getPreferenceTools, u as IdentifierSchema } from "./tools-8p4M7SP7.mjs";
2
+ export { AppendIdentifiersSchema, DeleteIdentifiersSchema, DeletePreferencesSchema, IdentifierSchema, QueryPreferencesSchema, UpdateIdentifiersItemSchema, UpdateIdentifiersSchema, UpsertPreferencesPurposeSchema, UpsertPreferencesRecordSchema, UpsertPreferencesSchema, getPreferenceTools };
@@ -0,0 +1,239 @@
1
+ import { createListResult, createToolResult, defineTool, z } from "@transcend-io/mcp-server-core";
2
+ //#region src/tools/preferences_query.ts
3
+ const IdentifierSchema = z.object({
4
+ value: z.string().describe("Identifier value"),
5
+ type: z.string().optional().describe("Identifier type (optional)")
6
+ });
7
+ const QueryPreferencesSchema = z.object({
8
+ partition: z.string().describe("Partition/organization context"),
9
+ identifiers: z.array(IdentifierSchema).describe("Array of identifier objects to query")
10
+ });
11
+ function createPreferencesQueryTool(clients) {
12
+ const { rest } = clients;
13
+ return defineTool({
14
+ name: "preferences_query",
15
+ description: "Query consent preferences for multiple users by their identifiers",
16
+ category: "Preference Management",
17
+ readOnly: true,
18
+ annotations: {
19
+ readOnlyHint: true,
20
+ destructiveHint: false,
21
+ idempotentHint: true
22
+ },
23
+ zodSchema: QueryPreferencesSchema,
24
+ handler: async ({ partition, identifiers }) => {
25
+ const result = await rest.queryPreferences({
26
+ partition,
27
+ identifiers: identifiers.map((id) => ({
28
+ value: id.value,
29
+ type: id.type
30
+ }))
31
+ });
32
+ return createListResult(result, { totalCount: result.length });
33
+ }
34
+ });
35
+ }
36
+ //#endregion
37
+ //#region src/tools/preferences_append_identifiers.ts
38
+ const AppendIdentifiersSchema = z.object({
39
+ partition: z.string().describe("Partition/organization context"),
40
+ user_id: z.string().describe("User ID to append identifiers to"),
41
+ identifiers: z.array(IdentifierSchema).describe("Array of identifier objects to append")
42
+ });
43
+ function createPreferencesAppendIdentifiersTool(clients) {
44
+ const { rest } = clients;
45
+ return defineTool({
46
+ name: "preferences_append_identifiers",
47
+ description: "Append additional identifiers to an existing user preference record",
48
+ category: "Preference Management",
49
+ readOnly: false,
50
+ confirmationHint: "Appends identifiers to the user preference record",
51
+ annotations: {
52
+ readOnlyHint: false,
53
+ destructiveHint: false,
54
+ idempotentHint: false
55
+ },
56
+ zodSchema: AppendIdentifiersSchema,
57
+ handler: async ({ partition, user_id, identifiers }) => {
58
+ return createToolResult(true, {
59
+ ...await rest.appendIdentifiers(partition, user_id, identifiers.map((id) => ({
60
+ value: id.value,
61
+ type: id.type
62
+ }))),
63
+ identifiersAdded: identifiers.length,
64
+ message: "Identifiers appended successfully"
65
+ });
66
+ }
67
+ });
68
+ }
69
+ //#endregion
70
+ //#region src/tools/preferences_delete.ts
71
+ const DeletePreferencesSchema = z.object({
72
+ partition: z.string().describe("Partition/organization context"),
73
+ identifiers: z.array(IdentifierSchema).describe("Array of identifier objects to delete")
74
+ });
75
+ function createPreferencesDeleteTool(clients) {
76
+ const { rest } = clients;
77
+ return defineTool({
78
+ name: "preferences_delete",
79
+ description: "Delete consent preferences for specified users",
80
+ category: "Preference Management",
81
+ readOnly: false,
82
+ confirmationHint: "Deletes preference data for the identifiers",
83
+ annotations: {
84
+ readOnlyHint: false,
85
+ destructiveHint: true,
86
+ idempotentHint: false
87
+ },
88
+ zodSchema: DeletePreferencesSchema,
89
+ handler: async ({ partition, identifiers }) => {
90
+ const result = await rest.deletePreferences(partition, identifiers.map((id) => ({
91
+ value: id.value,
92
+ type: id.type
93
+ })));
94
+ return createToolResult(true, {
95
+ ...result,
96
+ message: `Successfully deleted ${result.count} preference records`
97
+ });
98
+ }
99
+ });
100
+ }
101
+ //#endregion
102
+ //#region src/tools/preferences_delete_identifiers.ts
103
+ const DeleteIdentifiersSchema = z.object({
104
+ partition: z.string().describe("Partition/organization context"),
105
+ user_id: z.string().describe("User ID to delete identifiers from"),
106
+ identifiers: z.array(IdentifierSchema).describe("Array of identifier objects to delete")
107
+ });
108
+ function createPreferencesDeleteIdentifiersTool(clients) {
109
+ const { rest } = clients;
110
+ return defineTool({
111
+ name: "preferences_delete_identifiers",
112
+ description: "Delete specific identifiers from a user preference record",
113
+ category: "Preference Management",
114
+ readOnly: false,
115
+ confirmationHint: "Deletes identifiers from the user preference record",
116
+ annotations: {
117
+ readOnlyHint: false,
118
+ destructiveHint: true,
119
+ idempotentHint: false
120
+ },
121
+ zodSchema: DeleteIdentifiersSchema,
122
+ handler: async ({ partition, user_id, identifiers }) => {
123
+ return createToolResult(true, {
124
+ ...await rest.deleteIdentifiers(partition, user_id, identifiers.map((id) => ({
125
+ value: id.value,
126
+ type: id.type
127
+ }))),
128
+ identifiersDeleted: identifiers.length,
129
+ message: "Identifiers deleted successfully"
130
+ });
131
+ }
132
+ });
133
+ }
134
+ //#endregion
135
+ //#region src/tools/preferences_update_identifiers.ts
136
+ const UpdateIdentifiersItemSchema = z.object({
137
+ oldValue: z.string().describe("Old identifier value"),
138
+ newValue: z.string().describe("New identifier value"),
139
+ type: z.string().optional().describe("Identifier type (optional)")
140
+ });
141
+ const UpdateIdentifiersSchema = z.object({
142
+ partition: z.string().describe("Partition/organization context"),
143
+ user_id: z.string().describe("User ID to update identifiers for"),
144
+ identifiers: z.array(UpdateIdentifiersItemSchema).describe("Array of identifier update objects with old and new values")
145
+ });
146
+ function createPreferencesUpdateIdentifiersTool(clients) {
147
+ const { rest } = clients;
148
+ return defineTool({
149
+ name: "preferences_update_identifiers",
150
+ description: "Update existing identifiers for a user (e.g., when email changes)",
151
+ category: "Preference Management",
152
+ readOnly: false,
153
+ confirmationHint: "Updates identifiers for the user preference record",
154
+ annotations: {
155
+ readOnlyHint: false,
156
+ destructiveHint: false,
157
+ idempotentHint: true
158
+ },
159
+ zodSchema: UpdateIdentifiersSchema,
160
+ handler: async ({ partition, user_id, identifiers }) => {
161
+ return createToolResult(true, {
162
+ ...await rest.updateIdentifiers(partition, user_id, identifiers.map((id) => ({
163
+ oldValue: id.oldValue,
164
+ newValue: id.newValue,
165
+ type: id.type
166
+ }))),
167
+ identifiersUpdated: identifiers.length,
168
+ message: "Identifiers updated successfully"
169
+ });
170
+ }
171
+ });
172
+ }
173
+ //#endregion
174
+ //#region src/tools/preferences_upsert.ts
175
+ const UpsertPreferencesPurposeSchema = z.object({
176
+ purpose: z.string().describe("Purpose slug"),
177
+ enabled: z.boolean().describe("Whether consent is granted")
178
+ });
179
+ const UpsertPreferencesRecordSchema = z.object({
180
+ identifier: z.string().describe("User identifier"),
181
+ identifierType: z.string().optional().describe("Identifier type (optional)"),
182
+ purposes: z.array(UpsertPreferencesPurposeSchema).describe("Array of purpose consent settings"),
183
+ confirmed: z.boolean().optional().describe("Whether consent was explicitly confirmed")
184
+ });
185
+ const UpsertPreferencesSchema = z.object({
186
+ partition: z.string().describe("Partition/organization context"),
187
+ records: z.array(UpsertPreferencesRecordSchema).describe("Array of preference records to upsert")
188
+ });
189
+ function createPreferencesUpsertTool(clients) {
190
+ const { rest } = clients;
191
+ return defineTool({
192
+ name: "preferences_upsert",
193
+ description: "Batch upsert consent preference records for multiple users",
194
+ category: "Preference Management",
195
+ readOnly: false,
196
+ confirmationHint: "Creates or updates preference records for users",
197
+ annotations: {
198
+ readOnlyHint: false,
199
+ destructiveHint: false,
200
+ idempotentHint: true
201
+ },
202
+ zodSchema: UpsertPreferencesSchema,
203
+ handler: async ({ partition, records }) => {
204
+ const result = await rest.upsertPreferences({
205
+ partition,
206
+ records: records.map((record) => ({
207
+ identifier: record.identifier,
208
+ identifierType: record.identifierType,
209
+ purposes: record.purposes.map((p) => ({
210
+ purpose: p.purpose,
211
+ enabled: p.enabled
212
+ })),
213
+ confirmed: record.confirmed
214
+ }))
215
+ });
216
+ return createToolResult(true, {
217
+ ...result,
218
+ recordsProcessed: records.length,
219
+ message: `Successfully upserted ${result.count} preference records`
220
+ });
221
+ }
222
+ });
223
+ }
224
+ //#endregion
225
+ //#region src/tools/index.ts
226
+ function getPreferenceTools(clients) {
227
+ return [
228
+ createPreferencesQueryTool(clients),
229
+ createPreferencesUpsertTool(clients),
230
+ createPreferencesDeleteTool(clients),
231
+ createPreferencesAppendIdentifiersTool(clients),
232
+ createPreferencesUpdateIdentifiersTool(clients),
233
+ createPreferencesDeleteIdentifiersTool(clients)
234
+ ];
235
+ }
236
+ //#endregion
237
+ export { UpdateIdentifiersItemSchema as a, DeletePreferencesSchema as c, QueryPreferencesSchema as d, UpsertPreferencesSchema as i, AppendIdentifiersSchema as l, UpsertPreferencesPurposeSchema as n, UpdateIdentifiersSchema as o, UpsertPreferencesRecordSchema as r, DeleteIdentifiersSchema as s, getPreferenceTools as t, IdentifierSchema as u };
238
+
239
+ //# sourceMappingURL=tools-8p4M7SP7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-8p4M7SP7.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"],"sourcesContent":["import { createListResult, defineTool, z, type ToolClients } from '@transcend-io/mcp-server-core';\n\nexport const IdentifierSchema = z.object({\n value: z.string().describe('Identifier value'),\n type: z.string().optional().describe('Identifier type (optional)'),\n});\nexport type IdentifierInput = z.infer<typeof IdentifierSchema>;\n\nexport const QueryPreferencesSchema = z.object({\n partition: z.string().describe('Partition/organization context'),\n identifiers: z.array(IdentifierSchema).describe('Array of identifier objects to query'),\n});\nexport type QueryPreferencesInput = z.infer<typeof QueryPreferencesSchema>;\n\nexport function createPreferencesQueryTool(clients: ToolClients) {\n const { rest } = clients;\n return defineTool({\n name: 'preferences_query',\n description: 'Query consent preferences for multiple users by their identifiers',\n category: 'Preference Management',\n readOnly: true,\n annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true },\n zodSchema: QueryPreferencesSchema,\n handler: async ({ partition, identifiers }) => {\n const result = await rest.queryPreferences({\n partition,\n identifiers: identifiers.map((id) => ({\n value: id.value,\n type: id.type,\n })),\n });\n\n return createListResult(result, {\n totalCount: result.length,\n });\n },\n });\n}\n","import { createToolResult, defineTool, z, type ToolClients } from '@transcend-io/mcp-server-core';\n\nimport { IdentifierSchema } from './preferences_query.js';\n\nexport const AppendIdentifiersSchema = z.object({\n partition: z.string().describe('Partition/organization context'),\n user_id: z.string().describe('User ID to append identifiers to'),\n identifiers: z.array(IdentifierSchema).describe('Array of identifier objects to append'),\n});\nexport type AppendIdentifiersInput = z.infer<typeof AppendIdentifiersSchema>;\n\nexport function createPreferencesAppendIdentifiersTool(clients: ToolClients) {\n const { rest } = clients;\n return defineTool({\n name: 'preferences_append_identifiers',\n description: 'Append additional identifiers to an existing user preference record',\n category: 'Preference Management',\n readOnly: false,\n confirmationHint: 'Appends identifiers to the user preference record',\n annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false },\n zodSchema: AppendIdentifiersSchema,\n handler: async ({ partition, user_id, identifiers }) => {\n const result = await rest.appendIdentifiers(\n partition,\n user_id,\n identifiers.map((id) => ({\n value: id.value,\n type: id.type,\n })),\n );\n\n return createToolResult(true, {\n ...result,\n identifiersAdded: identifiers.length,\n message: 'Identifiers appended successfully',\n });\n },\n });\n}\n","import { createToolResult, defineTool, z, type ToolClients } from '@transcend-io/mcp-server-core';\n\nimport { IdentifierSchema } from './preferences_query.js';\n\nexport const DeletePreferencesSchema = z.object({\n partition: z.string().describe('Partition/organization context'),\n identifiers: z.array(IdentifierSchema).describe('Array of identifier objects to delete'),\n});\nexport type DeletePreferencesInput = z.infer<typeof DeletePreferencesSchema>;\n\nexport function createPreferencesDeleteTool(clients: ToolClients) {\n const { rest } = clients;\n return defineTool({\n name: 'preferences_delete',\n description: 'Delete consent preferences for specified users',\n category: 'Preference Management',\n readOnly: false,\n confirmationHint: 'Deletes preference data for the identifiers',\n annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },\n zodSchema: DeletePreferencesSchema,\n handler: async ({ partition, identifiers }) => {\n const result = await rest.deletePreferences(\n partition,\n identifiers.map((id) => ({\n value: id.value,\n type: id.type,\n })),\n );\n\n return createToolResult(true, {\n ...result,\n message: `Successfully deleted ${result.count} preference records`,\n });\n },\n });\n}\n","import { createToolResult, defineTool, z, type ToolClients } from '@transcend-io/mcp-server-core';\n\nimport { IdentifierSchema } from './preferences_query.js';\n\nexport const DeleteIdentifiersSchema = z.object({\n partition: z.string().describe('Partition/organization context'),\n user_id: z.string().describe('User ID to delete identifiers from'),\n identifiers: z.array(IdentifierSchema).describe('Array of identifier objects to delete'),\n});\nexport type DeleteIdentifiersInput = z.infer<typeof DeleteIdentifiersSchema>;\n\nexport function createPreferencesDeleteIdentifiersTool(clients: ToolClients) {\n const { rest } = clients;\n return defineTool({\n name: 'preferences_delete_identifiers',\n description: 'Delete specific identifiers from a user preference record',\n category: 'Preference Management',\n readOnly: false,\n confirmationHint: 'Deletes identifiers from the user preference record',\n annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: false },\n zodSchema: DeleteIdentifiersSchema,\n handler: async ({ partition, user_id, identifiers }) => {\n const result = await rest.deleteIdentifiers(\n partition,\n user_id,\n identifiers.map((id) => ({\n value: id.value,\n type: id.type,\n })),\n );\n\n return createToolResult(true, {\n ...result,\n identifiersDeleted: identifiers.length,\n message: 'Identifiers deleted successfully',\n });\n },\n });\n}\n","import { createToolResult, defineTool, z, type ToolClients } from '@transcend-io/mcp-server-core';\n\nexport const UpdateIdentifiersItemSchema = z.object({\n oldValue: z.string().describe('Old identifier value'),\n newValue: z.string().describe('New identifier value'),\n type: z.string().optional().describe('Identifier type (optional)'),\n});\nexport type UpdateIdentifiersItemInput = z.infer<typeof UpdateIdentifiersItemSchema>;\n\nexport const UpdateIdentifiersSchema = z.object({\n partition: z.string().describe('Partition/organization context'),\n user_id: z.string().describe('User ID to update identifiers for'),\n identifiers: z\n .array(UpdateIdentifiersItemSchema)\n .describe('Array of identifier update objects with old and new values'),\n});\nexport type UpdateIdentifiersInput = z.infer<typeof UpdateIdentifiersSchema>;\n\nexport function createPreferencesUpdateIdentifiersTool(clients: ToolClients) {\n const { rest } = clients;\n return defineTool({\n name: 'preferences_update_identifiers',\n description: 'Update existing identifiers for a user (e.g., when email changes)',\n category: 'Preference Management',\n readOnly: false,\n confirmationHint: 'Updates identifiers for the user preference record',\n annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },\n zodSchema: UpdateIdentifiersSchema,\n handler: async ({ partition, user_id, identifiers }) => {\n const result = await rest.updateIdentifiers(\n partition,\n user_id,\n identifiers.map((id) => ({\n oldValue: id.oldValue,\n newValue: id.newValue,\n type: id.type,\n })),\n );\n\n return createToolResult(true, {\n ...result,\n identifiersUpdated: identifiers.length,\n message: 'Identifiers updated successfully',\n });\n },\n });\n}\n","import { createToolResult, defineTool, z, type ToolClients } from '@transcend-io/mcp-server-core';\n\nexport const UpsertPreferencesPurposeSchema = z.object({\n purpose: z.string().describe('Purpose slug'),\n enabled: z.boolean().describe('Whether consent is granted'),\n});\nexport type UpsertPreferencesPurposeInput = z.infer<typeof UpsertPreferencesPurposeSchema>;\n\nexport const UpsertPreferencesRecordSchema = z.object({\n identifier: z.string().describe('User identifier'),\n identifierType: z.string().optional().describe('Identifier type (optional)'),\n purposes: z.array(UpsertPreferencesPurposeSchema).describe('Array of purpose consent settings'),\n confirmed: z.boolean().optional().describe('Whether consent was explicitly confirmed'),\n});\nexport type UpsertPreferencesRecordInput = z.infer<typeof UpsertPreferencesRecordSchema>;\n\nexport const UpsertPreferencesSchema = z.object({\n partition: z.string().describe('Partition/organization context'),\n records: z.array(UpsertPreferencesRecordSchema).describe('Array of preference records to upsert'),\n});\nexport type UpsertPreferencesInput = z.infer<typeof UpsertPreferencesSchema>;\n\nexport function createPreferencesUpsertTool(clients: ToolClients) {\n const { rest } = clients;\n return defineTool({\n name: 'preferences_upsert',\n description: 'Batch upsert consent preference records for multiple users',\n category: 'Preference Management',\n readOnly: false,\n confirmationHint: 'Creates or updates preference records for users',\n annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true },\n zodSchema: UpsertPreferencesSchema,\n handler: async ({ partition, records }) => {\n const result = await rest.upsertPreferences({\n partition,\n records: records.map((record) => ({\n identifier: record.identifier,\n identifierType: record.identifierType,\n purposes: record.purposes.map((p) => ({\n purpose: p.purpose,\n enabled: p.enabled,\n })),\n confirmed: record.confirmed,\n })),\n });\n\n return createToolResult(true, {\n ...result,\n recordsProcessed: records.length,\n message: `Successfully upserted ${result.count} preference records`,\n });\n },\n });\n}\n","import type { ToolDefinition, ToolClients } from '@transcend-io/mcp-server-core';\n\nimport { createPreferencesAppendIdentifiersTool } from './preferences_append_identifiers.js';\nimport { createPreferencesDeleteTool } from './preferences_delete.js';\nimport { createPreferencesDeleteIdentifiersTool } from './preferences_delete_identifiers.js';\nimport { createPreferencesQueryTool } from './preferences_query.js';\nimport { createPreferencesUpdateIdentifiersTool } from './preferences_update_identifiers.js';\nimport { createPreferencesUpsertTool } from './preferences_upsert.js';\n\nexport function getPreferenceTools(clients: ToolClients): ToolDefinition[] {\n return [\n createPreferencesQueryTool(clients),\n createPreferencesUpsertTool(clients),\n createPreferencesDeleteTool(clients),\n createPreferencesAppendIdentifiersTool(clients),\n createPreferencesUpdateIdentifiersTool(clients),\n createPreferencesDeleteIdentifiersTool(clients),\n ];\n}\n"],"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,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;;;;AChCJ,MAAa,0BAA0B,EAAE,OAAO;CAC9C,WAAW,EAAE,QAAQ,CAAC,SAAS,iCAAiC;CAChE,SAAS,EAAE,QAAQ,CAAC,SAAS,mCAAmC;CAChE,aAAa,EAAE,MAAM,iBAAiB,CAAC,SAAS,wCAAwC;CACzF,CAAC;AAGF,SAAgB,uCAAuC,SAAsB;CAC3E,MAAM,EAAE,SAAS;AACjB,QAAO,WAAW;EAChB,MAAM;EACN,aAAa;EACb,UAAU;EACV,UAAU;EACV,kBAAkB;EAClB,aAAa;GAAE,cAAc;GAAO,iBAAiB;GAAO,gBAAgB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55 @@
1
+ {
2
+ "name": "@transcend-io/mcp-server-preferences",
3
+ "version": "0.1.0",
4
+ "description": "Transcend MCP Server — Preference Management tools.",
5
+ "homepage": "https://github.com/transcend-io/tools/tree/main/packages/mcp/mcp-server-preferences",
6
+ "license": "Apache-2.0",
7
+ "author": "Transcend Inc.",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/transcend-io/tools.git",
11
+ "directory": "packages/mcp/mcp-server-preferences"
12
+ },
13
+ "bin": {
14
+ "transcend-mcp-preferences": "./dist/cli.mjs"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "types": "./dist/index.d.mts",
22
+ "exports": {
23
+ ".": {
24
+ "@transcend-io/source": "./src/index.ts",
25
+ "types": "./dist/index.d.mts",
26
+ "default": "./dist/index.mjs"
27
+ }
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "scripts": {
33
+ "build": "tsdown",
34
+ "test": "vitest run",
35
+ "typecheck": "tsc -p tsconfig.json --noEmit",
36
+ "check:exports": "attw --pack . --ignore-rules cjs-resolves-to-esm",
37
+ "check:publint": "publint --level warning --strict --pack pnpm"
38
+ },
39
+ "dependencies": {
40
+ "@modelcontextprotocol/sdk": "catalog:",
41
+ "@transcend-io/mcp-server-core": "workspace:*",
42
+ "zod": "catalog:"
43
+ },
44
+ "devDependencies": {
45
+ "@arethetypeswrong/cli": "catalog:",
46
+ "@types/node": "catalog:",
47
+ "publint": "catalog:",
48
+ "tsdown": "catalog:",
49
+ "typescript": "catalog:",
50
+ "vitest": "catalog:"
51
+ },
52
+ "engines": {
53
+ "node": ">=22.12.0"
54
+ }
55
+ }