@hubspot/cli 8.5.0-beta.0 → 8.5.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 (87) hide show
  1. package/api/migrate.js +3 -3
  2. package/bin/cli.js +3 -0
  3. package/commands/app/migrate.js +4 -4
  4. package/commands/getStarted.js +2 -2
  5. package/commands/project/add.js +3 -3
  6. package/commands/project/create.js +10 -7
  7. package/commands/project/delete.js +2 -2
  8. package/commands/project/deploy.js +4 -3
  9. package/commands/project/dev/index.js +5 -4
  10. package/commands/project/info.js +2 -2
  11. package/commands/project/migrate.js +5 -5
  12. package/commands/project/profile/add.js +2 -2
  13. package/commands/project/profile/delete.js +2 -2
  14. package/commands/project/upload.js +3 -3
  15. package/commands/project/validate.js +2 -2
  16. package/commands/project/watch.js +2 -2
  17. package/commands/project.js +6 -3
  18. package/commands/testAccount/create.js +4 -4
  19. package/lang/en.d.ts +2 -0
  20. package/lang/en.js +6 -4
  21. package/lib/app/migrate.js +7 -0
  22. package/lib/doctor/Doctor.js +2 -2
  23. package/lib/getStartedV2Actions.js +2 -2
  24. package/lib/projects/ProjectLogsManager.js +6 -3
  25. package/lib/projects/create/index.js +2 -2
  26. package/lib/projects/create/legacy.js +2 -2
  27. package/lib/projects/create/v2.js +2 -2
  28. package/lib/projects/delete.js +2 -2
  29. package/lib/projects/deploy.d.ts +1 -1
  30. package/lib/projects/deploy.js +2 -2
  31. package/lib/projects/upload.js +4 -4
  32. package/lib/prompts/projectsLogsPrompt.js +3 -0
  33. package/lib/theme/cmsDevServerProcess.js +1 -1
  34. package/mcp-server/Tool.d.ts +15 -0
  35. package/mcp-server/Tool.js +53 -0
  36. package/mcp-server/server.js +5 -3
  37. package/mcp-server/tools/cms/HsCreateFunctionTool.d.ts +4 -2
  38. package/mcp-server/tools/cms/HsCreateFunctionTool.js +8 -6
  39. package/mcp-server/tools/cms/HsCreateModuleTool.d.ts +4 -2
  40. package/mcp-server/tools/cms/HsCreateModuleTool.js +8 -6
  41. package/mcp-server/tools/cms/HsCreateTemplateTool.d.ts +4 -2
  42. package/mcp-server/tools/cms/HsCreateTemplateTool.js +8 -6
  43. package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +4 -2
  44. package/mcp-server/tools/cms/HsFunctionLogsTool.js +8 -6
  45. package/mcp-server/tools/cms/HsListFunctionsTool.d.ts +4 -2
  46. package/mcp-server/tools/cms/HsListFunctionsTool.js +8 -6
  47. package/mcp-server/tools/cms/HsListTool.d.ts +4 -2
  48. package/mcp-server/tools/cms/HsListTool.js +8 -6
  49. package/mcp-server/tools/index.d.ts +3 -2
  50. package/mcp-server/tools/index.js +22 -22
  51. package/mcp-server/tools/project/AddFeatureToProjectTool.d.ts +6 -4
  52. package/mcp-server/tools/project/AddFeatureToProjectTool.js +8 -6
  53. package/mcp-server/tools/project/CreateProjectTool.d.ts +6 -4
  54. package/mcp-server/tools/project/CreateProjectTool.js +9 -7
  55. package/mcp-server/tools/project/CreateTestAccountTool.d.ts +4 -2
  56. package/mcp-server/tools/project/CreateTestAccountTool.js +20 -8
  57. package/mcp-server/tools/project/DeployProjectTool.d.ts +4 -2
  58. package/mcp-server/tools/project/DeployProjectTool.js +4 -6
  59. package/mcp-server/tools/project/DocFetchTool.d.ts +4 -2
  60. package/mcp-server/tools/project/DocFetchTool.js +8 -6
  61. package/mcp-server/tools/project/DocsSearchTool.d.ts +9 -3
  62. package/mcp-server/tools/project/DocsSearchTool.js +32 -9
  63. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +4 -2
  64. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +8 -6
  65. package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +4 -2
  66. package/mcp-server/tools/project/GetApplicationInfoTool.js +8 -6
  67. package/mcp-server/tools/project/GetBuildLogsTool.d.ts +4 -2
  68. package/mcp-server/tools/project/GetBuildLogsTool.js +8 -6
  69. package/mcp-server/tools/project/GetBuildStatusTool.d.ts +4 -2
  70. package/mcp-server/tools/project/GetBuildStatusTool.js +8 -6
  71. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +4 -2
  72. package/mcp-server/tools/project/GetConfigValuesTool.js +12 -7
  73. package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +4 -2
  74. package/mcp-server/tools/project/GuidedWalkthroughTool.js +4 -6
  75. package/mcp-server/tools/project/UploadProjectTools.d.ts +4 -2
  76. package/mcp-server/tools/project/UploadProjectTools.js +9 -7
  77. package/mcp-server/tools/project/ValidateProjectTool.d.ts +4 -2
  78. package/mcp-server/tools/project/ValidateProjectTool.js +8 -6
  79. package/mcp-server/tools/project/constants.d.ts +2 -2
  80. package/mcp-server/types.d.ts +0 -7
  81. package/mcp-server/types.js +1 -13
  82. package/mcp-server/utils/logger.d.ts +10 -0
  83. package/mcp-server/utils/logger.js +29 -0
  84. package/mcp-server/utils/toolUsageTracking.js +0 -2
  85. package/package.json +10 -10
  86. package/lib/projects/platformVersion.d.ts +0 -9
  87. package/lib/projects/platformVersion.js +0 -39
