@kintone/mcp-server 1.0.0 → 1.2.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 (48) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +35 -14
  3. package/dist/{client.js → client/index.js} +4 -9
  4. package/dist/client/types/client.js +1 -0
  5. package/dist/config/command-line.js +2 -1
  6. package/dist/config/index.js +30 -62
  7. package/dist/config/parser.js +72 -0
  8. package/dist/config/schema.js +4 -0
  9. package/dist/config/types/config.js +1 -0
  10. package/dist/index.js +16 -6
  11. package/dist/lib/filesystem.js +47 -0
  12. package/dist/schema/app/field-properties.js +330 -0
  13. package/dist/schema/app/form-layout.js +105 -0
  14. package/dist/schema/app/index.js +3 -0
  15. package/dist/schema/app/properties-parameter.js +638 -0
  16. package/dist/schema/record/index.js +2 -0
  17. package/dist/schema/record/records.js +1 -1
  18. package/dist/server/index.js +17 -0
  19. package/dist/server/tool-filters.js +14 -0
  20. package/dist/server/types/server.js +1 -0
  21. package/dist/tools/factory.js +10 -0
  22. package/dist/tools/index.js +23 -0
  23. package/dist/tools/kintone/app/add-app.js +40 -0
  24. package/dist/tools/kintone/app/add-form-fields.js +50 -0
  25. package/dist/tools/kintone/app/delete-form-fields.js +51 -0
  26. package/dist/tools/kintone/app/deploy-app.js +48 -0
  27. package/dist/tools/kintone/app/get-app-deploy-status.js +42 -0
  28. package/dist/tools/kintone/app/get-app.js +7 -8
  29. package/dist/tools/kintone/app/get-apps.js +7 -8
  30. package/dist/tools/kintone/app/get-form-fields.js +20 -107
  31. package/dist/tools/kintone/app/get-form-layout.js +45 -0
  32. package/dist/tools/kintone/app/get-general-settings.js +119 -0
  33. package/dist/tools/kintone/app/get-process-management.js +12 -8
  34. package/dist/tools/kintone/app/update-form-fields.js +50 -0
  35. package/dist/tools/kintone/app/update-form-layout.js +48 -0
  36. package/dist/tools/kintone/app/update-general-settings.js +119 -0
  37. package/dist/tools/kintone/file/download-file.js +49 -0
  38. package/dist/tools/kintone/record/add-records.js +8 -9
  39. package/dist/tools/kintone/record/delete-records.js +7 -8
  40. package/dist/tools/kintone/record/get-records.js +8 -9
  41. package/dist/tools/kintone/record/update-records.js +8 -9
  42. package/dist/tools/kintone/record/update-statuses.js +7 -8
  43. package/dist/tools/types/tool.js +1 -0
  44. package/dist/version.js +1 -1
  45. package/package.json +11 -6
  46. package/dist/server.js +0 -20
  47. package/dist/tool-filters.js +0 -14
  48. package/dist/tools/utils.js +0 -8
@@ -5,16 +5,39 @@ import { updateRecords } from "./kintone/record/update-records.js";
5
5
  import { getApp } from "./kintone/app/get-app.js";
6
6
  import { getApps } from "./kintone/app/get-apps.js";
7
7
  import { getFormFields } from "./kintone/app/get-form-fields.js";
8
+ import { getFormLayout } from "./kintone/app/get-form-layout.js";
9
+ import { updateFormFields } from "./kintone/app/update-form-fields.js";
10
+ import { updateFormLayout } from "./kintone/app/update-form-layout.js";
11
+ import { deleteFormFields } from "./kintone/app/delete-form-fields.js";
8
12
  import { getProcessManagement } from "./kintone/app/get-process-management.js";
13
+ import { getAppDeployStatus } from "./kintone/app/get-app-deploy-status.js";
14
+ import { getGeneralSettings } from "./kintone/app/get-general-settings.js";
15
+ import { addFormFields } from "./kintone/app/add-form-fields.js";
9
16
  import { updateStatuses } from "./kintone/record/update-statuses.js";
