@contentful/mcp-tools 0.12.10 → 0.12.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +10 -26
- package/dist/index.js +29 -24
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,8 @@ interface ContentfulConfig {
|
|
|
70
70
|
deliveryToken?: string;
|
|
71
71
|
/** Contentful Delivery API host (used with deliveryToken for custom CDA endpoints) */
|
|
72
72
|
hostDelivery?: string;
|
|
73
|
+
/** Server-controlled root directory for space export output */
|
|
74
|
+
exportBaseDir?: string;
|
|
73
75
|
/** Environment IDs that are protected from write/delete operations */
|
|
74
76
|
protectedEnvironments?: string[];
|
|
75
77
|
/** Maximum number of IDs allowed in a single bulk-operation tool call. Defaults to 10 when unset. */
|
|
@@ -10532,9 +10534,7 @@ declare class ContentfulMcpTools {
|
|
|
10532
10534
|
export: zod.ZodOptional<zod.ZodObject<{
|
|
10533
10535
|
spaceId: zod.ZodOptional<zod.ZodString>;
|
|
10534
10536
|
environmentId: zod.ZodOptional<zod.ZodString>;
|
|
10535
|
-
exportDir: zod.ZodOptional<zod.ZodOptional<zod.ZodString>>;
|
|
10536
10537
|
saveFile: zod.ZodOptional<zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>>;
|
|
10537
|
-
contentFile: zod.ZodOptional<zod.ZodOptional<zod.ZodString>>;
|
|
10538
10538
|
includeDrafts: zod.ZodOptional<zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>>;
|
|
10539
10539
|
includeArchived: zod.ZodOptional<zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>>;
|
|
10540
10540
|
skipContentModel: zod.ZodOptional<zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>>;
|
|
@@ -10605,14 +10605,11 @@ declare class ContentfulMcpTools {
|
|
|
10605
10605
|
}, zod.ZodTypeAny, "passthrough">>>>;
|
|
10606
10606
|
downloadAssets: zod.ZodOptional<zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>>;
|
|
10607
10607
|
maxAllowedLimit: zod.ZodOptional<zod.ZodDefault<zod.ZodOptional<zod.ZodNumber>>>;
|
|
10608
|
-
errorLogFile: zod.ZodOptional<zod.ZodOptional<zod.ZodString>>;
|
|
10609
10608
|
useVerboseRenderer: zod.ZodOptional<zod.ZodOptional<zod.ZodBoolean>>;
|
|
10610
10609
|
}, "strip", zod.ZodTypeAny, {
|
|
10611
10610
|
spaceId?: string | undefined;
|
|
10612
10611
|
environmentId?: string | undefined;
|
|
10613
|
-
exportDir?: string | undefined;
|
|
10614
10612
|
saveFile?: boolean | undefined;
|
|
10615
|
-
contentFile?: string | undefined;
|
|
10616
10613
|
includeDrafts?: boolean | undefined;
|
|
10617
10614
|
includeArchived?: boolean | undefined;
|
|
10618
10615
|
skipContentModel?: boolean | undefined;
|
|
@@ -10627,14 +10624,11 @@ declare class ContentfulMcpTools {
|
|
|
10627
10624
|
queryAssets?: unknown;
|
|
10628
10625
|
downloadAssets?: boolean | undefined;
|
|
10629
10626
|
maxAllowedLimit?: number | undefined;
|
|
10630
|
-
errorLogFile?: string | undefined;
|
|
10631
10627
|
useVerboseRenderer?: boolean | undefined;
|
|
10632
10628
|
}, {
|
|
10633
10629
|
spaceId?: string | undefined;
|
|
10634
10630
|
environmentId?: string | undefined;
|
|
10635
|
-
exportDir?: string | undefined;
|
|
10636
10631
|
saveFile?: boolean | undefined;
|
|
10637
|
-
contentFile?: string | undefined;
|
|
10638
10632
|
includeDrafts?: boolean | undefined;
|
|
10639
10633
|
includeArchived?: boolean | undefined;
|
|
10640
10634
|
skipContentModel?: boolean | undefined;
|
|
@@ -10663,7 +10657,6 @@ declare class ContentfulMcpTools {
|
|
|
10663
10657
|
}, zod.ZodTypeAny, "passthrough"> | undefined;
|
|
10664
10658
|
downloadAssets?: boolean | undefined;
|
|
10665
10659
|
maxAllowedLimit?: number | undefined;
|
|
10666
|
-
errorLogFile?: string | undefined;
|
|
10667
10660
|
useVerboseRenderer?: boolean | undefined;
|
|
10668
10661
|
}>>;
|
|
10669
10662
|
import: zod.ZodOptional<zod.ZodObject<{
|
|
@@ -10690,10 +10683,9 @@ declare class ContentfulMcpTools {
|
|
|
10690
10683
|
environmentId?: string | undefined;
|
|
10691
10684
|
retryLimit?: number | undefined;
|
|
10692
10685
|
timeout?: number | undefined;
|
|
10693
|
-
contentFile?: string | undefined;
|
|
10694
10686
|
skipContentModel?: boolean | undefined;
|
|
10695
|
-
errorLogFile?: string | undefined;
|
|
10696
10687
|
useVerboseRenderer?: boolean | undefined;
|
|
10688
|
+
contentFile?: string | undefined;
|
|
10697
10689
|
contentModelOnly?: boolean | undefined;
|
|
10698
10690
|
skipLocales?: boolean | undefined;
|
|
10699
10691
|
skipContentUpdates?: boolean | undefined;
|
|
@@ -10702,16 +10694,16 @@ declare class ContentfulMcpTools {
|
|
|
10702
10694
|
skipAssetUpdates?: boolean | undefined;
|
|
10703
10695
|
assetsDirectory?: string | undefined;
|
|
10704
10696
|
rateLimit?: number | undefined;
|
|
10697
|
+
errorLogFile?: string | undefined;
|
|
10705
10698
|
}, {
|
|
10706
10699
|
content?: Record<string, any> | undefined;
|
|
10707
10700
|
spaceId?: string | undefined;
|
|
10708
10701
|
environmentId?: string | undefined;
|
|
10709
10702
|
retryLimit?: number | undefined;
|
|
10710
10703
|
timeout?: number | undefined;
|
|
10711
|
-
contentFile?: string | undefined;
|
|
10712
10704
|
skipContentModel?: boolean | undefined;
|
|
10713
|
-
errorLogFile?: string | undefined;
|
|
10714
10705
|
useVerboseRenderer?: boolean | undefined;
|
|
10706
|
+
contentFile?: string | undefined;
|
|
10715
10707
|
contentModelOnly?: boolean | undefined;
|
|
10716
10708
|
skipLocales?: boolean | undefined;
|
|
10717
10709
|
skipContentUpdates?: boolean | undefined;
|
|
@@ -10720,6 +10712,7 @@ declare class ContentfulMcpTools {
|
|
|
10720
10712
|
skipAssetUpdates?: boolean | undefined;
|
|
10721
10713
|
assetsDirectory?: string | undefined;
|
|
10722
10714
|
rateLimit?: number | undefined;
|
|
10715
|
+
errorLogFile?: string | undefined;
|
|
10723
10716
|
}>>;
|
|
10724
10717
|
};
|
|
10725
10718
|
annotations: {
|
|
@@ -10734,9 +10727,7 @@ declare class ContentfulMcpTools {
|
|
|
10734
10727
|
export?: {
|
|
10735
10728
|
spaceId?: string | undefined;
|
|
10736
10729
|
environmentId?: string | undefined;
|
|
10737
|
-
exportDir?: string | undefined;
|
|
10738
10730
|
saveFile?: boolean | undefined;
|
|
10739
|
-
contentFile?: string | undefined;
|
|
10740
10731
|
includeDrafts?: boolean | undefined;
|
|
10741
10732
|
includeArchived?: boolean | undefined;
|
|
10742
10733
|
skipContentModel?: boolean | undefined;
|
|
@@ -10751,7 +10742,6 @@ declare class ContentfulMcpTools {
|
|
|
10751
10742
|
queryAssets?: unknown;
|
|
10752
10743
|
downloadAssets?: boolean | undefined;
|
|
10753
10744
|
maxAllowedLimit?: number | undefined;
|
|
10754
|
-
errorLogFile?: string | undefined;
|
|
10755
10745
|
useVerboseRenderer?: boolean | undefined;
|
|
10756
10746
|
} | undefined;
|
|
10757
10747
|
import?: {
|
|
@@ -10760,10 +10750,9 @@ declare class ContentfulMcpTools {
|
|
|
10760
10750
|
environmentId?: string | undefined;
|
|
10761
10751
|
retryLimit?: number | undefined;
|
|
10762
10752
|
timeout?: number | undefined;
|
|
10763
|
-
contentFile?: string | undefined;
|
|
10764
10753
|
skipContentModel?: boolean | undefined;
|
|
10765
|
-
errorLogFile?: string | undefined;
|
|
10766
10754
|
useVerboseRenderer?: boolean | undefined;
|
|
10755
|
+
contentFile?: string | undefined;
|
|
10767
10756
|
contentModelOnly?: boolean | undefined;
|
|
10768
10757
|
skipLocales?: boolean | undefined;
|
|
10769
10758
|
skipContentUpdates?: boolean | undefined;
|
|
@@ -10772,6 +10761,7 @@ declare class ContentfulMcpTools {
|
|
|
10772
10761
|
skipAssetUpdates?: boolean | undefined;
|
|
10773
10762
|
assetsDirectory?: string | undefined;
|
|
10774
10763
|
rateLimit?: number | undefined;
|
|
10764
|
+
errorLogFile?: string | undefined;
|
|
10775
10765
|
} | undefined;
|
|
10776
10766
|
}, extra?: _modelcontextprotocol_sdk_shared_protocol_js.RequestHandlerExtra<_modelcontextprotocol_sdk_types_js.ServerRequest, _modelcontextprotocol_sdk_types_js.ServerNotification>) => Promise<ToolResponse>;
|
|
10777
10767
|
};
|
|
@@ -10782,9 +10772,7 @@ declare class ContentfulMcpTools {
|
|
|
10782
10772
|
spaceId: zod.ZodString;
|
|
10783
10773
|
environmentId: zod.ZodString;
|
|
10784
10774
|
} & {
|
|
10785
|
-
exportDir: zod.ZodOptional<zod.ZodString>;
|
|
10786
10775
|
saveFile: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
|
|
10787
|
-
contentFile: zod.ZodOptional<zod.ZodString>;
|
|
10788
10776
|
includeDrafts: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
|
|
10789
10777
|
includeArchived: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
|
|
10790
10778
|
skipContentModel: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
|
|
@@ -10855,7 +10843,6 @@ declare class ContentfulMcpTools {
|
|
|
10855
10843
|
}, zod.ZodTypeAny, "passthrough">>>;
|
|
10856
10844
|
downloadAssets: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
|
|
10857
10845
|
maxAllowedLimit: zod.ZodDefault<zod.ZodOptional<zod.ZodNumber>>;
|
|
10858
|
-
errorLogFile: zod.ZodOptional<zod.ZodString>;
|
|
10859
10846
|
useVerboseRenderer: zod.ZodOptional<zod.ZodBoolean>;
|
|
10860
10847
|
};
|
|
10861
10848
|
annotations: {
|
|
@@ -10879,11 +10866,8 @@ declare class ContentfulMcpTools {
|
|
|
10879
10866
|
contentOnly: boolean;
|
|
10880
10867
|
downloadAssets: boolean;
|
|
10881
10868
|
maxAllowedLimit: number;
|
|
10882
|
-
exportDir?: string | undefined;
|
|
10883
|
-
contentFile?: string | undefined;
|
|
10884
10869
|
queryEntries?: unknown;
|
|
10885
10870
|
queryAssets?: unknown;
|
|
10886
|
-
errorLogFile?: string | undefined;
|
|
10887
10871
|
useVerboseRenderer?: boolean | undefined;
|
|
10888
10872
|
}, extra?: _modelcontextprotocol_sdk_shared_protocol_js.RequestHandlerExtra<_modelcontextprotocol_sdk_types_js.ServerRequest, _modelcontextprotocol_sdk_types_js.ServerNotification>) => Promise<ToolResponse>;
|
|
10889
10873
|
};
|
|
@@ -10930,10 +10914,10 @@ declare class ContentfulMcpTools {
|
|
|
10930
10914
|
skipAssetUpdates: boolean;
|
|
10931
10915
|
rateLimit: number;
|
|
10932
10916
|
content?: Record<string, any> | undefined;
|
|
10933
|
-
contentFile?: string | undefined;
|
|
10934
|
-
errorLogFile?: string | undefined;
|
|
10935
10917
|
useVerboseRenderer?: boolean | undefined;
|
|
10918
|
+
contentFile?: string | undefined;
|
|
10936
10919
|
assetsDirectory?: string | undefined;
|
|
10920
|
+
errorLogFile?: string | undefined;
|
|
10937
10921
|
}, extra?: _modelcontextprotocol_sdk_shared_protocol_js.RequestHandlerExtra<_modelcontextprotocol_sdk_types_js.ServerRequest, _modelcontextprotocol_sdk_types_js.ServerNotification>) => Promise<ToolResponse>;
|
|
10938
10922
|
};
|
|
10939
10923
|
spaceToSpaceMigrationHandler: {
|
package/dist/index.js
CHANGED
|
@@ -270,7 +270,7 @@ var InvokeAiActionToolParams = BaseToolSchema.extend({
|
|
|
270
270
|
async function pollForCompletion(contentfulClient, params, aiActions, pollInterval = 3e4, maxAttempts = 10) {
|
|
271
271
|
const completedActions = /* @__PURE__ */ new Map();
|
|
272
272
|
for (let attempt = 0; attempt < maxAttempts && completedActions.size < aiActions.length; attempt++) {
|
|
273
|
-
await new Promise((
|
|
273
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
274
274
|
await Promise.allSettled(
|
|
275
275
|
aiActions.filter((action) => !completedActions.has(action.sys.id)).map(async (action) => {
|
|
276
276
|
try {
|
|
@@ -1153,7 +1153,7 @@ async function waitForBulkActionCompletion(contentfulClient, baseParams, bulkAct
|
|
|
1153
1153
|
bulkActionId
|
|
1154
1154
|
});
|
|
1155
1155
|
while (action.sys.status === "inProgress" || action.sys.status === "created") {
|
|
1156
|
-
await new Promise((
|
|
1156
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
1157
1157
|
action = await contentfulClient.bulkAction.get({
|
|
1158
1158
|
...baseParams,
|
|
1159
1159
|
bulkActionId
|
|
@@ -5728,6 +5728,10 @@ function createUsageTools(config) {
|
|
|
5728
5728
|
};
|
|
5729
5729
|
}
|
|
5730
5730
|
|
|
5731
|
+
// src/tools/jobs/space-to-space-migration/exportSpace.ts
|
|
5732
|
+
import { mkdir, mkdtemp, realpath } from "fs/promises";
|
|
5733
|
+
import { join, resolve } from "path";
|
|
5734
|
+
|
|
5731
5735
|
// src/tools/jobs/space-to-space-migration/types.ts
|
|
5732
5736
|
import { z as z82 } from "zod";
|
|
5733
5737
|
|
|
@@ -5766,11 +5770,7 @@ function stripUnsupportedQueryKeys(knownKeys) {
|
|
|
5766
5770
|
};
|
|
5767
5771
|
}
|
|
5768
5772
|
var ExportParamsSchema = BaseToolSchema.extend({
|
|
5769
|
-
exportDir: z82.string().optional().describe(
|
|
5770
|
-
"Directory to save the exported space data (optional, defaults to current directory)"
|
|
5771
|
-
),
|
|
5772
5773
|
saveFile: z82.boolean().optional().default(true).describe("Save the exported space data to a file"),
|
|
5773
|
-
contentFile: z82.string().optional().describe("Custom filename for the exported space data (optional)"),
|
|
5774
5774
|
includeDrafts: z82.boolean().optional().default(false).describe("Include draft entries in the export"),
|
|
5775
5775
|
includeArchived: z82.boolean().optional().default(false).describe("Include archived entries in the export"),
|
|
5776
5776
|
skipContentModel: z82.boolean().optional().default(false).describe("Skip exporting content types"),
|
|
@@ -5785,7 +5785,6 @@ var ExportParamsSchema = BaseToolSchema.extend({
|
|
|
5785
5785
|
queryAssets: AssetQuerySchema.passthrough().transform(stripUnsupportedQueryKeys(Object.keys(AssetQuerySchema.shape))).optional().describe("Export only assets that match query parameters"),
|
|
5786
5786
|
downloadAssets: z82.boolean().optional().default(false).describe("Download actual asset files"),
|
|
5787
5787
|
maxAllowedLimit: z82.number().optional().default(1e3).describe("Maximum number of items per request"),
|
|
5788
|
-
errorLogFile: z82.string().optional().describe("Path to error log output file"),
|
|
5789
5788
|
useVerboseRenderer: z82.boolean().optional().describe("Line-by-line logging, useful for CI")
|
|
5790
5789
|
});
|
|
5791
5790
|
var ImportParamsSchema = BaseToolSchema.extend({
|
|
@@ -5809,6 +5808,14 @@ var ImportParamsSchema = BaseToolSchema.extend({
|
|
|
5809
5808
|
});
|
|
5810
5809
|
|
|
5811
5810
|
// src/tools/jobs/space-to-space-migration/exportSpace.ts
|
|
5811
|
+
var EXPORT_FILE_NAME = "contentful-export.json";
|
|
5812
|
+
var EXPORT_ERROR_LOG_FILE_NAME = "contentful-export-error.log";
|
|
5813
|
+
async function createExportDirectory(baseDir) {
|
|
5814
|
+
const configuredBase = resolve(baseDir ?? process.cwd());
|
|
5815
|
+
await mkdir(configuredBase, { recursive: true });
|
|
5816
|
+
const canonicalBase = await realpath(configuredBase);
|
|
5817
|
+
return mkdtemp(join(canonicalBase, "contentful-export-"));
|
|
5818
|
+
}
|
|
5812
5819
|
function createExportSpaceTool(config) {
|
|
5813
5820
|
async function tool2(args) {
|
|
5814
5821
|
const clientConfig = createClientConfig(config);
|
|
@@ -5818,12 +5825,16 @@ function createExportSpaceTool(config) {
|
|
|
5818
5825
|
}
|
|
5819
5826
|
const safeOptions = ExportParamsSchema.parse({
|
|
5820
5827
|
...args,
|
|
5821
|
-
environmentId: args.environmentId || "master"
|
|
5822
|
-
exportDir: args.exportDir || process.cwd(),
|
|
5823
|
-
contentFile: args.contentFile || `contentful-export-${args.spaceId}.json`
|
|
5828
|
+
environmentId: args.environmentId || "master"
|
|
5824
5829
|
});
|
|
5830
|
+
const exportDir = await createExportDirectory(config.exportBaseDir);
|
|
5825
5831
|
const exportOptions = {
|
|
5826
5832
|
...safeOptions,
|
|
5833
|
+
exportDir,
|
|
5834
|
+
contentFile: EXPORT_FILE_NAME,
|
|
5835
|
+
// contentful-export resolves a caller-provided errorLogFile relative to
|
|
5836
|
+
// process.cwd(). Pass an absolute, server-generated path instead.
|
|
5837
|
+
errorLogFile: join(exportDir, EXPORT_ERROR_LOG_FILE_NAME),
|
|
5827
5838
|
managementToken,
|
|
5828
5839
|
host: config.host ?? "api.contentful.com",
|
|
5829
5840
|
...config.deliveryToken && { deliveryToken: config.deliveryToken },
|
|
@@ -5831,15 +5842,11 @@ function createExportSpaceTool(config) {
|
|
|
5831
5842
|
};
|
|
5832
5843
|
try {
|
|
5833
5844
|
const contentfulExport = await import("contentful-export");
|
|
5834
|
-
const path = await import("path");
|
|
5835
5845
|
const result = await contentfulExport.default(exportOptions);
|
|
5836
|
-
const exportPath =
|
|
5837
|
-
exportOptions.exportDir,
|
|
5838
|
-
exportOptions.contentFile
|
|
5839
|
-
);
|
|
5846
|
+
const exportPath = join(exportDir, EXPORT_FILE_NAME);
|
|
5840
5847
|
return createSuccessResponse("Space exported successfully", {
|
|
5841
|
-
spaceId:
|
|
5842
|
-
environmentId:
|
|
5848
|
+
spaceId: safeOptions.spaceId,
|
|
5849
|
+
environmentId: safeOptions.environmentId,
|
|
5843
5850
|
exportPath,
|
|
5844
5851
|
contentTypes: result.contentTypes?.length || 0,
|
|
5845
5852
|
entries: result.entries?.length || 0,
|
|
@@ -5873,9 +5880,7 @@ spaceId // [string] [required] - ID of the space with source dat
|
|
|
5873
5880
|
`,
|
|
5874
5881
|
optionalParams: `
|
|
5875
5882
|
environmentId // [string] [default: 'master'] - ID of the environment in the source space
|
|
5876
|
-
exportDir // [string] [default: process.cwd()] - Path to export JSON output
|
|
5877
5883
|
saveFile // [boolean] [default: true] - Save the export as a JSON file
|
|
5878
|
-
contentFile // [string] - Filename for exported data
|
|
5879
5884
|
|
|
5880
5885
|
includeDrafts // [boolean] [default: false] - Include drafts in exported entries
|
|
5881
5886
|
includeArchived // [boolean] [default: false] - Include archived entries
|
|
@@ -5894,7 +5899,6 @@ downloadAssets // [boolean] - Download asset files to disk
|
|
|
5894
5899
|
|
|
5895
5900
|
maxAllowedLimit // [number] [default: 1000] - Page size for requests
|
|
5896
5901
|
|
|
5897
|
-
errorLogFile // [string] - Path to error log output file
|
|
5898
5902
|
useVerboseRenderer // [boolean] [default: false] - Line-by-line logging, useful for CI
|
|
5899
5903
|
`
|
|
5900
5904
|
},
|
|
@@ -6028,17 +6032,18 @@ Once the workflow is started, you will need to call the tools in the following o
|
|
|
6028
6032
|
5. import_space
|
|
6029
6033
|
6. space_to_space_migration_handler with enableWorkflow=false (to conclude the workflow)
|
|
6030
6034
|
|
|
6031
|
-
## Path Configuration
|
|
6032
|
-
-
|
|
6035
|
+
## Path Configuration:
|
|
6036
|
+
- Export output paths are managed by the server and are not user-configurable.
|
|
6037
|
+
- Use the exportPath returned by export_space as the source content file for the import step.
|
|
6033
6038
|
|
|
6034
6039
|
### Asset Handling Paths:
|
|
6035
|
-
- When downloadAssets=true, the export tool creates an assets directory structure
|
|
6040
|
+
- When downloadAssets=true, the export tool creates an assets directory structure next to the returned export file, under: <export directory>/images.ctfassets.net/
|
|
6036
6041
|
- The import tool expects assetsDirectory to point to the images.ctfassets.net directory, not the parent export directory
|
|
6037
6042
|
|
|
6038
6043
|
Troubleshooting:
|
|
6039
6044
|
- If the start_space_to_space_migration is not found, try to call it again on behalf of the user.
|
|
6040
6045
|
- If space_to_space_param_collection or other tools are not found, ask the user to confirm they are ready to proceed, as the tools need to be enabled first.
|
|
6041
|
-
- If import fails with path errors, verify that
|
|
6046
|
+
- If import fails with path errors, verify that the returned exportPath and assetsDirectory paths are correctly aligned and accessible.
|
|
6042
6047
|
`;
|
|
6043
6048
|
|
|
6044
6049
|
// src/tools/jobs/space-to-space-migration/migrationHandler.ts
|