@burdenoff/mcp-libs 2026.511.1
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 +76 -0
- package/dist/chunk-4GBVJ4OY.js +847 -0
- package/dist/chunk-4GBVJ4OY.js.map +1 -0
- package/dist/chunk-H2OYWLOA.js +919 -0
- package/dist/chunk-H2OYWLOA.js.map +1 -0
- package/dist/chunk-JFEQYSWM.js +174 -0
- package/dist/chunk-JFEQYSWM.js.map +1 -0
- package/dist/chunk-WWFVD7BO.js +273 -0
- package/dist/chunk-WWFVD7BO.js.map +1 -0
- package/dist/context-1jV4NsLv.d.cts +138 -0
- package/dist/context-1jV4NsLv.d.ts +138 -0
- package/dist/core/index.cjs +953 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +59 -0
- package/dist/core/index.d.ts +59 -0
- package/dist/core/index.js +3 -0
- package/dist/core/index.js.map +1 -0
- package/dist/http-BP4c721D.d.cts +22 -0
- package/dist/http-DXTeCD5r.d.ts +22 -0
- package/dist/index.cjs +1013 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/module-DBcfA-i3.d.ts +67 -0
- package/dist/module-DFQBZNK6.d.cts +67 -0
- package/dist/modules/auth/index.cjs +533 -0
- package/dist/modules/auth/index.cjs.map +1 -0
- package/dist/modules/auth/index.d.cts +51 -0
- package/dist/modules/auth/index.d.ts +51 -0
- package/dist/modules/auth/index.js +159 -0
- package/dist/modules/auth/index.js.map +1 -0
- package/dist/modules/billing/index.cjs +655 -0
- package/dist/modules/billing/index.cjs.map +1 -0
- package/dist/modules/billing/index.d.cts +8 -0
- package/dist/modules/billing/index.d.ts +8 -0
- package/dist/modules/billing/index.js +606 -0
- package/dist/modules/billing/index.js.map +1 -0
- package/dist/modules/channels/index.cjs +443 -0
- package/dist/modules/channels/index.cjs.map +1 -0
- package/dist/modules/channels/index.d.cts +8 -0
- package/dist/modules/channels/index.d.ts +8 -0
- package/dist/modules/channels/index.js +394 -0
- package/dist/modules/channels/index.js.map +1 -0
- package/dist/modules/conversations/index.cjs +288 -0
- package/dist/modules/conversations/index.cjs.map +1 -0
- package/dist/modules/conversations/index.d.cts +8 -0
- package/dist/modules/conversations/index.d.ts +8 -0
- package/dist/modules/conversations/index.js +239 -0
- package/dist/modules/conversations/index.js.map +1 -0
- package/dist/modules/devportal/index.cjs +796 -0
- package/dist/modules/devportal/index.cjs.map +1 -0
- package/dist/modules/devportal/index.d.cts +8 -0
- package/dist/modules/devportal/index.d.ts +8 -0
- package/dist/modules/devportal/index.js +747 -0
- package/dist/modules/devportal/index.js.map +1 -0
- package/dist/modules/export/index.cjs +333 -0
- package/dist/modules/export/index.cjs.map +1 -0
- package/dist/modules/export/index.d.cts +8 -0
- package/dist/modules/export/index.d.ts +8 -0
- package/dist/modules/export/index.js +284 -0
- package/dist/modules/export/index.js.map +1 -0
- package/dist/modules/files/index.cjs +278 -0
- package/dist/modules/files/index.cjs.map +1 -0
- package/dist/modules/files/index.d.cts +8 -0
- package/dist/modules/files/index.d.ts +8 -0
- package/dist/modules/files/index.js +229 -0
- package/dist/modules/files/index.js.map +1 -0
- package/dist/modules/groups/index.cjs +451 -0
- package/dist/modules/groups/index.cjs.map +1 -0
- package/dist/modules/groups/index.d.cts +8 -0
- package/dist/modules/groups/index.d.ts +8 -0
- package/dist/modules/groups/index.js +402 -0
- package/dist/modules/groups/index.js.map +1 -0
- package/dist/modules/health/index.cjs +159 -0
- package/dist/modules/health/index.cjs.map +1 -0
- package/dist/modules/health/index.d.cts +8 -0
- package/dist/modules/health/index.d.ts +8 -0
- package/dist/modules/health/index.js +36 -0
- package/dist/modules/health/index.js.map +1 -0
- package/dist/modules/integrations/index.cjs +316 -0
- package/dist/modules/integrations/index.cjs.map +1 -0
- package/dist/modules/integrations/index.d.cts +8 -0
- package/dist/modules/integrations/index.d.ts +8 -0
- package/dist/modules/integrations/index.js +267 -0
- package/dist/modules/integrations/index.js.map +1 -0
- package/dist/modules/notifications/index.cjs +222 -0
- package/dist/modules/notifications/index.cjs.map +1 -0
- package/dist/modules/notifications/index.d.cts +8 -0
- package/dist/modules/notifications/index.d.ts +8 -0
- package/dist/modules/notifications/index.js +173 -0
- package/dist/modules/notifications/index.js.map +1 -0
- package/dist/modules/organizations/index.cjs +267 -0
- package/dist/modules/organizations/index.cjs.map +1 -0
- package/dist/modules/organizations/index.d.cts +8 -0
- package/dist/modules/organizations/index.d.ts +8 -0
- package/dist/modules/organizations/index.js +218 -0
- package/dist/modules/organizations/index.js.map +1 -0
- package/dist/modules/products/index.cjs +736 -0
- package/dist/modules/products/index.cjs.map +1 -0
- package/dist/modules/products/index.d.cts +8 -0
- package/dist/modules/products/index.d.ts +8 -0
- package/dist/modules/products/index.js +687 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/rbac/index.cjs +378 -0
- package/dist/modules/rbac/index.cjs.map +1 -0
- package/dist/modules/rbac/index.d.cts +8 -0
- package/dist/modules/rbac/index.d.ts +8 -0
- package/dist/modules/rbac/index.js +329 -0
- package/dist/modules/rbac/index.js.map +1 -0
- package/dist/modules/sandbox/index.cjs +318 -0
- package/dist/modules/sandbox/index.cjs.map +1 -0
- package/dist/modules/sandbox/index.d.cts +8 -0
- package/dist/modules/sandbox/index.d.ts +8 -0
- package/dist/modules/sandbox/index.js +225 -0
- package/dist/modules/sandbox/index.js.map +1 -0
- package/dist/modules/scheduler/index.cjs +267 -0
- package/dist/modules/scheduler/index.cjs.map +1 -0
- package/dist/modules/scheduler/index.d.cts +8 -0
- package/dist/modules/scheduler/index.d.ts +8 -0
- package/dist/modules/scheduler/index.js +218 -0
- package/dist/modules/scheduler/index.js.map +1 -0
- package/dist/modules/security/index.cjs +529 -0
- package/dist/modules/security/index.cjs.map +1 -0
- package/dist/modules/security/index.d.cts +8 -0
- package/dist/modules/security/index.d.ts +8 -0
- package/dist/modules/security/index.js +480 -0
- package/dist/modules/security/index.js.map +1 -0
- package/dist/modules/store/index.cjs +450 -0
- package/dist/modules/store/index.cjs.map +1 -0
- package/dist/modules/store/index.d.cts +8 -0
- package/dist/modules/store/index.d.ts +8 -0
- package/dist/modules/store/index.js +401 -0
- package/dist/modules/store/index.js.map +1 -0
- package/dist/modules/support/index.cjs +285 -0
- package/dist/modules/support/index.cjs.map +1 -0
- package/dist/modules/support/index.d.cts +8 -0
- package/dist/modules/support/index.d.ts +8 -0
- package/dist/modules/support/index.js +236 -0
- package/dist/modules/support/index.js.map +1 -0
- package/dist/modules/tags/index.cjs +421 -0
- package/dist/modules/tags/index.cjs.map +1 -0
- package/dist/modules/tags/index.d.cts +8 -0
- package/dist/modules/tags/index.d.ts +8 -0
- package/dist/modules/tags/index.js +372 -0
- package/dist/modules/tags/index.js.map +1 -0
- package/dist/modules/tours/index.cjs +225 -0
- package/dist/modules/tours/index.cjs.map +1 -0
- package/dist/modules/tours/index.d.cts +8 -0
- package/dist/modules/tours/index.d.ts +8 -0
- package/dist/modules/tours/index.js +176 -0
- package/dist/modules/tours/index.js.map +1 -0
- package/dist/modules/vibecontrols/index.cjs +5551 -0
- package/dist/modules/vibecontrols/index.cjs.map +1 -0
- package/dist/modules/vibecontrols/index.d.cts +8 -0
- package/dist/modules/vibecontrols/index.d.ts +8 -0
- package/dist/modules/vibecontrols/index.js +4380 -0
- package/dist/modules/vibecontrols/index.js.map +1 -0
- package/dist/modules/workspaces/index.cjs +552 -0
- package/dist/modules/workspaces/index.cjs.map +1 -0
- package/dist/modules/workspaces/index.d.cts +8 -0
- package/dist/modules/workspaces/index.d.ts +8 -0
- package/dist/modules/workspaces/index.js +503 -0
- package/dist/modules/workspaces/index.js.map +1 -0
- package/dist/tool-name-CQf_IqAj.d.cts +47 -0
- package/dist/tool-name-DlnrBsZ6.d.ts +47 -0
- package/dist/transports/index.cjs +183 -0
- package/dist/transports/index.cjs.map +1 -0
- package/dist/transports/index.d.cts +13 -0
- package/dist/transports/index.d.ts +13 -0
- package/dist/transports/index.js +3 -0
- package/dist/transports/index.js.map +1 -0
- package/package.json +125 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { mcpToolName, errorResult, jsonResult } from '../../chunk-H2OYWLOA.js';
|
|
2
|
+
import { writeFile } from 'fs/promises';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
// src/modules/export/operations.ts
|
|
6
|
+
var LIST_EXPORT_JOBS = `
|
|
7
|
+
query ListExportJobs($context: ContextInput!, $filter: ExportJobFilterInput, $pagination: ExportPaginationInput) {
|
|
8
|
+
listExportJobs(context: $context, filter: $filter, pagination: $pagination) {
|
|
9
|
+
edges { node {
|
|
10
|
+
id name status progress totalEntities processedEntities
|
|
11
|
+
startedAt completedAt downloadUrl downloadExpiresAt
|
|
12
|
+
} }
|
|
13
|
+
pageInfo { totalCount hasNextPage }
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
var GET_EXPORT_JOB = `
|
|
18
|
+
query GetExportJob($context: ContextInput, $id: ID!) {
|
|
19
|
+
getExportJob(context: $context, id: $id) {
|
|
20
|
+
id name status progress
|
|
21
|
+
downloadUrl downloadExpiresAt totalSizeBytes
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
var CREATE_EXPORT_JOB = `
|
|
26
|
+
mutation CreateExportJob($context: ContextInput!, $input: CreateExportJobInput!) {
|
|
27
|
+
createExportJob(context: $context, input: $input) {
|
|
28
|
+
id status progress entityTypes
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
var LIST_EXPORT_TEMPLATES = `
|
|
33
|
+
query ListExportTemplates($context: ContextInput!, $pagination: ExportPaginationInput) {
|
|
34
|
+
listExportTemplates(context: $context, pagination: $pagination) {
|
|
35
|
+
edges { node { id name entityTypes format includeMedia includeMetadata } }
|
|
36
|
+
pageInfo { totalCount }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
var GET_EXPORT_TEMPLATE = `
|
|
41
|
+
query GetExportTemplate($context: ContextInput, $id: ID!) {
|
|
42
|
+
getExportTemplate(context: $context, id: $id) {
|
|
43
|
+
id name entityTypes format
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
// src/modules/export/tools.ts
|
|
49
|
+
function readWorkspaceContext(ctx) {
|
|
50
|
+
const auth = ctx.auth.read();
|
|
51
|
+
if (!auth?.workspaceId) return null;
|
|
52
|
+
return { workspaceId: auth.workspaceId };
|
|
53
|
+
}
|
|
54
|
+
var ExportFormatEnum = z.enum(["JSON", "CSV", "ZIP"]);
|
|
55
|
+
function registerExportTools(server, ctx, track) {
|
|
56
|
+
server.registerTool(
|
|
57
|
+
track(mcpToolName(ctx.productName, "export_jobs_list")),
|
|
58
|
+
{
|
|
59
|
+
title: "List Export Jobs",
|
|
60
|
+
description: "List export jobs in the active workspace.",
|
|
61
|
+
inputSchema: {
|
|
62
|
+
status: z.string().optional().describe("Filter by status (will be uppercased)"),
|
|
63
|
+
limit: z.number().optional().describe("Page size (default 50)")
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
async ({ status, limit }) => {
|
|
67
|
+
try {
|
|
68
|
+
const context = readWorkspaceContext(ctx);
|
|
69
|
+
if (!context) {
|
|
70
|
+
return errorResult("No workspace set. Run the auth workspace_set tool first.");
|
|
71
|
+
}
|
|
72
|
+
const filter = {};
|
|
73
|
+
if (status !== void 0) filter.status = status.toUpperCase();
|
|
74
|
+
const data = await ctx.gql.workspace.request(LIST_EXPORT_JOBS, {
|
|
75
|
+
context,
|
|
76
|
+
filter: Object.keys(filter).length > 0 ? filter : void 0,
|
|
77
|
+
pagination: { first: limit ?? 50 }
|
|
78
|
+
});
|
|
79
|
+
return jsonResult({
|
|
80
|
+
items: data.listExportJobs.edges.map((e) => e.node),
|
|
81
|
+
pageInfo: data.listExportJobs.pageInfo
|
|
82
|
+
});
|
|
83
|
+
} catch (error) {
|
|
84
|
+
ctx.logger.error("export_jobs_list failed", { error: String(error) });
|
|
85
|
+
return errorResult(
|
|
86
|
+
`Failed to list export jobs: ${error instanceof Error ? error.message : String(error)}`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
server.registerTool(
|
|
92
|
+
track(mcpToolName(ctx.productName, "export_jobs_get")),
|
|
93
|
+
{
|
|
94
|
+
title: "Get Export Job",
|
|
95
|
+
description: "Get an export job by ID.",
|
|
96
|
+
inputSchema: { id: z.string().describe("Export job ID") }
|
|
97
|
+
},
|
|
98
|
+
async ({ id }) => {
|
|
99
|
+
try {
|
|
100
|
+
const context = readWorkspaceContext(ctx);
|
|
101
|
+
if (!context) {
|
|
102
|
+
return errorResult("No workspace set. Run the auth workspace_set tool first.");
|
|
103
|
+
}
|
|
104
|
+
const data = await ctx.gql.workspace.request(
|
|
105
|
+
GET_EXPORT_JOB,
|
|
106
|
+
{ context, id }
|
|
107
|
+
);
|
|
108
|
+
if (!data.getExportJob) return errorResult(`Export job ${id} not found`);
|
|
109
|
+
return jsonResult(data.getExportJob);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
ctx.logger.error("export_jobs_get failed", { error: String(error) });
|
|
112
|
+
return errorResult(
|
|
113
|
+
`Failed to get export job: ${error instanceof Error ? error.message : String(error)}`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
server.registerTool(
|
|
119
|
+
track(mcpToolName(ctx.productName, "export_jobs_create")),
|
|
120
|
+
{
|
|
121
|
+
title: "Create Export Job",
|
|
122
|
+
description: "Create an export job for one or more entity types.",
|
|
123
|
+
inputSchema: {
|
|
124
|
+
name: z.string().describe("Job name"),
|
|
125
|
+
entityTypes: z.array(z.string()).describe("Entity types to export"),
|
|
126
|
+
format: ExportFormatEnum.optional().describe("Output format (default JSON)"),
|
|
127
|
+
includeMedia: z.boolean().optional().describe("Include media files (default false)"),
|
|
128
|
+
includeMetadata: z.boolean().optional().describe("Include metadata (default true)"),
|
|
129
|
+
from: z.string().optional().describe("Date range start (ISO)"),
|
|
130
|
+
to: z.string().optional().describe("Date range end (ISO)")
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
async ({ name, entityTypes, format, includeMedia, includeMetadata, from, to }) => {
|
|
134
|
+
try {
|
|
135
|
+
const context = readWorkspaceContext(ctx);
|
|
136
|
+
if (!context) {
|
|
137
|
+
return errorResult("No workspace set. Run the auth workspace_set tool first.");
|
|
138
|
+
}
|
|
139
|
+
const input = {
|
|
140
|
+
name,
|
|
141
|
+
entityTypes,
|
|
142
|
+
format: format ?? "JSON",
|
|
143
|
+
includeMedia: includeMedia === true,
|
|
144
|
+
includeMetadata: includeMetadata !== false
|
|
145
|
+
};
|
|
146
|
+
if (from !== void 0) input.dateRangeStart = from;
|
|
147
|
+
if (to !== void 0) input.dateRangeEnd = to;
|
|
148
|
+
const data = await ctx.gql.workspace.request(
|
|
149
|
+
CREATE_EXPORT_JOB,
|
|
150
|
+
{ context, input }
|
|
151
|
+
);
|
|
152
|
+
return jsonResult(data.createExportJob);
|
|
153
|
+
} catch (error) {
|
|
154
|
+
ctx.logger.error("export_jobs_create failed", { error: String(error) });
|
|
155
|
+
return errorResult(
|
|
156
|
+
`Failed to create export job: ${error instanceof Error ? error.message : String(error)}`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
server.registerTool(
|
|
162
|
+
track(mcpToolName(ctx.productName, "export_download")),
|
|
163
|
+
{
|
|
164
|
+
title: "Download Export Job",
|
|
165
|
+
description: "Download a completed export job to a local file path.",
|
|
166
|
+
inputSchema: {
|
|
167
|
+
jobId: z.string().describe("Export job ID"),
|
|
168
|
+
to: z.string().describe("Local file path to write")
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
async ({ jobId, to }) => {
|
|
172
|
+
try {
|
|
173
|
+
const context = readWorkspaceContext(ctx);
|
|
174
|
+
if (!context) {
|
|
175
|
+
return errorResult("No workspace set. Run the auth workspace_set tool first.");
|
|
176
|
+
}
|
|
177
|
+
const data = await ctx.gql.workspace.request(
|
|
178
|
+
GET_EXPORT_JOB,
|
|
179
|
+
{ context, id: jobId }
|
|
180
|
+
);
|
|
181
|
+
if (!data.getExportJob) return errorResult(`Export job ${jobId} not found`);
|
|
182
|
+
const url = data.getExportJob.downloadUrl;
|
|
183
|
+
if (!url) {
|
|
184
|
+
return errorResult(
|
|
185
|
+
`Job ${jobId} has no downloadUrl yet (status=${data.getExportJob.status ?? "UNKNOWN"}).`
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
const res = await fetch(url);
|
|
189
|
+
if (!res.ok) {
|
|
190
|
+
return errorResult(`Download failed: ${res.status} ${res.statusText}`);
|
|
191
|
+
}
|
|
192
|
+
const buf = Buffer.from(await res.arrayBuffer());
|
|
193
|
+
await writeFile(to, buf);
|
|
194
|
+
return jsonResult({ status: "success", path: to, bytes: buf.length });
|
|
195
|
+
} catch (error) {
|
|
196
|
+
ctx.logger.error("export_download failed", { error: String(error) });
|
|
197
|
+
return errorResult(
|
|
198
|
+
`Failed to download export: ${error instanceof Error ? error.message : String(error)}`
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
);
|
|
203
|
+
server.registerTool(
|
|
204
|
+
track(mcpToolName(ctx.productName, "export_templates_list")),
|
|
205
|
+
{
|
|
206
|
+
title: "List Export Templates",
|
|
207
|
+
description: "List export templates in the active workspace.",
|
|
208
|
+
inputSchema: {
|
|
209
|
+
limit: z.number().optional().describe("Page size (default 50)")
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
async ({ limit }) => {
|
|
213
|
+
try {
|
|
214
|
+
const context = readWorkspaceContext(ctx);
|
|
215
|
+
if (!context) {
|
|
216
|
+
return errorResult("No workspace set. Run the auth workspace_set tool first.");
|
|
217
|
+
}
|
|
218
|
+
const data = await ctx.gql.workspace.request(LIST_EXPORT_TEMPLATES, {
|
|
219
|
+
context,
|
|
220
|
+
pagination: { first: limit ?? 50 }
|
|
221
|
+
});
|
|
222
|
+
return jsonResult({
|
|
223
|
+
items: data.listExportTemplates.edges.map((e) => e.node),
|
|
224
|
+
pageInfo: data.listExportTemplates.pageInfo
|
|
225
|
+
});
|
|
226
|
+
} catch (error) {
|
|
227
|
+
ctx.logger.error("export_templates_list failed", { error: String(error) });
|
|
228
|
+
return errorResult(
|
|
229
|
+
`Failed to list export templates: ${error instanceof Error ? error.message : String(error)}`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
server.registerTool(
|
|
235
|
+
track(mcpToolName(ctx.productName, "export_templates_get")),
|
|
236
|
+
{
|
|
237
|
+
title: "Get Export Template",
|
|
238
|
+
description: "Get an export template by ID.",
|
|
239
|
+
inputSchema: { id: z.string().describe("Template ID") }
|
|
240
|
+
},
|
|
241
|
+
async ({ id }) => {
|
|
242
|
+
try {
|
|
243
|
+
const context = readWorkspaceContext(ctx);
|
|
244
|
+
if (!context) {
|
|
245
|
+
return errorResult("No workspace set. Run the auth workspace_set tool first.");
|
|
246
|
+
}
|
|
247
|
+
const data = await ctx.gql.workspace.request(
|
|
248
|
+
GET_EXPORT_TEMPLATE,
|
|
249
|
+
{ context, id }
|
|
250
|
+
);
|
|
251
|
+
if (!data.getExportTemplate) return errorResult(`Template ${id} not found`);
|
|
252
|
+
return jsonResult(data.getExportTemplate);
|
|
253
|
+
} catch (error) {
|
|
254
|
+
ctx.logger.error("export_templates_get failed", { error: String(error) });
|
|
255
|
+
return errorResult(
|
|
256
|
+
`Failed to get export template: ${error instanceof Error ? error.message : String(error)}`
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/modules/export/index.ts
|
|
264
|
+
var exportModule = {
|
|
265
|
+
id: "export",
|
|
266
|
+
version: "0.0.1",
|
|
267
|
+
displayName: "Export",
|
|
268
|
+
dependsOn: ["auth"],
|
|
269
|
+
capabilities: { tools: {} },
|
|
270
|
+
register(server, ctx) {
|
|
271
|
+
const tools = [];
|
|
272
|
+
const track = (n) => {
|
|
273
|
+
tools.push(n);
|
|
274
|
+
return n;
|
|
275
|
+
};
|
|
276
|
+
registerExportTools(server, ctx, track);
|
|
277
|
+
return { tools, resources: [], prompts: [] };
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
var export_default = exportModule;
|
|
281
|
+
|
|
282
|
+
export { export_default as default };
|
|
283
|
+
//# sourceMappingURL=index.js.map
|
|
284
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/export/operations.ts","../../../src/modules/export/tools.ts","../../../src/modules/export/index.ts"],"names":[],"mappings":";;;;;AAAO,IAAM,gBAAA,GAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAYzB,IAAM,cAAA,GAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AASvB,IAAM,iBAAA,GAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAQ1B,IAAM,qBAAA,GAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAS9B,IAAM,mBAAA,GAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;;ACPnC,SAAS,qBAAqB,GAAA,EAAiD;AAC7E,EAAA,MAAM,IAAA,GAAO,GAAA,CAAI,IAAA,CAAK,IAAA,EAAK;AAC3B,EAAA,IAAI,CAAC,IAAA,EAAM,WAAA,EAAa,OAAO,IAAA;AAC/B,EAAA,OAAO,EAAE,WAAA,EAAa,IAAA,CAAK,WAAA,EAAY;AACzC;AAEA,IAAM,mBAAmB,CAAA,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AA0B;AAAA,EAC9B,EAAA,EAAI,QAAA;AAAA,EACJ,OAAA,EAAS,OAAA;AAAA,EACT,WAAA,EAAa,QAAA;AAAA,EACb,SAAA,EAAW,CAAC,MAAM,CAAA;AAAA,EAClB,YAAA,EAAc,EAAE,KAAA,EAAO,EAAC,EAAE;AAAA,EAE1B,QAAA,CAAS,QAAmB,GAAA,EAAqC;AAC/D,IAAA,MAAM,QAAkB,EAAC;AACzB,IAAA,MAAM,KAAA,GAAQ,CAAC,CAAA,KAAsB;AACnC,MAAA,KAAA,CAAM,KAAK,CAAC,CAAA;AACZ,MAAA,OAAO,CAAA;AAAA,IACT,CAAA;AAEA,IAAA,mBAAA,CAAoB,MAAA,EAAQ,KAAK,KAAK,CAAA;AAEtC,IAAA,OAAO,EAAE,KAAA,EAAO,SAAA,EAAW,EAAC,EAAG,OAAA,EAAS,EAAC,EAAE;AAAA,EAC7C;AACF,CAAA;AAEA,IAAO,cAAA,GAAQ","file":"index.js","sourcesContent":["export const LIST_EXPORT_JOBS = `\n query ListExportJobs($context: ContextInput!, $filter: ExportJobFilterInput, $pagination: ExportPaginationInput) {\n listExportJobs(context: $context, filter: $filter, pagination: $pagination) {\n edges { node {\n id name status progress totalEntities processedEntities\n startedAt completedAt downloadUrl downloadExpiresAt\n } }\n pageInfo { totalCount hasNextPage }\n }\n }\n`;\n\nexport const GET_EXPORT_JOB = `\n query GetExportJob($context: ContextInput, $id: ID!) {\n getExportJob(context: $context, id: $id) {\n id name status progress\n downloadUrl downloadExpiresAt totalSizeBytes\n }\n }\n`;\n\nexport const CREATE_EXPORT_JOB = `\n mutation CreateExportJob($context: ContextInput!, $input: CreateExportJobInput!) {\n createExportJob(context: $context, input: $input) {\n id status progress entityTypes\n }\n }\n`;\n\nexport const LIST_EXPORT_TEMPLATES = `\n query ListExportTemplates($context: ContextInput!, $pagination: ExportPaginationInput) {\n listExportTemplates(context: $context, pagination: $pagination) {\n edges { node { id name entityTypes format includeMedia includeMetadata } }\n pageInfo { totalCount }\n }\n }\n`;\n\nexport const GET_EXPORT_TEMPLATE = `\n query GetExportTemplate($context: ContextInput, $id: ID!) {\n getExportTemplate(context: $context, id: $id) {\n id name entityTypes format\n }\n }\n`;\n","/**\n * Export MCP tools — export jobs lifecycle, templates, download.\n * Surface mirrors cli-sdk/src/modules/export/commands.ts.\n */\n\nimport { writeFile } from 'fs/promises';\nimport { z } from 'zod';\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { jsonResult, errorResult, mcpToolName, type McpContext } from '../../core/index.js';\nimport * as ops from './operations.js';\n\ninterface JobNode {\n id: string;\n name?: string;\n status?: string;\n progress?: number;\n totalEntities?: number;\n processedEntities?: number;\n startedAt?: string;\n completedAt?: string;\n downloadUrl?: string;\n downloadExpiresAt?: string;\n}\n\ninterface TemplateNode {\n id: string;\n name?: string;\n entityTypes?: string[];\n format?: string;\n}\n\nfunction readWorkspaceContext(ctx: McpContext): { workspaceId: string } | null {\n const auth = ctx.auth.read();\n if (!auth?.workspaceId) return null;\n return { workspaceId: auth.workspaceId };\n}\n\nconst ExportFormatEnum = z.enum(['JSON', 'CSV', 'ZIP']);\n\nexport function registerExportTools(\n server: McpServer,\n ctx: McpContext,\n track: (n: string) => string,\n): void {\n // ── Jobs ────────────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'export_jobs_list')),\n {\n title: 'List Export Jobs',\n description: 'List export jobs in the active workspace.',\n inputSchema: {\n status: z.string().optional().describe('Filter by status (will be uppercased)'),\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ status, limit }) => {\n try {\n const context = readWorkspaceContext(ctx);\n if (!context) {\n return errorResult('No workspace set. Run the auth workspace_set tool first.');\n }\n const filter: Record<string, unknown> = {};\n if (status !== undefined) filter.status = status.toUpperCase();\n const data = await ctx.gql.workspace.request<{\n listExportJobs: {\n edges: Array<{ node: JobNode }>;\n pageInfo: { totalCount: number; hasNextPage: boolean };\n };\n }>(ops.LIST_EXPORT_JOBS, {\n context,\n filter: Object.keys(filter).length > 0 ? filter : undefined,\n pagination: { first: limit ?? 50 },\n });\n return jsonResult({\n items: data.listExportJobs.edges.map((e) => e.node),\n pageInfo: data.listExportJobs.pageInfo,\n });\n } catch (error) {\n ctx.logger.error('export_jobs_list failed', { error: String(error) });\n return errorResult(\n `Failed to list export jobs: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'export_jobs_get')),\n {\n title: 'Get Export Job',\n description: 'Get an export job by ID.',\n inputSchema: { id: z.string().describe('Export job ID') },\n },\n async ({ id }) => {\n try {\n const context = readWorkspaceContext(ctx);\n if (!context) {\n return errorResult('No workspace set. Run the auth workspace_set tool first.');\n }\n const data = await ctx.gql.workspace.request<{ getExportJob: JobNode | null }>(\n ops.GET_EXPORT_JOB,\n { context, id },\n );\n if (!data.getExportJob) return errorResult(`Export job ${id} not found`);\n return jsonResult(data.getExportJob);\n } catch (error) {\n ctx.logger.error('export_jobs_get failed', { error: String(error) });\n return errorResult(\n `Failed to get export job: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'export_jobs_create')),\n {\n title: 'Create Export Job',\n description: 'Create an export job for one or more entity types.',\n inputSchema: {\n name: z.string().describe('Job name'),\n entityTypes: z.array(z.string()).describe('Entity types to export'),\n format: ExportFormatEnum.optional().describe('Output format (default JSON)'),\n includeMedia: z.boolean().optional().describe('Include media files (default false)'),\n includeMetadata: z.boolean().optional().describe('Include metadata (default true)'),\n from: z.string().optional().describe('Date range start (ISO)'),\n to: z.string().optional().describe('Date range end (ISO)'),\n },\n },\n async ({ name, entityTypes, format, includeMedia, includeMetadata, from, to }) => {\n try {\n const context = readWorkspaceContext(ctx);\n if (!context) {\n return errorResult('No workspace set. Run the auth workspace_set tool first.');\n }\n const input: Record<string, unknown> = {\n name,\n entityTypes,\n format: format ?? 'JSON',\n includeMedia: includeMedia === true,\n includeMetadata: includeMetadata !== false,\n };\n if (from !== undefined) input.dateRangeStart = from;\n if (to !== undefined) input.dateRangeEnd = to;\n const data = await ctx.gql.workspace.request<{ createExportJob: JobNode }>(\n ops.CREATE_EXPORT_JOB,\n { context, input },\n );\n return jsonResult(data.createExportJob);\n } catch (error) {\n ctx.logger.error('export_jobs_create failed', { error: String(error) });\n return errorResult(\n `Failed to create export job: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'export_download')),\n {\n title: 'Download Export Job',\n description: 'Download a completed export job to a local file path.',\n inputSchema: {\n jobId: z.string().describe('Export job ID'),\n to: z.string().describe('Local file path to write'),\n },\n },\n async ({ jobId, to }) => {\n try {\n const context = readWorkspaceContext(ctx);\n if (!context) {\n return errorResult('No workspace set. Run the auth workspace_set tool first.');\n }\n const data = await ctx.gql.workspace.request<{ getExportJob: JobNode | null }>(\n ops.GET_EXPORT_JOB,\n { context, id: jobId },\n );\n if (!data.getExportJob) return errorResult(`Export job ${jobId} not found`);\n const url = data.getExportJob.downloadUrl;\n if (!url) {\n return errorResult(\n `Job ${jobId} has no downloadUrl yet (status=${data.getExportJob.status ?? 'UNKNOWN'}).`,\n );\n }\n const res = await fetch(url);\n if (!res.ok) {\n return errorResult(`Download failed: ${res.status} ${res.statusText}`);\n }\n const buf = Buffer.from(await res.arrayBuffer());\n await writeFile(to, buf);\n return jsonResult({ status: 'success', path: to, bytes: buf.length });\n } catch (error) {\n ctx.logger.error('export_download failed', { error: String(error) });\n return errorResult(\n `Failed to download export: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n // ── Templates ───────────────────────────────────────────────────────────\n server.registerTool(\n track(mcpToolName(ctx.productName, 'export_templates_list')),\n {\n title: 'List Export Templates',\n description: 'List export templates in the active workspace.',\n inputSchema: {\n limit: z.number().optional().describe('Page size (default 50)'),\n },\n },\n async ({ limit }) => {\n try {\n const context = readWorkspaceContext(ctx);\n if (!context) {\n return errorResult('No workspace set. Run the auth workspace_set tool first.');\n }\n const data = await ctx.gql.workspace.request<{\n listExportTemplates: {\n edges: Array<{ node: TemplateNode }>;\n pageInfo: { totalCount: number };\n };\n }>(ops.LIST_EXPORT_TEMPLATES, {\n context,\n pagination: { first: limit ?? 50 },\n });\n return jsonResult({\n items: data.listExportTemplates.edges.map((e) => e.node),\n pageInfo: data.listExportTemplates.pageInfo,\n });\n } catch (error) {\n ctx.logger.error('export_templates_list failed', { error: String(error) });\n return errorResult(\n `Failed to list export templates: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n\n server.registerTool(\n track(mcpToolName(ctx.productName, 'export_templates_get')),\n {\n title: 'Get Export Template',\n description: 'Get an export template by ID.',\n inputSchema: { id: z.string().describe('Template ID') },\n },\n async ({ id }) => {\n try {\n const context = readWorkspaceContext(ctx);\n if (!context) {\n return errorResult('No workspace set. Run the auth workspace_set tool first.');\n }\n const data = await ctx.gql.workspace.request<{ getExportTemplate: TemplateNode | null }>(\n ops.GET_EXPORT_TEMPLATE,\n { context, id },\n );\n if (!data.getExportTemplate) return errorResult(`Template ${id} not found`);\n return jsonResult(data.getExportTemplate);\n } catch (error) {\n ctx.logger.error('export_templates_get failed', { error: String(error) });\n return errorResult(\n `Failed to get export template: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n );\n}\n","/**\n * Export module — workspace data export jobs and templates.\n * Surface mirrors cli-sdk/src/modules/export/.\n */\n\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { McpContext, McpModule, ModuleRegistration } from '../../core/index.js';\nimport { registerExportTools } from './tools.js';\n\nconst exportModule: McpModule = {\n id: 'export',\n version: '0.0.1',\n displayName: 'Export',\n dependsOn: ['auth'],\n capabilities: { tools: {} },\n\n register(server: McpServer, ctx: McpContext): ModuleRegistration {\n const tools: string[] = [];\n const track = (n: string): string => {\n tools.push(n);\n return n;\n };\n\n registerExportTools(server, ctx, track);\n\n return { tools, resources: [], prompts: [] };\n },\n};\n\nexport default exportModule;\n"]}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
require('graphql-request');
|
|
5
|
+
require('cross-fetch');
|
|
6
|
+
require('@modelcontextprotocol/sdk/server/mcp.js');
|
|
7
|
+
require('@modelcontextprotocol/sdk/types.js');
|
|
8
|
+
|
|
9
|
+
// src/modules/files/tools.ts
|
|
10
|
+
|
|
11
|
+
// src/core/errors.ts
|
|
12
|
+
var McpInternalError = class extends Error {
|
|
13
|
+
cause;
|
|
14
|
+
constructor(message, cause) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "McpInternalError";
|
|
17
|
+
this.cause = cause;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// src/core/result.ts
|
|
22
|
+
function jsonResult(data, structured) {
|
|
23
|
+
const result = {
|
|
24
|
+
content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
|
|
25
|
+
};
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
function errorResult(message, hint) {
|
|
29
|
+
const text = hint ? `${message}
|
|
30
|
+
|
|
31
|
+
Hint: ${hint}` : message;
|
|
32
|
+
return { content: [{ type: "text", text }], isError: true };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/core/tool-name.ts
|
|
36
|
+
var MAX_TOOL_NAME_LENGTH = 63;
|
|
37
|
+
function assertSafeName(name, kind) {
|
|
38
|
+
if (name.length > MAX_TOOL_NAME_LENGTH) {
|
|
39
|
+
throw new McpInternalError(
|
|
40
|
+
`Tool name '${name}' exceeds ${MAX_TOOL_NAME_LENGTH} characters (some MCP clients truncate at 64).`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return name;
|
|
44
|
+
}
|
|
45
|
+
function mcpToolName(productName, ...parts) {
|
|
46
|
+
if (!productName) {
|
|
47
|
+
throw new McpInternalError("mcpToolName: productName is required");
|
|
48
|
+
}
|
|
49
|
+
const name = [productName, ...parts].filter(Boolean).join("_");
|
|
50
|
+
return assertSafeName(name);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/modules/files/operations.ts
|
|
54
|
+
var BROWSE_FOLDER = `
|
|
55
|
+
query BrowseFolder($folderId: ID, $pagination: PaginationInput) {
|
|
56
|
+
getFolder(id: $folderId) {
|
|
57
|
+
id name path
|
|
58
|
+
files { id name size mimeType }
|
|
59
|
+
subFolders { id name path level }
|
|
60
|
+
}
|
|
61
|
+
getFilesInFolder(folderId: $folderId, pagination: $pagination) {
|
|
62
|
+
files { id name size mimeType extension createdAt }
|
|
63
|
+
total hasMore
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
var INITIATE_UPLOAD = `
|
|
68
|
+
mutation InitiateUpload($input: InitiateUploadInput!) {
|
|
69
|
+
initiateUpload(input: $input) {
|
|
70
|
+
session { id fileName fileSize s3Bucket s3Key }
|
|
71
|
+
uploadUrl
|
|
72
|
+
presignedUrls { partNumber url expiresAt }
|
|
73
|
+
multipartUploadId
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
var COMPLETE_UPLOAD = `
|
|
78
|
+
mutation CompleteUpload($input: CompleteUploadInput!) {
|
|
79
|
+
completeUpload(input: $input) {
|
|
80
|
+
file { id name size s3Bucket s3Key downloadUrl }
|
|
81
|
+
fileId
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
var CREATE_SHARE = `
|
|
86
|
+
mutation CreateShare($input: FileCreateShareInput!) {
|
|
87
|
+
createShare(input: $input) {
|
|
88
|
+
id token shareType accessLevel expiresAt requiresPassword
|
|
89
|
+
downloadCount maxDownloads createdAt
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
var REVOKE_SHARE = `
|
|
94
|
+
mutation RevokeShare($id: ID!) {
|
|
95
|
+
revokeShare(id: $id) {
|
|
96
|
+
id revokedAt revokedBy
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
`;
|
|
100
|
+
|
|
101
|
+
// src/modules/files/tools.ts
|
|
102
|
+
var VisibilityEnum = zod.z.enum(["PRIVATE", "WORKSPACE", "PUBLIC"]);
|
|
103
|
+
var ShareAccessEnum = zod.z.enum(["VIEW", "DOWNLOAD"]);
|
|
104
|
+
function registerFilesTools(server, ctx, track) {
|
|
105
|
+
server.registerTool(
|
|
106
|
+
track(mcpToolName(ctx.productName, "files_browse")),
|
|
107
|
+
{
|
|
108
|
+
title: "Browse Folder",
|
|
109
|
+
description: "Browse a workspace folder. Returns subfolders and paginated files. Omit folderId to browse the root.",
|
|
110
|
+
inputSchema: {
|
|
111
|
+
folderId: zod.z.string().optional().describe("Folder ID (omit to browse root)"),
|
|
112
|
+
limit: zod.z.number().optional().describe("Page size (default 100)"),
|
|
113
|
+
offset: zod.z.number().optional().describe("Skip results")
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
async ({ folderId, limit, offset }) => {
|
|
117
|
+
try {
|
|
118
|
+
const pagination = {};
|
|
119
|
+
if (limit !== void 0) pagination.limit = limit;
|
|
120
|
+
if (offset !== void 0) pagination.offset = offset;
|
|
121
|
+
const data = await ctx.gql.workspace.request(BROWSE_FOLDER, {
|
|
122
|
+
folderId: folderId ?? null,
|
|
123
|
+
pagination: Object.keys(pagination).length > 0 ? pagination : void 0
|
|
124
|
+
});
|
|
125
|
+
return jsonResult({
|
|
126
|
+
folder: data.getFolder,
|
|
127
|
+
files: data.getFilesInFolder.files,
|
|
128
|
+
total: data.getFilesInFolder.total,
|
|
129
|
+
hasMore: data.getFilesInFolder.hasMore
|
|
130
|
+
});
|
|
131
|
+
} catch (error) {
|
|
132
|
+
ctx.logger.error("files_browse failed", { error });
|
|
133
|
+
return errorResult(
|
|
134
|
+
`Failed to browse folder: ${error instanceof Error ? error.message : String(error)}`
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
server.registerTool(
|
|
140
|
+
track(mcpToolName(ctx.productName, "files_upload_initiate")),
|
|
141
|
+
{
|
|
142
|
+
title: "Initiate File Upload",
|
|
143
|
+
description: "Initiate a multipart upload session. Returns presigned URL(s) the caller must PUT bytes to, plus a sessionId to use with files_upload_complete. MCP cannot read local files; the caller is responsible for streaming bytes to the returned URL(s).",
|
|
144
|
+
inputSchema: {
|
|
145
|
+
fileName: zod.z.string().describe("File name including extension"),
|
|
146
|
+
fileSize: zod.z.number().describe("File size in bytes"),
|
|
147
|
+
sha256Hash: zod.z.string().describe("Hex SHA-256 of the file contents"),
|
|
148
|
+
mimeType: zod.z.string().optional().describe("MIME type (default: application/octet-stream)"),
|
|
149
|
+
extension: zod.z.string().optional().describe("File extension without leading dot"),
|
|
150
|
+
folderId: zod.z.string().optional().describe("Target folder ID"),
|
|
151
|
+
visibility: VisibilityEnum.optional().describe("Visibility (default: WORKSPACE)")
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
async ({ fileName, fileSize, sha256Hash, mimeType, extension, folderId, visibility }) => {
|
|
155
|
+
try {
|
|
156
|
+
const input = {
|
|
157
|
+
fileName,
|
|
158
|
+
fileSize,
|
|
159
|
+
sha256Hash,
|
|
160
|
+
mimeType: mimeType ?? "application/octet-stream",
|
|
161
|
+
visibility: visibility ?? "WORKSPACE"
|
|
162
|
+
};
|
|
163
|
+
if (extension !== void 0) input.extension = extension;
|
|
164
|
+
if (folderId !== void 0) input.folderId = folderId;
|
|
165
|
+
const data = await ctx.gql.workspace.request(INITIATE_UPLOAD, { input });
|
|
166
|
+
return jsonResult(data.initiateUpload);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
ctx.logger.error("files_upload_initiate failed", { error });
|
|
169
|
+
return errorResult(
|
|
170
|
+
`Failed to initiate upload: ${error instanceof Error ? error.message : String(error)}`
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
server.registerTool(
|
|
176
|
+
track(mcpToolName(ctx.productName, "files_upload_complete")),
|
|
177
|
+
{
|
|
178
|
+
title: "Complete File Upload",
|
|
179
|
+
description: "Complete an in-flight upload session previously initiated by files_upload_initiate.",
|
|
180
|
+
inputSchema: {
|
|
181
|
+
sessionId: zod.z.string().describe("Session ID from files_upload_initiate"),
|
|
182
|
+
folderId: zod.z.string().optional().describe("Target folder ID (overrides initiate)"),
|
|
183
|
+
description: zod.z.string().optional().describe("File description")
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
async ({ sessionId, folderId, description }) => {
|
|
187
|
+
try {
|
|
188
|
+
const input = { sessionId };
|
|
189
|
+
if (folderId !== void 0) input.folderId = folderId;
|
|
190
|
+
if (description !== void 0) input.description = description;
|
|
191
|
+
const data = await ctx.gql.workspace.request(COMPLETE_UPLOAD, { input });
|
|
192
|
+
return jsonResult(data.completeUpload);
|
|
193
|
+
} catch (error) {
|
|
194
|
+
ctx.logger.error("files_upload_complete failed", { error });
|
|
195
|
+
return errorResult(
|
|
196
|
+
`Failed to complete upload: ${error instanceof Error ? error.message : String(error)}`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
);
|
|
201
|
+
server.registerTool(
|
|
202
|
+
track(mcpToolName(ctx.productName, "files_share_create")),
|
|
203
|
+
{
|
|
204
|
+
title: "Create File Share",
|
|
205
|
+
description: "Create a shareable link for a file with optional access controls.",
|
|
206
|
+
inputSchema: {
|
|
207
|
+
fileId: zod.z.string().describe("File ID to share"),
|
|
208
|
+
access: ShareAccessEnum.optional().describe("Access level (default: DOWNLOAD)"),
|
|
209
|
+
expiresAt: zod.z.string().optional().describe("Expiry timestamp in ISO 8601"),
|
|
210
|
+
password: zod.z.string().optional().describe("Optional password to gate the share"),
|
|
211
|
+
maxDownloads: zod.z.number().optional().describe("Maximum download count")
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
async ({ fileId, access, expiresAt, password, maxDownloads }) => {
|
|
215
|
+
try {
|
|
216
|
+
const input = {
|
|
217
|
+
fileId,
|
|
218
|
+
shareType: "PUBLIC_LINK",
|
|
219
|
+
accessLevel: access ?? "DOWNLOAD"
|
|
220
|
+
};
|
|
221
|
+
if (expiresAt !== void 0) input.expiresAt = expiresAt;
|
|
222
|
+
if (password !== void 0) input.password = password;
|
|
223
|
+
if (maxDownloads !== void 0) input.maxDownloads = maxDownloads;
|
|
224
|
+
const data = await ctx.gql.workspace.request(CREATE_SHARE, { input });
|
|
225
|
+
return jsonResult(data.createShare);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
ctx.logger.error("files_share_create failed", { error });
|
|
228
|
+
return errorResult(
|
|
229
|
+
`Failed to create share: ${error instanceof Error ? error.message : String(error)}`
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
server.registerTool(
|
|
235
|
+
track(mcpToolName(ctx.productName, "files_share_revoke")),
|
|
236
|
+
{
|
|
237
|
+
title: "Revoke File Share",
|
|
238
|
+
description: "Revoke a previously created file share by ID.",
|
|
239
|
+
inputSchema: {
|
|
240
|
+
id: zod.z.string().describe("Share ID to revoke")
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
async ({ id }) => {
|
|
244
|
+
try {
|
|
245
|
+
const data = await ctx.gql.workspace.request(REVOKE_SHARE, { id });
|
|
246
|
+
return jsonResult(data.revokeShare);
|
|
247
|
+
} catch (error) {
|
|
248
|
+
ctx.logger.error("files_share_revoke failed", { error });
|
|
249
|
+
return errorResult(
|
|
250
|
+
`Failed to revoke share: ${error instanceof Error ? error.message : String(error)}`
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// src/modules/files/index.ts
|
|
258
|
+
var filesModule = {
|
|
259
|
+
id: "files",
|
|
260
|
+
version: "0.0.1",
|
|
261
|
+
displayName: "Files",
|
|
262
|
+
dependsOn: ["auth"],
|
|
263
|
+
capabilities: { tools: {} },
|
|
264
|
+
register(server, ctx) {
|
|
265
|
+
const tools = [];
|
|
266
|
+
const track = (n) => {
|
|
267
|
+
tools.push(n);
|
|
268
|
+
return n;
|
|
269
|
+
};
|
|
270
|
+
registerFilesTools(server, ctx, track);
|
|
271
|
+
return { tools, resources: [], prompts: [] };
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
var files_default = filesModule;
|
|
275
|
+
|
|
276
|
+
module.exports = files_default;
|
|
277
|
+
//# sourceMappingURL=index.cjs.map
|
|
278
|
+
//# sourceMappingURL=index.cjs.map
|