@hubspot/cli 7.10.0-beta.1 → 7.10.0-experimental.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 (201) hide show
  1. package/bin/cli.js +5 -4
  2. package/commands/__tests__/getStarted.test.js +10 -0
  3. package/commands/__tests__/project.test.js +3 -0
  4. package/commands/account/__tests__/rename.test.js +10 -3
  5. package/commands/account/auth.js +10 -14
  6. package/commands/account/clean.js +11 -19
  7. package/commands/account/createOverride.js +15 -11
  8. package/commands/account/info.js +8 -5
  9. package/commands/account/list.js +15 -19
  10. package/commands/account/remove.js +23 -22
  11. package/commands/account/removeOverride.js +6 -6
  12. package/commands/account/rename.js +2 -2
  13. package/commands/account/use.js +19 -8
  14. package/commands/app/__tests__/migrate.test.js +8 -4
  15. package/commands/app/migrate.js +2 -2
  16. package/commands/auth.js +18 -14
  17. package/commands/config/migrate.js +5 -5
  18. package/commands/customObject/createSchema.js +2 -3
  19. package/commands/customObject/updateSchema.js +2 -3
  20. package/commands/getStarted.js +2 -3
  21. package/commands/hubdb/__tests__/list.test.js +1 -0
  22. package/commands/hubdb/list.js +2 -2
  23. package/commands/init.js +36 -32
  24. package/commands/project/__tests__/deploy.test.js +10 -5
  25. package/commands/project/__tests__/devUnifiedFlow.test.js +6 -4
  26. package/commands/project/__tests__/lint.test.js +709 -0
  27. package/commands/project/__tests__/logs.test.js +4 -0
  28. package/commands/project/__tests__/validate.test.js +2 -2
  29. package/commands/project/cloneApp.js +2 -2
  30. package/commands/project/deploy.js +2 -2
  31. package/commands/project/dev/deprecatedFlow.js +4 -5
  32. package/commands/project/dev/index.js +6 -3
  33. package/commands/project/dev/unifiedFlow.js +4 -5
  34. package/commands/project/lint.d.ts +6 -0
  35. package/commands/project/lint.js +178 -0
  36. package/commands/project/logs.js +2 -3
  37. package/commands/project/profile/add.js +6 -7
  38. package/commands/project/profile/delete.js +2 -2
  39. package/commands/project/upload.js +2 -2
  40. package/commands/project/validate.js +2 -2
  41. package/commands/project.js +2 -0
  42. package/commands/sandbox/__tests__/create.test.js +14 -5
  43. package/commands/sandbox/create.js +4 -5
  44. package/commands/sandbox/delete.js +23 -20
  45. package/commands/testAccount/__tests__/create.test.js +5 -5
  46. package/commands/testAccount/create.js +2 -2
  47. package/commands/testAccount/delete.js +9 -8
  48. package/lang/en.d.ts +40 -6
  49. package/lang/en.js +54 -14
  50. package/lib/__tests__/buildAccount.test.js +22 -30
  51. package/lib/__tests__/commonOpts.test.js +9 -13
  52. package/lib/__tests__/developerTestAccounts.test.js +29 -17
  53. package/lib/__tests__/importData.test.js +20 -10
  54. package/lib/__tests__/oauth.test.js +19 -8
  55. package/lib/__tests__/sandboxSync.test.js +33 -11
  56. package/lib/__tests__/sandboxes.test.js +30 -19
  57. package/lib/__tests__/usageTracking.test.js +10 -10
  58. package/lib/__tests__/validation.test.js +32 -32
  59. package/lib/accountTypes.d.ts +9 -9
  60. package/lib/accountTypes.js +2 -4
  61. package/lib/app/__tests__/migrate.test.js +15 -0
  62. package/lib/app/__tests__/migrate_legacy.test.js +9 -0
  63. package/lib/app/migrate_legacy.d.ts +2 -2
  64. package/lib/buildAccount.d.ts +4 -4
  65. package/lib/buildAccount.js +7 -14
  66. package/lib/commonOpts.js +3 -3
  67. package/lib/configMigrate.d.ts +2 -2
  68. package/lib/configMigrate.js +42 -18
  69. package/lib/configOptions.js +3 -2
  70. package/lib/developerTestAccounts.d.ts +3 -3
  71. package/lib/developerTestAccounts.js +4 -7
  72. package/lib/doctor/DiagnosticInfoBuilder.d.ts +1 -1
  73. package/lib/doctor/DiagnosticInfoBuilder.js +9 -6
  74. package/lib/doctor/Doctor.js +4 -3
  75. package/lib/doctor/__tests__/Diagnosis.test.js +4 -3
  76. package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +17 -9
  77. package/lib/doctor/__tests__/Doctor.test.js +14 -0
  78. package/lib/importData.js +8 -7
  79. package/lib/links.js +5 -5
  80. package/lib/middleware/{__test__ → __tests__}/commandTargetingUtils.test.js +3 -3
  81. package/lib/middleware/{__test__ → __tests__}/configMiddleware.test.js +23 -22
  82. package/lib/middleware/{__test__ → __tests__}/gitMiddleware.test.js +9 -7
  83. package/lib/middleware/autoUpdateMiddleware.js +12 -4
  84. package/lib/middleware/commandTargetingUtils.js +3 -2
  85. package/lib/middleware/configMiddleware.d.ts +6 -1
  86. package/lib/middleware/configMiddleware.js +36 -15
  87. package/lib/middleware/gitMiddleware.js +8 -4
  88. package/lib/oauth.d.ts +2 -2
  89. package/lib/oauth.js +8 -10
  90. package/lib/projects/__tests__/AppDevModeInterface.test.js +17 -6
  91. package/lib/projects/__tests__/DevServerManager.test.js +1 -0
  92. package/lib/projects/__tests__/LocalDevProcess.test.js +1 -0
  93. package/lib/projects/__tests__/components.test.js +1 -1
  94. package/lib/projects/__tests__/deploy.test.js +1 -0
  95. package/lib/projects/__tests__/uieLinting.test.js +640 -0
  96. package/lib/projects/components.js +1 -1
  97. package/lib/projects/create/__tests__/v2.test.js +11 -0
  98. package/lib/projects/localDev/AppDevModeInterface.js +2 -2
  99. package/lib/projects/localDev/DevServerManager_DEPRECATED.js +2 -2
  100. package/lib/projects/localDev/DevSessionManager.d.ts +17 -0
  101. package/lib/projects/localDev/DevSessionManager.js +56 -0
  102. package/lib/projects/localDev/LocalDevLogger.d.ts +3 -0
  103. package/lib/projects/localDev/LocalDevLogger.js +13 -4
  104. package/lib/projects/localDev/LocalDevManager_DEPRECATED.js +3 -3
  105. package/lib/projects/localDev/LocalDevProcess.d.ts +1 -0
  106. package/lib/projects/localDev/LocalDevProcess.js +12 -1
  107. package/lib/projects/localDev/LocalDevState.d.ts +3 -0
  108. package/lib/projects/localDev/LocalDevState.js +9 -0
  109. package/lib/projects/localDev/helpers/account.d.ts +10 -10
  110. package/lib/projects/localDev/helpers/account.js +6 -11
  111. package/lib/projects/localDev/helpers/devSessionsApi.d.ts +9 -0
  112. package/lib/projects/localDev/helpers/devSessionsApi.js +19 -0
  113. package/lib/projects/uieLinting.d.ts +33 -0
  114. package/lib/projects/uieLinting.js +222 -0
  115. package/lib/projects/urls.js +5 -6
  116. package/lib/prompts/__tests__/downloadProjectPrompt.test.js +7 -5
  117. package/lib/prompts/accountNamePrompt.js +3 -3
  118. package/lib/prompts/accountsPrompt.d.ts +1 -1
  119. package/lib/prompts/accountsPrompt.js +6 -7
  120. package/lib/prompts/confirmImportDataPrompt.js +2 -2
  121. package/lib/prompts/downloadProjectPrompt.d.ts +1 -0
  122. package/lib/prompts/downloadProjectPrompt.js +5 -2
  123. package/lib/prompts/importDataTestAccountSelectPrompt.js +4 -5
  124. package/lib/prompts/personalAccessKeyPrompt.js +2 -2
  125. package/lib/prompts/projectDevTargetAccountPrompt.d.ts +3 -3
  126. package/lib/prompts/projectDevTargetAccountPrompt.js +5 -7
  127. package/lib/prompts/sandboxesPrompt.js +7 -8
  128. package/lib/prompts/setAsDefaultAccountPrompt.js +7 -6
  129. package/lib/sandboxSync.d.ts +2 -2
  130. package/lib/sandboxSync.js +3 -9
  131. package/lib/sandboxes.d.ts +4 -4
  132. package/lib/sandboxes.js +6 -11
  133. package/lib/serverlessLogs.js +2 -2
  134. package/lib/theme/__tests__/migrate.test.js +15 -0
  135. package/lib/ui/index.js +6 -3
  136. package/lib/usageTracking.js +15 -8
  137. package/lib/validation.js +13 -11
  138. package/mcp-server/tools/cms/HsCreateFunctionTool.js +4 -2
  139. package/mcp-server/tools/cms/HsCreateModuleTool.js +4 -2
  140. package/mcp-server/tools/cms/HsCreateTemplateTool.js +4 -2
  141. package/mcp-server/tools/cms/HsFunctionLogsTool.js +4 -2
  142. package/mcp-server/tools/cms/HsListFunctionsTool.js +3 -1
  143. package/mcp-server/tools/cms/HsListTool.js +3 -1
  144. package/mcp-server/tools/cms/__tests__/HsCreateFunctionTool.test.js +1 -0
  145. package/mcp-server/tools/index.js +4 -0
  146. package/mcp-server/tools/project/AddFeatureToProjectTool.js +4 -2
  147. package/mcp-server/tools/project/CreateProjectTool.js +4 -2
  148. package/mcp-server/tools/project/CreateTestAccountTool.js +42 -19
  149. package/mcp-server/tools/project/DeployProjectTool.js +3 -1
  150. package/mcp-server/tools/project/DocFetchTool.js +6 -4
  151. package/mcp-server/tools/project/DocsSearchTool.d.ts +1 -1
  152. package/mcp-server/tools/project/DocsSearchTool.js +10 -8
  153. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +1 -1
  154. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +9 -7
  155. package/mcp-server/tools/project/GetApplicationInfoTool.js +8 -6
  156. package/mcp-server/tools/project/GetBuildLogsTool.d.ts +26 -0
  157. package/mcp-server/tools/project/GetBuildLogsTool.js +125 -0
  158. package/mcp-server/tools/project/GetBuildStatusTool.d.ts +26 -0
  159. package/mcp-server/tools/project/GetBuildStatusTool.js +166 -0
  160. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +1 -1
  161. package/mcp-server/tools/project/GetConfigValuesTool.js +9 -7
  162. package/mcp-server/tools/project/GuidedWalkthroughTool.d.ts +1 -1
  163. package/mcp-server/tools/project/GuidedWalkthroughTool.js +5 -3
  164. package/mcp-server/tools/project/UploadProjectTools.js +3 -1
  165. package/mcp-server/tools/project/ValidateProjectTool.js +4 -2
  166. package/mcp-server/tools/project/__tests__/CreateTestAccountTool.test.js +226 -3
  167. package/mcp-server/tools/project/__tests__/DocFetchTool.test.js +5 -1
  168. package/mcp-server/tools/project/__tests__/DocsSearchTool.test.js +23 -11
  169. package/mcp-server/tools/project/__tests__/GetApiUsagePatternsByAppIdTool.test.js +7 -5
  170. package/mcp-server/tools/project/__tests__/GetApplicationInfoTool.test.js +7 -5
  171. package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.d.ts +1 -0
  172. package/mcp-server/tools/project/__tests__/GetBuildLogsTool.test.js +305 -0
  173. package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.d.ts +1 -0
  174. package/mcp-server/tools/project/__tests__/GetBuildStatusTool.test.js +240 -0
  175. package/mcp-server/tools/project/__tests__/GetConfigValuesTool.test.js +8 -6
  176. package/mcp-server/utils/__tests__/content.test.js +21 -20
  177. package/mcp-server/utils/__tests__/feedbackTracking.test.js +34 -28
  178. package/mcp-server/utils/config.d.ts +1 -0
  179. package/mcp-server/utils/config.js +10 -0
  180. package/mcp-server/utils/content.d.ts +1 -1
  181. package/mcp-server/utils/content.js +2 -2
  182. package/mcp-server/utils/feedbackTracking.d.ts +1 -1
  183. package/mcp-server/utils/feedbackTracking.js +3 -3
  184. package/mcp-server/utils/toolUsageTracking.js +4 -3
  185. package/package.json +8 -7
  186. package/types/LocalDev.d.ts +1 -0
  187. package/lib/middleware/__test__/notificationsMiddleware.test.js +0 -8
  188. package/lib/middleware/notificationsMiddleware.d.ts +0 -1
  189. package/lib/middleware/notificationsMiddleware.js +0 -28
  190. package/mcp-server/utils/__tests__/cliConfig.test.js +0 -110
  191. package/mcp-server/utils/cliConfig.d.ts +0 -1
  192. package/mcp-server/utils/cliConfig.js +0 -12
  193. /package/{lib/middleware/__test__/commandTargetingUtils.test.d.ts → commands/project/__tests__/lint.test.d.ts} +0 -0
  194. /package/lib/middleware/{__test__/configMiddleware.test.d.ts → __tests__/commandTargetingUtils.test.d.ts} +0 -0
  195. /package/lib/middleware/{__test__/gitMiddleware.test.d.ts → __tests__/configMiddleware.test.d.ts} +0 -0
  196. /package/lib/middleware/{__test__/notificationsMiddleware.test.d.ts → __tests__/gitMiddleware.test.d.ts} +0 -0
  197. /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.d.ts +0 -0
  198. /package/lib/middleware/{__test__ → __tests__}/requestMiddleware.test.js +0 -0
  199. /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.d.ts +0 -0
  200. /package/lib/middleware/{__test__ → __tests__}/yargsChecksMiddleware.test.js +0 -0
  201. /package/{mcp-server/utils/__tests__/cliConfig.test.d.ts → lib/projects/__tests__/uieLinting.test.d.ts} +0 -0
