Skip to content

Commit 6436927

Browse files
committed
feat(codecompanion-workspace.json): update workspace configuration with new paths and more detailed system prompts
chore(server.ts): improve port configuration and environment variable support
1 parent 13146f7 commit 6436927

14 files changed

+1705
-1037
lines changed

AI-ACTIONS-PLAN.md

Lines changed: 0 additions & 573 deletions
This file was deleted.

AI-ACTIONS-README.md

Lines changed: 0 additions & 118 deletions
This file was deleted.

CLAUDE.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

codecompanion-workspace.json

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
{
22
"name": "Contentful MCP",
33
"version": "1.0.0",
4-
"system_prompt": "Contentful MCP is a tool for interacting with the Contentful API, providing functionality for working with entries, assets, content types, and AI Actions within the Contentful headless CMS platform. This project is organized into handlers for different entity types, with support for standard CRUD operations as well as specialized bulk actions.",
4+
"system_prompt": "Contentful MCP is a TypeScript-based Model Context Protocol (MCP) implementation for interacting with Contentful's Content Management API, particularly focusing on AI Actions integration. The project follows a modular architecture with handlers for different entity types (entries, assets, content types, AI actions), and includes utility functions for generating schemas and validating inputs.",
5+
"vars": {
6+
"typescript_path": "src/types",
7+
"handlers_path": "src/handlers",
8+
"utils_path": "src/utils",
9+
"config_path": "src/config"
10+
},
511
"groups": [
612
{
713
"name": "Core",
8-
"system_prompt": "I've grouped core files together into a group called \"${group_name}\". These files represent the main entry points and configuration for the Contentful MCP project.\n\nBelow are the relevant files which we will be discussing:\n\n${group_files}",
14+
"system_prompt": "I've grouped core files together into a group called \"${group_name}\". These files represent the main entry points and configuration for the Contentful MCP project. They handle client setup, API connectivity, and server initialization.\n\nBelow are the relevant files which we will be discussing:\n\n${group_files}",
915
"data": ["index", "ai-actions-client", "client"]
1016
},
1117
{
1218
"name": "Handlers",
13-
"system_prompt": "I've grouped handler files together into a group called \"${group_name}\". These files contain the implementation of various API handlers for different entity types in Contentful.\n\nBelow are the relevant files which we will be discussing:\n\n${group_files}",
19+
"system_prompt": "I've grouped handler files together into a group called \"${group_name}\". These files contain the implementation of various API handlers for different entity types in Contentful, providing CRUD operations and specialized functions.\n\nBelow are the relevant files which we will be discussing:\n\n${group_files}",
1420
"data": [
1521
"entry-handlers",
1622
"asset-handlers",
@@ -22,86 +28,85 @@
2228
},
2329
{
2430
"name": "Types",
25-
"system_prompt": "I've grouped type definition files together into a group called \"${group_name}\". These files define the TypeScript interfaces and types used throughout the project.\n\nBelow are the relevant files which we will be discussing:\n\n${group_files}",
31+
"system_prompt": "I've grouped type definition files together into a group called \"${group_name}\". These files define the TypeScript interfaces and types used throughout the project, providing type safety and documentation.\n\nBelow are the relevant files which we will be discussing:\n\n${group_files}",
2632
"data": ["ai-actions-types", "tools-types"]
2733
},
2834
{
2935
"name": "Utils",
30-
"system_prompt": "I've grouped utility files together into a group called \"${group_name}\". These files provide helper functions and utilities used across the project.\n\nBelow are the relevant files which we will be discussing:\n\n${group_files}",
36+
"system_prompt": "I've grouped utility files together into a group called \"${group_name}\". These files provide helper functions and utilities used across the project for common operations and data transformations.\n\nBelow are the relevant files which we will be discussing:\n\n${group_files}",
3137
"data": ["ai-action-tool-generator", "summarizer", "validation"]
3238
}
3339
],
3440
"data": {
3541
"index": {
3642
"type": "file",
3743
"path": "src/index.ts",
38-
"description": "The main entry point for the Contentful MCP project."
44+
"description": "The main entry point for the Contentful MCP project where handlers are registered and the server is initialized."
3945
},
4046
"ai-actions-client": {
4147
"type": "file",
42-
"path": "src/config/ai-actions-client.ts",
43-
"description": "Configuration for the AI Actions client used to interact with Contentful's AI Actions API."
48+
"path": "${config_path}/ai-actions-client.ts",
49+
"description": "Configuration for the AI Actions client used to interact with Contentful's AI Actions API, with specialized authentication and endpoint handling."
4450
},
4551
"client": {
4652
"type": "file",
47-
"path": "src/config/client.ts",
48-
"description": "Configuration for the main Contentful client used to interact with the Contentful API."
53+
"path": "${config_path}/client.ts",
54+
"description": "Configuration for the main Contentful client used to interact with the Contentful API, handling authentication and base configuration."
4955
},
5056
"entry-handlers": {
5157
"type": "file",
52-
"path": "src/handlers/entry-handlers.ts",
53-
"description": "Handlers for CRUD operations and other actions on Contentful entries."
58+
"path": "${handlers_path}/entry-handlers.ts",
59+
"description": "Handlers for CRUD operations and other actions on Contentful entries, including bulk publishing and unpublishing functionality."
5460
},
5561
"asset-handlers": {
5662
"type": "file",
57-
"path": "src/handlers/asset-handlers.ts",
58-
"description": "Handlers for CRUD operations and other actions on Contentful assets."
63+
"path": "${handlers_path}/asset-handlers.ts",
64+
"description": "Handlers for CRUD operations and other actions on Contentful assets, including upload, update and publishing."
5965
},
6066
"content-type-handlers": {
6167
"type": "file",
62-
"path": "src/handlers/content-type-handlers.ts",
63-
"description": "Handlers for CRUD operations and other actions on Contentful content types."
68+
"path": "${handlers_path}/content-type-handlers.ts",
69+
"description": "Handlers for CRUD operations and other actions on Contentful content types, defining the structure of entries."
6470
},
6571
"ai-action-handlers": {
6672
"type": "file",
67-
"path": "src/handlers/ai-action-handlers.ts",
68-
"description": "Handlers for CRUD operations and other actions on Contentful AI Actions."
73+
"path": "${handlers_path}/ai-action-handlers.ts",
74+
"description": "Handlers for CRUD operations and other actions on Contentful AI Actions, including invocation and result retrieval."
6975
},
7076
"bulk-action-handlers": {
7177
"type": "file",
72-
"path": "src/handlers/bulk-action-handlers.ts",
73-
"description": "Handlers for bulk operations on Contentful entities."
78+
"path": "${handlers_path}/bulk-action-handlers.ts",
79+
"description": "Handlers for bulk operations on Contentful entities, optimizing performance for operations on multiple items."
7480
},
7581
"space-handlers": {
7682
"type": "file",
77-
"path": "src/handlers/space-handlers.ts",
78-
"description": "Handlers for operations on Contentful spaces."
83+
"path": "${handlers_path}/space-handlers.ts",
84+
"description": "Handlers for operations on Contentful spaces, providing top-level organization functionality."
7985
},
8086
"ai-actions-types": {
8187
"type": "file",
82-
"path": "src/types/ai-actions.ts",
83-
"description": "Type definitions for AI Actions entities and operations."
88+
"path": "${typescript_path}/ai-actions.ts",
89+
"description": "Type definitions for AI Actions entities and operations, including configuration, templates, and variables schemas."
8490
},
8591
"tools-types": {
8692
"type": "file",
87-
"path": "src/types/tools.ts",
88-
"description": "Type definitions for the tools used in the project."
93+
"path": "${typescript_path}/tools.ts",
94+
"description": "Type definitions for the MCP tools used in the project, defining the interface between the model and Contentful."
8995
},
9096
"ai-action-tool-generator": {
9197
"type": "file",
92-
"path": "src/utils/ai-action-tool-generator.ts",
93-
"description": "Utility for generating tool configurations for AI Actions."
98+
"path": "${utils_path}/ai-action-tool-generator.ts",
99+
"description": "Utility for generating tool configurations for AI Actions, mapping parameters and creating JSON schemas."
94100
},
95101
"summarizer": {
96102
"type": "file",
97-
"path": "src/utils/summarizer.ts",
98-
"description": "Utility for summarizing content and responses."
103+
"path": "${utils_path}/summarizer.ts",
104+
"description": "Utility for summarizing content and responses to provide concise information to the model."
99105
},
100106
"validation": {
101107
"type": "file",
102-
"path": "src/utils/validation.ts",
103-
"description": "Utility for validating input data and responses."
108+
"path": "${utils_path}/validation.ts",
109+
"description": "Utility for validating input data and responses to ensure data integrity and proper formatting."
104110
}
105111
}
106-
}
107-
112+
}

