@hubspot/cli 8.15.0 → 8.16.0-beta.1

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 (141) hide show
  1. package/api/releases.d.ts +4 -1
  2. package/bin/cli.js +2 -0
  3. package/commands/account/auth.d.ts +3 -2
  4. package/commands/account/auth.js +21 -10
  5. package/commands/app/migrate.js +3 -3
  6. package/commands/project/add.d.ts +3 -2
  7. package/commands/project/add.js +10 -8
  8. package/commands/project/appInstallStatus.d.ts +2 -2
  9. package/commands/project/appInstallStatus.js +2 -2
  10. package/commands/project/create.d.ts +4 -2
  11. package/commands/project/create.js +16 -4
  12. package/commands/project/deploy.d.ts +2 -2
  13. package/commands/project/deploy.js +2 -2
  14. package/commands/project/download.d.ts +2 -2
  15. package/commands/project/download.js +2 -2
  16. package/commands/project/info.d.ts +1 -1
  17. package/commands/project/info.js +1 -1
  18. package/commands/project/installApp.d.ts +2 -2
  19. package/commands/project/installApp.js +2 -2
  20. package/commands/project/listBuilds.d.ts +2 -2
  21. package/commands/project/listBuilds.js +2 -2
  22. package/commands/project/migrate.js +4 -4
  23. package/commands/project/release/create.d.ts +2 -2
  24. package/commands/project/release/create.js +7 -3
  25. package/commands/project/release/info.d.ts +2 -2
  26. package/commands/project/release/info.js +2 -2
  27. package/commands/project/release/list.d.ts +2 -2
  28. package/commands/project/release/list.js +2 -2
  29. package/commands/project/release/preview.d.ts +9 -0
  30. package/commands/project/release/preview.js +167 -0
  31. package/commands/project/release.js +7 -1
  32. package/commands/project/upload.d.ts +2 -2
  33. package/commands/project/upload.js +2 -2
  34. package/commands/project/validate.d.ts +2 -2
  35. package/commands/project/validate.js +2 -2
  36. package/commands/testAccount/create.d.ts +2 -2
  37. package/commands/testAccount/create.js +2 -2
  38. package/lang/en.d.ts +27 -0
  39. package/lang/en.js +32 -4
  40. package/lib/accountAuth.d.ts +1 -0
  41. package/lib/accountAuth.js +8 -0
  42. package/lib/app/urls.d.ts +0 -1
  43. package/lib/app/urls.js +0 -4
  44. package/lib/constants.d.ts +6 -0
  45. package/lib/constants.js +11 -0
  46. package/lib/jsonOutput/accountAuth.d.ts +7 -0
  47. package/lib/jsonOutput/accountAuth.js +6 -0
  48. package/lib/jsonOutput/projectAdd.d.ts +9 -0
  49. package/lib/jsonOutput/projectAdd.js +10 -0
  50. package/lib/jsonOutput/{appInstallStatus.d.ts → projectAppInstallStatus.d.ts} +2 -2
  51. package/lib/jsonOutput/{appInstallStatus.js → projectAppInstallStatus.js} +1 -1
  52. package/lib/jsonOutput/projectCreate.d.ts +8 -0
  53. package/lib/jsonOutput/projectCreate.js +7 -0
  54. package/lib/jsonOutput/projectDeploy.d.ts +5 -0
  55. package/lib/jsonOutput/{deploy.js → projectDeploy.js} +1 -1
  56. package/lib/jsonOutput/projectDownload.d.ts +7 -0
  57. package/lib/jsonOutput/{download.js → projectDownload.js} +1 -1
  58. package/lib/jsonOutput/{installApp.d.ts → projectInstallApp.d.ts} +2 -2
  59. package/lib/jsonOutput/{installApp.js → projectInstallApp.js} +1 -1
  60. package/lib/jsonOutput/{listBuilds.d.ts → projectListBuilds.d.ts} +2 -2
  61. package/lib/jsonOutput/{listBuilds.js → projectListBuilds.js} +1 -1
  62. package/lib/jsonOutput/{release.d.ts → projectRelease.d.ts} +15 -8
  63. package/lib/jsonOutput/{release.js → projectRelease.js} +11 -4
  64. package/lib/jsonOutput/{upload.d.ts → projectUpload.d.ts} +2 -2
  65. package/lib/jsonOutput/{upload.js → projectUpload.js} +1 -1
  66. package/lib/jsonOutput/{validate.d.ts → projectValidate.d.ts} +2 -2
  67. package/lib/jsonOutput/{validate.js → projectValidate.js} +1 -1
  68. package/lib/jsonOutput/{createTestAccount.d.ts → testAccountCreate.d.ts} +2 -2
  69. package/lib/jsonOutput/{createTestAccount.js → testAccountCreate.js} +1 -1
  70. package/lib/middleware/deprecationWarningMiddleware.d.ts +1 -0
  71. package/lib/middleware/deprecationWarningMiddleware.js +57 -0
  72. package/lib/projects/add/legacyAddComponent.d.ts +2 -1
  73. package/lib/projects/add/legacyAddComponent.js +3 -0
  74. package/lib/projects/add/v2AddComponent.d.ts +2 -1
  75. package/lib/projects/add/v2AddComponent.js +7 -1
  76. package/lib/projects/localDev/LocalDevWatcher.js +1 -1
  77. package/lib/projects/release.d.ts +2 -2
  78. package/lib/projects/validate.d.ts +1 -1
  79. package/lib/prompts/projectProfilePrompt.d.ts +7 -0
  80. package/lib/prompts/projectProfilePrompt.js +1 -1
  81. package/lib/testUtils.d.ts +5 -0
  82. package/lib/testUtils.js +24 -0
  83. package/lib/ui/index.js +11 -1
  84. package/lib/ui/uiMessages.d.ts +1 -0
  85. package/lib/ui/uiMessages.js +1 -0
  86. package/mcp-server/Tool.d.ts +6 -1
  87. package/mcp-server/Tool.js +6 -4
  88. package/mcp-server/server.js +26 -4
  89. package/mcp-server/tools/cms/HsCreateFunctionTool.js +1 -1
  90. package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +1 -1
  91. package/mcp-server/tools/cms/HsFunctionLogsTool.js +59 -5
  92. package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
  93. package/mcp-server/tools/index.js +2 -0
  94. package/mcp-server/tools/project/AddFeatureToProjectTool.js +31 -31
  95. package/mcp-server/tools/project/AuthAccountTool.d.ts +1 -0
  96. package/mcp-server/tools/project/AuthAccountTool.js +36 -5
  97. package/mcp-server/tools/project/CreateProjectTool.js +13 -3
  98. package/mcp-server/tools/project/CreateTestAccountTool.js +13 -13
  99. package/mcp-server/tools/project/DeployProjectTool.d.ts +2 -2
  100. package/mcp-server/tools/project/DeployProjectTool.js +34 -16
  101. package/mcp-server/tools/project/DocFetchTool.js +1 -1
  102. package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
  103. package/mcp-server/tools/project/DocsSearchTool.js +18 -9
  104. package/mcp-server/tools/project/FindProjectsTool.js +12 -0
  105. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +3 -2
  106. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +38 -10
  107. package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +2 -1
  108. package/mcp-server/tools/project/GetApplicationInfoTool.js +13 -14
  109. package/mcp-server/tools/project/GetBuildLogsTool.d.ts +2 -1
  110. package/mcp-server/tools/project/GetBuildLogsTool.js +12 -9
  111. package/mcp-server/tools/project/GetBuildStatusTool.d.ts +2 -1
  112. package/mcp-server/tools/project/GetBuildStatusTool.js +12 -9
  113. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +2 -1
  114. package/mcp-server/tools/project/GetConfigValuesTool.js +11 -8
  115. package/mcp-server/tools/project/KnowledgeSearchTool.d.ts +29 -0
  116. package/mcp-server/tools/project/KnowledgeSearchTool.js +82 -0
  117. package/mcp-server/tools/project/UploadProjectTools.d.ts +2 -2
  118. package/mcp-server/tools/project/UploadProjectTools.js +52 -39
  119. package/mcp-server/tools/project/ValidateProjectTool.js +23 -7
  120. package/mcp-server/tools/project/apps.d.ts +8 -0
  121. package/mcp-server/tools/project/apps.js +7 -0
  122. package/mcp-server/tools/project/constants.d.ts +3 -0
  123. package/mcp-server/tools/project/constants.js +11 -1
  124. package/mcp-server/tools/project/productionConfirmation.d.ts +12 -0
  125. package/mcp-server/tools/project/productionConfirmation.js +45 -0
  126. package/mcp-server/tools/project/resolveAccount.d.ts +15 -0
  127. package/mcp-server/tools/project/resolveAccount.js +60 -0
  128. package/mcp-server/utils/command.d.ts +1 -0
  129. package/mcp-server/utils/command.js +8 -0
  130. package/mcp-server/utils/content.d.ts +1 -0
  131. package/mcp-server/utils/content.js +5 -0
  132. package/mcp-server/utils/elicitSelection.d.ts +11 -0
  133. package/mcp-server/utils/elicitSelection.js +25 -0
  134. package/mcp-server/utils/elicitation.d.ts +11 -0
  135. package/mcp-server/utils/elicitation.js +38 -0
  136. package/package.json +23 -22
  137. package/ui/components/Table.d.ts +8 -8
  138. package/lib/jsonOutput/deploy.d.ts +0 -5
  139. package/lib/jsonOutput/download.d.ts +0 -7
  140. /package/lib/jsonOutput/{info.d.ts → projectInfo.d.ts} +0 -0
  141. /package/lib/jsonOutput/{info.js → projectInfo.js} +0 -0