@@ -4,8 +4,9 @@ import { trackToolUsage } from '../../utils/toolUsageTracking.js';
4
4
  import { http } from '@hubspot/local-dev-lib/http';
5
5
  import { formatTextContents } from '../../utils/content.js';
6
6
  import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
7
- import { getAccountId } from '@hubspot/local-dev-lib/config';
7
+ import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
8
8
  import { absoluteCurrentWorkingDirectory } from './constants.js';
9
+ import { setupHubSpotConfig } from '../../utils/config.js';
9
10
  const inputSchema = { absoluteCurrentWorkingDirectory };
10
11
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
12
  const inputSchemaZodObject = z.object({ ...inputSchema });
@@ -15,13 +16,14 @@ export class GetApplicationInfoTool extends Tool {
15
16
  super(mcpServer);
16
17
  }
17
18
  async handler({ absoluteCurrentWorkingDirectory, }) {
19
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
18
20
  await trackToolUsage(toolName);
19
21
  try {
20
22
  // Get account ID from CLI config
21
- const accountId = getAccountId();
23
+ const accountId = getConfigDefaultAccountIfExists()?.accountId;
22
24
  if (!accountId) {
23
25
  const authErrorMessage = `No account ID found. Please run \`hs account auth\` to configure an account, or set a default account with \`hs account use <account>\``;
24
- return formatTextContents(absoluteCurrentWorkingDirectory, authErrorMessage);
26
+ return formatTextContents(authErrorMessage);
25
27
  }
26
28
  const response = await http.get(accountId, {
27
29
  url: `app/feature/utilization/public/v3/insights/apps`,
@@ -29,15 +31,15 @@ export class GetApplicationInfoTool extends Tool {
29
31
  // Format the response for display
30
32
  const { data } = response;
31
33
  const formattedResult = JSON.stringify(data, null, 2);
32
- return formatTextContents(absoluteCurrentWorkingDirectory, formattedResult);
34
+ return formatTextContents(formattedResult);
33
35
  }
34
36
  catch (error) {
35
37
  if (isHubSpotHttpError(error)) {
36
38
  // Handle HubSpot-specific HTTP errors
37
- return formatTextContents(absoluteCurrentWorkingDirectory, error.toString());
39
+ return formatTextContents(error.toString());
38
40
  }
39
41
  const errorMessage = `${error instanceof Error ? error.message : String(error)}`;
40
- return formatTextContents(absoluteCurrentWorkingDirectory, errorMessage);
42
+ return formatTextContents(errorMessage);
41
43
  }
42
44
  }
43
45
  register() {
@@ -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
+ absoluteProjectPath: z.ZodString;
6
+ absoluteCurrentWorkingDirectory: z.ZodString;
7
+ buildId: z.ZodNumber;
8
+ logLevel: z.ZodDefault<z.ZodOptional<z.ZodEnum<["ERROR", "WARN", "INFO", "ALL"]>>>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ buildId: number;
11
+ absoluteProjectPath: string;
12
+ absoluteCurrentWorkingDirectory: string;
13
+ logLevel: "ERROR" | "WARN" | "INFO" | "ALL";
14
+ }, {
15
+ buildId: number;
16
+ absoluteProjectPath: string;
17
+ absoluteCurrentWorkingDirectory: string;
18
+ logLevel?: "ERROR" | "WARN" | "INFO" | "ALL" | undefined;
19
+ }>;
20
+ export type GetBuildLogsInputSchema = z.infer<typeof inputSchemaZodObject>;
21
+ export declare class GetBuildLogsTool extends Tool<GetBuildLogsInputSchema> {
22
+ constructor(mcpServer: McpServer);
23
+ handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, logLevel, }: GetBuildLogsInputSchema): Promise<TextContentResponse>;
24
+ register(): RegisteredTool;
25
+ }
26
+ export {};
@@ -0,0 +1,125 @@
1
+ import { Tool } from '../../types.js';
2
+ import { z } from 'zod';
3
+ import { trackToolUsage } from '../../utils/toolUsageTracking.js';
4
+ import { formatTextContents } from '../../utils/content.js';
5
+ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
6
+ import { http } from '@hubspot/local-dev-lib/http';
7
+ import { getProjectConfig, validateProjectConfig, } from '../../../lib/projects/config.js';
8
+ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
9
+ import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
10
+ import { setupHubSpotConfig } from '../../utils/config.js';
11
+ const TOOL_NAME = 'get-build-logs';
12
+ const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
13
+ const inputSchema = {
14
+ absoluteProjectPath,
15
+ absoluteCurrentWorkingDirectory,
16
+ buildId: z
17
+ .number()
18
+ .describe('Build ID to fetch logs for. Use get-build-status to find recent build IDs.'),
19
+ logLevel: z
20
+ .enum(['ERROR', 'WARN', 'INFO', 'ALL'])
21
+ .optional()
22
+ .default('ALL')
23
+ .describe('Filter logs by level. ERROR: Show only errors, WARN: Show only warnings, INFO: Show only info, ALL: Show all logs.'),
24
+ };
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
+ const inputSchemaZodObject = z.object({ ...inputSchema });
27
+ function flattenLogs(response) {
28
+ const allLogs = [];
29
+ response.logs.forEach(substep => {
30
+ substep.logs.forEach(log => {
31
+ allLogs.push(log);
32
+ });
33
+ });
34
+ return allLogs.sort((a, b) => a.timestamp - b.timestamp);
35
+ }
36
+ function filterLogsByLevel(logs, logLevel) {
37
+ if (logLevel === 'ALL') {
38
+ return logs;
39
+ }
40
+ return logs.filter(log => log.logLevel === logLevel);
41
+ }
42
+ function formatLogs(logs) {
43
+ if (logs.length === 0) {
44
+ return 'No logs found.';
45
+ }
46
+ return logs
47
+ .map(log => {
48
+ const timestamp = new Date(log.timestamp).toLocaleString('en-US', {
49
+ month: 'short',
50
+ day: 'numeric',
51
+ year: 'numeric',
52
+ hour: 'numeric',
53
+ minute: 'numeric',
54
+ second: 'numeric',
55
+ timeZoneName: 'short',
56
+ });
57
+ const component = log.pipelineSubstepName || `Step ${log.pipelineStepId}`;
58
+ return `[${log.logLevel}][${component}] ${timestamp} ${log.message}`;
59
+ })
60
+ .join('\n');
61
+ }
62
+ export class GetBuildLogsTool extends Tool {
63
+ constructor(mcpServer) {
64
+ super(mcpServer);
65
+ }
66
+ async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, logLevel, }) {
67
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
68
+ await trackToolUsage(TOOL_NAME);
69
+ try {
70
+ const accountId = getConfigDefaultAccountIfExists()?.accountId;
71
+ if (!accountId) {
72
+ return formatTextContents(absoluteCurrentWorkingDirectory, 'No account ID found. Please run `hs account auth` to configure an account, or set a default account with `hs account use <account>`');
73
+ }
74
+ const { projectConfig, projectDir } = await getProjectConfig(absoluteProjectPath);
75
+ validateProjectConfig(projectConfig, projectDir);
76
+ const projectName = projectConfig.name;
77
+ const response = await http.get(accountId, {
78
+ url: `${PROJECTS_LOGS_API_PATH}/logs/projects/${encodeURIComponent(projectName)}/builds/${buildId}`,
79
+ });
80
+ const buildLogsResponse = response.data;
81
+ if (!buildLogsResponse.logs || buildLogsResponse.logs.length === 0) {
82
+ return formatTextContents(absoluteCurrentWorkingDirectory, `No logs found for build #${buildId} in project '${projectName}'.`);
83
+ }
84
+ const allLogs = flattenLogs(buildLogsResponse);
85
+ if (allLogs.length === 0) {
86
+ return formatTextContents(absoluteCurrentWorkingDirectory, `No logs found for build #${buildId} in project '${projectName}'.`);
87
+ }
88
+ const filteredLogs = filterLogsByLevel(allLogs, logLevel);
89
+ let output;
90
+ if (filteredLogs.length === 0) {
91
+ // No logs match filter, show all logs instead
92
+ output = `No ${logLevel} level logs found for build #${buildId} in '${projectName}'.\nShowing all logs instead:\n\n${formatLogs(allLogs)}`;
93
+ }
94
+ else {
95
+ output = `Logs for build #${buildId} in '${projectName}' (${logLevel} level):\n\n${formatLogs(filteredLogs)}`;
96
+ }
97
+ return formatTextContents(absoluteCurrentWorkingDirectory, output);
98
+ }
99
+ catch (error) {
100
+ let errorMessage;
101
+ if (isHubSpotHttpError(error)) {
102
+ errorMessage = error.toString();
103
+ }
104
+ else if (error instanceof Error) {
105
+ errorMessage = error.message;
106
+ }
107
+ else {
108
+ errorMessage = String(error);
109
+ }
110
+ return formatTextContents(absoluteCurrentWorkingDirectory, errorMessage);
111
+ }
112
+ }
113
+ register() {
114
+ return this.mcpServer.registerTool(TOOL_NAME, {
115
+ title: 'Get HubSpot Project Build Logs',
116
+ description: 'Retrieves build logs for a specific HubSpot project build. Use this to debug build failures by viewing the full build pipeline output. This tool is for more comprehensive troubleshootings or addressing build WARNINGs, build errors should be troubleshooted with get-build-status tool first. Logs can be filtered by level (ERROR, WARN, INFO, or ALL). Use `hs project list-builds` first to identify the build ID and error messages.',
117
+ inputSchema,
118
+ annotations: {
119
+ readOnlyHint: true,
120
+ openWorldHint: true,
121
+ idempotentHint: true,
122
+ },
123
+ }, this.handler);
124
+ }
125
+ }
@@ -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
+ absoluteProjectPath: z.ZodString;
6
+ absoluteCurrentWorkingDirectory: z.ZodString;
7
+ buildId: z.ZodOptional<z.ZodNumber>;
8
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ limit: number;
11
+ absoluteProjectPath: string;
12
+ absoluteCurrentWorkingDirectory: string;
13
+ buildId?: number | undefined;
14
+ }, {
15
+ absoluteProjectPath: string;
16
+ absoluteCurrentWorkingDirectory: string;
17
+ limit?: number | undefined;
18
+ buildId?: number | undefined;
19
+ }>;
20
+ export type GetBuildStatusInputSchema = z.infer<typeof inputSchemaZodObject>;
21
+ export declare class GetBuildStatusTool extends Tool<GetBuildStatusInputSchema> {
22
+ constructor(mcpServer: McpServer);
23
+ handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, limit, }: GetBuildStatusInputSchema): Promise<TextContentResponse>;
24
+ register(): RegisteredTool;
25
+ }
26
+ export {};
@@ -0,0 +1,166 @@
1
+ import { Tool } from '../../types.js';
2
+ import { z } from 'zod';
3
+ import { trackToolUsage } from '../../utils/toolUsageTracking.js';
4
+ import { formatTextContents } from '../../utils/content.js';
5
+ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
6
+ import { fetchProjectBuilds, getBuildStatus, } from '@hubspot/local-dev-lib/api/projects';
7
+ import { getProjectConfig, validateProjectConfig, } from '../../../lib/projects/config.js';
8
+ import moment from 'moment';
9
+ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
10
+ import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
11
+ import { setupHubSpotConfig } from '../../utils/config.js';
12
+ const TOOL_NAME = 'get-build-status';
13
+ const inputSchema = {
14
+ absoluteProjectPath,
15
+ absoluteCurrentWorkingDirectory,
16
+ buildId: z
17
+ .number()
18
+ .optional()
19
+ .describe('Optional: Specific build ID to inspect. If omitted, shows recent builds to help identify the latest build.'),
20
+ limit: z
21
+ .number()
22
+ .optional()
23
+ .default(3)
24
+ .describe('Number of recent builds to fetch when buildId is not specified.'),
25
+ };
26
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
+ const inputSchemaZodObject = z.object({ ...inputSchema });
28
+ function getStatusIcon(status) {
29
+ return status === 'SUCCESS' ? '✓' : '⚠️';
30
+ }
31
+ function formatDuration(startedAt, finishedAt) {
32
+ const duration = moment.duration(moment(finishedAt).diff(moment(startedAt)));
33
+ const days = Math.floor(duration.asDays());
34
+ const hours = duration.hours();
35
+ const minutes = duration.minutes();
36
+ const seconds = duration.seconds();
37
+ const parts = [];
38
+ if (days > 0)
39
+ parts.push(`${days}d`);
40
+ if (hours > 0)
41
+ parts.push(`${hours}h`);
42
+ if (minutes > 0)
43
+ parts.push(`${minutes}m`);
44
+ if (seconds > 0 || parts.length === 0)
45
+ parts.push(`${seconds}s`);
46
+ return parts.join(' ');
47
+ }
48
+ function formatSubbuilds(subbuilds, indent = ' ') {
49
+ const lines = [];
50
+ subbuilds.forEach(sub => {
51
+ const icon = getStatusIcon(sub.status);
52
+ lines.push(`${indent}${icon} ${sub.buildName} (${sub.buildType}): ${sub.status}`);
53
+ if (sub.errorMessage) {
54
+ lines.push(`${indent} Error: ${sub.errorMessage}`);
55
+ }
56
+ });
57
+ return lines;
58
+ }
59
+ function formatBuildList(builds) {
60
+ const lines = [];
61
+ builds.forEach((build, index) => {
62
+ const icon = getStatusIcon(build.status);
63
+ const timeAgo = moment(build.finishedAt).fromNow();
64
+ const duration = formatDuration(build.startedAt, build.finishedAt);
65
+ lines.push(`Build #${build.buildId} - ${build.status} ${icon}`);
66
+ lines.push(` Finished: ${timeAgo} (Duration: ${duration})`);
67
+ if (build.uploadMessage) {
68
+ lines.push(` Message: ${build.uploadMessage}`);
69
+ }
70
+ if (build.status === 'FAILURE' && build.buildErrorMessage) {
71
+ lines.push(` Error: ${build.buildErrorMessage}`);
72
+ }
73
+ if (build.subbuildStatuses.length > 0) {
74
+ lines.push(` Subbuilds:`);
75
+ lines.push(...formatSubbuilds(build.subbuildStatuses, ' '));
76
+ }
77
+ if (index < builds.length - 1) {
78
+ lines.push('');
79
+ }
80
+ });
81
+ return lines.join('\n');
82
+ }
83
+ function formatBuildDetails(build) {
84
+ const lines = [];
85
+ const icon = getStatusIcon(build.status);
86
+ lines.push(`Build #${build.buildId} Details\n`);
87
+ lines.push(`Status: ${build.status} ${icon}`);
88
+ lines.push(`Platform Version: ${build.platformVersion}`);
89
+ lines.push(`Started: ${moment(build.startedAt).format('YYYY-MM-DD HH:mm:ss UTC')}`);
90
+ lines.push(`Finished: ${moment(build.finishedAt).format('YYYY-MM-DD HH:mm:ss UTC')}`);
91
+ lines.push(`Duration: ${formatDuration(build.startedAt, build.finishedAt)}`);
92
+ if (build.uploadMessage) {
93
+ lines.push(`\nUpload Message:\n${build.uploadMessage}`);
94
+ }
95
+ if (build.buildErrorMessage) {
96
+ lines.push(`\nBuild Error:\n${build.buildErrorMessage}`);
97
+ }
98
+ if (build.subbuildStatuses.length > 0) {
99
+ lines.push(`\nSubbuilds:`);
100
+ lines.push(...formatSubbuilds(build.subbuildStatuses));
101
+ }
102
+ else {
103
+ lines.push(`\nSubbuilds: None`);
104
+ }
105
+ return lines.join('\n');
106
+ }
107
+ export class GetBuildStatusTool extends Tool {
108
+ constructor(mcpServer) {
109
+ super(mcpServer);
110
+ }
111
+ async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildId, limit, }) {
112
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
113
+ await trackToolUsage(TOOL_NAME);
114
+ try {
115
+ const accountId = getConfigDefaultAccountIfExists()?.accountId;
116
+ if (!accountId) {
117
+ return formatTextContents(absoluteCurrentWorkingDirectory, 'No account ID found. Please run `hs account auth` to configure an account, or set a default account with `hs account use <account>`');
118
+ }
119
+ const { projectConfig, projectDir } = await getProjectConfig(absoluteProjectPath);
120
+ validateProjectConfig(projectConfig, projectDir);
121
+ const projectName = projectConfig.name;
122
+ let output;
123
+ if (buildId) {
124
+ const response = await getBuildStatus(accountId, projectName, buildId);
125
+ const build = response.data;
126
+ output = formatBuildDetails(build);
127
+ }
128
+ else {
129
+ const response = await fetchProjectBuilds(accountId, projectName, {
130
+ limit,
131
+ });
132
+ const { results } = response.data;
133
+ if (!results || results.length === 0) {
134
+ return formatTextContents(absoluteCurrentWorkingDirectory, `No builds found for project '${projectName}'.`);
135
+ }
136
+ output = `Recent builds for '${projectName}':\n\n${formatBuildList(results)}`;
137
+ }
138
+ return formatTextContents(absoluteCurrentWorkingDirectory, output);
139
+ }
140
+ catch (error) {
141
+ let errorMessage;
142
+ if (isHubSpotHttpError(error)) {
143
+ errorMessage = error.toString();
144
+ }
145
+ else if (error instanceof Error) {
146
+ errorMessage = error.message;
147
+ }
148
+ else {
149
+ errorMessage = String(error);
150
+ }
151
+ return formatTextContents(absoluteCurrentWorkingDirectory, errorMessage);
152
+ }
153
+ }
154
+ register() {
155
+ return this.mcpServer.registerTool(TOOL_NAME, {
156
+ title: 'Get HubSpot Projects Build Status and Errors',
157
+ description: 'Retrieves build status and error messages for HubSpot projects. When buildId is omitted, shows recent builds with their status(default 3) - use this to find the latest builds when troubleshooting. When buildId is provided, shows detailed error information for that specific build. Displays buildErrorMessage and subbuild failures to help diagnose build issues.',
158
+ inputSchema,
159
+ annotations: {
160
+ readOnlyHint: true,
161
+ openWorldHint: true,
162
+ idempotentHint: true,
163
+ },
164
+ }, this.handler);
165
+ }
166
+ }
@@ -17,7 +17,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
17
17
  type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
