@kywi-software/mcp 0.1.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.
Files changed (119) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +77 -0
  3. package/dist/__tests__/auto-detect.test.d.ts +2 -0
  4. package/dist/__tests__/auto-detect.test.d.ts.map +1 -0
  5. package/dist/__tests__/auto-detect.test.js +134 -0
  6. package/dist/__tests__/auto-detect.test.js.map +1 -0
  7. package/dist/__tests__/config.test.d.ts +2 -0
  8. package/dist/__tests__/config.test.d.ts.map +1 -0
  9. package/dist/__tests__/config.test.js +72 -0
  10. package/dist/__tests__/config.test.js.map +1 -0
  11. package/dist/__tests__/developer-mutation.test.d.ts +2 -0
  12. package/dist/__tests__/developer-mutation.test.d.ts.map +1 -0
  13. package/dist/__tests__/developer-mutation.test.js +511 -0
  14. package/dist/__tests__/developer-mutation.test.js.map +1 -0
  15. package/dist/__tests__/developer-read-only.test.d.ts +2 -0
  16. package/dist/__tests__/developer-read-only.test.d.ts.map +1 -0
  17. package/dist/__tests__/developer-read-only.test.js +192 -0
  18. package/dist/__tests__/developer-read-only.test.js.map +1 -0
  19. package/dist/__tests__/site-content-tools.test.d.ts +2 -0
  20. package/dist/__tests__/site-content-tools.test.d.ts.map +1 -0
  21. package/dist/__tests__/site-content-tools.test.js +446 -0
  22. package/dist/__tests__/site-content-tools.test.js.map +1 -0
  23. package/dist/__tests__/site-layout-tools.test.d.ts +2 -0
  24. package/dist/__tests__/site-layout-tools.test.d.ts.map +1 -0
  25. package/dist/__tests__/site-layout-tools.test.js +316 -0
  26. package/dist/__tests__/site-layout-tools.test.js.map +1 -0
  27. package/dist/__tests__/site-other-tools.test.d.ts +2 -0
  28. package/dist/__tests__/site-other-tools.test.d.ts.map +1 -0
  29. package/dist/__tests__/site-other-tools.test.js +318 -0
  30. package/dist/__tests__/site-other-tools.test.js.map +1 -0
  31. package/dist/config.d.ts +31 -0
  32. package/dist/config.d.ts.map +1 -0
  33. package/dist/config.js +4 -0
  34. package/dist/config.js.map +1 -0
  35. package/dist/developer/auto-detect.d.ts +17 -0
  36. package/dist/developer/auto-detect.d.ts.map +1 -0
  37. package/dist/developer/auto-detect.js +54 -0
  38. package/dist/developer/auto-detect.js.map +1 -0
  39. package/dist/developer/cli.d.ts +3 -0
  40. package/dist/developer/cli.d.ts.map +1 -0
  41. package/dist/developer/cli.js +14 -0
  42. package/dist/developer/cli.js.map +1 -0
  43. package/dist/developer/index.d.ts +4 -0
  44. package/dist/developer/index.d.ts.map +1 -0
  45. package/dist/developer/index.js +9 -0
  46. package/dist/developer/index.js.map +1 -0
  47. package/dist/developer/server.d.ts +4 -0
  48. package/dist/developer/server.d.ts.map +1 -0
  49. package/dist/developer/server.js +29 -0
  50. package/dist/developer/server.js.map +1 -0
  51. package/dist/developer/tools/api-keys.d.ts +48 -0
  52. package/dist/developer/tools/api-keys.d.ts.map +1 -0
  53. package/dist/developer/tools/api-keys.js +51 -0
  54. package/dist/developer/tools/api-keys.js.map +1 -0
  55. package/dist/developer/tools/config-mutation.d.ts +139 -0
  56. package/dist/developer/tools/config-mutation.d.ts.map +1 -0
  57. package/dist/developer/tools/config-mutation.js +277 -0
  58. package/dist/developer/tools/config-mutation.js.map +1 -0
  59. package/dist/developer/tools/content-type-tools.d.ts +32 -0
  60. package/dist/developer/tools/content-type-tools.d.ts.map +1 -0
  61. package/dist/developer/tools/content-type-tools.js +92 -0
  62. package/dist/developer/tools/content-type-tools.js.map +1 -0
  63. package/dist/developer/tools/read-only.d.ts +86 -0
  64. package/dist/developer/tools/read-only.d.ts.map +1 -0
  65. package/dist/developer/tools/read-only.js +235 -0
  66. package/dist/developer/tools/read-only.js.map +1 -0
  67. package/dist/developer/tools/scaffolding.d.ts +67 -0
  68. package/dist/developer/tools/scaffolding.d.ts.map +1 -0
  69. package/dist/developer/tools/scaffolding.js +207 -0
  70. package/dist/developer/tools/scaffolding.js.map +1 -0
  71. package/dist/index.d.ts +7 -0
  72. package/dist/index.d.ts.map +1 -0
  73. package/dist/index.js +6 -0
  74. package/dist/index.js.map +1 -0
  75. package/dist/shared.d.ts +15 -0
  76. package/dist/shared.d.ts.map +1 -0
  77. package/dist/shared.js +7 -0
  78. package/dist/shared.js.map +1 -0
  79. package/dist/site/cli.d.ts +3 -0
  80. package/dist/site/cli.d.ts.map +1 -0
  81. package/dist/site/cli.js +12 -0
  82. package/dist/site/cli.js.map +1 -0
  83. package/dist/site/index.d.ts +4 -0
  84. package/dist/site/index.d.ts.map +1 -0
  85. package/dist/site/index.js +9 -0
  86. package/dist/site/index.js.map +1 -0
  87. package/dist/site/server.d.ts +10 -0
  88. package/dist/site/server.d.ts.map +1 -0
  89. package/dist/site/server.js +73 -0
  90. package/dist/site/server.js.map +1 -0
  91. package/dist/site/tools/content.d.ts +250 -0
  92. package/dist/site/tools/content.d.ts.map +1 -0
  93. package/dist/site/tools/content.js +329 -0
  94. package/dist/site/tools/content.js.map +1 -0
  95. package/dist/site/tools/feeds.d.ts +62 -0
  96. package/dist/site/tools/feeds.d.ts.map +1 -0
  97. package/dist/site/tools/feeds.js +97 -0
  98. package/dist/site/tools/feeds.js.map +1 -0
  99. package/dist/site/tools/layout.d.ts +163 -0
  100. package/dist/site/tools/layout.d.ts.map +1 -0
  101. package/dist/site/tools/layout.js +226 -0
  102. package/dist/site/tools/layout.js.map +1 -0
  103. package/dist/site/tools/media.d.ts +38 -0
  104. package/dist/site/tools/media.d.ts.map +1 -0
  105. package/dist/site/tools/media.js +52 -0
  106. package/dist/site/tools/media.js.map +1 -0
  107. package/dist/site/tools/search.d.ts +40 -0
  108. package/dist/site/tools/search.d.ts.map +1 -0
  109. package/dist/site/tools/search.js +60 -0
  110. package/dist/site/tools/search.js.map +1 -0
  111. package/dist/site/tools/users.d.ts +60 -0
  112. package/dist/site/tools/users.d.ts.map +1 -0
  113. package/dist/site/tools/users.js +71 -0
  114. package/dist/site/tools/users.js.map +1 -0
  115. package/dist/site/tools/webhooks.d.ts +34 -0
  116. package/dist/site/tools/webhooks.d.ts.map +1 -0
  117. package/dist/site/tools/webhooks.js +44 -0
  118. package/dist/site/tools/webhooks.js.map +1 -0
  119. package/package.json +61 -0
