@contentful/mcp-tools 0.3.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -4268,12 +4268,12 @@ declare class ContentfulMcpTools {
4268
4268
  spaceId: string;
4269
4269
  environmentId: string;
4270
4270
  query: {
4271
+ query?: string | undefined;
4271
4272
  skip?: number | undefined;
4272
4273
  limit?: number | undefined;
4273
4274
  select?: string | undefined;
4274
4275
  include?: number | undefined;
4275
4276
  order?: string | undefined;
4276
- query?: string | undefined;
4277
4277
  links_to_entry?: string | undefined;
4278
4278
  content_type?: string | undefined;
4279
4279
  'fields.title'?: string | undefined;
@@ -5479,7 +5479,6 @@ declare class ContentfulMcpTools {
5479
5479
  organizationId: zod.ZodString;
5480
5480
  conceptId: zod.ZodOptional<zod.ZodString>;
5481
5481
  limit: zod.ZodOptional<zod.ZodNumber>;
5482
- skip: zod.ZodOptional<zod.ZodNumber>;
5483
5482
  select: zod.ZodOptional<zod.ZodString>;
5484
5483
  include: zod.ZodOptional<zod.ZodNumber>;
5485
5484
  order: zod.ZodOptional<zod.ZodString>;
@@ -5493,7 +5492,6 @@ declare class ContentfulMcpTools {
5493
5492
  };
5494
5493
  tool: (params: {
5495
5494
  organizationId: string;
5496
- skip?: number | undefined;
5497
5495
  limit?: number | undefined;
5498
5496
  select?: string | undefined;
5499
5497
  include?: number | undefined;
@@ -5723,11 +5721,34 @@ declare class ContentfulMcpTools {
5723
5721
  description: string;
5724
5722
  inputParams: {
5725
5723
  organizationId: zod.ZodString;
5726
- limit: zod.ZodOptional<zod.ZodNumber>;
5727
- skip: zod.ZodOptional<zod.ZodNumber>;
5728
- select: zod.ZodOptional<zod.ZodString>;
5729
- include: zod.ZodOptional<zod.ZodNumber>;
5730
- order: zod.ZodOptional<zod.ZodString>;
5724
+ query: zod.ZodOptional<zod.ZodUnion<[zod.ZodObject<{
5725
+ query: zod.ZodOptional<zod.ZodString>;
5726
+ pageNext: zod.ZodOptional<zod.ZodString>;
5727
+ pagePrev: zod.ZodOptional<zod.ZodString>;
5728
+ limit: zod.ZodOptional<zod.ZodNumber>;
5729
+ order: zod.ZodOptional<zod.ZodString>;
5730
+ skip: zod.ZodOptional<zod.ZodNever>;
5731
+ }, "passthrough", zod.ZodTypeAny, zod.objectOutputType<{
5732
+ query: zod.ZodOptional<zod.ZodString>;
5733
+ pageNext: zod.ZodOptional<zod.ZodString>;
5734
+ pagePrev: zod.ZodOptional<zod.ZodString>;
5735
+ limit: zod.ZodOptional<zod.ZodNumber>;
5736
+ order: zod.ZodOptional<zod.ZodString>;
5737
+ skip: zod.ZodOptional<zod.ZodNever>;
5738
+ }, zod.ZodTypeAny, "passthrough">, zod.objectInputType<{
5739
+ query: zod.ZodOptional<zod.ZodString>;
5740
+ pageNext: zod.ZodOptional<zod.ZodString>;
5741
+ pagePrev: zod.ZodOptional<zod.ZodString>;
5742
+ limit: zod.ZodOptional<zod.ZodNumber>;
5743
+ order: zod.ZodOptional<zod.ZodString>;
5744
+ skip: zod.ZodOptional<zod.ZodNever>;
5745
+ }, zod.ZodTypeAny, "passthrough">>, zod.ZodObject<{
5746
+ pageUrl: zod.ZodOptional<zod.ZodString>;
5747
+ }, "strip", zod.ZodTypeAny, {
5748
+ pageUrl?: string | undefined;
5749
+ }, {
5750
+ pageUrl?: string | undefined;
5751
+ }>]>>;
5731
5752
  };
5732
5753
  annotations: {
5733
5754
  readOnlyHint: boolean;
@@ -5735,11 +5756,16 @@ declare class ContentfulMcpTools {
5735
5756
  };
5736
5757
  tool: (params: {
5737
5758
  organizationId: string;
5738
- skip?: number | undefined;
5739
- limit?: number | undefined;
5740
- select?: string | undefined;
5741
- include?: number | undefined;
5742
- order?: string | undefined;
5759
+ query?: zod.objectOutputType<{
5760
+ query: zod.ZodOptional<zod.ZodString>;
5761
+ pageNext: zod.ZodOptional<zod.ZodString>;
5762
+ pagePrev: zod.ZodOptional<zod.ZodString>;
5763
+ limit: zod.ZodOptional<zod.ZodNumber>;
5764
+ order: zod.ZodOptional<zod.ZodString>;
5765
+ skip: zod.ZodOptional<zod.ZodNever>;
5766
+ }, zod.ZodTypeAny, "passthrough"> | {
5767
+ pageUrl?: string | undefined;
5768
+ } | undefined;
5743
5769
  }, extra?: _modelcontextprotocol_sdk_shared_protocol_js.RequestHandlerExtra<_modelcontextprotocol_sdk_types_js.ServerRequest, _modelcontextprotocol_sdk_types_js.ServerNotification>) => Promise<ToolResponse>;
5744
5770
  };
5745
5771
  updateConceptScheme: {
package/dist/index.js CHANGED
@@ -3689,28 +3689,58 @@ function getConceptSchemeTool(config) {
3689
3689
  // src/tools/taxonomies/concept-schemes/listConceptSchemes.ts
3690
3690
  import { z as z63 } from "zod";
3691
3691
  import ctfl8 from "contentful-management";
3692
+ import { cloneDeep } from "lodash-es";
3692
3693
  var ListConceptSchemesToolParams = z63.object({
3693
- organizationId: z63.string().describe("The ID of the Contentful organization"),
3694
- limit: z63.number().optional().describe("Maximum number of concept schemes to return"),
3695
- skip: z63.number().optional().describe("Skip this many concept schemes for pagination"),
3696
- select: z63.string().optional().describe("Comma-separated list of fields to return"),
3697
- include: z63.number().optional().describe("Include this many levels of linked entries"),
3698
- order: z63.string().optional().describe("Order concept schemes by this field")
3699
- });
3694
+ organizationId: z63.string(),
3695
+ query: z63.union([
3696
+ z63.object({
3697
+ query: z63.string().optional(),
3698
+ pageNext: z63.string().optional().describe("Cursor token for the next page of concept schemes"),
3699
+ pagePrev: z63.string().optional().describe(
3700
+ "Cursor token for the previous page of concept schemes"
3701
+ ),
3702
+ limit: z63.number().optional().describe("Maximum number of concept schemes to return"),
3703
+ order: z63.string().optional().describe("Order concept schemes by this field"),
3704
+ skip: z63.never().optional()
3705
+ }).passthrough(),
3706
+ // handles [key: string]: any from BasicQueryOptions
3707
+ z63.object({
3708
+ pageUrl: z63.string().optional()
3709
+ })
3710
+ ]).optional().describe(
3711
+ 'Query parameters for listing concept schemes, supports either pageUrl for cursor-based pagination. Offset "skip" pagination is not supported.'
3712
+ )
3713
+ }).describe(
3714
+ "Parameters for listing concept schemes, cursor-based pagination is strictly enforced"
3715
+ );
3700
3716
  function listConceptSchemesTool(config) {
3701
3717
  async function tool2(args) {
3702
3718
  const clientConfig = createClientConfig(config);
3703
3719
  delete clientConfig.space;
3704
3720
  const contentfulClient = ctfl8.createClient(clientConfig, { type: "plain" });
3721
+ const query = {};
3722
+ if (args.query) {
3723
+ if ("pageUrl" in args.query && args.query.pageUrl) {
3724
+ query["pageUrl"] = args.query.pageUrl;
3725
+ } else {
3726
+ const complexQuery = cloneDeep(args.query);
3727
+ if (complexQuery["query"]) query["query"] = complexQuery["query"];
3728
+ if (complexQuery["pageNext"])
3729
+ query["pageNext"] = complexQuery["pageNext"];
3730
+ if (complexQuery["pagePrev"])
3731
+ query["pagePrev"] = complexQuery["pagePrev"];
3732
+ if (complexQuery["select"]) query["select"] = complexQuery["select"];
3733
+ if (complexQuery["include"]) query["include"] = complexQuery["include"];
3734
+ if (complexQuery["order"]) query["order"] = complexQuery["order"];
3735
+ if (complexQuery["limit"]) query["limit"] = complexQuery["limit"];
3736
+ }
3737
+ }
3738
+ if (!query["limit"] && !query["pageUrl"]) {
3739
+ query["limit"] = 10;
3740
+ }
3705
3741
  const conceptSchemes = await contentfulClient.conceptScheme.getMany({
3706
3742
  organizationId: args.organizationId,
3707
- query: {
3708
- limit: args.limit || 10,
3709
- skip: args.skip || 0,
3710
- ...args.select && { select: args.select },
3711
- ...args.include && { include: args.include },
3712
- ...args.order && { order: args.order }
3713
- }
3743
+ query
3714
3744
  });
3715
3745
  const summarizedConceptSchemes = conceptSchemes.items.map(
3716
3746
  (conceptScheme) => ({
@@ -3731,14 +3761,14 @@ function listConceptSchemesTool(config) {
3731
3761
  },
3732
3762
  {
3733
3763
  maxItems: 10,
3734
- remainingMessage: "To see more concept schemes, please ask me to retrieve the next page using the skip parameter."
3764
+ remainingMessage: "To see more concept schemes, please ask me to retrieve the next page using cursor based pagination with pageNext and pagePrev."
3735
3765
  }
3736
3766
  );
3767
+ const queryLimit = args.query && "limit" in args.query ? args.query.limit : void 0;
3737
3768
  return createSuccessResponse("Concept schemes retrieved successfully", {
3738
3769
  conceptSchemes: summarized,
3739
3770
  total: conceptSchemes.total || conceptSchemes.items.length,
3740
- limit: conceptSchemes.limit || args.limit || 10,
3741
- skip: conceptSchemes.skip || args.skip || 0
3771
+ limit: conceptSchemes.limit || queryLimit || 10
3742
3772
  });
3743
3773
  }
3744
3774
  return withErrorHandling(tool2, "Error listing concept schemes");
@@ -4093,7 +4123,6 @@ var ListConceptsToolParams = z70.object({
4093
4123
  organizationId: z70.string().describe("The ID of the Contentful organization"),
4094
4124
  conceptId: z70.string().optional().describe("The ID of the concept (required for descendants/ancestors)"),
4095
4125
  limit: z70.number().optional().describe("Maximum number of concepts to return"),
4096
- skip: z70.number().optional().describe("Skip this many concepts for pagination"),
4097
4126
  select: z70.string().optional().describe("Comma-separated list of fields to return"),
4098
4127
  include: z70.number().optional().describe("Include this many levels of linked entries"),
4099
4128
  order: z70.string().optional().describe("Order concepts by this field"),
@@ -4124,7 +4153,6 @@ function listConceptsTool(config) {
4124
4153
  organizationId: args.organizationId,
4125
4154
  conceptId: args.conceptId,
4126
4155
  ...args.limit && { limit: args.limit },
4127
- ...args.skip && { skip: args.skip },
4128
4156
  ...args.select && { select: args.select },
4129
4157
  ...args.include && { include: args.include },
4130
4158
  ...args.order && { order: args.order }
@@ -4150,7 +4178,6 @@ function listConceptsTool(config) {
4150
4178
  organizationId: args.organizationId,
4151
4179
  conceptId: args.conceptId,
4152
4180
  ...args.limit && { limit: args.limit },
4153
- ...args.skip && { skip: args.skip },
4154
4181
  ...args.select && { select: args.select },
4155
4182
  ...args.include && { include: args.include },
4156
4183
  ...args.order && { order: args.order }
@@ -4175,7 +4202,6 @@ function listConceptsTool(config) {
4175
4202
  organizationId: args.organizationId,
4176
4203
  query: {
4177
4204
  limit: args.limit || 10,
4178
- skip: args.skip || 0,
4179
4205
  ...args.select && { select: args.select },
4180
4206
  ...args.include && { include: args.include },
4181
4207
  ...args.order && { order: args.order }
@@ -4279,6 +4305,8 @@ function createTaxonomyTools(config) {
4279
4305
 
4280
4306
  // src/tools/jobs/space-to-space-migration/exportSpace.ts
4281
4307
  import { z as z72 } from "zod";
4308
+ import * as contentfulExportModule from "contentful-export";
4309
+ import { join } from "path";
4282
4310
 
4283
4311
  // src/types/querySchema.ts
4284
4312
  import { z as z71 } from "zod";
@@ -4300,6 +4328,7 @@ var AssetQuerySchema = z71.object({
4300
4328
  });
4301
4329
 
4302
4330
  // src/tools/jobs/space-to-space-migration/exportSpace.ts
4331
+ var contentfulExport = contentfulExportModule.default ?? contentfulExportModule;
4303
4332
  var ExportSpaceToolParams = BaseToolSchema.extend({
4304
4333
  exportDir: z72.string().optional().describe(
4305
4334
  "Directory to save the exported space data (optional, defaults to current directory)"
@@ -4349,10 +4378,8 @@ function createExportSpaceTool(config) {
4349
4378
  contentFile: args.contentFile || `contentful-export-${args.spaceId}.json`
4350
4379
  };
4351
4380
  try {
4352
- const contentfulExport = await import("contentful-export");
4353
- const path = await import("path");
4354
- const result = await contentfulExport.default(exportOptions);
4355
- const exportPath = path.join(
4381
+ const result = await contentfulExport(exportOptions);
4382
+ const exportPath = join(
4356
4383
  exportOptions.exportDir,
4357
4384
  exportOptions.contentFile
4358
4385
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/mcp-tools",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -27,6 +27,7 @@
27
27
  "dev": "tsup --watch",
28
28
  "test": "vitest",
29
29
  "test:run": "vitest run",
30
+ "typecheck": "tsc --noEmit -p tsconfig.lib.json && tsc --noEmit -p tsconfig.spec.json",
30
31
  "format": "prettier --check \"**/*.{ts,js,json,md}\"",
31
32
  "format:fix": "prettier --write \"**/*.{ts,js,json,md}\"",
32
33
  "lint": "eslint --ext .ts,.js .",
@@ -46,12 +47,14 @@
46
47
  "contentful-import": "^9.4.129",
47
48
  "contentful-management": "^11.54.3",
48
49
  "fast-xml-parser": "^5.3.8",
50
+ "lodash-es": "^4.17.23",
49
51
  "outdent": "^0.8.0",
50
52
  "tsup": "^8.5.0",
51
53
  "vitest": "^3.2.4",
52
54
  "zod": "^3.25.76"
53
55
  },
54
56
  "devDependencies": {
57
+ "@types/lodash-es": "^4.17.12",
55
58
  "@types/node": "^22.16.5",
56
59
  "eslint": "^9.35.0",
57
60
  "prettier": "^3.6.2",