17
+ import { addApp } from "./kintone/app/add-app.js";
18
+ import { deployApp } from "./kintone/app/deploy-app.js";
19
+ import { updateGeneralSettings } from "./kintone/app/update-general-settings.js";
20
+ import { downloadFile } from "./kintone/file/download-file.js";
21
+ export { createToolCallback } from "./factory.js";
10
22
  export const tools = [
11
23
  getApp,
12
24
  getApps,
13
25
  getFormFields,
26
+ getFormLayout,
27
+ updateFormFields,
28
+ updateFormLayout,
29
+ deleteFormFields,
14
30
  getProcessManagement,
31
+ getAppDeployStatus,
32
+ getGeneralSettings,
33
+ addFormFields,
15
34
  updateStatuses,
16
35
  addRecords,
17
36
  deleteRecords,
18
37
  getRecords,
19
38
  updateRecords,
39
+ addApp,
40
+ deployApp,
41
+ updateGeneralSettings,
42
+ downloadFile,
20
43
  ];
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ import { createTool } from "../../factory.js";
3
+ const inputSchema = {
4
+ name: z
5
+ .string()
6
+ .max(64)
7
+ .describe("The name of the app to create (max 64 characters)"),
8
+ space: z
9
+ .number()
10
+ .optional()
11
+ .describe("The space ID where the app will be created"),
12
+ };
13
+ const outputSchema = {
14
+ app: z.string().describe("The ID of the created app"),
15
+ revision: z.string().describe("The revision number of the created app"),
16
+ };
17
+ const toolName = "kintone-add-app";
18
+ const toolConfig = {
19
+ title: "Add App",
20
+ description: "Create a new app in the pre-live environment on kintone. The pre-live environment is a temporary storage area where app information is saved before deployment. To reflect changes to the production environment, execute the kintone-deploy-app tool after this tool.",
21
+ inputSchema,
22
+ outputSchema,
23
+ };
24
+ const callback = async ({ name, space }, { client }) => {
25
+ const app = await client.app.addApp({ name, space });
26
+ const result = {
27
+ app: app.app,
28
+ revision: app.revision,
29
+ };
30
+ return {
31
+ structuredContent: result,
32
+ content: [
33
+ {
34
+ type: "text",
35
+ text: JSON.stringify(result, null, 2),
36
+ },
37
+ ],
38
+ };
39
+ };
40
+ export const addApp = createTool(toolName, toolConfig, callback);
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ import { createTool } from "../../factory.js";
3
+ import { propertiesForParameterSchema } from "../../../schema/app/index.js";
4
+ const inputSchema = {
5
+ app: z
6
+ .string()
7
+ .describe("The ID of the app to add fields to (numeric value as string)"),
8
+ properties: propertiesForParameterSchema.describe("Object containing field configurations to add"),
9
+ revision: z
10
+ .string()
11
+ .optional()
12
+ .describe("Expected app configuration revision number. If the specified revision number does not match the current app's revision, an error will occur and the update will not be performed. If not specified or set to '-1', the revision number will not be checked."),
13
+ };
14
+ const outputSchema = {
15
+ revision: z.string().describe("Updated app configuration revision number"),
16
+ };
17
+ const toolName = "kintone-add-form-fields";
18
+ const toolConfig = {
19
+ title: "Add Form Fields",
20
+ description: "Add new fields to a kintone app (preview environment only). " +
21
+ "Requires App Management permissions. " +
22
+ "Field codes must be unique, max 128 chars, cannot start with numbers, and only '_' symbol allowed. " +
23
+ "For selection fields (DROP_DOWN/RADIO_BUTTON/CHECK_BOX/MULTI_SELECT), option keys must exactly match their label values. " +
24
+ "Options require 'label' and 'index' properties. " +
25
+ "For lookup fields, use appropriate field type (NUMBER for RECORD_NUMBER, SINGLE_LINE_TEXT for text fields). " +
26
+ "Use kintone-get-form-fields first to check existing fields. " +
27
+ "Changes require kintone-deploy-app to apply to live app.",
28
+ inputSchema,
29
+ outputSchema,
30
+ };
31
+ const callback = async ({ app, properties, revision }, { client }) => {
32
+ const response = await client.app.addFormFields({
33
+ app,
34
+ properties,
35
+ revision,
36
+ });
37
+ const result = {
38
+ revision: response.revision,
39
+ };
40
+ return {
41
+ structuredContent: result,
42
+ content: [
43
+ {
44
+ type: "text",
45
+ text: JSON.stringify(result, null, 2),
46
+ },
47
+ ],
48
+ };
49
+ };
50
+ export const addFormFields = createTool(toolName, toolConfig, callback);
@@ -0,0 +1,51 @@
1
+ import { z } from "zod";
2
+ import { createTool } from "../../factory.js";
3
+ const inputSchema = {
4
+ app: z
5
+ .string()
6
+ .describe("The ID of the app to delete form fields from (numeric value as string)"),
7
+ fields: z
8
+ .array(z.string())
9
+ .min(1, "At least one field code is required")
10
+ .max(100, "Maximum 100 fields can be deleted at once")
11
+ .describe("Array of field codes to delete"),
12
+ revision: z
13
+ .string()
14
+ .optional()
15
+ .describe("Expected app configuration revision number. If the specified revision number does not match the current app's revision, an error will occur and the update will not be performed. If not specified or set to '-1', the revision number will not be checked."),
16
+ };
17
+ const outputSchema = {
18
+ revision: z.string().describe("The new revision number after deletion"),
19
+ };
20
+ const toolName = "kintone-delete-form-fields";
21
+ const toolConfig = {
22
+ title: "Delete Form Fields",
23
+ description: "Delete form fields from a kintone app (preview environment only). " +
24
+ "Maximum 100 fields can be deleted at once. " +
25
+ "Cannot delete status, assignee, or category fields. " +
26
+ "Useful for recreating lookup fields when updates fail. " +
27
+ "Use kintone-get-form-fields first to verify field codes. " +
28
+ "Changes require kintone-deploy-app to apply to live app.",
29
+ inputSchema,
30
+ outputSchema,
31
+ };
32
+ const callback = async ({ app, fields, revision }, { client }) => {
33
+ const response = (await client.app.deleteFormFields({
34
+ app,
35
+ fields,
36
+ revision,
37
+ }));
38
+ const result = {
39
+ revision: response.revision,
40
+ };
41
+ return {
42
+ structuredContent: result,
43
+ content: [
44
+ {
45
+ type: "text",
46
+ text: JSON.stringify(result, null, 2),
47
+ },
48
+ ],
49
+ };
50
+ };
51
+ export const deleteFormFields = createTool(toolName, toolConfig, callback);
@@ -0,0 +1,48 @@
1
+ import { z } from "zod";
2
+ import { createTool } from "../../factory.js";
3
+ const inputSchema = {
4
+ apps: z
5
+ .array(z.object({
6
+ app: z
7
+ .string()
8
+ .describe("The ID of the app to deploy (numeric value as string)"),
9
+ revision: z
10
+ .string()
11
+ .optional()
12
+ .describe("The expected revision number"),
13
+ }))
14
+ .min(1)
15
+ .max(300)
16
+ .describe("List of apps to deploy (minimum 1, maximum 300 apps)"),
17
+ revert: z
18
+ .boolean()
19
+ .optional()
20
+ .describe("If true, revert changes instead of deploying (default: false)"),
21
+ };
22
+ const outputSchema = {
23
+ message: z.string().describe("Deployment status message"),
24
+ };
25
+ const toolName = "kintone-deploy-app";
26
+ const toolConfig = {
27
+ title: "Deploy App Settings",
28
+ description: "Deploy app settings from pre-live to production environment on kintone. " +
29
+ "This is an asynchronous API - use kintone-get-app-deploy-status tool to check deployment progress.",
30
+ inputSchema,
31
+ outputSchema,
32
+ };
33
+ const callback = async ({ apps, revert }, { client }) => {
34
+ await client.app.deployApp({ apps, revert });
35
+ const result = {
36
+ message: `Deployment initiated for ${apps.length} app(s). Use kintone-get-app-deploy-status tool to check progress.`,
37
+ };
38
+ return {
39
+ structuredContent: result,
40
+ content: [
41
+ {
42
+ type: "text",
43
+ text: JSON.stringify(result, null, 2),
44
+ },
45
+ ],
46
+ };
47
+ };
48
+ export const deployApp = createTool(toolName, toolConfig, callback);
@@ -0,0 +1,42 @@
1
+ import { z } from "zod";
2
+ import { createTool } from "../../factory.js";
3
+ const inputSchema = {
4
+ apps: z
5
+ .array(z.union([z.string(), z.number()]))
6
+ .min(1, "At least one app ID is required")
7
+ .max(300, "Maximum 300 app IDs allowed")
8
+ .describe("Array of app IDs to check deploy status (maximum 300)"),
9
+ };
10
+ const deployStatusEnum = z.enum(["PROCESSING", "SUCCESS", "FAIL", "CANCEL"], {
11
+ description: "Deployment status: PROCESSING (in progress), SUCCESS (completed), FAIL (failed), CANCEL (canceled)",
12
+ });
13
+ const outputSchema = {
14
+ apps: z
15
+ .array(z.object({
16
+ app: z.string().describe("The app ID"),
17
+ status: deployStatusEnum.describe("The deployment status"),
18
+ }))
19
+ .describe("Array of app deploy statuses"),
20
+ };
21
+ const toolName = "kintone-get-app-deploy-status";
22
+ const toolConfig = {
23
+ title: "Get App Deploy Status",
24
+ description: "Get app deploy status from kintone",
25
+ inputSchema,
26
+ outputSchema,
27
+ };
28
+ const callback = async ({ apps }, { client }) => {
29
+ const result = await client.app.getDeployStatus({
30
+ apps,
31
+ });
32
+ return {
33
+ structuredContent: result,
34
+ content: [
35
+ {
36
+ type: "text",
37
+ text: JSON.stringify(result, null, 2),
38
+ },
39
+ ],
40
+ };
41
+ };
42
+ export const getAppDeployStatus = createTool(toolName, toolConfig, callback);
@@ -1,7 +1,5 @@
1
1
  import { z } from "zod";
