@contentful/mcp-tools 0.3.0 → 0.4.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/dist/index.d.ts +39 -13
- package/dist/index.js +120 -65
- package/package.json +5 -2
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
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
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
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
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
|
@@ -54,7 +54,7 @@ function withErrorHandling(handler, errorPrefix = "Error") {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// src/utils/tools.ts
|
|
57
|
-
import
|
|
57
|
+
import { createClient } from "contentful-management";
|
|
58
58
|
import { z } from "zod";
|
|
59
59
|
var BaseToolSchema = z.object({
|
|
60
60
|
spaceId: z.string().describe("The ID of the Contentful space"),
|
|
@@ -69,7 +69,7 @@ function createToolClient(config, params) {
|
|
|
69
69
|
"X-Contentful-User-Agent-Tool": `contentful-mcp/${config.mcpVersion}`
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
return
|
|
72
|
+
return createClient(clientConfig);
|
|
73
73
|
}
|
|
74
74
|
function createClientConfig(config) {
|
|
75
75
|
const clientConfig = {
|
|
@@ -750,7 +750,9 @@ var AssetMetadataSchema = z13.object({
|
|
|
750
750
|
var FileSchema = z14.object({
|
|
751
751
|
fileName: z14.string().describe("The name of the file"),
|
|
752
752
|
contentType: z14.string().describe("The MIME type of the file"),
|
|
753
|
-
upload: z14.string().optional().describe(
|
|
753
|
+
upload: z14.string().optional().describe(
|
|
754
|
+
"The file source. Accepts either a publicly accessible https:// URL, or a base64-encoded data URI (e.g. data:image/png;base64,...). Use the data URI format to upload local files \u2014 the MCP client should base64-encode the file before passing it here."
|
|
755
|
+
)
|
|
754
756
|
});
|
|
755
757
|
var UploadAssetToolParams = BaseToolSchema.extend({
|
|
756
758
|
title: z14.string().describe("The title of the asset"),
|
|
@@ -769,11 +771,37 @@ function uploadAssetTool(config) {
|
|
|
769
771
|
};
|
|
770
772
|
const contentfulClient = createToolClient(config, args);
|
|
771
773
|
const locale = args.locale || "en-US";
|
|
774
|
+
const fileField = {
|
|
775
|
+
fileName: args.file.fileName,
|
|
776
|
+
contentType: args.file.contentType
|
|
777
|
+
};
|
|
778
|
+
if (args.file.upload?.startsWith("data:")) {
|
|
779
|
+
const commaIndex = args.file.upload.indexOf(",");
|
|
780
|
+
if (commaIndex === -1) {
|
|
781
|
+
throw new Error(
|
|
782
|
+
"Invalid data URI format. Expected data:<mime>;base64,<data>"
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
const base64 = args.file.upload.slice(commaIndex + 1);
|
|
786
|
+
const decoded = Buffer.from(base64, "base64");
|
|
787
|
+
const buffer = decoded.buffer.slice(
|
|
788
|
+
decoded.byteOffset,
|
|
789
|
+
decoded.byteOffset + decoded.byteLength
|
|
790
|
+
);
|
|
791
|
+
const upload = await contentfulClient.upload.create(params, {
|
|
792
|
+
file: buffer
|
|
793
|
+
});
|
|
794
|
+
fileField.uploadFrom = {
|
|
795
|
+
sys: { type: "Link", linkType: "Upload", id: upload.sys.id }
|
|
796
|
+
};
|
|
797
|
+
} else if (args.file.upload) {
|
|
798
|
+
fileField.upload = args.file.upload;
|
|
799
|
+
}
|
|
772
800
|
const assetProps = {
|
|
773
801
|
fields: {
|
|
774
802
|
title: { [locale]: args.title },
|
|
775
803
|
description: args.description ? { [locale]: args.description } : void 0,
|
|
776
|
-
file: { [locale]:
|
|
804
|
+
file: { [locale]: fileField }
|
|
777
805
|
},
|
|
778
806
|
metadata: args.metadata
|
|
779
807
|
};
|
|
@@ -1260,7 +1288,7 @@ function createAssetTools(config) {
|
|
|
1260
1288
|
return {
|
|
1261
1289
|
uploadAsset: {
|
|
1262
1290
|
title: "upload_asset",
|
|
1263
|
-
description: "Upload a new asset",
|
|
1291
|
+
description: "Upload a new asset. When uploading local binary files as base64, always re-encode from the source file immediately before the tool call \u2014 never re-use base64 from a previous tool output or from context.",
|
|
1264
1292
|
inputParams: UploadAssetToolParams.shape,
|
|
1265
1293
|
annotations: {
|
|
1266
1294
|
readOnlyHint: false,
|
|
@@ -3300,7 +3328,7 @@ function createLocaleTools(config) {
|
|
|
3300
3328
|
|
|
3301
3329
|
// src/tools/orgs/listOrgs.ts
|
|
3302
3330
|
import { z as z54 } from "zod";
|
|
3303
|
-
import
|
|
3331
|
+
import { createClient as createClient2 } from "contentful-management";
|
|
3304
3332
|
var ListOrgsToolParams = z54.object({
|
|
3305
3333
|
limit: z54.number().optional().describe("Maximum number of organizations to return (max 10)"),
|
|
3306
3334
|
skip: z54.number().optional().describe("Skip this many organizations for pagination"),
|
|
@@ -3311,7 +3339,7 @@ function listOrgsTool(config) {
|
|
|
3311
3339
|
async function tool2(args) {
|
|
3312
3340
|
const clientConfig = createClientConfig(config);
|
|
3313
3341
|
delete clientConfig.space;
|
|
3314
|
-
const contentfulClient =
|
|
3342
|
+
const contentfulClient = createClient2(clientConfig);
|
|
3315
3343
|
const organizations = await contentfulClient.organization.getAll({
|
|
3316
3344
|
query: {
|
|
3317
3345
|
limit: Math.min(args.limit || 10, 10),
|
|
@@ -3348,7 +3376,7 @@ function listOrgsTool(config) {
|
|
|
3348
3376
|
|
|
3349
3377
|
// src/tools/orgs/getOrg.ts
|
|
3350
3378
|
import { z as z55 } from "zod";
|
|
3351
|
-
import
|
|
3379
|
+
import { createClient as createClient3 } from "contentful-management";
|
|
3352
3380
|
var GetOrgToolParams = z55.object({
|
|
3353
3381
|
organizationId: z55.string().describe("The ID of the organization to retrieve")
|
|
3354
3382
|
});
|
|
@@ -3356,7 +3384,7 @@ function getOrgTool(config) {
|
|
|
3356
3384
|
async function tool2(args) {
|
|
3357
3385
|
const clientConfig = createClientConfig(config);
|
|
3358
3386
|
delete clientConfig.space;
|
|
3359
|
-
const contentfulClient =
|
|
3387
|
+
const contentfulClient = createClient3(clientConfig);
|
|
3360
3388
|
const organization = await contentfulClient.organization.get({
|
|
3361
3389
|
organizationId: args.organizationId
|
|
3362
3390
|
});
|
|
@@ -3397,7 +3425,7 @@ function createOrgTools(config) {
|
|
|
3397
3425
|
|
|
3398
3426
|
// src/tools/spaces/listSpaces.ts
|
|
3399
3427
|
import { z as z56 } from "zod";
|
|
3400
|
-
import
|
|
3428
|
+
import { createClient as createClient4 } from "contentful-management";
|
|
3401
3429
|
var ListSpacesToolParams = z56.object({
|
|
3402
3430
|
limit: z56.number().optional().describe("Maximum number of spaces to return (max 10)"),
|
|
3403
3431
|
skip: z56.number().optional().describe("Skip this many spaces for pagination"),
|
|
@@ -3408,7 +3436,7 @@ function listSpacesTool(config) {
|
|
|
3408
3436
|
async function tool2(args) {
|
|
3409
3437
|
const clientConfig = createClientConfig(config);
|
|
3410
3438
|
delete clientConfig.space;
|
|
3411
|
-
const contentfulClient =
|
|
3439
|
+
const contentfulClient = createClient4(clientConfig);
|
|
3412
3440
|
const spaces = await contentfulClient.space.getMany({
|
|
3413
3441
|
query: {
|
|
3414
3442
|
limit: Math.min(args.limit || 10, 10),
|
|
@@ -3445,7 +3473,7 @@ function listSpacesTool(config) {
|
|
|
3445
3473
|
|
|
3446
3474
|
// src/tools/spaces/getSpace.ts
|
|
3447
3475
|
import { z as z57 } from "zod";
|
|
3448
|
-
import
|
|
3476
|
+
import { createClient as createClient5 } from "contentful-management";
|
|
3449
3477
|
var GetSpaceToolParams = z57.object({
|
|
3450
3478
|
spaceId: z57.string().describe("The ID of the space to retrieve")
|
|
3451
3479
|
});
|
|
@@ -3453,7 +3481,7 @@ function getSpaceTool(config) {
|
|
|
3453
3481
|
async function tool2(args) {
|
|
3454
3482
|
const clientConfig = createClientConfig(config);
|
|
3455
3483
|
delete clientConfig.space;
|
|
3456
|
-
const contentfulClient =
|
|
3484
|
+
const contentfulClient = createClient5(clientConfig);
|
|
3457
3485
|
const space = await contentfulClient.space.get({
|
|
3458
3486
|
spaceId: args.spaceId
|
|
3459
3487
|
});
|
|
@@ -3597,7 +3625,7 @@ function createTagTools(config) {
|
|
|
3597
3625
|
|
|
3598
3626
|
// src/tools/taxonomies/concept-schemes/createConceptScheme.ts
|
|
3599
3627
|
import { z as z61 } from "zod";
|
|
3600
|
-
import
|
|
3628
|
+
import { createClient as createClient6 } from "contentful-management";
|
|
3601
3629
|
|
|
3602
3630
|
// src/types/conceptPayloadTypes.ts
|
|
3603
3631
|
import { z as z60 } from "zod";
|
|
@@ -3629,7 +3657,7 @@ function createConceptSchemeTool(config) {
|
|
|
3629
3657
|
async function tool2(args) {
|
|
3630
3658
|
const clientConfig = createClientConfig(config);
|
|
3631
3659
|
delete clientConfig.space;
|
|
3632
|
-
const contentfulClient =
|
|
3660
|
+
const contentfulClient = createClient6(clientConfig);
|
|
3633
3661
|
const conceptSchemePayload = {
|
|
3634
3662
|
prefLabel: args.prefLabel,
|
|
3635
3663
|
...Object.fromEntries(
|
|
@@ -3664,7 +3692,7 @@ function createConceptSchemeTool(config) {
|
|
|
3664
3692
|
|
|
3665
3693
|
// src/tools/taxonomies/concept-schemes/getConceptScheme.ts
|
|
3666
3694
|
import { z as z62 } from "zod";
|
|
3667
|
-
import
|
|
3695
|
+
import { createClient as createClient7 } from "contentful-management";
|
|
3668
3696
|
var GetConceptSchemeToolParams = z62.object({
|
|
3669
3697
|
organizationId: z62.string().describe("The ID of the Contentful organization"),
|
|
3670
3698
|
conceptSchemeId: z62.string().describe("The ID of the concept scheme to retrieve")
|
|
@@ -3673,7 +3701,7 @@ function getConceptSchemeTool(config) {
|
|
|
3673
3701
|
async function tool2(args) {
|
|
3674
3702
|
const clientConfig = createClientConfig(config);
|
|
3675
3703
|
delete clientConfig.space;
|
|
3676
|
-
const contentfulClient =
|
|
3704
|
+
const contentfulClient = createClient7(clientConfig);
|
|
3677
3705
|
const params = {
|
|
3678
3706
|
organizationId: args.organizationId,
|
|
3679
3707
|
conceptSchemeId: args.conceptSchemeId
|
|
@@ -3688,29 +3716,59 @@ function getConceptSchemeTool(config) {
|
|
|
3688
3716
|
|
|
3689
3717
|
// src/tools/taxonomies/concept-schemes/listConceptSchemes.ts
|
|
3690
3718
|
import { z as z63 } from "zod";
|
|
3691
|
-
import
|
|
3719
|
+
import { createClient as createClient8 } from "contentful-management";
|
|
3720
|
+
import { cloneDeep } from "lodash-es";
|
|
3692
3721
|
var ListConceptSchemesToolParams = z63.object({
|
|
3693
|
-
organizationId: z63.string()
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3722
|
+
organizationId: z63.string(),
|
|
3723
|
+
query: z63.union([
|
|
3724
|
+
z63.object({
|
|
3725
|
+
query: z63.string().optional(),
|
|
3726
|
+
pageNext: z63.string().optional().describe("Cursor token for the next page of concept schemes"),
|
|
3727
|
+
pagePrev: z63.string().optional().describe(
|
|
3728
|
+
"Cursor token for the previous page of concept schemes"
|
|
3729
|
+
),
|
|
3730
|
+
limit: z63.number().optional().describe("Maximum number of concept schemes to return"),
|
|
3731
|
+
order: z63.string().optional().describe("Order concept schemes by this field"),
|
|
3732
|
+
skip: z63.never().optional()
|
|
3733
|
+
}).passthrough(),
|
|
3734
|
+
// handles [key: string]: any from BasicQueryOptions
|
|
3735
|
+
z63.object({
|
|
3736
|
+
pageUrl: z63.string().optional()
|
|
3737
|
+
})
|
|
3738
|
+
]).optional().describe(
|
|
3739
|
+
'Query parameters for listing concept schemes, supports either pageUrl for cursor-based pagination. Offset "skip" pagination is not supported.'
|
|
3740
|
+
)
|
|
3741
|
+
}).describe(
|
|
3742
|
+
"Parameters for listing concept schemes, cursor-based pagination is strictly enforced"
|
|
3743
|
+
);
|
|
3700
3744
|
function listConceptSchemesTool(config) {
|
|
3701
3745
|
async function tool2(args) {
|
|
3702
3746
|
const clientConfig = createClientConfig(config);
|
|
3703
3747
|
delete clientConfig.space;
|
|
3704
|
-
const contentfulClient =
|
|
3748
|
+
const contentfulClient = createClient8(clientConfig);
|
|
3749
|
+
const query = {};
|
|
3750
|
+
if (args.query) {
|
|
3751
|
+
if ("pageUrl" in args.query && args.query.pageUrl) {
|
|
3752
|
+
query["pageUrl"] = args.query.pageUrl;
|
|
3753
|
+
} else {
|
|
3754
|
+
const complexQuery = cloneDeep(args.query);
|
|
3755
|
+
if (complexQuery["query"]) query["query"] = complexQuery["query"];
|
|
3756
|
+
if (complexQuery["pageNext"])
|
|
3757
|
+
query["pageNext"] = complexQuery["pageNext"];
|
|
3758
|
+
if (complexQuery["pagePrev"])
|
|
3759
|
+
query["pagePrev"] = complexQuery["pagePrev"];
|
|
3760
|
+
if (complexQuery["select"]) query["select"] = complexQuery["select"];
|
|
3761
|
+
if (complexQuery["include"]) query["include"] = complexQuery["include"];
|
|
3762
|
+
if (complexQuery["order"]) query["order"] = complexQuery["order"];
|
|
3763
|
+
if (complexQuery["limit"]) query["limit"] = complexQuery["limit"];
|
|
3764
|
+
}
|
|
3765
|
+
}
|
|
3766
|
+
if (!query["limit"] && !query["pageUrl"]) {
|
|
3767
|
+
query["limit"] = 10;
|
|
3768
|
+
}
|
|
3705
3769
|
const conceptSchemes = await contentfulClient.conceptScheme.getMany({
|
|
3706
3770
|
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
|
-
}
|
|
3771
|
+
query
|
|
3714
3772
|
});
|
|
3715
3773
|
const summarizedConceptSchemes = conceptSchemes.items.map(
|
|
3716
3774
|
(conceptScheme) => ({
|
|
@@ -3731,14 +3789,14 @@ function listConceptSchemesTool(config) {
|
|
|
3731
3789
|
},
|
|
3732
3790
|
{
|
|
3733
3791
|
maxItems: 10,
|
|
3734
|
-
remainingMessage: "To see more concept schemes, please ask me to retrieve the next page using
|
|
3792
|
+
remainingMessage: "To see more concept schemes, please ask me to retrieve the next page using cursor based pagination with pageNext and pagePrev."
|
|
3735
3793
|
}
|
|
3736
3794
|
);
|
|
3795
|
+
const queryLimit = args.query && "limit" in args.query ? args.query.limit : void 0;
|
|
3737
3796
|
return createSuccessResponse("Concept schemes retrieved successfully", {
|
|
3738
3797
|
conceptSchemes: summarized,
|
|
3739
3798
|
total: conceptSchemes.total || conceptSchemes.items.length,
|
|
3740
|
-
limit: conceptSchemes.limit ||
|
|
3741
|
-
skip: conceptSchemes.skip || args.skip || 0
|
|
3799
|
+
limit: conceptSchemes.limit || queryLimit || 10
|
|
3742
3800
|
});
|
|
3743
3801
|
}
|
|
3744
3802
|
return withErrorHandling(tool2, "Error listing concept schemes");
|
|
@@ -3746,7 +3804,7 @@ function listConceptSchemesTool(config) {
|
|
|
3746
3804
|
|
|
3747
3805
|
// src/tools/taxonomies/concept-schemes/updateConceptScheme.ts
|
|
3748
3806
|
import { z as z64 } from "zod";
|
|
3749
|
-
import
|
|
3807
|
+
import { createClient as createClient9 } from "contentful-management";
|
|
3750
3808
|
var UpdateConceptSchemeToolParams = z64.object({
|
|
3751
3809
|
organizationId: z64.string().describe("The ID of the Contentful organization"),
|
|
3752
3810
|
conceptSchemeId: z64.string().describe("The ID of the concept scheme to update"),
|
|
@@ -3768,7 +3826,7 @@ function updateConceptSchemeTool(config) {
|
|
|
3768
3826
|
async function tool2(args) {
|
|
3769
3827
|
const clientConfig = createClientConfig(config);
|
|
3770
3828
|
delete clientConfig.space;
|
|
3771
|
-
const contentfulClient =
|
|
3829
|
+
const contentfulClient = createClient9(clientConfig);
|
|
3772
3830
|
const params = {
|
|
3773
3831
|
organizationId: args.organizationId,
|
|
3774
3832
|
conceptSchemeId: args.conceptSchemeId
|
|
@@ -3795,11 +3853,11 @@ function updateConceptSchemeTool(config) {
|
|
|
3795
3853
|
}
|
|
3796
3854
|
});
|
|
3797
3855
|
if (args.uri !== void 0) {
|
|
3798
|
-
|
|
3799
|
-
op:
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
}
|
|
3856
|
+
if (args.uri === null) {
|
|
3857
|
+
patchOperations.push({ op: "remove", path: "/uri" });
|
|
3858
|
+
} else {
|
|
3859
|
+
patchOperations.push({ op: "replace", path: "/uri", value: args.uri });
|
|
3860
|
+
}
|
|
3803
3861
|
}
|
|
3804
3862
|
if (args.addConcept) {
|
|
3805
3863
|
const conceptLink = {
|
|
@@ -3820,7 +3878,7 @@ function updateConceptSchemeTool(config) {
|
|
|
3820
3878
|
value: conceptLink
|
|
3821
3879
|
});
|
|
3822
3880
|
}
|
|
3823
|
-
const updatedConceptScheme = await contentfulClient.conceptScheme.
|
|
3881
|
+
const updatedConceptScheme = await contentfulClient.conceptScheme.patch(
|
|
3824
3882
|
{
|
|
3825
3883
|
...params,
|
|
3826
3884
|
version: args.version
|
|
@@ -3836,7 +3894,7 @@ function updateConceptSchemeTool(config) {
|
|
|
3836
3894
|
|
|
3837
3895
|
// src/tools/taxonomies/concept-schemes/deleteConceptScheme.ts
|
|
3838
3896
|
import { z as z65 } from "zod";
|
|
3839
|
-
import
|
|
3897
|
+
import { createClient as createClient10 } from "contentful-management";
|
|
3840
3898
|
var DeleteConceptSchemeToolParams = z65.object({
|
|
3841
3899
|
organizationId: z65.string().describe("The ID of the Contentful organization"),
|
|
3842
3900
|
conceptSchemeId: z65.string().describe("The ID of the concept scheme to delete"),
|
|
@@ -3846,7 +3904,7 @@ function deleteConceptSchemeTool(config) {
|
|
|
3846
3904
|
async function tool2(args) {
|
|
3847
3905
|
const clientConfig = createClientConfig(config);
|
|
3848
3906
|
delete clientConfig.space;
|
|
3849
|
-
const contentfulClient =
|
|
3907
|
+
const contentfulClient = createClient10(clientConfig);
|
|
3850
3908
|
await contentfulClient.conceptScheme.delete({
|
|
3851
3909
|
organizationId: args.organizationId,
|
|
3852
3910
|
conceptSchemeId: args.conceptSchemeId,
|
|
@@ -3928,7 +3986,7 @@ function createConceptSchemeTools(config) {
|
|
|
3928
3986
|
|
|
3929
3987
|
// src/tools/taxonomies/concepts/createConcept.ts
|
|
3930
3988
|
import { z as z66 } from "zod";
|
|
3931
|
-
import
|
|
3989
|
+
import { createClient as createClient11 } from "contentful-management";
|
|
3932
3990
|
var CreateConceptToolParams = z66.object({
|
|
3933
3991
|
organizationId: z66.string().describe("The ID of the Contentful organization"),
|
|
3934
3992
|
conceptId: z66.string().optional().describe(
|
|
@@ -3952,7 +4010,7 @@ function createConceptTool(config) {
|
|
|
3952
4010
|
async function tool2(args) {
|
|
3953
4011
|
const clientConfig = createClientConfig(config);
|
|
3954
4012
|
delete clientConfig.space;
|
|
3955
|
-
const contentfulClient =
|
|
4013
|
+
const contentfulClient = createClient11(clientConfig);
|
|
3956
4014
|
const conceptPayload = {
|
|
3957
4015
|
prefLabel: args.prefLabel,
|
|
3958
4016
|
...args.uri !== void 0 && { uri: args.uri },
|
|
@@ -3982,7 +4040,7 @@ function createConceptTool(config) {
|
|
|
3982
4040
|
|
|
3983
4041
|
// src/tools/taxonomies/concepts/deleteConcept.ts
|
|
3984
4042
|
import { z as z67 } from "zod";
|
|
3985
|
-
import
|
|
4043
|
+
import { createClient as createClient12 } from "contentful-management";
|
|
3986
4044
|
var DeleteConceptToolParams = z67.object({
|
|
3987
4045
|
organizationId: z67.string().describe("The ID of the Contentful organization"),
|
|
3988
4046
|
conceptId: z67.string().describe("The ID of the concept to delete"),
|
|
@@ -3992,7 +4050,7 @@ function deleteConceptTool(config) {
|
|
|
3992
4050
|
async function tool2(args) {
|
|
3993
4051
|
const clientConfig = createClientConfig(config);
|
|
3994
4052
|
delete clientConfig.space;
|
|
3995
|
-
const contentfulClient =
|
|
4053
|
+
const contentfulClient = createClient12(clientConfig);
|
|
3996
4054
|
await contentfulClient.concept.delete({
|
|
3997
4055
|
organizationId: args.organizationId,
|
|
3998
4056
|
conceptId: args.conceptId,
|
|
@@ -4007,7 +4065,7 @@ function deleteConceptTool(config) {
|
|
|
4007
4065
|
|
|
4008
4066
|
// src/tools/taxonomies/concepts/updateConcept.ts
|
|
4009
4067
|
import { z as z68 } from "zod";
|
|
4010
|
-
import
|
|
4068
|
+
import { createClient as createClient13 } from "contentful-management";
|
|
4011
4069
|
var UpdateConceptToolParams = z68.object({
|
|
4012
4070
|
organizationId: z68.string().describe("The ID of the Contentful organization"),
|
|
4013
4071
|
conceptId: z68.string().describe("The ID of the concept to update"),
|
|
@@ -4030,7 +4088,7 @@ function updateConceptTool(config) {
|
|
|
4030
4088
|
async function tool2(args) {
|
|
4031
4089
|
const clientConfig = createClientConfig(config);
|
|
4032
4090
|
delete clientConfig.space;
|
|
4033
|
-
const contentfulClient =
|
|
4091
|
+
const contentfulClient = createClient13(clientConfig);
|
|
4034
4092
|
const existingConcept = await contentfulClient.concept.get({
|
|
4035
4093
|
organizationId: args.organizationId,
|
|
4036
4094
|
conceptId: args.conceptId
|
|
@@ -4050,7 +4108,7 @@ function updateConceptTool(config) {
|
|
|
4050
4108
|
broader: args.broader ?? existingConcept.broader,
|
|
4051
4109
|
related: args.related ?? existingConcept.related
|
|
4052
4110
|
};
|
|
4053
|
-
const updatedConcept = await contentfulClient.concept.
|
|
4111
|
+
const updatedConcept = await contentfulClient.concept.update(
|
|
4054
4112
|
{
|
|
4055
4113
|
organizationId: args.organizationId,
|
|
4056
4114
|
conceptId: args.conceptId,
|
|
@@ -4067,7 +4125,7 @@ function updateConceptTool(config) {
|
|
|
4067
4125
|
|
|
4068
4126
|
// src/tools/taxonomies/concepts/getConcept.ts
|
|
4069
4127
|
import { z as z69 } from "zod";
|
|
4070
|
-
import
|
|
4128
|
+
import { createClient as createClient14 } from "contentful-management";
|
|
4071
4129
|
var GetConceptToolParams = z69.object({
|
|
4072
4130
|
organizationId: z69.string().describe("The ID of the Contentful organization"),
|
|
4073
4131
|
conceptId: z69.string().describe("The ID of the concept to retrieve")
|
|
@@ -4076,7 +4134,7 @@ function getConceptTool(config) {
|
|
|
4076
4134
|
async function tool2(args) {
|
|
4077
4135
|
const clientConfig = createClientConfig(config);
|
|
4078
4136
|
delete clientConfig.space;
|
|
4079
|
-
const contentfulClient =
|
|
4137
|
+
const contentfulClient = createClient14(clientConfig);
|
|
4080
4138
|
const concept = await contentfulClient.concept.get({
|
|
4081
4139
|
organizationId: args.organizationId,
|
|
4082
4140
|
conceptId: args.conceptId
|
|
@@ -4088,12 +4146,11 @@ function getConceptTool(config) {
|
|
|
4088
4146
|
|
|
4089
4147
|
// src/tools/taxonomies/concepts/listConcepts.ts
|
|
4090
4148
|
import { z as z70 } from "zod";
|
|
4091
|
-
import
|
|
4149
|
+
import { createClient as createClient15 } from "contentful-management";
|
|
4092
4150
|
var ListConceptsToolParams = z70.object({
|
|
4093
4151
|
organizationId: z70.string().describe("The ID of the Contentful organization"),
|
|
4094
4152
|
conceptId: z70.string().optional().describe("The ID of the concept (required for descendants/ancestors)"),
|
|
4095
4153
|
limit: z70.number().optional().describe("Maximum number of concepts to return"),
|
|
4096
|
-
skip: z70.number().optional().describe("Skip this many concepts for pagination"),
|
|
4097
4154
|
select: z70.string().optional().describe("Comma-separated list of fields to return"),
|
|
4098
4155
|
include: z70.number().optional().describe("Include this many levels of linked entries"),
|
|
4099
4156
|
order: z70.string().optional().describe("Order concepts by this field"),
|
|
@@ -4105,7 +4162,7 @@ function listConceptsTool(config) {
|
|
|
4105
4162
|
async function tool2(args) {
|
|
4106
4163
|
const clientConfig = createClientConfig(config);
|
|
4107
4164
|
delete clientConfig.space;
|
|
4108
|
-
const contentfulClient =
|
|
4165
|
+
const contentfulClient = createClient15(clientConfig);
|
|
4109
4166
|
if ((args.getDescendants || args.getAncestors) && !args.conceptId) {
|
|
4110
4167
|
throw new Error(
|
|
4111
4168
|
"conceptId is required when getting descendants or ancestors"
|
|
@@ -4124,7 +4181,6 @@ function listConceptsTool(config) {
|
|
|
4124
4181
|
organizationId: args.organizationId,
|
|
4125
4182
|
conceptId: args.conceptId,
|
|
4126
4183
|
...args.limit && { limit: args.limit },
|
|
4127
|
-
...args.skip && { skip: args.skip },
|
|
4128
4184
|
...args.select && { select: args.select },
|
|
4129
4185
|
...args.include && { include: args.include },
|
|
4130
4186
|
...args.order && { order: args.order }
|
|
@@ -4150,7 +4206,6 @@ function listConceptsTool(config) {
|
|
|
4150
4206
|
organizationId: args.organizationId,
|
|
4151
4207
|
conceptId: args.conceptId,
|
|
4152
4208
|
...args.limit && { limit: args.limit },
|
|
4153
|
-
...args.skip && { skip: args.skip },
|
|
4154
4209
|
...args.select && { select: args.select },
|
|
4155
4210
|
...args.include && { include: args.include },
|
|
4156
4211
|
...args.order && { order: args.order }
|
|
@@ -4175,7 +4230,6 @@ function listConceptsTool(config) {
|
|
|
4175
4230
|
organizationId: args.organizationId,
|
|
4176
4231
|
query: {
|
|
4177
4232
|
limit: args.limit || 10,
|
|
4178
|
-
skip: args.skip || 0,
|
|
4179
4233
|
...args.select && { select: args.select },
|
|
4180
4234
|
...args.include && { include: args.include },
|
|
4181
4235
|
...args.order && { order: args.order }
|
|
@@ -4279,6 +4333,8 @@ function createTaxonomyTools(config) {
|
|
|
4279
4333
|
|
|
4280
4334
|
// src/tools/jobs/space-to-space-migration/exportSpace.ts
|
|
4281
4335
|
import { z as z72 } from "zod";
|
|
4336
|
+
import * as contentfulExportModule from "contentful-export";
|
|
4337
|
+
import { join } from "path";
|
|
4282
4338
|
|
|
4283
4339
|
// src/types/querySchema.ts
|
|
4284
4340
|
import { z as z71 } from "zod";
|
|
@@ -4300,6 +4356,7 @@ var AssetQuerySchema = z71.object({
|
|
|
4300
4356
|
});
|
|
4301
4357
|
|
|
4302
4358
|
// src/tools/jobs/space-to-space-migration/exportSpace.ts
|
|
4359
|
+
var contentfulExport = contentfulExportModule.default ?? contentfulExportModule;
|
|
4303
4360
|
var ExportSpaceToolParams = BaseToolSchema.extend({
|
|
4304
4361
|
exportDir: z72.string().optional().describe(
|
|
4305
4362
|
"Directory to save the exported space data (optional, defaults to current directory)"
|
|
@@ -4349,10 +4406,8 @@ function createExportSpaceTool(config) {
|
|
|
4349
4406
|
contentFile: args.contentFile || `contentful-export-${args.spaceId}.json`
|
|
4350
4407
|
};
|
|
4351
4408
|
try {
|
|
4352
|
-
const
|
|
4353
|
-
const
|
|
4354
|
-
const result = await contentfulExport.default(exportOptions);
|
|
4355
|
-
const exportPath = path.join(
|
|
4409
|
+
const result = await contentfulExport(exportOptions);
|
|
4410
|
+
const exportPath = join(
|
|
4356
4411
|
exportOptions.exportDir,
|
|
4357
4412
|
exportOptions.contentFile
|
|
4358
4413
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/mcp-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
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 .",
|
|
@@ -44,14 +45,16 @@
|
|
|
44
45
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
45
46
|
"contentful-export": "^7.21.78",
|
|
46
47
|
"contentful-import": "^9.4.129",
|
|
47
|
-
"contentful-management": "^
|
|
48
|
+
"contentful-management": "^12.2.0",
|
|
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",
|