@@ -4,6 +4,7 @@ import { formatTextContents } from '../../utils/content.js';
4
4
  import { walk } from '@hubspot/local-dev-lib/fs';
5
5
  import path from 'path';
6
6
  import { PROJECT_CONFIG_FILE } from '../../../lib/constants.js';
7
+ import { elicitSelection } from '../../utils/elicitSelection.js';
7
8
  const TOOL_NAME = 'find-projects';
8
9
  const IGNORE_DIRS = ['node_modules', '.git', '.vite'];
9
10
  const inputSchema = {
@@ -25,6 +26,17 @@ export class FindProjectsTool extends Tool {
25
26
  return formatTextContents(`No ${PROJECT_CONFIG_FILE} files found under ${absoluteDirectory}.`);
26
27
  }
27
28
  const projectDirs = projectFiles.map(file => path.dirname(file));
29
+ if (projectDirs.length > 1) {
30
+ const selected = await elicitSelection(this.mcpServer, this.logger, {
31
+ message: 'Select the HubSpot project to use.',
32
+ title: 'HubSpot project',
33
+ options: projectDirs.map(dir => ({ value: dir, label: dir })),
34
+ });
35
+ if (selected) {
36
+ return formatTextContents(`Selected project: ${selected}`);
37
+ }
38
+ return formatTextContents(`Several projects are available. Ask the user which to use, then call ${TOOL_NAME} again with absoluteDirectory narrowed to one of: ${projectDirs.join(', ')}.`);
39
+ }
28
40
  const output = [
29
41
  `Found ${projectFiles.length} project(s):`,
30
42
  '',
@@ -6,14 +6,15 @@ import { z } from 'zod';
6
6
  declare const inputSchemaZodObject: z.ZodObject<{
7
7
  absoluteCurrentWorkingDirectory: z.ZodString;
8
8
  absoluteProjectPath: z.ZodOptional<z.ZodString>;
9
- appId: z.ZodString;
9
+ account: z.ZodOptional<z.ZodString>;
10
+ appId: z.ZodOptional<z.ZodString>;
10
11
  startDate: z.ZodOptional<z.ZodString>;
11
12
  endDate: z.ZodOptional<z.ZodString>;
12
13
  }, z.core.$strip>;
13
14
  export type GetApiUsagePatternsByAppIdInputSchema = z.infer<typeof inputSchemaZodObject>;
14
15
  export declare class GetApiUsagePatternsByAppIdTool extends Tool<GetApiUsagePatternsByAppIdInputSchema> {
15
16
  constructor(mcpServer: McpServer, logger: McpLogger);
16
- handler({ appId, startDate, endDate, absoluteCurrentWorkingDirectory, absoluteProjectPath, }: GetApiUsagePatternsByAppIdInputSchema): Promise<McpToolResponse>;
17
+ handler({ appId, startDate, endDate, account, absoluteCurrentWorkingDirectory, absoluteProjectPath, }: GetApiUsagePatternsByAppIdInputSchema): Promise<McpToolResponse>;
17
18
  register(): RegisteredTool;
18
19
  }
19
20
  export {};
@@ -3,16 +3,20 @@ import { z } from 'zod';
3
3
  import { http } from '@hubspot/local-dev-lib/http';
4
4
  import { formatTextContents } from '../../utils/content.js';
5
5
  import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
6
- import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
6
+ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
7
7
  import { setupHubSpotConfig } from '../../utils/config.js';
8
- import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
8
+ import { resolveAccountId } from './resolveAccount.js';
9
9
  import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
10
+ import { elicitSelection } from '../../utils/elicitSelection.js';
11
+ import { getApps } from './apps.js';
10
12
  const inputSchema = {
11
13
  absoluteCurrentWorkingDirectory,
12
14
  absoluteProjectPath: absoluteProjectPath.optional(),
15
+ account,
13
16
  appId: z
14
17
  .string()
15
- .describe('The numeric app ID as a string (e.g., "3003909"). Must contain only digits. Use get-apps-info to find available app IDs.'),
18
+ .describe('The numeric app ID as a string (e.g., "3003909"). Must contain only digits. If omitted and the account has several apps, you will be asked to choose one.')
19
+ .optional(),
16
20
  startDate: z
17
21
  .string()
18
22
  .describe('Start date for the usage patterns query in YYYY-MM-DD format (e.g., 2025-01-01).')
@@ -29,17 +33,41 @@ export class GetApiUsagePatternsByAppIdTool extends Tool {
29
33
  constructor(mcpServer, logger) {
30
34
  super(mcpServer, logger, toolName);
31
35
  }
32
- async handler({ appId, startDate, endDate, absoluteCurrentWorkingDirectory, absoluteProjectPath, }) {
36
+ async handler({ appId, startDate, endDate, account, absoluteCurrentWorkingDirectory, absoluteProjectPath, }) {
33
37
  setupHubSpotConfig(absoluteProjectPath ?? absoluteCurrentWorkingDirectory);
34
38
  try {
35
- const { recommended } = await discoverAccountTargets();
36
- const accountId = recommended?.accountId;
37
- if (!accountId) {
38
- const authErrorMessage = `No account ID found. Call the auth-account tool to authenticate a HubSpot account.`;
39
- return formatTextContents(authErrorMessage);
39
+ const resolved = await resolveAccountId(this.mcpServer, this.logger, {
40
+ toolName,
41
+ account,
42
+ });
43
+ if ('response' in resolved) {
44
+ return resolved.response;
45
+ }
46
+ const { accountId } = resolved;
47
+ let resolvedAppId = appId;
48
+ if (!resolvedAppId) {
49
+ const { applications } = await getApps(accountId);
50
+ const apps = applications ?? [];
51
+ if (apps.length === 0) {
52
+ return formatTextContents('No apps found for this account. Nothing to inspect.');
53
+ }
54
+ const selected = await elicitSelection(this.mcpServer, this.logger, {
55
+ message: 'Select the app to inspect usage patterns for.',
56
+ title: 'HubSpot app',
57
+ options: apps.map(app => ({
58
+ value: String(app.appId),
59
+ label: `${app.appName} (${app.appId})`,
60
+ })),
61
+ });
62
+ if (!selected) {
63
+ return formatTextContents(`Several apps are available. Ask the user which to use, then call ${toolName} again with the appId argument set to one of: ${apps
64
+ .map(app => `${app.appName} (appId ${app.appId})`)
65
+ .join(', ')}.`);
66
+ }
67
+ resolvedAppId = selected;
40
68
  }
41
69
  const response = await http.get(accountId, {
42
- url: `app/feature/utilization/public/v3/insights/app/${appId}/usage-patterns`,
70
+ url: `app/feature/utilization/public/v3/insights/app/${resolvedAppId}/usage-patterns`,
43
71
  params: {
44
72
  ...(startDate && { startDate }),
45
73
  ...(endDate && { endDate }),
@@ -6,11 +6,12 @@ import { z } from 'zod';
6
6
  declare const inputSchemaZodObject: z.ZodObject<{
7
7
  absoluteCurrentWorkingDirectory: z.ZodString;
8
8
  absoluteProjectPath: z.ZodOptional<z.ZodString>;
9
+ account: z.ZodOptional<z.ZodString>;
9
10
  }, z.core.$strip>;
10
11
  export type GetApplicationInfoInputSchema = z.infer<typeof inputSchemaZodObject>;
11
12
  export declare class GetApplicationInfoTool extends Tool<GetApplicationInfoInputSchema> {
12
13
  constructor(mcpServer: McpServer, logger: McpLogger);
13
- handler({ absoluteCurrentWorkingDirectory, absoluteProjectPath, }: GetApplicationInfoInputSchema): Promise<McpToolResponse>;
14
+ handler({ account, absoluteCurrentWorkingDirectory, absoluteProjectPath, }: GetApplicationInfoInputSchema): Promise<McpToolResponse>;
14
15
  register(): RegisteredTool;
15
16
  }
16
17
  export {};
@@ -1,15 +1,16 @@
1
1
  import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
- import { http } from '@hubspot/local-dev-lib/http';
4
3
  import { formatTextContents } from '../../utils/content.js';
5
4
  import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
6
- import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
5
+ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
7
6
  import { setupHubSpotConfig } from '../../utils/config.js';
8
- import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
7
+ import { resolveAccountId } from './resolveAccount.js';
9
8
  import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
9
+ import { getApps } from './apps.js';
10
10
  const inputSchema = {
11
11
  absoluteCurrentWorkingDirectory,
12
12
  absoluteProjectPath: absoluteProjectPath.optional(),
13
+ account,
13
14
  };
14
15
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
16
  const inputSchemaZodObject = z.object({ ...inputSchema });
@@ -18,20 +19,18 @@ export class GetApplicationInfoTool extends Tool {
18
19
  constructor(mcpServer, logger) {
19
20
  super(mcpServer, logger, toolName);
20
21
  }
21
- async handler({ absoluteCurrentWorkingDirectory, absoluteProjectPath, }) {
22
+ async handler({ account, absoluteCurrentWorkingDirectory, absoluteProjectPath, }) {
22
23
  setupHubSpotConfig(absoluteProjectPath ?? absoluteCurrentWorkingDirectory);
23
24
  try {
24
- const { recommended } = await discoverAccountTargets();
25
- const accountId = recommended?.accountId;
26
- if (!accountId) {
27
- const authErrorMessage = `No account ID found. Call the auth-account tool to authenticate a HubSpot account.`;
28
- return formatTextContents(authErrorMessage);
29
- }
30
- const response = await http.get(accountId, {
31
- url: `app/feature/utilization/public/v3/insights/apps`,
25
+ const resolved = await resolveAccountId(this.mcpServer, this.logger, {
26
+ toolName,
27
+ account,
32
28
  });
33
- // Format the response for display
34
- const { data } = response;
29
+ if ('response' in resolved) {
30
+ return resolved.response;
31
+ }
32
+ const { accountId } = resolved;
33
+ const data = await getApps(accountId);
35
34
  const formattedResult = JSON.stringify(data, null, 2);
36
35
  return formatTextContents(formattedResult);
37
36
  }
@@ -6,6 +6,7 @@ import { z } from 'zod';
6
6
  declare const inputSchemaZodObject: z.ZodObject<{
7
7
  absoluteProjectPath: z.ZodString;
8
8
  absoluteCurrentWorkingDirectory: z.ZodString;
9
+ account: z.ZodOptional<z.ZodString>;
9
10
  buildId: z.ZodNumber;
10
11
  logLevel: z.ZodOptional<z.ZodEnum<{
11
12
  ERROR: "ERROR";
@@ -17,7 +18,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
17
18
  export type GetBuildLogsInputSchema = z.infer<typeof inputSchemaZodObject>;
18
19
  export declare class GetBuildLogsTool extends Tool<GetBuildLogsInputSchema> {
19
20
  constructor(mcpServer: McpServer, logger: McpLogger);
20
- handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, logLevel, }: GetBuildLogsInputSchema): Promise<McpToolResponse>;
21
+ handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, account, buildId, logLevel, }: GetBuildLogsInputSchema): Promise<McpToolResponse>;
21
22
  register(): RegisteredTool;
22
23
  }
23
24
  export {};
@@ -4,14 +4,15 @@ import { formatTextContents } from '../../utils/content.js';
4
4
  import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
5
5
  import { http } from '@hubspot/local-dev-lib/http';
6
6
  import { getProjectConfig } from '../../../lib/projects/config.js';
7
- import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
7
+ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
8
8
  import { setupHubSpotConfig } from '../../utils/config.js';
9
- import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
9
+ import { resolveAccountId } from './resolveAccount.js';
10
10
  const TOOL_NAME = 'get-build-logs';
11
11
  const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
12
12
  const inputSchema = {
13
13
  absoluteProjectPath,
14
14
  absoluteCurrentWorkingDirectory,
15
+ account,
15
16
  buildId: z
16
17
  .number()
17
18
  .describe('Build ID to fetch logs for. Use get-build-status to find recent build IDs.'),
@@ -61,18 +62,20 @@ export class GetBuildLogsTool extends Tool {
61
62
  constructor(mcpServer, logger) {
62
63
  super(mcpServer, logger, TOOL_NAME);
63
64
  }
64
- async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, logLevel, }) {
65
+ async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, account, buildId, logLevel, }) {
65
66
  setupHubSpotConfig(absoluteProjectPath);
66
67
  try {
67
68
  const { projectConfig, projectDir } = getProjectConfig(absoluteProjectPath);
68
- const { recommended } = await discoverAccountTargets({
69
- projectDir,
70
- projectConfig,
69
+ const resolved = await resolveAccountId(this.mcpServer, this.logger, {
70
+ toolName: TOOL_NAME,
71
+ absoluteCurrentWorkingDirectory,
72
+ account,
73
+ discoverOptions: { projectDir, projectConfig },
71
74
  });
72
- const accountId = recommended?.accountId;
73
- if (!accountId) {
74
- return formatTextContents(absoluteCurrentWorkingDirectory, 'No account ID found. Call the auth-account tool to authenticate a HubSpot account.');
75
+ if ('response' in resolved) {
76
+ return resolved.response;
75
77
  }
78
+ const { accountId } = resolved;
76
79
  const projectName = projectConfig.name;
77
80
  const response = await http.get(accountId, {
78
81
  url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${encodeURIComponent(projectName)}/builds/${buildId}`,
@@ -6,13 +6,14 @@ import { z } from 'zod';
6
6
  declare const inputSchemaZodObject: z.ZodObject<{
7
7
  absoluteProjectPath: z.ZodString;
8
8
  absoluteCurrentWorkingDirectory: z.ZodString;
9
+ account: z.ZodOptional<z.ZodString>;
9
10
  buildId: z.ZodOptional<z.ZodNumber>;
10
11
  limit: z.ZodOptional<z.ZodNumber>;
11
12
  }, z.core.$strip>;
12
13
  export type GetBuildStatusInputSchema = z.infer<typeof inputSchemaZodObject>;
13
14
  export declare class GetBuildStatusTool extends Tool<GetBuildStatusInputSchema> {
14
15
  constructor(mcpServer: McpServer, logger: McpLogger);
15
- handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, limit, }: GetBuildStatusInputSchema): Promise<McpToolResponse>;
16
+ handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, account, buildId, limit, }: GetBuildStatusInputSchema): Promise<McpToolResponse>;
16
17
  register(): RegisteredTool;
17
18
  }
18
19
  export {};
@@ -5,13 +5,14 @@ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
5
5
  import { fetchProjectBuilds, getBuildStatus, } from '@hubspot/local-dev-lib/api/projects';
6
6
  import { getProjectConfig } from '../../../lib/projects/config.js';
7
7
  import moment from 'moment';
8
- import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
8
+ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
9
9
  import { setupHubSpotConfig } from '../../utils/config.js';
10
- import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
10
+ import { resolveAccountId } from './resolveAccount.js';
11
11
  const TOOL_NAME = 'get-build-status';
12
12
  const inputSchema = {
13
13
  absoluteProjectPath,
14
14
  absoluteCurrentWorkingDirectory,
15
+ account,
15
16
  buildId: z
16
17
  .number()
17
18
  .optional()
@@ -106,18 +107,20 @@ export class GetBuildStatusTool extends Tool {
106
107
  constructor(mcpServer, logger) {
107
108
  super(mcpServer, logger, TOOL_NAME);
108
109
  }
109
- async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, limit, }) {
110
+ async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, account, buildId, limit, }) {
110
111
  setupHubSpotConfig(absoluteProjectPath);
111
112
  try {
112
113
  const { projectConfig, projectDir } = getProjectConfig(absoluteProjectPath);
113
- const { recommended } = await discoverAccountTargets({
114
- projectDir,
115
- projectConfig,
114
+ const resolved = await resolveAccountId(this.mcpServer, this.logger, {
115
+ toolName: TOOL_NAME,
116
+ absoluteCurrentWorkingDirectory,
117
+ account,
118
+ discoverOptions: { projectDir, projectConfig },
116
119
  });
117
- const accountId = recommended?.accountId;
118
- if (!accountId) {
119
- return formatTextContents(absoluteCurrentWorkingDirectory, 'No account ID found. Call the auth-account tool to authenticate a HubSpot account.');
120
+ if ('response' in resolved) {
121
+ return resolved.response;
120
122
  }
123
+ const { accountId } = resolved;
121
124
  const projectName = projectConfig.name;
122
125
  let output;
123
126
  if (buildId) {
@@ -6,13 +6,14 @@ import { z } from 'zod';
6
6
  declare const inputSchemaZodObject: z.ZodObject<{
7
7
  absoluteCurrentWorkingDirectory: z.ZodString;
8
8
  absoluteProjectPath: z.ZodOptional<z.ZodString>;
9
+ account: z.ZodOptional<z.ZodString>;
9
10
  platformVersion: z.ZodString;
10
11
  featureType: z.ZodString;
11
12
  }, z.core.$strip>;
12
13
  type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
13
14
  export declare class GetConfigValuesTool extends Tool<InputSchemaType> {
14
15
  constructor(mcpServer: McpServer, logger: McpLogger);
15
- handler({ platformVersion, featureType, absoluteCurrentWorkingDirectory, absoluteProjectPath, }: InputSchemaType): Promise<McpToolResponse>;
16
+ handler({ platformVersion, featureType, account, absoluteCurrentWorkingDirectory, absoluteProjectPath, }: InputSchemaType): Promise<McpToolResponse>;
16
17
  register(): RegisteredTool;
17
18
  }
18
19
  export {};
@@ -1,15 +1,16 @@
1
1
  import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { formatTextContents } from '../../utils/content.js';
4
- import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
4
+ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
5
5
  import { getIntermediateRepresentationSchema } from '@hubspot/project-parsing-lib/schema';
6
6
  import { mapToInternalType } from '@hubspot/project-parsing-lib/transform';
7
7
  import { isLegacyProject } from '@hubspot/project-parsing-lib/projects';
8
8
  import { setupHubSpotConfig } from '../../utils/config.js';
9
- import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
9
+ import { resolveAccountId } from './resolveAccount.js';
10
10
  const inputSchema = {
11
11
  absoluteCurrentWorkingDirectory,
12
12
  absoluteProjectPath: absoluteProjectPath.optional(),
13
+ account,
13
14
  platformVersion: z
14
15
  .string()
15
16
  .describe('The platform version for the project. Located in the hsproject.json file.'),
@@ -26,18 +27,20 @@ export class GetConfigValuesTool extends Tool {
26
27
  constructor(mcpServer, logger) {
27
28
  super(mcpServer, logger, toolName);
28
29
  }
29
- async handler({ platformVersion, featureType, absoluteCurrentWorkingDirectory, absoluteProjectPath, }) {
30
+ async handler({ platformVersion, featureType, account, absoluteCurrentWorkingDirectory, absoluteProjectPath, }) {
30
31
  setupHubSpotConfig(absoluteProjectPath ?? absoluteCurrentWorkingDirectory);
31
32
  try {
32
33
  if (isLegacyProject(platformVersion)) {
33
34
  return formatTextContents(`Can only be used on projects with a minimum platformVersion of 2025.2`);
34
35
  }
35
- const { recommended } = await discoverAccountTargets();
36
- const accountId = recommended?.accountId;
37
- if (!accountId) {
38
- const authErrorMessage = `No account ID found. Call the auth-account tool to authenticate a HubSpot account.`;
39
- return formatTextContents(authErrorMessage);
36
+ const resolved = await resolveAccountId(this.mcpServer, this.logger, {
37
+ toolName,
38
+ account,
39
+ });
40
+ if ('response' in resolved) {
41
+ return resolved.response;
40
42
  }
43
+ const { accountId } = resolved;
41
44
  const schema = await getIntermediateRepresentationSchema({
42
45
  platformVersion,
43
46
  projectSourceDir: '',
@@ -0,0 +1,29 @@
1
+ import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { McpLogger } from '../../utils/logger.js';
3
+ import z from 'zod';
4
+ import { McpToolResponse } from '../../types.js';
5
+ import { Tool } from '../../Tool.js';
6
+ declare const inputSchema: {
7
+ absoluteCurrentWorkingDirectory: z.ZodString;
8
+ knowledgeSearchQuery: z.ZodString;
9
+ knowledgeSearchLimit: z.ZodDefault<z.ZodNumber>;
10
+ };
11
+ export interface KnowledgeSearchResponse {
12
+ total: number;
13
+ results: {
14
+ title: string;
15
+ description: string;
16
+ url: string;
17
+ score: number;
18
+ }[];
19
+ }
20
+ type InputSchemaType = z.infer<z.ZodObject<typeof inputSchema>>;
21
+ export declare class KnowledgeSearchTool extends Tool<InputSchemaType> {
22
+ constructor(mcpServer: McpServer, logger: McpLogger);
23
+ protected getTrackingMeta(_input: InputSchemaType): {
24
+ [key: string]: string;
25
+ } | undefined;
26
+ handler({ knowledgeSearchQuery, knowledgeSearchLimit, absoluteCurrentWorkingDirectory, }: InputSchemaType): Promise<McpToolResponse>;
27
+ register(): RegisteredTool;
28
+ }
29
+ export {};
@@ -0,0 +1,82 @@
1
+ import { http } from '@hubspot/local-dev-lib/http/unauthed';
2
+ import z from 'zod';
3
+ import { Tool } from '../../Tool.js';
4
+ import { formatTextContents } from '../../utils/content.js';
5
+ import { absoluteCurrentWorkingDirectory, knowledgeSearchQuery, } from './constants.js';
6
+ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
7
+ import { setupHubSpotConfig } from '../../utils/config.js';
8
+ import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
9
+ const knowledgeSearchLimit = z
10
+ .number()
11
+ .int()
12
+ .min(1)
13
+ .max(20)
14
+ .default(5)
15
+ .describe('Maximum number of results to return.');
16
+ const inputSchema = {
17
+ absoluteCurrentWorkingDirectory,
18
+ knowledgeSearchQuery,
19
+ knowledgeSearchLimit,
20
+ };
21
+ const toolName = 'search-knowledge-base';
22
+ // The HubSpot Knowledge Base (knowledge.hubspot.com) is hosted on the blog
23
+ // system in HubSpot's own portal, so results are scoped by domain and portal.
24
+ const KNOWLEDGE_BASE_DOMAIN = 'knowledge.hubspot.com';
25
+ const KNOWLEDGE_BASE_PORTAL_ID = 53;
26
+ // The knowledge base has no developer API/feature tier data, so redirect those
27
+ // questions to the docs even when the model reaches this tool by mistake.
28
+ const DEV_TIER_ROUTING_HINT = 'Note: the knowledge base does not cover developer API or feature tier requirements. For whether an API or feature is available on a subscription tier, use search-docs then fetch-doc.';
29
+ export class KnowledgeSearchTool extends Tool {
30
+ constructor(mcpServer, logger) {
31
+ super(mcpServer, logger, toolName);
32
+ }
33
+ getTrackingMeta(_input) {
34
+ return { mode: 'knowledge-search' };
35
+ }
36
+ async handler({ knowledgeSearchQuery, knowledgeSearchLimit, absoluteCurrentWorkingDirectory, }) {
37
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
38
+ try {
39
+ const params = new URLSearchParams({
40
+ term: knowledgeSearchQuery,
41
+ type: 'BLOG_POST',
42
+ domain: KNOWLEDGE_BASE_DOMAIN,
43
+ portalId: String(KNOWLEDGE_BASE_PORTAL_ID),
44
+ limit: String(knowledgeSearchLimit),
45
+ });
46
+ const response = await http.get({
47
+ url: `https://api.hubapi.com/contentsearch/v2/search?${params}`,
48
+ });
49
+ const { total, results } = response.data;
50
+ if (!results || results.length === 0) {
51
+ return formatTextContents('No knowledge base articles found for your query.', DEV_TIER_ROUTING_HINT);
52
+ }
53
+ const formattedResults = results
54
+ .map(result => `**${result.title}**\n${result.description}\nURL: ${result.url}\nScore: ${result.score}\n---\n`)
55
+ .join('\n');
56
+ const successMessage = `Found ${total} results, showing top ${results.length}:\n\n${formattedResults}`;
57
+ return formatTextContents(successMessage, DEV_TIER_ROUTING_HINT);
58
+ }
59
+ catch (error) {
60
+ this.logger.debug(toolName, {
61
+ message: 'Handler caught error',
62
+ error: getErrorMessage(error),
63
+ });
64
+ if (isHubSpotHttpError(error)) {
65
+ return formatTextContents(error.toString());
66
+ }
67
+ const errorMessage = `Error searching the knowledge base: ${getErrorMessage(error)}`;
68
+ return formatTextContents(errorMessage);
69
+ }
70
+ }
71
+ register() {
72
+ return this.mcpServer.registerTool(toolName, {
73
+ title: 'Search HubSpot Knowledge Base',
74
+ description: 'Do not use this to find whether a developer API or feature is available on a subscription tier or plan (for example "is the content audit API available on Content Hub Professional"). Use `search-docs` then `fetch-doc` for that. Use this only for how-to guidance on using HubSpot products and features, and for account or subscription settings. This searches the HubSpot Knowledge Base (knowledge.hubspot.com) and returns the most relevant help articles, each with a URL.',
75
+ inputSchema,
76
+ annotations: {
77
+ readOnlyHint: true,
78
+ openWorldHint: true,
79
+ },
80
+ }, (input, extra) => this.wrappedHandler(input, extra));
81
+ }
82
+ }
@@ -5,14 +5,14 @@ import { McpToolResponse } from '../../types.js';
5
5
  import { Tool, ToolExtra } from '../../Tool.js';
6
6
  declare const inputSchemaZodObject: z.ZodObject<{
7
7
  absoluteProjectPath: z.ZodString;
8
- absoluteCurrentWorkingDirectory: z.ZodString;
9
8
  uploadMessage: z.ZodString;
10
9
  profile: z.ZodOptional<z.ZodString>;
10
+ confirmProductionAccount: z.ZodOptional<z.ZodBoolean>;
11
11
  }, z.z.core.$strip>;
12
12
  type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
13
13
  export declare class UploadProjectTools extends Tool<InputSchemaType> {
14
14
  constructor(mcpServer: McpServer, logger: McpLogger);
15
- handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, profile, uploadMessage, }: InputSchemaType, extra?: ToolExtra): Promise<McpToolResponse>;
15
+ handler({ absoluteProjectPath, profile, uploadMessage, confirmProductionAccount, }: InputSchemaType, extra?: ToolExtra): Promise<McpToolResponse>;
16
16
  register(): RegisteredTool;
17
17
  }
18
18
  export {};
@@ -3,21 +3,25 @@ import z from 'zod';
3
3
  import { getAllHsProfiles } from '@hubspot/project-parsing-lib/profiles';
4
4
  import { getProjectConfig } from '../../../lib/projects/config.js';
5
5
  import { Tool } from '../../Tool.js';
6
- import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
7
- import { formatTextContent, formatTextContents } from '../../utils/content.js';
6
+ import { absoluteProjectPath, confirmProductionAccount } from './constants.js';
7
+ import { formatErrorTextContents, formatTextContent, formatTextContents, } from '../../utils/content.js';
8
8
  import { HubSpotCommand } from '../../utils/command.js';
9
9
  import { setupHubSpotConfig } from '../../utils/config.js';
10
10
  import { parseCommandJsonOutput } from '../../utils/json.js';
11
- import { UploadSchema } from '../../../lib/jsonOutput/upload.js';
11
+ import { ProjectUploadSchema } from '../../../lib/jsonOutput/projectUpload.js';
12
+ import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
13
+ import { generateProfilePromptOption } from '../../../lib/prompts/projectProfilePrompt.js';
14
+ import { elicitSelection } from '../../utils/elicitSelection.js';
15
+ import { confirmProductionTargets, setTargetAccount, } from './productionConfirmation.js';
12
16
  const inputSchema = {
13
17
  absoluteProjectPath,
14
- absoluteCurrentWorkingDirectory,
15
18
  uploadMessage: z
16
19
  .string()
17
20
  .describe('A 1 sentence message that concisely describes the changes that are being uploaded.'),
18
21
  profile: z
19
22
  .optional(z.string())
20
- .describe('The profile to use for the upload. Only required for projects configured with profiles. If the project uses profiles and the user has not specified one, ask them rather than inferring from filenames in the directory. NEVER automatically choose a profile based on files you see. Profile files have the format: "hsprofile.<profile>.json".'),
23
+ .describe('The profile to use for the upload. Only set this when the user names a profile. If it is omitted and the project uses profiles, the tool asks the user to choose one. NEVER automatically choose a profile based on files you see. Profile files have the format: "hsprofile.<profile>.json".'),
24
+ confirmProductionAccount,
21
25
  };
22
26
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
27
  const inputSchemaZodObject = z.object({
@@ -28,58 +32,67 @@ export class UploadProjectTools extends Tool {
28
32
  constructor(mcpServer, logger) {
29
33
  super(mcpServer, logger, toolName);
30
34
  }
31
- async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, profile, uploadMessage, }, extra) {
32
- setupHubSpotConfig(absoluteCurrentWorkingDirectory);
35
+ async handler({ absoluteProjectPath, profile, uploadMessage, confirmProductionAccount, }, extra) {
36
+ setupHubSpotConfig(absoluteProjectPath);
37
+ const { projectDir, projectConfig } = getProjectConfig(absoluteProjectPath);
38
+ let selectedProfile = profile;
39
+ if (!selectedProfile) {
40
+ const profiles = await getAllHsProfiles(path.join(projectDir, projectConfig.srcDir));
41
+ if (profiles.length > 0) {
42
+ const options = profiles.map(profileName => ({
43
+ value: profileName,
44
+ label: generateProfilePromptOption(projectDir, projectConfig, profileName).name,
45
+ }));
46
+ selectedProfile = await elicitSelection(this.mcpServer, this.logger, {
47
+ message: 'Select the profile to use for the upload.',
48
+ title: 'Project profile',
49
+ options,
50
+ });
51
+ if (!selectedProfile) {
52
+ return formatErrorTextContents(`Several profiles are available. Ask the user which to use, then call ${toolName} again with the profile argument set to one of these profile names: ${options
53
+ .map(option => option.value)
54
+ .join(', ')}. The profiles target these accounts: ${options
55
+ .map(option => option.label)
56
+ .join(', ')}.`);
57
+ }
58
+ }
59
+ }
60
+ const targets = await discoverAccountTargets({
61
+ projectDir,
62
+ projectConfig,
63
+ profileName: selectedProfile,
64
+ });
65
+ const blockedResponse = await confirmProductionTargets(this.mcpServer, this.logger, {
66
+ targets,
67
+ action: `Upload ${projectConfig.name}`,
68
+ toolName,
69
+ confirmedInConversation: confirmProductionAccount,
70
+ });
71
+ if (blockedResponse) {
72
+ return blockedResponse;
73
+ }
33
74
  const command = new HubSpotCommand('project upload', [
34
75
  { name: 'force', value: true },
35
76
  { name: 'json', value: true },
36
77
  ]);
37
- const content = [];
38
78
  if (uploadMessage) {
39
79
  command.addFlag('message', uploadMessage);
40
80
  }
41
- if (profile) {
42
- command.addFlag('profile', profile);
43
- }
44
- else {
45
- let hasProfiles = false;
46
- try {
47
- const { projectConfig } = getProjectConfig(absoluteProjectPath);
48
- const profiles = await getAllHsProfiles(path.join(absoluteProjectPath, projectConfig.srcDir));
49
- hasProfiles = profiles.length > 0;
50
- }
51
- catch (e) {
52
- this.logger.debug(toolName, {
53
- message: 'Handler caught error checking for profiles',
54
- error: e instanceof Error ? e.message : String(e),
55
- });
56
- // If any of these checks fail, the safest thing to do is to assume there are no profiles.
57
- hasProfiles = false;
58
- }
59
- if (hasProfiles) {
60
- content.push(formatTextContent(`Ask the user which profile they would like to use for the upload.`));
61
- }
62
- }
63
- if (content.length > 0) {
64
- return {
65
- content,
66
- structuredContent: {},
67
- };
68
- }
81
+ setTargetAccount(command, targets, selectedProfile);
69
82
  const { stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra);
70
83
  const response = await formatTextContents(stdout, stderr);
71
84
  // Add reminder about cards needing to be added to views
72
85
  response.content.push(formatTextContent('\nIMPORTANT: If this project contains cards, remember that uploading does NOT make them live automatically. Cards must be manually added to a view in HubSpot to become visible to users.'));
73
86
  response.structuredContent =
74
- parseCommandJsonOutput(stdout, UploadSchema, this.logger, toolName) ?? {};
87
+ parseCommandJsonOutput(stdout, ProjectUploadSchema, this.logger, toolName) ?? {};
75
88
  return response;
76
89
  }
77
90
  register() {
78
91
  return this.mcpServer.registerTool(toolName, {
79
92
  title: 'Upload HubSpot Project',
80
- description: 'DO NOT run this tool unless the user specifies they would like to upload the project, it is potentially destructive. Uploads the HubSpot project in current working directory. If the project does not exist, it will be created. MUST be ran from within the project directory. IMPORTANT: Uploading a project does NOT automatically make cards live or visible to users. Cards must be manually added to a view in HubSpot after upload to become visible. If you do not know the project path, use the find-projects tool first to locate HubSpot projects in the workspace.',
93
+ description: 'DO NOT run this tool unless the user specifies they would like to upload the project, it is potentially destructive. Uploads the HubSpot project in current working directory. If the project does not exist, it will be created. MUST be ran from within the project directory. IMPORTANT: Uploading a project does NOT automatically make cards live or visible to users. Cards must be manually added to a view in HubSpot after upload to become visible. Uploads to production accounts require confirmation from the user. If you do not know the project path, use the find-projects tool first to locate HubSpot projects in the workspace.',
81
94
  inputSchema,
82
- outputSchema: UploadSchema.shape,
95
+ outputSchema: ProjectUploadSchema.shape,
83
96
  annotations: {
84
97
  readOnlyHint: false,
85
98
  destructiveHint: true,