2
- import { createTool } from "../../utils.js";
3
- import { getKintoneClient } from "../../../client.js";
4
- import { parseKintoneClientConfig } from "../../../config/index.js";
2
+ import { createTool } from "../../factory.js";
5
3
  const inputSchema = {
6
4
  appId: z
7
5
  .string()
@@ -37,14 +35,14 @@ const outputSchema = {
37
35
  })
38
36
  .describe("The modifier information"),
39
37
  };
40
- export const getApp = createTool("kintone-get-app", {
38
+ const toolName = "kintone-get-app";
39
+ const toolConfig = {
41
40
  title: "Get App",
42
41
  description: "Get app settings from kintone",
43
42
  inputSchema,
44
43
  outputSchema,
45
- }, async ({ appId }) => {
46
- const config = parseKintoneClientConfig();
47
- const client = getKintoneClient(config);
44
+ };
45
+ const callback = async ({ appId }, { client }) => {
48
46
  const app = await client.app.getApp({ id: appId });
49
47
  const result = {
50
48
  appId: app.appId,
@@ -67,4 +65,5 @@ export const getApp = createTool("kintone-get-app", {
67
65
  },
68
66
  ],
69
67
  };
70
- });
68
+ };
69
+ export const getApp = createTool(toolName, toolConfig, callback);
@@ -1,7 +1,5 @@
1
1
  import { z } from "zod";
