@hubspot/cli 7.6.0-beta.11 → 7.6.0-beta.13
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/commands/app/__tests__/migrate.test.js +1 -0
- package/commands/getStarted.js +7 -20
- package/commands/mcp/setup.d.ts +0 -1
- package/commands/mcp/setup.js +11 -11
- package/commands/project/__tests__/add.test.js +64 -0
- package/commands/project/__tests__/create.test.js +57 -0
- package/commands/project/__tests__/deploy.test.js +3 -2
- package/commands/project/add.d.ts +1 -1
- package/commands/project/add.js +3 -5
- package/commands/project/create.js +7 -2
- package/commands/project/deploy.js +9 -61
- package/commands/project/dev/index.js +1 -1
- package/commands/project/dev/unifiedFlow.js +4 -1
- package/commands/project/migrate.js +26 -7
- package/commands/project/upload.js +2 -2
- package/commands/project/validate.js +1 -1
- package/commands/project/watch.js +2 -2
- package/lang/en.d.ts +20 -5
- package/lang/en.js +38 -22
- package/lang/en.lyaml +12 -12
- package/lib/__tests__/hasFeature.test.js +145 -7
- package/lib/__tests__/importData.test.js +1 -1
- package/lib/app/__tests__/migrate.test.js +14 -51
- package/lib/app/migrate.d.ts +2 -8
- package/lib/app/migrate.js +5 -73
- package/lib/constants.d.ts +4 -0
- package/lib/constants.js +4 -0
- package/lib/errorHandlers/index.d.ts +4 -0
- package/lib/errorHandlers/index.js +1 -1
- package/lib/hasFeature.js +6 -0
- package/lib/importData.js +1 -1
- package/lib/links.d.ts +1 -0
- package/lib/links.js +10 -3
- package/lib/mcp/setup.d.ts +0 -2
- package/lib/mcp/setup.js +4 -29
- package/lib/projects/__tests__/AppDevModeInterface.test.js +71 -44
- package/lib/projects/__tests__/LocalDevProcess.test.js +1 -0
- package/lib/projects/__tests__/components.test.js +164 -7
- package/lib/projects/__tests__/deploy.test.js +164 -0
- package/lib/projects/__tests__/platformVersion.test.d.ts +1 -0
- package/lib/projects/__tests__/{buildAndDeploy.test.js → platformVersion.test.js} +2 -2
- package/lib/projects/add/__tests__/legacyAddComponent.test.js +49 -6
- package/lib/projects/add/__tests__/v3AddComponent.test.js +142 -8
- package/lib/projects/add/legacyAddComponent.d.ts +1 -1
- package/lib/projects/add/legacyAddComponent.js +5 -1
- package/lib/projects/add/v3AddComponent.d.ts +2 -1
- package/lib/projects/add/v3AddComponent.js +22 -5
- package/lib/projects/components.d.ts +1 -0
- package/lib/projects/components.js +27 -1
- package/lib/projects/create/__tests__/v3.test.js +97 -9
- package/lib/projects/create/index.js +2 -2
- package/lib/projects/create/legacy.js +1 -1
- package/lib/projects/create/v3.d.ts +2 -2
- package/lib/projects/create/v3.js +35 -12
- package/lib/projects/deploy.d.ts +13 -0
- package/lib/projects/deploy.js +63 -0
- package/lib/projects/localDev/AppDevModeInterface.d.ts +5 -3
- package/lib/projects/localDev/AppDevModeInterface.js +110 -47
- package/lib/projects/localDev/DevServerManagerV2.js +1 -0
- package/lib/projects/localDev/LocalDevProcess.js +3 -1
- package/lib/projects/localDev/LocalDevState.d.ts +5 -2
- package/lib/projects/localDev/LocalDevState.js +9 -1
- package/lib/projects/localDev/helpers/project.d.ts +2 -2
- package/lib/projects/localDev/helpers/project.js +6 -8
- package/lib/projects/platformVersion.d.ts +1 -0
- package/lib/projects/platformVersion.js +10 -0
- package/lib/projects/{buildAndDeploy.d.ts → pollProjectBuildAndDeploy.d.ts} +0 -1
- package/lib/projects/{buildAndDeploy.js → pollProjectBuildAndDeploy.js} +0 -10
- package/lib/projects/upload.js +1 -1
- package/lib/projects/urls.d.ts +1 -0
- package/lib/projects/urls.js +3 -0
- package/lib/prompts/__tests__/projectAddPrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/projectAddPrompt.test.js +143 -0
- package/lib/prompts/__tests__/selectProjectTemplatePrompt.test.d.ts +1 -0
- package/lib/prompts/__tests__/selectProjectTemplatePrompt.test.js +160 -0
- package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +1 -0
- package/lib/prompts/importDataFilePathPrompt.js +4 -2
- package/lib/prompts/installAppPrompt.d.ts +6 -1
- package/lib/prompts/installAppPrompt.js +6 -1
- package/lib/prompts/projectAddPrompt.js +1 -1
- package/lib/prompts/promptUtils.d.ts +5 -0
- package/lib/prompts/promptUtils.js +9 -0
- package/lib/prompts/selectProjectTemplatePrompt.js +1 -1
- package/lib/theme/__tests__/migrate.test.d.ts +1 -0
- package/lib/theme/__tests__/migrate.test.js +233 -0
- package/lib/theme/migrate.d.ts +13 -0
- package/lib/theme/migrate.js +90 -0
- package/lib/ui/index.js +3 -6
- package/lib/usageTracking.js +2 -2
- package/mcp-server/tools/cms/HsCreateFunctionTool.d.ts +32 -0
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +96 -0
- package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +38 -0
- package/mcp-server/tools/cms/HsCreateModuleTool.js +118 -0
- package/mcp-server/tools/cms/HsCreateTemplateTool.d.ts +26 -0
- package/mcp-server/tools/cms/HsCreateTemplateTool.js +75 -0
- package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +32 -0
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +76 -0
- package/mcp-server/tools/cms/HsListFunctionsTool.d.ts +23 -0
- package/mcp-server/tools/cms/HsListFunctionsTool.js +58 -0
- package/mcp-server/tools/cms/HsListTool.js +1 -1
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.d.ts +1 -0
- package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +251 -0
- package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.d.ts +1 -0
- package/mcp-server/tools/cms/__tests__/HsCreateModuleTool.test.js +224 -0
- package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.d.ts +1 -0
- package/mcp-server/tools/cms/__tests__/HsCreateTemplateTool.test.js +206 -0
- package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.d.ts +1 -0
- package/mcp-server/tools/cms/__tests__/HsFunctionLogsTool.test.js +183 -0
- package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.d.ts +1 -0
- package/mcp-server/tools/cms/__tests__/HsListFunctionsTool.test.js +120 -0
- package/mcp-server/tools/cms/__tests__/HsListTool.test.js +1 -1
- package/mcp-server/tools/index.js +13 -1
- package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/AddFeatureToProjectTool.js +3 -3
- package/mcp-server/tools/project/CreateProjectTool.d.ts +3 -3
- package/mcp-server/tools/project/CreateProjectTool.js +5 -5
- package/mcp-server/tools/project/DeployProjectTool.js +1 -1
- package/mcp-server/tools/project/DocFetchTool.js +2 -2
- package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocsSearchTool.js +7 -7
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +4 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +14 -8
- package/mcp-server/tools/project/GuidedWalkthroughTool.js +1 -1
- package/mcp-server/tools/project/UploadProjectTools.js +2 -2
- package/mcp-server/tools/project/ValidateProjectTool.js +1 -1
- package/mcp-server/tools/project/__tests__/AddFeatureToProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/DeployProjectTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +2 -2
- package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +14 -12
- package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +9 -8
- package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +1 -1
- package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +1 -1
- package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +1 -1
- package/mcp-server/tools/project/constants.d.ts +1 -1
- package/mcp-server/tools/project/constants.js +14 -6
- package/mcp-server/utils/__tests__/cliConfig.test.d.ts +1 -0
- package/mcp-server/utils/__tests__/cliConfig.test.js +110 -0
- package/mcp-server/utils/cliConfig.d.ts +1 -0
- package/mcp-server/utils/cliConfig.js +12 -0
- package/package.json +4 -3
- package/types/LocalDev.d.ts +2 -1
- package/types/Projects.d.ts +1 -0
- package/ui/components/BoxWithTitle.d.ts +8 -0
- package/ui/components/BoxWithTitle.js +9 -0
- package/ui/components/HorizontalSelectPrompt.d.ts +8 -0
- package/ui/components/HorizontalSelectPrompt.js +30 -0
- package/ui/components/StatusMessageBoxes.d.ts +12 -0
- package/ui/components/StatusMessageBoxes.js +31 -0
- package/ui/lib/ui-testing-utils.d.ts +9 -0
- package/ui/lib/ui-testing-utils.js +47 -0
- package/ui/lib/useTerminalSize.d.ts +13 -0
- package/ui/lib/useTerminalSize.js +31 -0
- package/ui/styles.d.ts +18 -0
- package/ui/styles.js +18 -0
- package/ui/views/UiSandbox.d.ts +5 -0
- package/ui/views/UiSandbox.js +25 -0
- /package/lib/projects/__tests__/{buildAndDeploy.test.d.ts → deploy.test.d.ts} +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { Tool } from '../../types.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
|
|
4
|
+
import { runCommandInDir } from '../../utils/project.js';
|
|
5
|
+
import { formatTextContents, formatTextContent } from '../../utils/content.js';
|
|
6
|
+
import { trackToolUsage } from '../../utils/toolUsageTracking.js';
|
|
7
|
+
import { addFlag } from '../../utils/command.js';
|
|
8
|
+
import { CONTENT_TYPES } from '../../../types/Cms.js';
|
|
9
|
+
const inputSchema = {
|
|
10
|
+
absoluteCurrentWorkingDirectory,
|
|
11
|
+
userSuppliedName: z
|
|
12
|
+
.string()
|
|
13
|
+
.describe('REQUIRED - If not specified by the user, DO NOT choose. Ask the user to specify the name of the module they want to create.')
|
|
14
|
+
.optional(),
|
|
15
|
+
dest: z
|
|
16
|
+
.string()
|
|
17
|
+
.describe('The destination path where the module should be created on the current computer.')
|
|
18
|
+
.optional(),
|
|
19
|
+
moduleLabel: z
|
|
20
|
+
.string()
|
|
21
|
+
.describe('Label for module creation. Required for non-interactive module creation. If not provided, ask the user to provide it.')
|
|
22
|
+
.optional(),
|
|
23
|
+
reactType: z
|
|
24
|
+
.boolean()
|
|
25
|
+
.describe('Whether to create a React module. If the user has not specified that they want a React module, DO NOT choose for them, ask them what type of module they want to create HubL or React.')
|
|
26
|
+
.optional(),
|
|
27
|
+
contentTypes: z
|
|
28
|
+
.string()
|
|
29
|
+
.refine(val => {
|
|
30
|
+
if (!val)
|
|
31
|
+
return true; // optional
|
|
32
|
+
const types = val.split(',').map(t => t.trim().toUpperCase());
|
|
33
|
+
return types.every(type => CONTENT_TYPES.includes(type));
|
|
34
|
+
}, {
|
|
35
|
+
message: `Content types must be a comma-separated list of valid values: ${CONTENT_TYPES.join(', ')}`,
|
|
36
|
+
})
|
|
37
|
+
.describe(`Content types where the module can be used. Comma-separated list. Valid values: ${CONTENT_TYPES.join(', ')}. Defaults to "ANY".`)
|
|
38
|
+
.optional(),
|
|
39
|
+
global: z
|
|
40
|
+
.boolean()
|
|
41
|
+
.describe('Whether the module is global. Defaults to false.')
|
|
42
|
+
.optional(),
|
|
43
|
+
availableForNewContent: z
|
|
44
|
+
.boolean()
|
|
45
|
+
.describe('Whether the module is available for new content. Defaults to true.')
|
|
46
|
+
.optional(),
|
|
47
|
+
};
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
49
|
+
const inputSchemaZodObject = z.object({ ...inputSchema });
|
|
50
|
+
const toolName = 'create-cms-module';
|
|
51
|
+
export class HsCreateModuleTool extends Tool {
|
|
52
|
+
constructor(mcpServer) {
|
|
53
|
+
super(mcpServer);
|
|
54
|
+
}
|
|
55
|
+
async handler({ userSuppliedName, dest, moduleLabel, reactType, contentTypes, global, availableForNewContent, absoluteCurrentWorkingDirectory, }) {
|
|
56
|
+
await trackToolUsage(toolName);
|
|
57
|
+
const content = [];
|
|
58
|
+
// Always require a name
|
|
59
|
+
if (!userSuppliedName) {
|
|
60
|
+
content.push(formatTextContent(`Ask the user to specify the name of the module they want to create.`));
|
|
61
|
+
}
|
|
62
|
+
// Require module label
|
|
63
|
+
if (!moduleLabel) {
|
|
64
|
+
content.push(formatTextContent(`Ask the user to provide a label for the module.`));
|
|
65
|
+
}
|
|
66
|
+
// Ask about React vs HubL if not specified
|
|
67
|
+
if (reactType === undefined) {
|
|
68
|
+
content.push(formatTextContent(`Ask the user what type of module they want to create: HubL or React?`));
|
|
69
|
+
}
|
|
70
|
+
// If we have missing required information, return the prompts
|
|
71
|
+
if (content.length > 0) {
|
|
72
|
+
return {
|
|
73
|
+
content,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Build the command
|
|
77
|
+
let command = 'hs create module';
|
|
78
|
+
if (userSuppliedName) {
|
|
79
|
+
command += ` "${userSuppliedName}"`;
|
|
80
|
+
}
|
|
81
|
+
if (dest) {
|
|
82
|
+
command += ` "${dest}"`;
|
|
83
|
+
}
|
|
84
|
+
// Add module-specific flags
|
|
85
|
+
if (moduleLabel) {
|
|
86
|
+
command = addFlag(command, 'module-label', moduleLabel);
|
|
87
|
+
}
|
|
88
|
+
if (reactType !== undefined) {
|
|
89
|
+
command = addFlag(command, 'react-type', reactType);
|
|
90
|
+
}
|
|
91
|
+
if (contentTypes) {
|
|
92
|
+
command = addFlag(command, 'content-types', contentTypes);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
command = addFlag(command, 'content-types', 'ANY');
|
|
96
|
+
}
|
|
97
|
+
if (global !== undefined) {
|
|
98
|
+
command = addFlag(command, 'global', global);
|
|
99
|
+
}
|
|
100
|
+
if (availableForNewContent !== undefined) {
|
|
101
|
+
command = addFlag(command, 'available-for-new-content', availableForNewContent);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
|
|
105
|
+
return formatTextContents(stdout, stderr);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return formatTextContents(error instanceof Error ? error.message : `${error}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
register() {
|
|
112
|
+
return this.mcpServer.registerTool(toolName, {
|
|
113
|
+
title: 'Create HubSpot CMS Module',
|
|
114
|
+
description: 'Creates a new HubSpot CMS module using the hs create module command. Modules can be created non-interactively by specifying moduleLabel and other module options. You can create either HubL or React modules by setting the reactType parameter.',
|
|
115
|
+
inputSchema,
|
|
116
|
+
}, this.handler);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TextContentResponse, Tool } from '../../types.js';
|
|
2
|
+
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
declare const inputSchemaZodObject: z.ZodObject<{
|
|
5
|
+
absoluteCurrentWorkingDirectory: z.ZodString;
|
|
6
|
+
userSuppliedName: z.ZodOptional<z.ZodString>;
|
|
7
|
+
dest: z.ZodOptional<z.ZodString>;
|
|
8
|
+
templateType: z.ZodOptional<z.ZodEnum<["page-template", "email-template", "partial", "global-partial", "blog-listing-template", "blog-post-template", "search-template", "section"]>>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
absoluteCurrentWorkingDirectory: string;
|
|
11
|
+
dest?: string | undefined;
|
|
12
|
+
templateType?: "page-template" | "email-template" | "partial" | "global-partial" | "blog-listing-template" | "blog-post-template" | "search-template" | "section" | undefined;
|
|
13
|
+
userSuppliedName?: string | undefined;
|
|
14
|
+
}, {
|
|
15
|
+
absoluteCurrentWorkingDirectory: string;
|
|
16
|
+
dest?: string | undefined;
|
|
17
|
+
templateType?: "page-template" | "email-template" | "partial" | "global-partial" | "blog-listing-template" | "blog-post-template" | "search-template" | "section" | undefined;
|
|
18
|
+
userSuppliedName?: string | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export type HsCreateTemplateInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
21
|
+
export declare class HsCreateTemplateTool extends Tool<HsCreateTemplateInputSchema> {
|
|
22
|
+
constructor(mcpServer: McpServer);
|
|
23
|
+
handler({ userSuppliedName, dest, templateType, absoluteCurrentWorkingDirectory, }: HsCreateTemplateInputSchema): Promise<TextContentResponse>;
|
|
24
|
+
register(): RegisteredTool;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Tool } from '../../types.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
|
|
4
|
+
import { runCommandInDir } from '../../utils/project.js';
|
|
5
|
+
import { formatTextContents, formatTextContent } from '../../utils/content.js';
|
|
6
|
+
import { trackToolUsage } from '../../utils/toolUsageTracking.js';
|
|
7
|
+
import { addFlag } from '../../utils/command.js';
|
|
8
|
+
import { TEMPLATE_TYPES } from '../../../types/Cms.js';
|
|
9
|
+
const inputSchema = {
|
|
10
|
+
absoluteCurrentWorkingDirectory,
|
|
11
|
+
userSuppliedName: z
|
|
12
|
+
.string()
|
|
13
|
+
.describe('REQUIRED - If not specified by the user, DO NOT choose. Ask the user to specify the name of the template they want to create.')
|
|
14
|
+
.optional(),
|
|
15
|
+
dest: z
|
|
16
|
+
.string()
|
|
17
|
+
.describe('The destination path where the template should be created on the current computer.')
|
|
18
|
+
.optional(),
|
|
19
|
+
templateType: z
|
|
20
|
+
.enum(TEMPLATE_TYPES)
|
|
21
|
+
.describe(`Template type for template creation. Must be one of: ${TEMPLATE_TYPES.join(', ')}`)
|
|
22
|
+
.optional(),
|
|
23
|
+
};
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
+
const inputSchemaZodObject = z.object({ ...inputSchema });
|
|
26
|
+
const toolName = 'create-cms-template';
|
|
27
|
+
export class HsCreateTemplateTool extends Tool {
|
|
28
|
+
constructor(mcpServer) {
|
|
29
|
+
super(mcpServer);
|
|
30
|
+
}
|
|
31
|
+
async handler({ userSuppliedName, dest, templateType, absoluteCurrentWorkingDirectory, }) {
|
|
32
|
+
await trackToolUsage(toolName);
|
|
33
|
+
const content = [];
|
|
34
|
+
// Always require a name
|
|
35
|
+
if (!userSuppliedName) {
|
|
36
|
+
content.push(formatTextContent(`Ask the user to specify the name of the template they want to create.`));
|
|
37
|
+
}
|
|
38
|
+
// Require template type
|
|
39
|
+
if (!templateType) {
|
|
40
|
+
content.push(formatTextContent(`Ask the user what template type they want to create. Options are: ${TEMPLATE_TYPES.join(', ')}`));
|
|
41
|
+
}
|
|
42
|
+
// If we have missing required information, return the prompts
|
|
43
|
+
if (content.length > 0) {
|
|
44
|
+
return {
|
|
45
|
+
content,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Build the command
|
|
49
|
+
let command = 'hs create template';
|
|
50
|
+
if (userSuppliedName) {
|
|
51
|
+
command += ` "${userSuppliedName}"`;
|
|
52
|
+
}
|
|
53
|
+
if (dest) {
|
|
54
|
+
command += ` "${dest}"`;
|
|
55
|
+
}
|
|
56
|
+
// Add template type flag
|
|
57
|
+
if (templateType) {
|
|
58
|
+
command = addFlag(command, 'template-type', templateType);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
|
|
62
|
+
return formatTextContents(stdout, stderr);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return formatTextContents(error instanceof Error ? error.message : `${error}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
register() {
|
|
69
|
+
return this.mcpServer.registerTool(toolName, {
|
|
70
|
+
title: 'Create HubSpot CMS Template',
|
|
71
|
+
description: `Creates a new HubSpot CMS template using the hs create template command. Templates can be created non-interactively by specifying templateType. Supports all template types including: ${TEMPLATE_TYPES.join(', ')}.`,
|
|
72
|
+
inputSchema,
|
|
73
|
+
}, this.handler);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TextContentResponse, Tool } from '../../types.js';
|
|
2
|
+
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
declare const inputSchemaZodObject: z.ZodObject<{
|
|
5
|
+
absoluteCurrentWorkingDirectory: z.ZodString;
|
|
6
|
+
endpoint: z.ZodString;
|
|
7
|
+
account: z.ZodOptional<z.ZodString>;
|
|
8
|
+
latest: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
compact: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
endpoint: string;
|
|
13
|
+
absoluteCurrentWorkingDirectory: string;
|
|
14
|
+
account?: string | undefined;
|
|
15
|
+
limit?: number | undefined;
|
|
16
|
+
compact?: boolean | undefined;
|
|
17
|
+
latest?: boolean | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
endpoint: string;
|
|
20
|
+
absoluteCurrentWorkingDirectory: string;
|
|
21
|
+
account?: string | undefined;
|
|
22
|
+
limit?: number | undefined;
|
|
23
|
+
compact?: boolean | undefined;
|
|
24
|
+
latest?: boolean | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export type HsFunctionLogsInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
27
|
+
export declare class HsFunctionLogsTool extends Tool<HsFunctionLogsInputSchema> {
|
|
28
|
+
constructor(mcpServer: McpServer);
|
|
29
|
+
handler({ endpoint, account, latest, compact, limit, absoluteCurrentWorkingDirectory, }: HsFunctionLogsInputSchema): Promise<TextContentResponse>;
|
|
30
|
+
register(): RegisteredTool;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Tool } from '../../types.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { addFlag } from '../../utils/command.js';
|
|
4
|
+
import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
|
|
5
|
+
import { runCommandInDir } from '../../utils/project.js';
|
|
6
|
+
import { formatTextContents } from '../../utils/content.js';
|
|
7
|
+
import { trackToolUsage } from '../../utils/toolUsageTracking.js';
|
|
8
|
+
const inputSchema = {
|
|
9
|
+
absoluteCurrentWorkingDirectory,
|
|
10
|
+
endpoint: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe('The function endpoint/path to get logs for. Required. Example: "my-function" or "api/my-endpoint" (leading slash will be automatically removed)'),
|
|
13
|
+
account: z
|
|
14
|
+
.string()
|
|
15
|
+
.describe('The HubSpot account id or name from the HubSpot config file to use for the operation.')
|
|
16
|
+
.optional(),
|
|
17
|
+
latest: z
|
|
18
|
+
.boolean()
|
|
19
|
+
.describe('Get only the latest log entry for the function.')
|
|
20
|
+
.optional(),
|
|
21
|
+
compact: z.boolean().describe('Display logs in compact format.').optional(),
|
|
22
|
+
limit: z
|
|
23
|
+
.number()
|
|
24
|
+
.describe('Maximum number of log entries to retrieve.')
|
|
25
|
+
.optional(),
|
|
26
|
+
};
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
const inputSchemaZodObject = z.object({ ...inputSchema });
|
|
29
|
+
const toolName = 'get-cms-serverless-function-logs';
|
|
30
|
+
export class HsFunctionLogsTool extends Tool {
|
|
31
|
+
constructor(mcpServer) {
|
|
32
|
+
super(mcpServer);
|
|
33
|
+
}
|
|
34
|
+
async handler({ endpoint, account, latest, compact, limit, absoluteCurrentWorkingDirectory, }) {
|
|
35
|
+
await trackToolUsage(toolName);
|
|
36
|
+
// Ensure endpoint doesn't start with '/'
|
|
37
|
+
const normalizedEndpoint = endpoint.startsWith('/')
|
|
38
|
+
? endpoint.slice(1)
|
|
39
|
+
: endpoint;
|
|
40
|
+
let command = `hs logs ${normalizedEndpoint}`;
|
|
41
|
+
if (latest) {
|
|
42
|
+
command = addFlag(command, 'latest', latest);
|
|
43
|
+
}
|
|
44
|
+
if (compact) {
|
|
45
|
+
command = addFlag(command, 'compact', compact);
|
|
46
|
+
}
|
|
47
|
+
if (limit) {
|
|
48
|
+
command = addFlag(command, 'limit', limit);
|
|
49
|
+
}
|
|
50
|
+
if (account) {
|
|
51
|
+
command = addFlag(command, 'account', account);
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
|
|
55
|
+
return formatTextContents(stdout, stderr);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
59
|
+
return {
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'text',
|
|
63
|
+
text: `Error executing hs logs command: ${errorMessage}`,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
register() {
|
|
70
|
+
return this.mcpServer.registerTool(toolName, {
|
|
71
|
+
title: 'Get HubSpot CMS serverless function logs for an endpoint',
|
|
72
|
+
description: 'Retrieve logs for HubSpot CMS serverless functions. Use this tool to help debug issues with serverless functions by reading the production logs. Supports various options like latest, compact, and limiting results. Use after listing functions with list-cms-serverless-functions to get the endpoint path.',
|
|
73
|
+
inputSchema,
|
|
74
|
+
}, this.handler);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TextContentResponse, Tool } from '../../types.js';
|
|
2
|
+
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
declare const inputSchemaZodObject: z.ZodObject<{
|
|
5
|
+
absoluteCurrentWorkingDirectory: z.ZodString;
|
|
6
|
+
account: z.ZodOptional<z.ZodString>;
|
|
7
|
+
json: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
absoluteCurrentWorkingDirectory: string;
|
|
10
|
+
account?: string | undefined;
|
|
11
|
+
json?: boolean | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
absoluteCurrentWorkingDirectory: string;
|
|
14
|
+
account?: string | undefined;
|
|
15
|
+
json?: boolean | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
export type HsListFunctionsInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
18
|
+
export declare class HsListFunctionsTool extends Tool<HsListFunctionsInputSchema> {
|
|
19
|
+
constructor(mcpServer: McpServer);
|
|
20
|
+
handler({ account, json, absoluteCurrentWorkingDirectory, }: HsListFunctionsInputSchema): Promise<TextContentResponse>;
|
|
21
|
+
register(): RegisteredTool;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Tool } from '../../types.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { addFlag } from '../../utils/command.js';
|
|
4
|
+
import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
|
|
5
|
+
import { runCommandInDir } from '../../utils/project.js';
|
|
6
|
+
import { formatTextContents } from '../../utils/content.js';
|
|
7
|
+
import { trackToolUsage } from '../../utils/toolUsageTracking.js';
|
|
8
|
+
const inputSchema = {
|
|
9
|
+
absoluteCurrentWorkingDirectory,
|
|
10
|
+
account: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe('The HubSpot account id or name from the HubSpot config file to use for the operation.')
|
|
13
|
+
.optional(),
|
|
14
|
+
json: z
|
|
15
|
+
.boolean()
|
|
16
|
+
.describe('Return raw JSON output instead of formatted table. Useful for programmatic access.')
|
|
17
|
+
.optional(),
|
|
18
|
+
};
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
const inputSchemaZodObject = z.object({ ...inputSchema });
|
|
21
|
+
const toolName = 'list-cms-serverless-functions';
|
|
22
|
+
export class HsListFunctionsTool extends Tool {
|
|
23
|
+
constructor(mcpServer) {
|
|
24
|
+
super(mcpServer);
|
|
25
|
+
}
|
|
26
|
+
async handler({ account, json, absoluteCurrentWorkingDirectory, }) {
|
|
27
|
+
await trackToolUsage(toolName);
|
|
28
|
+
let command = 'hs function list';
|
|
29
|
+
if (json) {
|
|
30
|
+
command += ' --json';
|
|
31
|
+
}
|
|
32
|
+
if (account) {
|
|
33
|
+
command = addFlag(command, 'account', account);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const { stdout, stderr } = await runCommandInDir(absoluteCurrentWorkingDirectory, command);
|
|
37
|
+
return formatTextContents(stdout, stderr);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: `Error executing hs function list command: ${errorMessage}`,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
register() {
|
|
52
|
+
return this.mcpServer.registerTool(toolName, {
|
|
53
|
+
title: 'List HubSpot CMS Serverless Functions',
|
|
54
|
+
description: 'Get a list of all serverless functions deployed in a HubSpot portal/account. Shows function routes, HTTP methods, secrets, and timestamps.',
|
|
55
|
+
inputSchema,
|
|
56
|
+
}, this.handler);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -18,7 +18,7 @@ const inputSchema = {
|
|
|
18
18
|
};
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
20
|
const inputSchemaZodObject = z.object({ ...inputSchema });
|
|
21
|
-
const toolName = 'list-
|
|
21
|
+
const toolName = 'list-cms-remote-contents';
|
|
22
22
|
export class HsListTool extends Tool {
|
|
23
23
|
constructor(mcpServer) {
|
|
24
24
|
super(mcpServer);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|