@@ -1,7 +1,7 @@
1
1
  import { selectProjectTemplatePrompt, } from '../../prompts/selectProjectTemplatePrompt.js';
2
2
  import { projectNameAndDestPrompt } from '../../prompts/projectNameAndDestPrompt.js';
3
3
  import { DEFAULT_PROJECT_TEMPLATE_BRANCH, HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, EMPTY_PROJECT, } from '../../constants.js';
4
- import { isV2Project } from '../platformVersion.js';
4
+ import { isLegacyProject } from '@hubspot/project-parsing-lib/projects';
5
5
  import { v2ComponentFlow } from './v2.js';
6
6
  import { getProjectTemplateListFromRepo } from './legacy.js';
7
7
  import { commands } from '../../../lang/en.js';
@@ -9,7 +9,7 @@ export async function handleProjectCreationFlow(args) {
9
9
  const { platformVersion, templateSource, projectBase, auth: providedAuth, distribution: providedDistribution, } = args;
10
10
  const repo = templateSource || HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH;
11
11
  const projectNameAndDestPromptResponse = await projectNameAndDestPrompt(args);
12
- if (isV2Project(platformVersion)) {
12
+ if (!isLegacyProject(platformVersion)) {
13
13
  const { componentTemplateChoices, authType, distribution, repoConfig, projectContents, } = await v2ComponentFlow(platformVersion, projectBase, providedAuth, providedDistribution, args.derivedAccountId);
14
14
  const selectProjectTemplatePromptResponse = await selectProjectTemplatePrompt(args, undefined, projectContents !== EMPTY_PROJECT ? componentTemplateChoices : undefined);
15
15
  return {
@@ -1,13 +1,13 @@
1
1
  import { fetchRepoFile } from '@hubspot/local-dev-lib/api/github';
2
2
  import { DEFAULT_PROJECT_TEMPLATE_BRANCH, HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, PROJECT_COMPONENT_TYPES, } from '../../constants.js';
3
3
  import { debugError } from '../../errorHandlers/index.js';
4
- import { isV2Project } from '../platformVersion.js';
4
+ import { isLegacyProject } from '@hubspot/project-parsing-lib/projects';
5
5
  import { lib } from '../../../lang/en.js';
6
6
  const PROJECT_TEMPLATE_PROPERTIES = ['name', 'label', 'path'];
7
7
  export const EMPTY_PROJECT_TEMPLATE_NAME = 'no-template';
8
8
  export async function getConfigForPlatformVersion(platformVersion) {
9
9
  let path = '';
10
- if (isV2Project(platformVersion)) {
10
+ if (!isLegacyProject(platformVersion)) {
11
11
  path = `${platformVersion}/`;
12
12
  }
13
13
  const { data } = await fetchRepoFile(HUBSPOT_PROJECT_COMPONENTS_GITHUB_PATH, `${path}config.json`, DEFAULT_PROJECT_TEMPLATE_BRANCH);
@@ -2,7 +2,7 @@ import { marketplaceDistribution, oAuth, privateDistribution, staticAuth, EMPTY_
2
2
  import { commands, lib } from '../../../lang/en.js';
3
3
  import { listPrompt } from '../../prompts/promptUtils.js';
4
4
  import { APP_EVENTS_KEY as AppEventsKey } from '@hubspot/project-parsing-lib/constants';
5
- import { isV2Project } from '../platformVersion.js';
5
+ import { isLegacyProject } from '@hubspot/project-parsing-lib/projects';
6
6
  import path from 'path';
7
7
  import { getConfigForPlatformVersion } from './legacy.js';
8
8
  import { hasFeature } from '../../hasFeature.js';
@@ -134,7 +134,7 @@ export async function v2ComponentFlow(platformVersion, projectBase, providedAuth
134
134
  };
135
135
  }
136
136
  export function generateComponentPaths({ selectProjectTemplatePromptResponse, platformVersion, repoConfig, projectContents, authType, distribution, }) {
137
- if (!isV2Project(platformVersion)) {
137
+ if (isLegacyProject(platformVersion)) {
138
138
  return [];
139
139
  }
140
140
  const components = selectProjectTemplatePromptResponse.componentTemplates?.map((componentTemplate) => {
@@ -10,7 +10,7 @@ import { PromptExitError } from '../errors/PromptExitError.js';
10
10
  import { EXIT_CODES } from '../enums/exitCodes.js';
11
11
  import { AUTO_GENERATED_COMPONENT_TYPES } from '@hubspot/project-parsing-lib/constants';
12
12
  import { mapToUserFacingType } from '@hubspot/project-parsing-lib/transform';
13
- import { isV2Project } from './platformVersion.js';
13
+ import { isLegacyProject } from '@hubspot/project-parsing-lib/projects';
14
14
  import { COMPONENT_TYPES, SUBCOMPONENT_TYPES, } from '@hubspot/local-dev-lib/enums/build';
15
15
  export const DELETION_POLL_TIMEOUT_MS = 5 * 60 * 1000;
16
16
  export const DELETION_DEPLOY_SUCCESS_STATES = [
@@ -81,7 +81,7 @@ export async function checkDeployedComponents(accountId, projectName) {
81
81
  if (!platformVersion) {
82
82
  throw new Error(commands.project.delete.errors.noPlatformVersion);
83
83
  }
84
- if (!isV2Project(platformVersion)) {
84
+ if (isLegacyProject(platformVersion)) {
85
85
  const userVisibleComponents = [];
86
86
  projectData.deployedBuild?.subbuildStatuses?.forEach(item => {
87
87
  if (LEGACY_COMPONENTS_TO_FILTER.includes(item.buildType)) {
@@ -10,4 +10,4 @@ export declare function logDeployErrors(errorData: {
10
10
  };
11
11
  }>;
12
12
  }): void;
13
- export declare function handleProjectDeploy(targetAccountId: number, projectName: string, buildId: number, isV2Project: boolean, force: boolean): Promise<Deploy | undefined>;
13
+ export declare function handleProjectDeploy(targetAccountId: number, projectName: string, buildId: number, isLegacyProject: boolean, force: boolean): Promise<Deploy | undefined>;
@@ -47,9 +47,9 @@ function handleBlockedDeploy(deployResp) {
47
47
  uiLogger.log('');
48
48
  });
49
49
  }
50
- export async function handleProjectDeploy(targetAccountId, projectName, buildId, isV2Project, force) {
50
+ export async function handleProjectDeploy(targetAccountId, projectName, buildId, isLegacyProject, force) {
51
51
  let deployId;
52
- if (isV2Project) {
52
+ if (!isLegacyProject) {
53
53
  const { data: deployResp } = await deployProjectV2(targetAccountId, projectName, buildId, force);
54
54
  if (!deployResp || deployResp.buildResultType !== 'DEPLOY_QUEUED') {
55
55
  if (deployResp?.buildResultType === 'DEPLOY_BLOCKED') {
@@ -13,11 +13,11 @@ import util from 'node:util';
13
13
  import { lib } from '../../lang/en.js';
14
14
  import { ensureProjectExists } from './ensureProjectExists.js';
15
15
  import { uiLogger } from '../ui/logger.js';
16
- import { isV2Project } from './platformVersion.js';
17
16
  import ProjectValidationError from '../errors/ProjectValidationError.js';
18
17
  import { walk } from '@hubspot/local-dev-lib/fs';
19
18
  import { LEGACY_CONFIG_FILES } from '../constants.js';
20
19
  import { archiveWorkspacesAndDependencies, getPackageJsonPathsToUpdate, getLockfilePathsToUpdate, } from './workspaces.js';
20
+ import { isLegacyProject } from '@hubspot/project-parsing-lib/projects';
21
21
  async function uploadProjectFiles(accountId, projectName, filePath, uploadMessage, platformVersion, intermediateRepresentation) {
22
22
  const accountIdentifier = uiAccountDescription(accountId) || `${accountId}`;
23
23
  SpinniesManager.add('upload', {
@@ -54,7 +54,7 @@ export async function handleProjectUpload({ accountId, projectConfig, projectDir
54
54
  // Versions <= 2025.1 do not support the new npm workspaces bundling behavior.
55
55
  let workspaceMappings = [];
56
56
  let fileDependencyMappings = [];
57
- if (isV2Project(projectConfig.platformVersion)) {
57
+ if (!isLegacyProject(projectConfig.platformVersion)) {
58
58
  const parsedPackageJsons = await findAndParsePackageJsonFiles(srcDir);
59
59
  workspaceMappings = await collectWorkspaceDirectories(parsedPackageJsons);
60
60
  fileDependencyMappings = await collectFileDependencies(parsedPackageJsons);
@@ -132,7 +132,7 @@ export async function validateSourceDirectory(srcDir, projectConfig, projectDir)
132
132
  if (!projectFilePaths || projectFilePaths.length === 0) {
133
133
  throw new ProjectValidationError(lib.projectUpload.handleProjectUpload.emptySource(projectConfig.srcDir));
134
134
  }
135
- if (isV2Project(projectConfig.platformVersion)) {
135
+ if (!isLegacyProject(projectConfig.platformVersion)) {
136
136
  projectFilePaths.forEach(filePath => {
137
137
  const filename = path.basename(filePath);
138
138
  if (LEGACY_CONFIG_FILES.includes(filename)) {
@@ -143,7 +143,7 @@ export async function validateSourceDirectory(srcDir, projectConfig, projectDir)
143
143
  }
144
144
  export async function validateNoHSMetaMismatch(srcDir, projectConfig) {
145
145
  const hasHsMetaFiles = await projectContainsHsMetaFiles(srcDir);
146
- if (!isV2Project(projectConfig.platformVersion) && hasHsMetaFiles) {
146
+ if (isLegacyProject(projectConfig.platformVersion) && hasHsMetaFiles) {
147
147
  throw new ProjectValidationError(lib.projectUpload.wrongPlatformVersionMetaFiles);
148
148
  }
149
149
  }
@@ -4,6 +4,9 @@ export async function projectLogsPrompt({ functionChoices, promptOptions, projec
4
4
  if (!functionChoices) {
5
5
  return {};
6
6
  }
7
+ if (promptOptions?.function) {
8
+ return { functionName: promptOptions.function };
9
+ }
7
10
  if (functionChoices.length === 1) {
8
11
  return { functionName: functionChoices[0] };
9
12
  }
@@ -10,7 +10,7 @@ import { EXIT_CODES } from '../enums/exitCodes.js';
10
10
  const __filename = fileURLToPath(import.meta.url);
11
11
  const __dirname = path.dirname(__filename);
12
12
  // cms-dev-server version to install to isolated cache
13
- const TARGET_CMS_DEV_SERVER_VERSION = '1.2.16';
13
+ const TARGET_CMS_DEV_SERVER_VERSION = '1.2.26';
14
14
  /**
15
15
  * Ensures cms-dev-server is installed in an isolated cache directory.
16
16
  * This prevents React version conflicts with the CLI.
@@ -0,0 +1,15 @@
1
+ import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { McpLogger } from './utils/logger.js';
3
+ import { TextContentResponse } from './types.js';
4
+ export declare class Tool<InputSchema> {
5
+ protected mcpServer: McpServer;
6
+ protected logger: McpLogger;
7
+ protected toolName: string;
8
+ constructor(mcpServer: McpServer, logger: McpLogger, toolName: string);
9
+ register(): RegisteredTool;
10
+ handler(input: InputSchema): TextContentResponse | Promise<TextContentResponse>;
11
+ protected getTrackingMeta(input: InputSchema): {
12
+ [key: string]: string;
13
+ } | undefined;
14
+ protected wrappedHandler(input: InputSchema): Promise<TextContentResponse>;
15
+ }
@@ -0,0 +1,53 @@
1
+ import { formatTextContents } from './utils/content.js';
2
+ import { getErrorMessage } from '../lib/errorHandlers/index.js';
3
+ import { trackToolUsage } from './utils/toolUsageTracking.js';
4
+ export class Tool {
5
+ mcpServer;
6
+ logger;
7
+ toolName;
8
+ constructor(mcpServer, logger, toolName) {
9
+ this.mcpServer = mcpServer;
10
+ this.logger = logger;
11
+ this.toolName = toolName;
12
+ }
13
+ register() {
14
+ throw new Error('Must implement register');
15
+ }
16
+ handler(
17
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
18
+ input) {
19
+ throw new Error('Must implement handler');
20
+ }
21
+ getTrackingMeta(
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
+ input) {
24
+ return undefined;
25
+ }
26
+ async wrappedHandler(input) {
27
+ const startTime = Date.now();
28
+ try {
29
+ // `input` is logged unredacted. Tool input schemas MUST NOT include
30
+ // credentials or other sensitive values, since MCP clients (Claude
31
+ // Desktop, Inspector, etc.) will display these logs.
32
+ this.logger.debug(this.toolName, {
33
+ message: 'Tool invoked',
34
+ args: input,
35
+ });
36
+ await trackToolUsage(this.toolName, this.getTrackingMeta(input));
37
+ const result = await this.handler(input);
38
+ this.logger.debug(this.toolName, {
39
+ message: 'Tool completed',
40
+ durationMs: Date.now() - startTime,
41
+ });
42
+ return result;
43
+ }
44
+ catch (error) {
45
+ this.logger.error(this.toolName, {
46
+ message: 'Tool failed',
47
+ error: error instanceof Error ? error.message : String(error),
48
+ durationMs: Date.now() - startTime,
49
+ });
50
+ return formatTextContents(getErrorMessage(error));
51
+ }
52
+ }
53
+ }
@@ -1,13 +1,15 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
2
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
3
  import { registerProjectTools, registerCmsTools } from './tools/index.js';
4
+ import { McpLogger } from './utils/logger.js';
4
5
  const server = new McpServer({
5
6
  name: 'HubSpot CLI MCP Server',
6
7
  version: '0.0.1',
7
8
  description: 'Helps perform tasks for local development of HubSpot projects.',
8
- });
9
- registerProjectTools(server);
10
- registerCmsTools(server);
9
+ }, { capabilities: { logging: {} } });
10
+ const logger = new McpLogger(server);
11
+ registerProjectTools(server, logger);
12
+ registerCmsTools(server, logger);
11
13
  // Start receiving messages on stdin and sending messages on stdout
12
14
  const transport = new StdioServerTransport();
13
15
  server.connect(transport);
@@ -1,5 +1,7 @@
1
- import { TextContentResponse, Tool } from '../../types.js';
1
+ import { TextContentResponse } from '../../types.js';
2
+ import { Tool } from '../../Tool.js';
2
3
  import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { McpLogger } from '../../utils/logger.js';
3
5
  import { z } from 'zod';
4
6
  declare const inputSchemaZodObject: z.ZodObject<{
5
7
  absoluteCurrentWorkingDirectory: z.ZodString;
@@ -17,7 +19,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
17
19
  }, z.core.$strip>;
18
20
  export type HsCreateFunctionInputSchema = z.infer<typeof inputSchemaZodObject>;
19
21
  export declare class HsCreateFunctionTool extends Tool<HsCreateFunctionInputSchema> {
20
- constructor(mcpServer: McpServer);
22
+ constructor(mcpServer: McpServer, logger: McpLogger);
21
23
  handler({ dest, functionsFolder, filename, endpointMethod, endpointPath, absoluteCurrentWorkingDirectory, }: HsCreateFunctionInputSchema): Promise<TextContentResponse>;
22
24
  register(): RegisteredTool;
23
25
  }
@@ -1,9 +1,8 @@
1
- import { Tool } from '../../types.js';
1
+ import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
4
4
  import { runCommandInDir } from '../../utils/command.js';
5
5
  import { formatTextContents, formatTextContent } from '../../utils/content.js';
6
- import { trackToolUsage } from '../../utils/toolUsageTracking.js';
7
6
  import { addFlag } from '../../utils/command.js';
8
7
  import { HTTP_METHODS } from '../../../types/Cms.js';
9
8
  import { setupHubSpotConfig } from '../../utils/config.js';
@@ -35,12 +34,11 @@ const inputSchema = {
35
34
  const inputSchemaZodObject = z.object({ ...inputSchema });
36
35
  const toolName = 'create-cms-function';
37
36
  export class HsCreateFunctionTool extends Tool {
38
- constructor(mcpServer) {
39
- super(mcpServer);
37
+ constructor(mcpServer, logger) {
38
+ super(mcpServer, logger, toolName);
40
39
  }
41
40
  async handler({ dest, functionsFolder, filename, endpointMethod, endpointPath, absoluteCurrentWorkingDirectory, }) {
42
41
  setupHubSpotConfig(absoluteCurrentWorkingDirectory);
43
- await trackToolUsage(toolName);
44
42
  const content = [];
45
43
  // Require functions folder
46
44
  if (!functionsFolder) {
@@ -86,6 +84,10 @@ export class HsCreateFunctionTool extends Tool {
86
84
  return formatTextContents(stdout, stderr);
87
85
  }
88
86
  catch (error) {
87
+ this.logger.debug(toolName, {
88
+ message: 'Handler caught error',
89
+ error: error instanceof Error ? error.message : String(error),
90
+ });
89
91
  return formatTextContents(getErrorMessage(error));
90
92
  }
91
93
  }
@@ -100,6 +102,6 @@ export class HsCreateFunctionTool extends Tool {
100
102
  idempotentHint: false,
101
103
  openWorldHint: false,
102
104
  },
103
- }, this.handler);
105
+ }, input => this.wrappedHandler(input));
104
106
  }
105
107
  }
@@ -1,5 +1,7 @@
1
- import { TextContentResponse, Tool } from '../../types.js';
1
+ import { TextContentResponse } from '../../types.js';
2
+ import { Tool } from '../../Tool.js';
2
3
  import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { McpLogger } from '../../utils/logger.js';
3
5
  import { z } from 'zod';
4
6
  declare const inputSchemaZodObject: z.ZodObject<{
5
7
  absoluteCurrentWorkingDirectory: z.ZodString;
@@ -13,7 +15,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
13
15
  }, z.core.$strip>;
14
16
  export type HsCreateModuleInputSchema = z.infer<typeof inputSchemaZodObject>;
15
17
  export declare class HsCreateModuleTool extends Tool<HsCreateModuleInputSchema> {
16
- constructor(mcpServer: McpServer);
18
+ constructor(mcpServer: McpServer, logger: McpLogger);
17
19
  handler({ userSuppliedName, dest, moduleLabel, reactType, contentTypes, global, availableForNewContent, absoluteCurrentWorkingDirectory, }: HsCreateModuleInputSchema): Promise<TextContentResponse>;
18
20
  register(): RegisteredTool;
19
21
  }
@@ -1,9 +1,8 @@
1
- import { Tool } from '../../types.js';
1
+ import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
4
4
  import { runCommandInDir } from '../../utils/command.js';
5
5
  import { formatTextContents, formatTextContent } from '../../utils/content.js';
6
- import { trackToolUsage } from '../../utils/toolUsageTracking.js';
7
6
  import { addFlag } from '../../utils/command.js';
8
7
  import { CONTENT_TYPES } from '../../../types/Cms.js';
9
8
  import { setupHubSpotConfig } from '../../utils/config.js';
@@ -51,12 +50,11 @@ const inputSchema = {
51
50
  const inputSchemaZodObject = z.object({ ...inputSchema });
52
51
  const toolName = 'create-cms-module';
53
52
  export class HsCreateModuleTool extends Tool {
54
- constructor(mcpServer) {
55
- super(mcpServer);
53
+ constructor(mcpServer, logger) {
54
+ super(mcpServer, logger, toolName);
56
55
  }
57
56
  async handler({ userSuppliedName, dest, moduleLabel, reactType, contentTypes, global, availableForNewContent, absoluteCurrentWorkingDirectory, }) {
58
57
  setupHubSpotConfig(absoluteCurrentWorkingDirectory);
59
- await trackToolUsage(toolName);
60
58
  const content = [];
61
59
  // Always require a name
62
60
  if (!userSuppliedName) {
@@ -108,6 +106,10 @@ export class HsCreateModuleTool extends Tool {
108
106
  return formatTextContents(stdout, stderr);
109
107
  }
110
108
  catch (error) {
109
+ this.logger.debug(toolName, {
110
+ message: 'Handler caught error',
111
+ error: error instanceof Error ? error.message : String(error),
112
+ });
111
113
  return formatTextContents(getErrorMessage(error));
112
114
  }
113
115
  }
@@ -122,6 +124,6 @@ export class HsCreateModuleTool extends Tool {
122
124
  idempotentHint: false,
123
125
  openWorldHint: false,
124
126
  },
125
- }, this.handler);
127
+ }, input => this.wrappedHandler(input));
126
128
  }
127
129
  }
@@ -1,5 +1,7 @@
1
- import { TextContentResponse, Tool } from '../../types.js';
1
+ import { TextContentResponse } from '../../types.js';
2
+ import { Tool } from '../../Tool.js';
2
3
  import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { McpLogger } from '../../utils/logger.js';
3
5
  import { z } from 'zod';
4
6
  declare const inputSchemaZodObject: z.ZodObject<{
5
7
  absoluteCurrentWorkingDirectory: z.ZodString;
@@ -18,7 +20,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
18
20
  }, z.core.$strip>;
19
21
  export type HsCreateTemplateInputSchema = z.infer<typeof inputSchemaZodObject>;
20
22
  export declare class HsCreateTemplateTool extends Tool<HsCreateTemplateInputSchema> {
21
- constructor(mcpServer: McpServer);
23
+ constructor(mcpServer: McpServer, logger: McpLogger);
22
24
  handler({ userSuppliedName, dest, templateType, absoluteCurrentWorkingDirectory, }: HsCreateTemplateInputSchema): Promise<TextContentResponse>;
23
25
  register(): RegisteredTool;
24
26
  }
@@ -1,9 +1,8 @@
1
- import { Tool } from '../../types.js';
1
+ import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
4
4
  import { runCommandInDir } from '../../utils/command.js';
5
5
  import { formatTextContents, formatTextContent } from '../../utils/content.js';
6
- import { trackToolUsage } from '../../utils/toolUsageTracking.js';
7
6
  import { addFlag } from '../../utils/command.js';
8
7
  import { TEMPLATE_TYPES } from '../../../types/Cms.js';
9
8
  import { setupHubSpotConfig } from '../../utils/config.js';
@@ -27,12 +26,11 @@ const inputSchema = {
27
26
  const inputSchemaZodObject = z.object({ ...inputSchema });
28
27
  const toolName = 'create-cms-template';
29
28
  export class HsCreateTemplateTool extends Tool {
30
- constructor(mcpServer) {
31
- super(mcpServer);
29
+ constructor(mcpServer, logger) {
30
+ super(mcpServer, logger, toolName);
32
31
  }
33
32
  async handler({ userSuppliedName, dest, templateType, absoluteCurrentWorkingDirectory, }) {
34
33
  setupHubSpotConfig(absoluteCurrentWorkingDirectory);
35
- await trackToolUsage(toolName);
36
34
  const content = [];
37
35
  // Always require a name
38
36
  if (!userSuppliedName) {
@@ -65,6 +63,10 @@ export class HsCreateTemplateTool extends Tool {
65
63
  return formatTextContents(stdout, stderr);
66
64
  }
67
65
  catch (error) {
66
+ this.logger.debug(toolName, {
67
+ message: 'Handler caught error',
68
+ error: error instanceof Error ? error.message : String(error),
69
+ });
68
70
  return formatTextContents(getErrorMessage(error));
69
71
  }
70
72
  }
@@ -79,6 +81,6 @@ export class HsCreateTemplateTool extends Tool {
79
81
  idempotentHint: false,
80
82
  openWorldHint: false,
81
83
  },
82
- }, this.handler);
84
+ }, input => this.wrappedHandler(input));
83
85
  }
84
86
  }
@@ -1,5 +1,7 @@
1
- import { TextContentResponse, Tool } from '../../types.js';
1
+ import { TextContentResponse } from '../../types.js';
2
+ import { Tool } from '../../Tool.js';
2
3
  import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { McpLogger } from '../../utils/logger.js';
3
5
  import { z } from 'zod';
4
6
  declare const inputSchemaZodObject: z.ZodObject<{
5
7
  absoluteCurrentWorkingDirectory: z.ZodString;
@@ -11,7 +13,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
11
13
  }, z.core.$strip>;
12
14
  export type HsFunctionLogsInputSchema = z.infer<typeof inputSchemaZodObject>;
13
15
  export declare class HsFunctionLogsTool extends Tool<HsFunctionLogsInputSchema> {
14
- constructor(mcpServer: McpServer);
16
+ constructor(mcpServer: McpServer, logger: McpLogger);
15
17
  handler({ endpoint, account, latest, compact, limit, absoluteCurrentWorkingDirectory, }: HsFunctionLogsInputSchema): Promise<TextContentResponse>;
16
18
  register(): RegisteredTool;
17
19
  }
@@ -1,10 +1,9 @@
1
- import { Tool } from '../../types.js';
1
+ import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { addFlag } from '../../utils/command.js';
4
4
  import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
5
5
  import { runCommandInDir } from '../../utils/command.js';
6
6
  import { formatTextContents } from '../../utils/content.js';
7
- import { trackToolUsage } from '../../utils/toolUsageTracking.js';
8
7
  import { setupHubSpotConfig } from '../../utils/config.js';
9
8
  import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
10
9
  const inputSchema = {
@@ -30,12 +29,11 @@ const inputSchema = {
30
29
  const inputSchemaZodObject = z.object({ ...inputSchema });
31
30
  const toolName = 'get-cms-serverless-function-logs';
32
31
  export class HsFunctionLogsTool extends Tool {
33
- constructor(mcpServer) {
34
- super(mcpServer);
32
+ constructor(mcpServer, logger) {
33
+ super(mcpServer, logger, toolName);
35
34
  }
36
35
  async handler({ endpoint, account, latest, compact, limit, absoluteCurrentWorkingDirectory, }) {
37
36
  setupHubSpotConfig(absoluteCurrentWorkingDirectory);
38
- await trackToolUsage(toolName);
39
37
  // Ensure endpoint doesn't start with '/'
40
38
  const normalizedEndpoint = endpoint.startsWith('/')
41
39
  ? endpoint.slice(1)
@@ -58,6 +56,10 @@ export class HsFunctionLogsTool extends Tool {
58
56
  return formatTextContents(stdout, stderr);
59
57
  }
60
58
  catch (error) {
59
+ this.logger.debug(toolName, {
60
+ message: 'Handler caught error',
61
+ error: error instanceof Error ? error.message : String(error),
62
+ });
61
63
  return formatTextContents(`Error executing hs logs command: ${getErrorMessage(error)}`);
62
64
  }
63
65
  }
@@ -70,6 +72,6 @@ export class HsFunctionLogsTool extends Tool {
70
72
  readOnlyHint: true,
71
73
  openWorldHint: true,
72
74
  },
73
- }, this.handler);
75
+ }, input => this.wrappedHandler(input));
74
76
  }
75
77
  }
@@ -1,5 +1,7 @@
1
- import { TextContentResponse, Tool } from '../../types.js';
1
+ import { TextContentResponse } from '../../types.js';
2
+ import { Tool } from '../../Tool.js';
2
3
  import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { McpLogger } from '../../utils/logger.js';
3
5
  import { z } from 'zod';
4
6
  declare const inputSchemaZodObject: z.ZodObject<{
5
7
  absoluteCurrentWorkingDirectory: z.ZodString;
@@ -8,7 +10,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
8
10
  }, z.core.$strip>;
9
11
  export type HsListFunctionsInputSchema = z.infer<typeof inputSchemaZodObject>;
10
12
  export declare class HsListFunctionsTool extends Tool<HsListFunctionsInputSchema> {
11
- constructor(mcpServer: McpServer);
13
+ constructor(mcpServer: McpServer, logger: McpLogger);
12
14
  handler({ account, json, absoluteCurrentWorkingDirectory, }: HsListFunctionsInputSchema): Promise<TextContentResponse>;
13
15
  register(): RegisteredTool;
14
16
  }
@@ -1,10 +1,9 @@
1
- import { Tool } from '../../types.js';
1
+ import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { addFlag } from '../../utils/command.js';
4
4
  import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
5
5
  import { runCommandInDir } from '../../utils/command.js';
6
6
  import { formatTextContents } from '../../utils/content.js';
7
- import { trackToolUsage } from '../../utils/toolUsageTracking.js';
8
7
  import { setupHubSpotConfig } from '../../utils/config.js';
9
8
  import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
10
9
  const inputSchema = {
@@ -22,12 +21,11 @@ const inputSchema = {
22
21
  const inputSchemaZodObject = z.object({ ...inputSchema });
23
22
  const toolName = 'list-cms-serverless-functions';
24
23
  export class HsListFunctionsTool extends Tool {
25
- constructor(mcpServer) {
26
- super(mcpServer);
24
+ constructor(mcpServer, logger) {
25
+ super(mcpServer, logger, toolName);
27
26
  }
28
27
  async handler({ account, json, absoluteCurrentWorkingDirectory, }) {
29
28
  setupHubSpotConfig(absoluteCurrentWorkingDirectory);
30
- await trackToolUsage(toolName);
31
29
  let command = 'hs function list';
32
30
  if (json) {
33
31
  command += ' --json';
@@ -40,6 +38,10 @@ export class HsListFunctionsTool extends Tool {
40
38
  return formatTextContents(stdout, stderr);
41
39
  }
42
40
  catch (error) {
41
+ this.logger.debug(toolName, {
42
+ message: 'Handler caught error',
43
+ error: error instanceof Error ? error.message : String(error),
44
+ });
43
45
  return {
44
46
  content: [
45
47
  {
@@ -59,6 +61,6 @@ export class HsListFunctionsTool extends Tool {
59
61
  readOnlyHint: true,
60
62
  openWorldHint: true,
61
63
  },
62
- }, this.handler);
64
+ }, input => this.wrappedHandler(input));
63
65
  }
64
66
  }
@@ -1,5 +1,7 @@
1
- import { TextContentResponse, Tool } from '../../types.js';
1
+ import { TextContentResponse } from '../../types.js';
2
+ import { Tool } from '../../Tool.js';
2
3
  import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { McpLogger } from '../../utils/logger.js';
3
5
  import { z } from 'zod';
4
6
  declare const inputSchemaZodObject: z.ZodObject<{
5
7
  absoluteCurrentWorkingDirectory: z.ZodString;
@@ -8,7 +10,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
8
10
  }, z.core.$strip>;
9
11
  export type HsListInputSchema = z.infer<typeof inputSchemaZodObject>;
10
12
  export declare class HsListTool extends Tool<HsListInputSchema> {
11
- constructor(mcpServer: McpServer);
13
+ constructor(mcpServer: McpServer, logger: McpLogger);
12
14
  handler({ path, account, absoluteCurrentWorkingDirectory, }: HsListInputSchema): Promise<TextContentResponse>;
13
15
  register(): RegisteredTool;
14
16
  }
@@ -1,10 +1,9 @@
1
- import { Tool } from '../../types.js';
1
+ import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { addFlag } from '../../utils/command.js';
4
4
  import { absoluteCurrentWorkingDirectory } from '../project/constants.js';
5
5
  import { runCommandInDir } from '../../utils/command.js';
6
6
  import { formatTextContents } from '../../utils/content.js';
7
- import { trackToolUsage } from '../../utils/toolUsageTracking.js';
8
7
  import { setupHubSpotConfig } from '../../utils/config.js';
9
8
  import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
10
9
  const inputSchema = {
@@ -22,12 +21,11 @@ const inputSchema = {
22
21
  const inputSchemaZodObject = z.object({ ...inputSchema });
23
22
  const toolName = 'list-cms-remote-contents';
24
23
  export class HsListTool extends Tool {
25
- constructor(mcpServer) {
26
- super(mcpServer);
24
+ constructor(mcpServer, logger) {
25
+ super(mcpServer, logger, toolName);
27
26
  }
28
27
  async handler({ path, account, absoluteCurrentWorkingDirectory, }) {
29
28
  setupHubSpotConfig(absoluteCurrentWorkingDirectory);
30
- await trackToolUsage(toolName);
31
29
  let command = 'hs list';
32
30
  if (path) {
33
31
  command += ` ${path}`;
@@ -40,6 +38,10 @@ export class HsListTool extends Tool {
40
38
  return formatTextContents(stdout, stderr);
41
39
  }
42
40
  catch (error) {
41
+ this.logger.debug(toolName, {
42
+ message: 'Handler caught error',
43
+ error: error instanceof Error ? error.message : String(error),
44
+ });
43
45
  return {
44
46
  content: [
45
47
  {
@@ -59,6 +61,6 @@ export class HsListTool extends Tool {
59
61
  readOnlyHint: true,
60
62
  openWorldHint: true,
61
63
  },
62
- }, this.handler);
64
+ }, input => this.wrappedHandler(input));
63
65
  }
64
66
  }
@@ -1,3 +1,4 @@
1
1
  import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- export declare function registerProjectTools(mcpServer: McpServer): RegisteredTool[];
3
- export declare function registerCmsTools(mcpServer: McpServer): RegisteredTool[];
2
+ import { McpLogger } from '../utils/logger.js';
3
+ export declare function registerProjectTools(mcpServer: McpServer, logger: McpLogger): RegisteredTool[];
4
+ export declare function registerCmsTools(mcpServer: McpServer, logger: McpLogger): RegisteredTool[];