2
- import { createTool } from "../../utils.js";
3
- import { getKintoneClient } from "../../../client.js";
4
- import { parseKintoneClientConfig } from "../../../config/index.js";
2
+ import { createTool } from "../../factory.js";
5
3
  const inputSchema = {
6
4
  ids: z
7
5
  .array(z.string())
@@ -70,14 +68,14 @@ const appSchema = z.object({
70
68
  const outputSchema = {
71
69
  apps: z.array(appSchema).describe("Array of app information"),
72
70
  };
73
- export const getApps = createTool("kintone-get-apps", {
71
+ const toolName = "kintone-get-apps";
72
+ const toolConfig = {
74
73
  title: "Get Apps",
75
74
  description: "Get multiple app settings from kintone",
76
75
  inputSchema,
77
76
  outputSchema,
78
- }, async ({ ids, codes, name, spaceIds, offset, limit }) => {
79
- const config = parseKintoneClientConfig();
80
- const client = getKintoneClient(config);
77
+ };
78
+ const callback = async ({ ids, codes, name, spaceIds, offset, limit }, { client }) => {
81
79
  const response = await client.app.getApps({
82
80
  ids,
83
81
  codes,
@@ -109,4 +107,5 @@ export const getApps = createTool("kintone-get-apps", {
109
107
  },
110
108
  ],
111
109
  };
112
- });
110
+ };
111
+ export const getApps = createTool(toolName, toolConfig, callback);
@@ -1,7 +1,6 @@
1
1
  import { z } from "zod";
2
- import { createTool } from "../../utils.js";
3
- import { getKintoneClient } from "../../../client.js";
4
- import { parseKintoneClientConfig } from "../../../config/index.js";
2
+ import { createTool } from "../../factory.js";
3
+ import { propertiesForParameterSchema } from "../../../schema/app/index.js";
5
4
  const inputSchema = {
6
5
  app: z
7
6
  .string()
@@ -10,120 +9,33 @@ const inputSchema = {
10
9
  .enum(["ja", "en", "zh", "default", "user"])
11
10
  .optional()
12
11
  .describe("The language for field names"),
13
- };
14
- const fieldPropertySchema = z.object({
15
- type: z.string().describe("The field type"),
16
- code: z.string().describe("The field code"),
17
- label: z.string().describe("The field name"),
18
- enabled: z
19
- .boolean()
20
- .optional()
21
- .describe("Whether the field is enabled (for STATUS and CATEGORY fields)"),
22
- noLabel: z.boolean().optional().describe("Whether to hide the field name"),
23
- required: z.boolean().optional().describe("Whether the field is required"),
24
- unique: z.boolean().optional().describe("Whether the field must be unique"),
25
- maxValue: z.string().optional().describe("Maximum value"),
26
- minValue: z.string().optional().describe("Minimum value"),
27
- maxLength: z.string().optional().describe("Maximum length"),
28
- minLength: z.string().optional().describe("Minimum length"),
29
- defaultValue: z.any().optional().describe("Default value"),
30
- defaultNowValue: z
12
+ preview: z
31
13
  .boolean()
32
14
  .optional()
33
- .describe("Whether to use current date/time as default"),
34
- entities: z
35
- .array(z.object({
36
- type: z.enum(["USER", "GROUP", "ORGANIZATION"]),
37
- code: z.string(),
38
- }))
39
- .optional()
40
- .describe("Default entities for user/group/organization selection fields"),
41
- options: z
42
- .record(z.object({
43
- label: z.string(),
44
- index: z.string(),
45
- }))
46
- .optional()
47
- .describe("Options for selection fields"),
48
- align: z
49
- .enum(["HORIZONTAL", "VERTICAL"])
50
- .optional()
51
- .describe("Option alignment for radio/checkbox fields"),
52
- expression: z.string().optional().describe("Calculation formula"),
53
- hideExpression: z
54
- .boolean()
55
- .optional()
56
- .describe("Whether to hide the formula"),
57
- format: z.string().optional().describe("Display format"),
58
- displayScale: z.string().optional().describe("Number of decimal places"),
59
- unit: z.string().optional().describe("Unit symbol"),
60
- unitPosition: z
61
- .enum(["BEFORE", "AFTER"])
62
- .optional()
63
- .describe("Unit position"),
64
- digit: z.boolean().optional().describe("Whether to use thousands separator"),
65
- thumbnailSize: z.string().optional().describe("Image thumbnail size"),
66
- protocol: z
67
- .enum(["WEB", "CALL", "MAIL"])
68
- .optional()
69
- .describe("Link protocol"),
70
- lookup: z
71
- .object({
72
- relatedApp: z.object({
73
- app: z.string(),
74
- code: z.string(),
75
- }),
76
- relatedKeyField: z.string(),
77
- fieldMappings: z.array(z.object({
78
- field: z.string(),
79
- relatedField: z.string(),
80
- })),
81
- lookupPickerFields: z.array(z.string()),
82
- filterCond: z.string().optional(),
83
- sort: z.string().optional(),
84
- })
85
- .optional()
86
- .describe("Lookup settings"),
87
- referenceTable: z
88
- .object({
89
- relatedApp: z.object({
90
- app: z.string(),
91
- code: z.string(),
92
- }),
93
- condition: z.object({
94
- field: z.string(),
95
- relatedField: z.string(),
96
- }),
97
- filterCond: z.string().optional(),
98
- displayFields: z.array(z.string()),
99
- sort: z.string().optional(),
100
- size: z.string().optional(),
101
- })
102
- .optional()
103
- .describe("Related records settings"),
104
- fields: z.record(z.any()).optional().describe("Fields in subtable"),
105
- openGroup: z
106
- .boolean()
107
- .optional()
108
- .describe("Whether the group is expanded by default"),
109
- });
15
+ .describe("Whether to get form fields from pre-live environment"),
16
+ };
110
17
  const outputSchema = {
111
- properties: z
112
- .record(fieldPropertySchema)
113
- .describe("Object containing field configurations"),
18
+ properties: propertiesForParameterSchema.describe("Object containing field configurations"),
114
19
  revision: z.string().describe("App configuration revision number"),
115
20
  };
116
- export const getFormFields = createTool("kintone-get-form-fields", {
21
+ const toolName = "kintone-get-form-fields";
22
+ const toolConfig = {
117
23
  title: "Get Form Fields",
118
- description: "Get form field settings from a kintone app",
24
+ description: "Get form field settings from a kintone app. " +
25
+ "Returns detailed field information including type, code, label, and all configuration settings " +
26
+ "(required status, default values, validation rules, options for selection fields, lookup configurations). " +
27
+ "Response includes 'properties' object with all fields and 'revision' string. " +
28
+ "Essential for understanding current field structure before add/update/delete operations. " +
29
+ "Use to verify lookup field configurations and field mappings. " +
30
+ "Supports both live and pre-live app settings retrieval.",
119
31
  inputSchema,
120
32
  outputSchema,
121
- }, async ({ app, lang }) => {
122
- const config = parseKintoneClientConfig();
123
- const client = getKintoneClient(config);
33
+ };
34
+ const callback = async ({ app, lang, preview }, { client }) => {
124
35
  const response = await client.app.getFormFields({
125
36
  app,
126
37
  lang,
38
+ preview,
127
39
  });
128
40
  const result = {
129
41
  properties: response.properties,
@@ -138,4 +50,5 @@ export const getFormFields = createTool("kintone-get-form-fields", {
138
50
  },
139
51
  ],
140
52
  };
141
- });
53
+ };
54
+ export const getFormFields = createTool(toolName, toolConfig, callback);
@@ -0,0 +1,45 @@
1
+ import { z } from "zod";
2
+ import { createTool } from "../../factory.js";
3
+ import { layoutForParameterSchema } from "../../../schema/app/index.js";
4
+ const inputSchema = {
5
+ app: z
6
+ .string()
7
+ .describe("The ID of the app to retrieve form layout from (numeric value as string)"),
8
+ preview: z
9
+ .boolean()
10
+ .optional()
11
+ .describe("Whether to retrieve from preview environment (requires app administration permission for preview, record view/add permission for production)"),
12
+ };
13
+ const outputSchema = {
14
+ layout: layoutForParameterSchema.describe("Array of layout elements (rows, subtables, groups)"),
15
+ revision: z.string().describe("App configuration revision number"),
16
+ };
17
+ const callback = async ({ app, preview }, { client }) => {
18
+ const response = await client.app.getFormLayout({
19
+ app,
20
+ preview,
21
+ });
22
+ const result = {
23
+ layout: response.layout,
24
+ revision: response.revision,
25
+ };
26
+ return {
27
+ structuredContent: result,
28
+ content: [
29
+ {
30
+ type: "text",
31
+ text: JSON.stringify(result, null, 2),
32
+ },
33
+ ],
34
+ };
35
+ };
36
+ export const getFormLayout = createTool("kintone-get-form-layout", {
37
+ title: "Get Form Layout",
38
+ description: "Get form layout from a kintone app. " +
39
+ "Returns layout structure with rows, subtables, groups, and field positioning. " +
40
+ "Use to understand current form arrangement before layout updates. " +
41
+ "Essential when adding new fields that need specific positioning or when rearranging existing fields. " +
42
+ "Supports both live and pre-live app settings retrieval.",
43
+ inputSchema,
44
+ outputSchema,
45
+ }, callback);
@@ -0,0 +1,119 @@
1
+ import { z } from "zod";
2
+ import { createTool } from "../../factory.js";
3
+ const inputSchema = {
4
+ app: z
5
+ .string()
6
+ .describe("The ID of the app to retrieve (numeric value as string)"),
7
+ lang: z
8
+ .enum(["ja", "en", "zh", "default", "user"])
9
+ .optional()
10
+ .describe("The language for retrieving the app name and description"),
11
+ preview: z
12
+ .boolean()
13
+ .optional()
14
+ .describe("Whether to retrieve from preview environment (requires app administration permission for preview, record view/add permission for production)"),
15
+ };
16
+ const outputSchema = {
17
+ name: z.string().describe("The app name"),
18
+ description: z.string().describe("The app description"),
19
+ icon: z
20
+ .object({
21
+ type: z.enum(["FILE", "PRESET"]).describe("The icon type"),
22
+ key: z.string().optional().describe("The icon key"),
23
+ file: z
24
+ .object({
25
+ contentType: z.string().describe("The content type of the file"),
26
+ fileKey: z.string().describe("The file key"),
27
+ name: z.string().describe("The file name"),
28
+ size: z.string().describe("The file size"),
29
+ })
30
+ .optional()
31
+ .describe("File information (only when type is FILE)"),
32
+ })
33
+ .describe("The app icon settings"),
34
+ theme: z
35
+ .enum([
36
+ "WHITE",
37
+ "CLIPBOARD",
38
+ "BINDER",
39
+ "PENCIL",
40
+ "CLIPS",
41
+ "RED",
42
+ "BLUE",
43
+ "GREEN",
44
+ "YELLOW",
45
+ "BLACK",
46
+ ])
47
+ .describe("The app theme"),
48
+ titleField: z
49
+ .object({
50
+ selectionMode: z
51
+ .enum(["AUTO", "MANUAL"])
52
+ .describe("Title field selection mode"),
53
+ code: z.string().optional().describe("Field code for manual selection"),
54
+ })
55
+ .describe("Record title field configuration"),
56
+ enableThumbnails: z.boolean().describe("Whether thumbnails are enabled"),
57
+ enableBulkDeletion: z
58
+ .boolean()
59
+ .describe("Whether bulk record deletion is enabled"),
60
+ enableComments: z.boolean().describe("Whether comments are enabled"),
61
+ enableDuplicateRecord: z
62
+ .boolean()
63
+ .describe("Whether record duplication is enabled"),
64
+ enableInlineRecordEditing: z
65
+ .boolean()
66
+ .describe("Whether inline record editing is enabled"),
67
+ numberPrecision: z
68
+ .object({
69
+ digits: z.string().describe("The number of digits (1 to 30)"),
70
+ decimalPlaces: z
71
+ .string()
72
+ .describe("The number of decimal places (0 to 10)"),
73
+ roundingMode: z
74
+ .enum(["HALF_EVEN", "UP", "DOWN"])
75
+ .describe("The rounding mode"),
76
+ })
77
+ .describe("The numeric calculation settings"),
78
+ firstMonthOfFiscalYear: z
79
+ .string()
80
+ .describe("The first month of the fiscal year (1-12)"),
81
+ revision: z.string().describe("The revision number"),
82
+ };
83
+ const toolName = "kintone-get-general-settings";
84
+ const toolConfig = {
85
+ title: "Get General Settings",
86
+ description: "Get general settings of a kintone app",
87
+ inputSchema,
88
+ outputSchema,
89
+ };
90
+ const callback = async ({ app, lang, preview }, { client }) => {
91
+ const settings = await client.app.getAppSettings({ app, lang, preview });
92
+ console.log(settings);
93
+ const result = {
94
+ name: settings.name,
95
+ description: settings.description,
96
+ icon: settings.icon,
97
+ theme: settings.theme,
98
+ titleField: settings.titleField,
99
+ enableThumbnails: settings.enableThumbnails,
100
+ enableBulkDeletion: settings.enableBulkDeletion,
101
+ enableComments: settings.enableComments,
102
+ enableDuplicateRecord: settings.enableDuplicateRecord,
103
+ // @ts-ignore - enableInlineRecordEditing is not yet in the Kintone SDK types but exists in API response
104
+ enableInlineRecordEditing: settings.enableInlineRecordEditing,
105
+ numberPrecision: settings.numberPrecision,
106
+ firstMonthOfFiscalYear: settings.firstMonthOfFiscalYear,
107
+ revision: settings.revision,
108
+ };
109
+ return {
110
+ structuredContent: result,
111
+ content: [
112
+ {
113
+ type: "text",
114
+ text: JSON.stringify(result, null, 2),
115
+ },
116
+ ],
117
+ };
118
+ };
119
+ export const getGeneralSettings = createTool(toolName, toolConfig, callback);