18
18
  export declare class GetConfigValuesTool extends Tool<InputSchemaType> {
19
19
  constructor(mcpServer: McpServer);
20
- handler({ absoluteCurrentWorkingDirectory, platformVersion, featureType, }: InputSchemaType): Promise<TextContentResponse>;
20
+ handler({ platformVersion, featureType, absoluteCurrentWorkingDirectory, }: InputSchemaType): Promise<TextContentResponse>;
21
21
  register(): RegisteredTool;
22
22
  }
23
23
  export {};
@@ -4,7 +4,8 @@ import { formatTextContents } from '../../utils/content.js';
4
4
  import { absoluteCurrentWorkingDirectory } from './constants.js';
5
5
  import { getIntermediateRepresentationSchema, mapToInternalType, } from '@hubspot/project-parsing-lib';
6
6
  import { isV2Project } from '../../../lib/projects/platformVersion.js';
7
- import { getAccountIdFromCliConfig } from '../../utils/cliConfig.js';
7
+ import { getConfigDefaultAccountIfExists } from '@hubspot/local-dev-lib/config';
8
+ import { setupHubSpotConfig } from '../../utils/config.js';
8
9
  const inputSchema = {
9
10
  absoluteCurrentWorkingDirectory,
10
11
  platformVersion: z
@@ -23,15 +24,16 @@ export class GetConfigValuesTool extends Tool {
23
24
  constructor(mcpServer) {
24
25
  super(mcpServer);
25
26
  }
26
- async handler({ absoluteCurrentWorkingDirectory, platformVersion, featureType, }) {
27
+ async handler({ platformVersion, featureType, absoluteCurrentWorkingDirectory, }) {
28
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
27
29
  try {
28
30
  if (!isV2Project(platformVersion)) {
29
- return formatTextContents(absoluteCurrentWorkingDirectory, `Can only be used on projects with a minimum platformVersion of 2025.2`);
31
+ return formatTextContents(`Can only be used on projects with a minimum platformVersion of 2025.2`);
30
32
  }
31
- const accountId = getAccountIdFromCliConfig(absoluteCurrentWorkingDirectory);
33
+ const accountId = getConfigDefaultAccountIfExists()?.accountId;
32
34
  if (!accountId) {
33
35
  const authErrorMessage = `No account ID found. Please run \`hs account auth\` to configure an account, or set a default account with \`hs account use <account>\``;
34
- return formatTextContents(absoluteCurrentWorkingDirectory, authErrorMessage);
36
+ return formatTextContents(authErrorMessage);
35
37
  }
36
38
  const schema = await getIntermediateRepresentationSchema({
37
39
  platformVersion,
@@ -40,11 +42,11 @@ export class GetConfigValuesTool extends Tool {
40
42
  });
41
43
  const internalComponentType = mapToInternalType(featureType);
42
44
  if (schema[internalComponentType]) {
43
- return formatTextContents(absoluteCurrentWorkingDirectory, JSON.stringify({ config: schema[internalComponentType] }));
45
+ return formatTextContents(JSON.stringify({ config: schema[internalComponentType] }));
44
46
  }
45
47
  }
46
48
  catch (error) { }
47
- return formatTextContents(absoluteCurrentWorkingDirectory, `Unable to locate JSON schema for type ${featureType}`);
49
+ return formatTextContents(`Unable to locate JSON schema for type ${featureType}`);
48
50
  }
49
51
  register() {
50
52
  return this.mcpServer.registerTool(toolName, {
@@ -14,7 +14,7 @@ declare const inputSchemaZodObject: z.ZodObject<{
14
14
  type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
15
15
  export declare class GuidedWalkthroughTool extends Tool<InputSchemaType> {
16
16
  constructor(mcpServer: McpServer);
17
- handler({ absoluteCurrentWorkingDirectory, command, }: InputSchemaType): Promise<TextContentResponse>;
17
+ handler({ command, absoluteCurrentWorkingDirectory, }: InputSchemaType): Promise<TextContentResponse>;
18
18
  register(): RegisteredTool;
19
19
  }
20
20
  export {};
@@ -4,6 +4,7 @@ import { execAsync } from '../../utils/command.js';
4
4
  import { formatTextContents } from '../../utils/content.js';
5
5
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
6
6
  import { absoluteCurrentWorkingDirectory } from './constants.js';
7
+ import { setupHubSpotConfig } from '../../utils/config.js';
7
8
  const nextCommands = {
8
9
  'hs init': 'hs auth',
9
10
  'hs auth': 'hs project create',
@@ -31,13 +32,14 @@ export class GuidedWalkthroughTool extends Tool {
31
32
  constructor(mcpServer) {
32
33
  super(mcpServer);
33
34
  }
34
- async handler({ absoluteCurrentWorkingDirectory, command, }) {
35
+ async handler({ command, absoluteCurrentWorkingDirectory, }) {
36
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
35
37
  await trackToolUsage(toolName);
36
38
  if (command) {
37
39
  const { stdout } = await execAsync(`${command} --help`);
38
- return formatTextContents(absoluteCurrentWorkingDirectory, `Display this help output for the user amd wait for them to acknowledge: ${stdout}. ${nextCommands[command] ? `Once they are ready, A good command to look at next is ${nextCommands[command]}` : ''}`);
40
+ return formatTextContents(`Display this help output for the user amd wait for them to acknowledge: ${stdout}. ${nextCommands[command] ? `Once they are ready, A good command to look at next is ${nextCommands[command]}` : ''}`);
39
41
  }
40
- return formatTextContents(absoluteCurrentWorkingDirectory, 'Is there another command you would like to learn more about?');
42
+ return formatTextContents('Is there another command you would like to learn more about?');
41
43
  }
42
44
  register() {
43
45
  return this.mcpServer.registerTool(toolName, {
@@ -8,6 +8,7 @@ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constan
8
8
  import { formatTextContent, formatTextContents } from '../../utils/content.js';
9
9
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
10
10
  import { addFlag } from '../../utils/command.js';
11
+ import { setupHubSpotConfig } from '../../utils/config.js';
11
12
  const inputSchema = {
12
13
  absoluteProjectPath,
13
14
  absoluteCurrentWorkingDirectory,
@@ -28,6 +29,7 @@ export class UploadProjectTools extends Tool {
28
29
  super(mcpServer);
29
30
  }
30
31
  async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, profile, uploadMessage, }) {
32
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
31
33
  await trackToolUsage(toolName);
32
34
  let command = addFlag('hs project upload', 'force-create', true);
33
35
  const content = [];
@@ -60,7 +62,7 @@ export class UploadProjectTools extends Tool {
60
62
  };
61
63
  }
62
64
  const { stdout, stderr } = await runCommandInDir(absoluteProjectPath, command);
63
- return formatTextContents(absoluteCurrentWorkingDirectory, stdout, stderr);
65
+ return formatTextContents(stdout, stderr);
64
66
  }
65
67
  register() {
66
68
  return this.mcpServer.registerTool(toolName, {
@@ -4,6 +4,7 @@ import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constan
4
4
  import { runCommandInDir } from '../../utils/project.js';
5
5
  import { formatTextContents } from '../../utils/content.js';
6
6
  import { trackToolUsage } from '../../utils/toolUsageTracking.js';
7
+ import { setupHubSpotConfig } from '../../utils/config.js';
7
8
  const inputSchema = {
8
9
  absoluteProjectPath,
9
10
  absoluteCurrentWorkingDirectory,
@@ -16,13 +17,14 @@ export class ValidateProjectTool extends Tool {
16
17
  super(mcpServer);
17
18
  }
18
19
  async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, }) {
20
+ setupHubSpotConfig(absoluteCurrentWorkingDirectory);
19
21
  await trackToolUsage(toolName);
20
22
  try {
21
23
  const { stdout, stderr } = await runCommandInDir(absoluteProjectPath, 'hs project validate');
22
- return formatTextContents(absoluteCurrentWorkingDirectory, stdout, stderr);
24
+ return formatTextContents(stdout, stderr);
23
25
  }
24
26
  catch (error) {
25
- return formatTextContents(absoluteCurrentWorkingDirectory, error instanceof Error ? error.message : `${error}`);
27
+ return formatTextContents(error instanceof Error ? error.message : `${error}`);
26
28
  }
27
29
  }
28
30
  register() {