@@ -0,0 +1,51 @@
1
+ import { z } from 'zod';
2
+ import { textResult, errorResult } from '../../shared.js';
3
+ // ─── Exported handler functions (testable without server) ─────────────────
4
+ export async function handleCreateApiKey(http, args) {
5
+ try {
6
+ const result = await http.post('/api-keys', args);
7
+ return textResult(result);
8
+ }
9
+ catch (err) {
10
+ return errorResult(`Failed to create API key: ${err instanceof Error ? err.message : String(err)}`);
11
+ }
12
+ }
13
+ export async function handleListApiKeys(http) {
14
+ try {
15
+ const result = await http.get('/api-keys');
16
+ return textResult(result);
17
+ }
18
+ catch (err) {
19
+ return errorResult(`Failed to list API keys: ${err instanceof Error ? err.message : String(err)}`);
20
+ }
21
+ }
22
+ export async function handleRevokeApiKey(http, args) {
23
+ try {
24
+ const result = await http.delete(`/api-keys/${args.id}`);
25
+ return textResult(result);
26
+ }
27
+ catch (err) {
28
+ return errorResult(`Failed to revoke API key: ${err instanceof Error ? err.message : String(err)}`);
29
+ }
30
+ }
31
+ // ─── Registration ─────────────────────────────────────────────────────────────
32
+ export function registerApiKeyTools(server, http) {
33
+ server.registerTool('create_api_key', {
34
+ description: 'Create a new API key with specified scopes',
35
+ inputSchema: {
36
+ name: z.string().describe('Human-readable name for the API key'),
37
+ scopes: z.array(z.string()).describe('Permission scopes for the key (e.g. content:read, content:write)'),
38
+ },
39
+ }, async (args) => handleCreateApiKey(http, args));
40
+ server.registerTool('list_api_keys', {
41
+ description: 'List all API keys',
42
+ inputSchema: {},
43
+ }, async () => handleListApiKeys(http));
44
+ server.registerTool('revoke_api_key', {
45
+ description: 'Revoke an API key by ID',
46
+ inputSchema: {
47
+ id: z.string().describe('API key ID to revoke'),
48
+ },
49
+ }, async (args) => handleRevokeApiKey(http, args));
50
+ }
51
+ //# sourceMappingURL=api-keys.js.map
@@ -0,0 +1 @@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CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,WAAW,CAAC,6BAA6B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACrG,CAAC;AACH,CAAC;AAED,iFAAiF;AAEjF,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,IAAoB;IACzE,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE;QACpC,WAAW,EAAE,4CAA4C;QACzD,WAAW,EAAE;YACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;YAChE,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,kEAAkE,CAAC;SACzG;KACF,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAElD,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE;QACnC,WAAW,EAAE,mBAAmB;QAChC,WAAW,EAAE,EAAE;KAChB,EAAE,KAAK,IAAI,EAAE,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAA;IAEvC,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE;QACpC,WAAW,EAAE,yBAAyB;QACtC,WAAW,EAAE;YACX,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;SAChD;KACF,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACpD,CAAC"}
@@ -0,0 +1,139 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export interface ConfigMutationContext {
3
+ configPath: string;
4
+ }
5
+ export declare function handleAddContentType(ctx: ConfigMutationContext, args: {
6
+ name: string;
7
+ label: string;
8
+ baseType: string;
9
+ fields: Array<{
10
+ name: string;
11
+ type: string;
12
+ label: string;
13
+ required?: boolean | undefined;
14
+ }>;
15
+ }): Promise<{
16
+ content: [{
17
+ type: "text";
18
+ text: string;
19
+ }];
20
+ isError?: undefined;
21
+ }>;
22
+ export declare function handleAddField(ctx: ConfigMutationContext, args: {
23
+ contentTypeName: string;
24
+ field: {
25
+ name: string;
26
+ type: string;
27
+ label: string;
28
+ required?: boolean | undefined;
29
+ };
30
+ }): Promise<{
31
+ content: [{
32
+ type: "text";
33
+ text: string;
34
+ }];
35
+ isError?: undefined;
36
+ } | {
37
+ content: [{
38
+ type: "text";
39
+ text: string;
40
+ }];
41
+ isError: true;
42
+ }>;
43
+ export declare function handleRemoveField(ctx: ConfigMutationContext, args: {
44
+ contentTypeName: string;
45
+ fieldName: string;
46
+ }): Promise<{
47
+ content: [{
48
+ type: "text";
49
+ text: string;
50
+ }];
51
+ isError?: undefined;
52
+ } | {
53
+ content: [{
54
+ type: "text";
55
+ text: string;
56
+ }];
57
+ isError: true;
58
+ }>;
59
+ export declare function handleAddTheme(ctx: ConfigMutationContext, args: {
60
+ name: string;
61
+ label: string;
62
+ regions: string[];
63
+ }): Promise<{
64
+ content: [{
65
+ type: "text";
66
+ text: string;
67
+ }];
68
+ isError?: undefined;
69
+ }>;
70
+ export declare function handleUpdateContentType(ctx: ConfigMutationContext, args: {
71
+ name: string;
72
+ label?: string | undefined;
73
+ baseType?: string | undefined;
74
+ }): Promise<{
75
+ content: [{
76
+ type: "text";
77
+ text: string;
78
+ }];
79
+ isError?: undefined;
80
+ } | {
81
+ content: [{
82
+ type: "text";
83
+ text: string;
84
+ }];
85
+ isError: true;
86
+ }>;
87
+ export declare function handleUpdateThemeRegions(ctx: ConfigMutationContext, args: {
88
+ name: string;
89
+ regions: string[];
90
+ }): Promise<{
91
+ content: [{
92
+ type: "text";
93
+ text: string;
94
+ }];
95
+ isError?: undefined;
96
+ } | {
97
+ content: [{
98
+ type: "text";
99
+ text: string;
100
+ }];
101
+ isError: true;
102
+ }>;
103
+ export declare function handleAddModule(ctx: ConfigMutationContext, args: {
104
+ name: string;
105
+ label: string;
106
+ component: string;
107
+ }): Promise<{
108
+ content: [{
109
+ type: "text";
110
+ text: string;
111
+ }];
112
+ isError?: undefined;
113
+ }>;
114
+ export declare function handleAddPlugin(ctx: ConfigMutationContext, args: {
115
+ name: string;
116
+ label: string;
117
+ options?: Record<string, unknown> | undefined;
118
+ }): Promise<{
119
+ content: [{
120
+ type: "text";
121
+ text: string;
122
+ }];
123
+ isError?: undefined;
124
+ }>;
125
+ export declare function handleRunMigration(ctx: ConfigMutationContext): Promise<{
126
+ content: [{
127
+ type: "text";
128
+ text: string;
129
+ }];
130
+ isError?: undefined;
131
+ } | {
132
+ content: [{
133
+ type: "text";
134
+ text: string;
135
+ }];
136
+ isError: true;
137
+ }>;
138
+ export declare function registerConfigMutationTools(server: McpServer, ctx: ConfigMutationContext): void;
139
+ //# sourceMappingURL=config-mutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-mutation.d.ts","sourceRoot":"","sources":["../../../src/developer/tools/config-mutation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AAOxE,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAA;CACnB;AAcD,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,qBAAqB,EAC1B,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;KAAE,C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sB,eAAe,CACnC,GAAG,EAAE,qBAAqB,EAC1B,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;CAAE;;;;;;GAuBrF;AAED,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,qBAAqB;;;;;;;;;;;;GAalE;AAWD,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,qBAAqB,GAAG,IAAI,CA2E/F"}
@@ -0,0 +1,277 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+ import { execFile } from 'node:child_process';
3
+ import { promisify } from 'node:util';
4
+ import { z } from 'zod';
5
+ import { textResult, errorResult } from '../../shared.js';
6
+ const execFileAsync = promisify(execFile);
7
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
8
+ function readConfig(configPath) {
9
+ return readFileSync(configPath, 'utf-8');
10
+ }
11
+ function writeConfig(configPath, content) {
12
+ writeFileSync(configPath, content, 'utf-8');
13
+ }
14
+ // ─── Exported handler functions (testable without server) ─────────────────
15
+ export async function handleAddContentType(ctx, args) {
16
+ const raw = readConfig(ctx.configPath);
17
+ const fieldDefs = args.fields.map((f) => {
18
+ const parts = [`name: '${f.name}'`, `type: '${f.type}'`, `label: '${f.label}'`];
19
+ if (f.required) {
20
+ parts.push('required: true');
21
+ }
22
+ return ` { ${parts.join(', ')} }`;
23
+ });
24
+ const block = [
25
+ ``,
26
+ `defineContentType('${args.name}', {`,
27
+ ` label: '${args.label}',`,
28
+ ` baseType: '${args.baseType}',`,
29
+ ` fields: [`,
30
+ ...fieldDefs.map((d) => `${d},`),
31
+ ` ],`,
32
+ `})`,
33
+ ].join('\n');
34
+ const updated = raw + block + '\n';
35
+ writeConfig(ctx.configPath, updated);
36
+ return textResult({
37
+ added: args.name,
38
+ label: args.label,
39
+ fields: args.fields.length,
40
+ note: 'Content type appended to config. Run run_migration to update the database schema.',
41
+ });
42
+ }
43
+ export async function handleAddField(ctx, args) {
44
+ const raw = readConfig(ctx.configPath);
45
+ // Find the content type block
46
+ const typePattern = new RegExp(`(defineContentType\\s*\\(\\s*['"\`]${args.contentTypeName}['"\`]\\s*,\\s*\\{[\\s\\S]*?fields\\s*:\\s*\\[)`);
47
+ const match = typePattern.exec(raw);
48
+ if (!match) {
49
+ return errorResult(`Content type '${args.contentTypeName}' not found in config`);
50
+ }
51
+ const parts = [`name: '${args.field.name}'`, `type: '${args.field.type}'`, `label: '${args.field.label}'`];
52
+ if (args.field.required) {
53
+ parts.push('required: true');
54
+ }
55
+ const fieldLine = `\n { ${parts.join(', ')} },`;
56
+ const insertPos = match.index + match[0].length;
57
+ const updated = raw.slice(0, insertPos) + fieldLine + raw.slice(insertPos);
58
+ writeConfig(ctx.configPath, updated);
59
+ return textResult({
60
+ contentType: args.contentTypeName,
61
+ addedField: args.field.name,
62
+ note: 'Field added. Run run_migration to update the database schema.',
63
+ });
64
+ }
65
+ export async function handleRemoveField(ctx, args) {
66
+ const raw = readConfig(ctx.configPath);
67
+ // Find and remove the field line within the content type block
68
+ const fieldPattern = new RegExp(`(\\n\\s*\\{[^}]*name\\s*:\\s*['"\`]${args.fieldName}['"\`][^}]*\\}\\s*,?)`);
69
+ // First confirm we're in the right content type scope
70
+ const typeStart = raw.indexOf(`defineContentType('${args.contentTypeName}'`);
71
+ if (typeStart === -1) {
72
+ return errorResult(`Content type '${args.contentTypeName}' not found in config`);
73
+ }
74
+ // Search within the type block for the field
75
+ const typeBlock = raw.slice(typeStart);
76
+ const fieldMatch = fieldPattern.exec(typeBlock);
77
+ if (!fieldMatch) {
78
+ return errorResult(`Field '${args.fieldName}' not found in content type '${args.contentTypeName}'`);
79
+ }
80
+ const absolutePos = typeStart + fieldMatch.index;
81
+ const updated = raw.slice(0, absolutePos) + raw.slice(absolutePos + fieldMatch[0].length);
82
+ writeConfig(ctx.configPath, updated);
83
+ return textResult({
84
+ contentType: args.contentTypeName,
85
+ removedField: args.fieldName,
86
+ note: 'Field removed. Run run_migration to update the database schema.',
87
+ });
88
+ }
89
+ export async function handleAddTheme(ctx, args) {
90
+ const raw = readConfig(ctx.configPath);
91
+ const regionLines = args.regions.map((r) => ` '${r}',`);
92
+ const block = [
93
+ ``,
94
+ `defineTheme('${args.name}', {`,
95
+ ` label: '${args.label}',`,
96
+ ` regions: [`,
97
+ ...regionLines,
98
+ ` ],`,
99
+ `})`,
100
+ ].join('\n');
101
+ const updated = raw + block + '\n';
102
+ writeConfig(ctx.configPath, updated);
103
+ return textResult({
104
+ added: args.name,
105
+ label: args.label,
106
+ regions: args.regions,
107
+ });
108
+ }
109
+ export async function handleUpdateContentType(ctx, args) {
110
+ const raw = readConfig(ctx.configPath);
111
+ const typePattern = new RegExp(`(defineContentType\\s*\\(\\s*['"\`]${args.name}['"\`]\\s*,\\s*\\{)([\\s\\S]*?)(fields\\s*:\\s*\\[)`);
112
+ const match = typePattern.exec(raw);
113
+ if (!match) {
114
+ return errorResult(`Content type '${args.name}' not found in config`);
115
+ }
116
+ let block = match[2] ?? '';
117
+ if (args.label !== undefined) {
118
+ block = block.replace(/label\s*:\s*['"`][^'"`]*['"`]/, `label: '${args.label}'`);
119
+ }
120
+ if (args.baseType !== undefined) {
121
+ block = block.replace(/baseType\s*:\s*['"`][^'"`]*['"`]/, `baseType: '${args.baseType}'`);
122
+ }
123
+ const updated = raw.slice(0, match.index) +
124
+ match[1] + block + match[3] +
125
+ raw.slice(match.index + match[0].length);
126
+ writeConfig(ctx.configPath, updated);
127
+ return textResult({
128
+ updated: args.name,
129
+ label: args.label,
130
+ baseType: args.baseType,
131
+ note: 'Content type definition updated in config.',
132
+ });
133
+ }
134
+ export async function handleUpdateThemeRegions(ctx, args) {
135
+ const raw = readConfig(ctx.configPath);
136
+ const themePattern = new RegExp(`(defineTheme\\s*\\(\\s*['"\`]${args.name}['"\`]\\s*,\\s*\\{[\\s\\S]*?regions\\s*:\\s*\\[)[\\s\\S]*?(\\]\\s*,?\\s*\\}\\s*\\))`);
137
+ const match = themePattern.exec(raw);
138
+ if (!match) {
139
+ return errorResult(`Theme '${args.name}' not found in config`);
140
+ }
141
+ const regionLines = args.regions.map((r) => `\n '${r}',`).join('');
142
+ const updated = raw.slice(0, match.index) +
143
+ match[1] + regionLines + '\n ' + match[2] +
144
+ raw.slice(match.index + match[0].length);
145
+ writeConfig(ctx.configPath, updated);
146
+ return textResult({
147
+ updated: args.name,
148
+ regions: args.regions,
149
+ note: 'Theme regions updated in config.',
150
+ });
151
+ }
152
+ export async function handleAddModule(ctx, args) {
153
+ const raw = readConfig(ctx.configPath);
154
+ const block = [
155
+ ``,
156
+ `defineModule('${args.name}', {`,
157
+ ` label: '${args.label}',`,
158
+ ` component: '${args.component}',`,
159
+ `})`,
160
+ ].join('\n');
161
+ const updated = raw + block + '\n';
162
+ writeConfig(ctx.configPath, updated);
163
+ return textResult({
164
+ added: args.name,
165
+ label: args.label,
166
+ component: args.component,
167
+ });
168
+ }
169
+ export async function handleAddPlugin(ctx, args) {
170
+ const raw = readConfig(ctx.configPath);
171
+ const optionsStr = args.options
172
+ ? `\n options: ${JSON.stringify(args.options, null, 2).replace(/\n/g, '\n ')},`
173
+ : '';
174
+ const block = [
175
+ ``,
176
+ `definePlugin('${args.name}', {`,
177
+ ` label: '${args.label}',${optionsStr}`,
178
+ `})`,
179
+ ].join('\n');
180
+ const updated = raw + block + '\n';
181
+ writeConfig(ctx.configPath, updated);
182
+ return textResult({
183
+ added: args.name,
184
+ label: args.label,
185
+ options: args.options,
186
+ });
187
+ }
188
+ export async function handleRunMigration(ctx) {
189
+ const configDir = ctx.configPath.replace(/\/[^/]+$/, '');
190
+ try {
191
+ const { stdout, stderr } = await execFileAsync('npx', ['drizzle-kit', 'push'], {
192
+ cwd: configDir,
193
+ timeout: 30_000,
194
+ });
195
+ return textResult({ success: true, stdout, stderr });
196
+ }
197
+ catch (err) {
198
+ const message = err instanceof Error ? err.message : String(err);
199
+ return errorResult(`Migration failed: ${message}`);
200
+ }
201
+ }
202
+ // ─── Registration ─────────────────────────────────────────────────────────────
203
+ const fieldSchema = z.object({
204
+ name: z.string().describe('Field name'),
205
+ type: z.string().describe('Field type (e.g. text, richtext, number, boolean, image, relation)'),
206
+ label: z.string().describe('Human-readable label'),
207
+ required: z.boolean().optional().describe('Whether the field is required'),
208
+ });
209
+ export function registerConfigMutationTools(server, ctx) {
210
+ server.registerTool('add_content_type', {
211
+ description: 'Add a new content type definition to kywi.config.ts',
212
+ inputSchema: {
213
+ name: z.string().describe('Content type machine name'),
214
+ label: z.string().describe('Human-readable label'),
215
+ baseType: z.string().describe('Base type (e.g. page, folder, component)'),
216
+ fields: z.array(fieldSchema).describe('Array of field definitions'),
217
+ },
218
+ }, async (args) => handleAddContentType(ctx, args));
219
+ server.registerTool('add_field', {
220
+ description: 'Add a field to an existing content type in kywi.config.ts',
221
+ inputSchema: {
222
+ contentTypeName: z.string().describe('Name of the content type to modify'),
223
+ field: fieldSchema.describe('Field definition to add'),
224
+ },
225
+ }, async (args) => handleAddField(ctx, args));
226
+ server.registerTool('remove_field', {
227
+ description: 'Remove a field from a content type in kywi.config.ts',
228
+ inputSchema: {
229
+ contentTypeName: z.string().describe('Name of the content type'),
230
+ fieldName: z.string().describe('Name of the field to remove'),
231
+ },
232
+ }, async (args) => handleRemoveField(ctx, args));
233
+ server.registerTool('add_theme', {
234
+ description: 'Add a new theme definition to kywi.config.ts',
235
+ inputSchema: {
236
+ name: z.string().describe('Theme machine name'),
237
+ label: z.string().describe('Human-readable label'),
238
+ regions: z.array(z.string()).describe('Template region names (e.g. header, main, sidebar, footer)'),
239
+ },
240
+ }, async (args) => handleAddTheme(ctx, args));
241
+ server.registerTool('update_content_type', {
242
+ description: 'Modify an existing content type definition in kywi.config.ts (change label or baseType)',
243
+ inputSchema: {
244
+ name: z.string().describe('Content type machine name to update'),
245
+ label: z.string().optional().describe('New human-readable label'),
246
+ baseType: z.string().optional().describe('New base type (e.g. page, folder, component)'),
247
+ },
248
+ }, async (args) => handleUpdateContentType(ctx, args));
249
+ server.registerTool('update_theme_regions', {
250
+ description: 'Update the region list of a theme definition in kywi.config.ts',
251
+ inputSchema: {
252
+ name: z.string().describe('Theme machine name to update'),
253
+ regions: z.array(z.string()).describe('New list of region names'),
254
+ },
255
+ }, async (args) => handleUpdateThemeRegions(ctx, args));
256
+ server.registerTool('add_module', {
257
+ description: 'Add a module definition to kywi.config.ts',
258
+ inputSchema: {
259
+ name: z.string().describe('Module machine name'),
260
+ label: z.string().describe('Human-readable label'),
261
+ component: z.string().describe('Path to the React component file'),
262
+ },
263
+ }, async (args) => handleAddModule(ctx, args));
264
+ server.registerTool('add_plugin', {
265
+ description: 'Add a plugin definition to kywi.config.ts',
266
+ inputSchema: {
267
+ name: z.string().describe('Plugin machine name'),
268
+ label: z.string().describe('Human-readable label'),
269
+ options: z.record(z.unknown()).optional().describe('Plugin configuration options'),
270
+ },
271
+ }, async (args) => handleAddPlugin(ctx, args));
272
+ server.registerTool('run_migration', {
273
+ description: 'Run drizzle-kit push to apply schema changes to the database',
274
+ inputSchema: {},
275
+ }, async () => handleRunMigration(ctx));
276
+ }
277
+ //# sourceMappingURL=config-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-mutation.js","sourceRoot":"","sources":["../../../src/developer/tools/config-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEzD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAA;AAQzC,gFAAgF;AAEhF,SA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nE;KACF,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IAE9C,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE;QAChC,WAAW,EAAE,2CAA2C;QACxD,WAAW,EAAE;YACX,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;YAChD,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;YAClD,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;SACnF;KACF,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;IAE9C,MAAM,CAAC,YAAY,CAAC,eAAe,EAAE;QACnC,WAAW,EAAE,8DAA8D;QAC3E,WAAW,EAAE,EAAE;KAChB,EAAE,KAAK,IAAI,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAA;AACzC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { KywiSdkScope } from '@kywi-software/sdk';
3
+ import { textResult, errorResult } from '../../shared.js';
4
+ export interface ContentTypeFieldConfig {
5
+ name: string;
6
+ type: string;
7
+ label: string;
8
+ required?: boolean;
9
+ }
10
+ export interface ContentTypeConfig {
11
+ name: string;
12
+ label: string;
13
+ fields: ContentTypeFieldConfig[];
14
+ }
15
+ export interface GeneratedContentTypeTool {
16
+ name: string;
17
+ description: string;
18
+ handler: (args: Record<string, unknown>) => Promise<ReturnType<typeof textResult> | ReturnType<typeof errorResult>>;
19
+ }
20
+ /**
21
+ * For each content type, generates an `update_<typeName>` MCP tool that
22
+ * validates arguments against the type's field definitions and calls the
23
+ * SDK content update endpoint.
24
+ */
25
+ export declare function generateContentTypeTools(sdk: KywiSdkScope, contentTypes: ContentTypeConfig[]): GeneratedContentTypeTool[];
26
+ /**
27
+ * Registers one `update_<typeName>` MCP tool per content type.
28
+ * Call this after registering the static tools so auto-generated tools
29
+ * appear grouped at the end of the tool list.
30
+ */
31
+ export declare function registerContentTypeTools(server: McpServer, sdk: KywiSdkScope, contentTypes: ContentTypeConfig[]): void;
32
+ //# sourceMappingURL=content-type-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-type-tools.d.ts","sourceRoot":"","sources":["../../../src/developer/tools/content-type-tools.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAIzD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,sBAAsB,EAAE,CAAA;CACjC;AAID,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAA;CACpH;AA4BD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,YAAY,EACjB,YAAY,EAAE,iBAAiB,EAAE,GAChC,wBAAwB,EAAE,CA+C5B;AAID;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,YAAY,EACjB,YAAY,EAAE,iBAAiB,EAAE,GAChC,IAAI,CAoBN"}
@@ -0,0 +1,92 @@
1
+ import { z } from 'zod';
2
+ import { textResult, errorResult } from '../../shared.js';
3
+ // ─── Field type → Zod schema mapping ─────────────────────────────────────────
4
+ function fieldTypeToZod(type, required) {
5
+ let schema;
6
+ switch (type) {
7
+ case 'number':
8
+ schema = z.number();
9
+ break;
10
+ case 'boolean':
11
+ schema = z.boolean();
12
+ break;
13
+ case 'date':
14
+ schema = z.string().datetime({ offset: true });
15
+ break;
16
+ case 'multiSelect':
17
+ case 'json':
18
+ schema = z.array(z.unknown());
19
+ break;
20
+ default:
21
+ schema = z.string();
22
+ }
23
+ return required ? schema : schema.optional();
24
+ }
25
+ // ─── Factory function ─────────────────────────────────────────────────────────
26
+ /**
27
+ * For each content type, generates an `update_<typeName>` MCP tool that
28
+ * validates arguments against the type's field definitions and calls the
29
+ * SDK content update endpoint.
30
+ */
31
+ export function generateContentTypeTools(sdk, contentTypes) {
32
+ return contentTypes.map((ct) => ({
33
+ name: `update_${ct.name}`,
34
+ description: `Update a ${ct.label} content item by ID`,
35
+ handler: async (args) => {
36
+ const { id, ...fields } = args;
37
+ if (typeof id !== 'string' || !id) {
38
+ return errorResult(`update_${ct.name}: 'id' is required and must be a string`);
39
+ }
40
+ // Validate provided fields against the content type definition
41
+ const validFieldNames = new Set(ct.fields.map((f) => f.name));
42
+ const invalidFields = Object.keys(fields).filter((k) => !validFieldNames.has(k));
43
+ if (invalidFields.length > 0) {
44
+ return errorResult(`update_${ct.name}: unknown fields: ${invalidFields.join(', ')}. ` +
45
+ `Valid fields: ${[...validFieldNames].join(', ')}`);
46
+ }
47
+ // Check required fields that are being set to null/undefined
48
+ const requiredViolations = ct.fields
49
+ .filter((f) => f.required && Object.prototype.hasOwnProperty.call(fields, f.name))
50
+ .filter((f) => fields[f.name] === null || fields[f.name] === undefined || fields[f.name] === '')
51
+ .map((f) => f.name);
52
+ if (requiredViolations.length > 0) {
53
+ return errorResult(`update_${ct.name}: required fields cannot be empty: ${requiredViolations.join(', ')}`);
54
+ }
55
+ try {
56
+ const result = await sdk.content.update(ct.name, id, fields);
57
+ if (!result) {
58
+ return errorResult(`update_${ct.name}: item '${id}' not found or update failed`);
59
+ }
60
+ return textResult({ updated: true, contentType: ct.name, id, item: result });
61
+ }
62
+ catch (err) {
63
+ return errorResult(`update_${ct.name}: ${err instanceof Error ? err.message : String(err)}`);
64
+ }
65
+ },
66
+ }));
67
+ }
68
+ // ─── Registration ─────────────────────────────────────────────────────────────
69
+ /**
70
+ * Registers one `update_<typeName>` MCP tool per content type.
71
+ * Call this after registering the static tools so auto-generated tools
72
+ * appear grouped at the end of the tool list.
73
+ */
74
+ export function registerContentTypeTools(server, sdk, contentTypes) {
75
+ const tools = generateContentTypeTools(sdk, contentTypes);
76
+ for (const tool of tools) {
77
+ const ct = contentTypes.find((c) => `update_${c.name}` === tool.name);
78
+ // Build the inputSchema: id is always required, then each field is optional
79
+ const fieldSchemas = {
80
+ id: z.string().describe(`ID of the ${ct.label} item to update`),
81
+ };
82
+ for (const field of ct.fields) {
83
+ fieldSchemas[field.name] = fieldTypeToZod(field.type, false).describe(field.label);
84
+ }
85
+ const capturedHandler = tool.handler;
86
+ server.registerTool(tool.name, {
87
+ description: tool.description,
88
+ inputSchema: fieldSchemas,
89
+ }, async (args) => capturedHandler(args));
90
+ }
91
+ }
92
+ //# sourceMappingURL=content-type-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-type-tools.js","sourceRoot":"","sources":["../../../src/developer/tools/content-type-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAyBzD,gFAAgF;A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