src/index.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,28 @@ function getHandler(name: string) {
210210
// Handler for dynamic AI Action tools
211211
async function handleAiActionInvocation(actionId: string, args: any) {
212212
try {
213-
// The getInvocationParams method now handles parameter translation
213+
console.error(`Handling AI Action invocation for ${actionId} with args:`, JSON.stringify(args))
214+
215+
// Get the parameters using the updated getInvocationParams
214216
const params = aiActionToolContext.getInvocationParams(actionId, args)
215217

218+
// Directly use the variables property from getInvocationParams
219+
const invocationParams = {
220+
spaceId: params.spaceId,
221+
environmentId: params.environmentId,
222+
aiActionId: params.aiActionId,
223+
outputFormat: params.outputFormat,
224+
waitForCompletion: params.waitForCompletion,
225+
// Use variables directly - this is what we modified in getInvocationParams
226+
rawVariables: params.variables
227+
}
228+
229+
console.error(`Invoking AI Action with params:`, JSON.stringify(invocationParams))
230+
216231
// Invoke the AI Action
217-
return aiActionHandlers.invokeAiAction(params)
232+
return aiActionHandlers.invokeAiAction(invocationParams)
218233
} catch (error) {
234+
console.error(`Error invoking AI Action:`, error)
219235
return {
220236
isError: true,
221237
message: error instanceof Error ? error.message : String(error)

0 commit comments

Comments
 (0)