@hubspot/cli 8.15.0 → 8.16.0-beta.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 (125) 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/project/add.d.ts +3 -2
  6. package/commands/project/add.js +10 -8
  7. package/commands/project/appInstallStatus.d.ts +2 -2
  8. package/commands/project/appInstallStatus.js +2 -2
  9. package/commands/project/create.d.ts +4 -2
  10. package/commands/project/create.js +16 -4
  11. package/commands/project/deploy.d.ts +2 -2
  12. package/commands/project/deploy.js +2 -2
  13. package/commands/project/download.d.ts +2 -2
  14. package/commands/project/download.js +2 -2
  15. package/commands/project/info.d.ts +1 -1
  16. package/commands/project/info.js +1 -1
  17. package/commands/project/installApp.d.ts +2 -2
  18. package/commands/project/installApp.js +2 -2
  19. package/commands/project/listBuilds.d.ts +2 -2
  20. package/commands/project/listBuilds.js +2 -2
  21. package/commands/project/release/create.d.ts +2 -2
  22. package/commands/project/release/create.js +7 -3
  23. package/commands/project/release/info.d.ts +2 -2
  24. package/commands/project/release/info.js +2 -2
  25. package/commands/project/release/list.d.ts +2 -2
  26. package/commands/project/release/list.js +2 -2
  27. package/commands/project/release/preview.d.ts +9 -0
  28. package/commands/project/release/preview.js +167 -0
  29. package/commands/project/release.js +7 -1
  30. package/commands/project/upload.d.ts +2 -2
  31. package/commands/project/upload.js +2 -2
  32. package/commands/project/validate.d.ts +2 -2
  33. package/commands/project/validate.js +2 -2
  34. package/commands/testAccount/create.d.ts +2 -2
  35. package/commands/testAccount/create.js +2 -2
  36. package/lang/en.d.ts +25 -0
  37. package/lang/en.js +27 -2
  38. package/lib/app/urls.d.ts +0 -1
  39. package/lib/app/urls.js +0 -4
  40. package/lib/constants.d.ts +5 -0
  41. package/lib/constants.js +9 -0
  42. package/lib/jsonOutput/accountAuth.d.ts +7 -0
  43. package/lib/jsonOutput/accountAuth.js +6 -0
  44. package/lib/jsonOutput/projectAdd.d.ts +9 -0
  45. package/lib/jsonOutput/projectAdd.js +10 -0
  46. package/lib/jsonOutput/{appInstallStatus.d.ts → projectAppInstallStatus.d.ts} +2 -2
  47. package/lib/jsonOutput/{appInstallStatus.js → projectAppInstallStatus.js} +1 -1
  48. package/lib/jsonOutput/projectCreate.d.ts +8 -0
  49. package/lib/jsonOutput/projectCreate.js +7 -0
  50. package/lib/jsonOutput/projectDeploy.d.ts +5 -0
  51. package/lib/jsonOutput/{deploy.js → projectDeploy.js} +1 -1
  52. package/lib/jsonOutput/projectDownload.d.ts +7 -0
  53. package/lib/jsonOutput/{download.js → projectDownload.js} +1 -1
  54. package/lib/jsonOutput/{installApp.d.ts → projectInstallApp.d.ts} +2 -2
  55. package/lib/jsonOutput/{installApp.js → projectInstallApp.js} +1 -1
  56. package/lib/jsonOutput/{listBuilds.d.ts → projectListBuilds.d.ts} +2 -2
  57. package/lib/jsonOutput/{listBuilds.js → projectListBuilds.js} +1 -1
  58. package/lib/jsonOutput/{release.d.ts → projectRelease.d.ts} +15 -8
  59. package/lib/jsonOutput/{release.js → projectRelease.js} +11 -4
  60. package/lib/jsonOutput/{upload.d.ts → projectUpload.d.ts} +2 -2
  61. package/lib/jsonOutput/{upload.js → projectUpload.js} +1 -1
  62. package/lib/jsonOutput/{validate.d.ts → projectValidate.d.ts} +2 -2
  63. package/lib/jsonOutput/{validate.js → projectValidate.js} +1 -1
  64. package/lib/jsonOutput/{createTestAccount.d.ts → testAccountCreate.d.ts} +2 -2
  65. package/lib/jsonOutput/{createTestAccount.js → testAccountCreate.js} +1 -1
  66. package/lib/middleware/deprecationWarningMiddleware.d.ts +1 -0
  67. package/lib/middleware/deprecationWarningMiddleware.js +57 -0
  68. package/lib/projects/add/legacyAddComponent.d.ts +2 -1
  69. package/lib/projects/add/legacyAddComponent.js +3 -0
  70. package/lib/projects/add/v2AddComponent.d.ts +2 -1
  71. package/lib/projects/add/v2AddComponent.js +7 -1
  72. package/lib/projects/localDev/LocalDevWatcher.js +1 -1
  73. package/lib/projects/release.d.ts +2 -2
  74. package/lib/projects/validate.d.ts +1 -1
  75. package/mcp-server/Tool.d.ts +6 -1
  76. package/mcp-server/Tool.js +6 -4
  77. package/mcp-server/server.js +26 -4
  78. package/mcp-server/tools/cms/HsCreateFunctionTool.js +1 -1
  79. package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +1 -1
  80. package/mcp-server/tools/cms/HsFunctionLogsTool.js +59 -5
  81. package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
  82. package/mcp-server/tools/index.js +2 -0
  83. package/mcp-server/tools/project/AddFeatureToProjectTool.js +31 -31
  84. package/mcp-server/tools/project/AuthAccountTool.js +12 -2
  85. package/mcp-server/tools/project/CreateProjectTool.js +13 -3
  86. package/mcp-server/tools/project/CreateTestAccountTool.js +13 -13
  87. package/mcp-server/tools/project/DeployProjectTool.js +9 -1
  88. package/mcp-server/tools/project/DocFetchTool.js +1 -1
  89. package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
  90. package/mcp-server/tools/project/DocsSearchTool.js +18 -9
  91. package/mcp-server/tools/project/FindProjectsTool.js +12 -0
  92. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +3 -2
  93. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +38 -10
  94. package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +2 -1
  95. package/mcp-server/tools/project/GetApplicationInfoTool.js +13 -14
  96. package/mcp-server/tools/project/GetBuildLogsTool.d.ts +2 -1
  97. package/mcp-server/tools/project/GetBuildLogsTool.js +12 -9
  98. package/mcp-server/tools/project/GetBuildStatusTool.d.ts +2 -1
  99. package/mcp-server/tools/project/GetBuildStatusTool.js +12 -9
  100. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +2 -1
  101. package/mcp-server/tools/project/GetConfigValuesTool.js +11 -8
  102. package/mcp-server/tools/project/KnowledgeSearchTool.d.ts +29 -0
  103. package/mcp-server/tools/project/KnowledgeSearchTool.js +82 -0
  104. package/mcp-server/tools/project/UploadProjectTools.js +3 -3
  105. package/mcp-server/tools/project/ValidateProjectTool.js +23 -7
  106. package/mcp-server/tools/project/apps.d.ts +8 -0
  107. package/mcp-server/tools/project/apps.js +7 -0
  108. package/mcp-server/tools/project/constants.d.ts +2 -0
  109. package/mcp-server/tools/project/constants.js +8 -1
  110. package/mcp-server/tools/project/resolveAccount.d.ts +15 -0
  111. package/mcp-server/tools/project/resolveAccount.js +60 -0
  112. package/mcp-server/utils/command.d.ts +1 -0
  113. package/mcp-server/utils/command.js +8 -0
  114. package/mcp-server/utils/content.d.ts +1 -0
  115. package/mcp-server/utils/content.js +5 -0
  116. package/mcp-server/utils/elicitSelection.d.ts +11 -0
  117. package/mcp-server/utils/elicitSelection.js +25 -0
  118. package/mcp-server/utils/elicitation.d.ts +9 -0
  119. package/mcp-server/utils/elicitation.js +35 -0
  120. package/package.json +23 -22
  121. package/ui/components/Table.d.ts +8 -8
  122. package/lib/jsonOutput/deploy.d.ts +0 -5
  123. package/lib/jsonOutput/download.d.ts +0 -7
  124. /package/lib/jsonOutput/{info.d.ts → projectInfo.d.ts} +0 -0
  125. /package/lib/jsonOutput/{info.js → projectInfo.js} +0 -0
@@ -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
+ }
@@ -8,7 +8,7 @@ import { 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
12
  const inputSchema = {
13
13
  absoluteProjectPath,
14
14
  absoluteCurrentWorkingDirectory,
@@ -71,7 +71,7 @@ export class UploadProjectTools extends Tool {
71
71
  // Add reminder about cards needing to be added to views
72
72
  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
73
  response.structuredContent =
74
- parseCommandJsonOutput(stdout, UploadSchema, this.logger, toolName) ?? {};
74
+ parseCommandJsonOutput(stdout, ProjectUploadSchema, this.logger, toolName) ?? {};
75
75
  return response;
76
76
  }
77
77
  register() {
@@ -79,7 +79,7 @@ export class UploadProjectTools extends Tool {
79
79
  title: 'Upload HubSpot Project',
80
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.',
81
81
  inputSchema,
82
- outputSchema: UploadSchema.shape,
82
+ outputSchema: ProjectUploadSchema.shape,
83
83
  annotations: {
84
84
  readOnlyHint: false,
85
85
  destructiveHint: true,
@@ -1,10 +1,12 @@
1
1
  import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
4
- import { formatTextContents } from '../../utils/content.js';
4
+ import { formatTextContents, formatErrorTextContents, } from '../../utils/content.js';
5
5
  import { setupHubSpotConfig } from '../../utils/config.js';
6
6
  import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
7
- import { HubSpotCommand } from '../../utils/command.js';
7
+ import { HubSpotCommand, getCommandResultsFromError, } from '../../utils/command.js';
8
+ import { parseCommandJsonOutput } from '../../utils/json.js';
9
+ import { ProjectValidateSchema } from '../../../lib/jsonOutput/projectValidate.js';
8
10
  const inputSchema = {
9
11
  absoluteProjectPath,
10
12
  absoluteCurrentWorkingDirectory,
@@ -18,24 +20,38 @@ export class ValidateProjectTool extends Tool {
18
20
  }
19
21
  async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, }, extra) {
20
22
  setupHubSpotConfig(absoluteCurrentWorkingDirectory);
23
+ const command = new HubSpotCommand('project validate', [
24
+ { name: 'json', value: true },
25
+ ]);
26
+ let stdout = '';
27
+ let stderr = '';
21
28
  try {
22
- const command = new HubSpotCommand('project validate');
23
- const { stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra);
24
- return formatTextContents(stdout, stderr);
29
+ ({ stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra));
25
30
  }
26
31
  catch (error) {
27
32
  this.logger.debug(toolName, {
28
33
  message: 'Handler caught error',
29
- error: error instanceof Error ? error.message : String(error),
34
+ error: getErrorMessage(error),
30
35
  });
31
- return formatTextContents(getErrorMessage(error));
36
+ ({ stdout, stderr } = getCommandResultsFromError(error));
37
+ if (!stdout) {
38
+ return formatErrorTextContents(getErrorMessage(error));
39
+ }
32
40
  }
41
+ const structuredContent = parseCommandJsonOutput(stdout, ProjectValidateSchema, this.logger, toolName);
42
+ if (!structuredContent) {
43
+ return formatErrorTextContents(stdout, stderr);
44
+ }
45
+ const response = await formatTextContents(stdout, stderr);
46
+ response.structuredContent = structuredContent;
47
+ return response;
33
48
  }
34
49
  register() {
35
50
  return this.mcpServer.registerTool(toolName, {
36
51
  title: 'Validate HubSpot Project',
37
52
  description: 'Validates the HubSpot project and its configuration files. This tool does not need to be ran before uploading the project. If you do not know the project path, use the find-projects tool first to locate HubSpot projects in the workspace.',
38
53
  inputSchema,
54
+ outputSchema: ProjectValidateSchema.shape,
39
55
  annotations: {
40
56
  readOnlyHint: true,
41
57
  openWorldHint: false,
@@ -0,0 +1,8 @@
1
+ export interface AppInfo {
2
+ appId: number;
3
+ appName: string;
4
+ }
5
+ export interface GetAppsResponse {
6
+ applications: AppInfo[];
7
+ }
8
+ export declare function getApps(accountId: number): Promise<GetAppsResponse>;
@@ -0,0 +1,7 @@
1
+ import { http } from '@hubspot/local-dev-lib/http';
2
+ export async function getApps(accountId) {
3
+ const response = await http.get(accountId, {
4
+ url: 'app/feature/utilization/public/v3/insights/apps',
5
+ });
6
+ return response.data;
7
+ }
@@ -1,6 +1,7 @@
1
1
  import z from 'zod';
2
2
  export declare const absoluteProjectPath: z.ZodString;
3
3
  export declare const absoluteCurrentWorkingDirectory: z.ZodString;
4
+ export declare const account: z.ZodOptional<z.ZodString>;
4
5
  export declare const features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
5
6
  card: "card";
6
7
  settings: "settings";
@@ -17,3 +18,4 @@ export declare const features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
17
18
  }>>>;
18
19
  export declare const docsSearchQuery: z.ZodString;
19
20
  export declare const docUrl: z.ZodString;
21
+ export declare const knowledgeSearchQuery: z.ZodString;
@@ -5,6 +5,10 @@ export const absoluteProjectPath = z
5
5
  export const absoluteCurrentWorkingDirectory = z
6
6
  .string()
7
7
  .describe('The absolute path to the current working directory.');
8
+ export const account = z
9
+ .string()
10
+ .optional()
11
+ .describe('Optional: the HubSpot account ID or name to use. If omitted and several accounts are available, you will be asked to choose.');
8
12
  export const features = z
9
13
  .array(z.enum([
10
14
  'card',
@@ -20,7 +24,7 @@ export const features = z
20
24
  'page',
21
25
  'crm-bulk-action',
22
26
  ]))
23
- .describe('The features to include in the project, multiple options can be selected. "app-function" is also known as a private serverless function. "app-function-endpoint" is a serverless functions that is publicly accessible via endpoint. "workflow-action" is also known as a custom workflow action. "workflow-action-tool" is also known as agent tools. "crm-bulk-action" is an app actions extension that lets users act on multiple CRM records at once.')
27
+ .describe('The features to include in the project, multiple options can be selected. These are features of a developer-platform app, not CMS website assets. "app-function" is a private serverless function that runs inside the app and is not publicly accessible. It is distinct from a CMS serverless function, which is created with create-cms-function. "app-function-endpoint" is an app serverless function that is publicly accessible via an endpoint. "workflow-action" is also known as a custom workflow action. "workflow-action-tool" is also known as agent tools. "crm-bulk-action" is an app actions extension that lets users act on multiple CRM records at once.')
24
28
  .optional();
25
29
  export const docsSearchQuery = z
26
30
  .string()
@@ -28,3 +32,6 @@ export const docsSearchQuery = z
28
32
  export const docUrl = z
29
33
  .string()
30
34
  .describe('The URL of the HubSpot Developer Documentation to fetch.');
35
+ export const knowledgeSearchQuery = z
36
+ .string()
37
+ .describe('The question to search the general HubSpot Knowledge Base for. Use natural language, for example "how do I set up a workflow" or "what is included in the Marketing Hub Professional plan".');
@@ -0,0 +1,15 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { McpToolResponse } from '../../types.js';
3
+ import { McpLogger } from '../../utils/logger.js';
4
+ import { DiscoverAccountTargetsOptions } from '../../../types/AccountTargets.js';
5
+ export type ResolveAccountResult = {
6
+ accountId: number;
7
+ } | {
8
+ response: McpToolResponse;
9
+ };
10
+ export declare function resolveAccountId(mcpServer: McpServer, logger: McpLogger, params: {
11
+ toolName: string;
12
+ absoluteCurrentWorkingDirectory?: string;
13
+ account?: string;
14
+ discoverOptions?: DiscoverAccountTargetsOptions;
15
+ }): Promise<ResolveAccountResult>;
@@ -0,0 +1,60 @@
1
+ import { formatTextContents } from '../../utils/content.js';
2
+ import { enumField, requestElicitation } from '../../utils/elicitation.js';
3
+ import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
4
+ function formatAccountChoice(candidate) {
5
+ const name = candidate.accountName || String(candidate.accountId);
6
+ const parts = [`${name} (${candidate.category})`];
7
+ if (candidate.profileName) {
8
+ parts.push(`[profile: ${candidate.profileName}]`);
9
+ }
10
+ return parts.join(' ');
11
+ }
12
+ function fallbackResponse(message, absoluteCurrentWorkingDirectory) {
13
+ return absoluteCurrentWorkingDirectory
14
+ ? formatTextContents(absoluteCurrentWorkingDirectory, message)
15
+ : formatTextContents(message);
16
+ }
17
+ // Resolves the HubSpot account a tool should act on. Returns a numeric
18
+ // accountId when one is the obvious choice or the caller supplied a matching
19
+ // `account`. When several accounts are available and none is recommended, it
20
+ // asks the client to pick via elicitation. When the client cannot elicit (or
21
+ // declines), it returns a text response listing the candidates so the caller
22
+ // can return it directly. `toolName` names the tool in that fallback text.
23
+ export async function resolveAccountId(mcpServer, logger, params) {
24
+ const { candidates, recommended } = await discoverAccountTargets({
25
+ ...params.discoverOptions,
26
+ explicitAccount: params.account,
27
+ });
28
+ const available = candidates ?? [];
29
+ let accountId = recommended?.accountId;
30
+ if (!accountId && params.account) {
31
+ const match = available.find(candidate => String(candidate.accountId) === params.account ||
32
+ candidate.accountName === params.account);
33
+ accountId = match?.accountId;
34
+ }
35
+ if (!accountId && available.length > 0) {
36
+ const elicitation = await requestElicitation(mcpServer, {
37
+ message: 'Select the HubSpot account to use.',
38
+ fields: {
39
+ account: enumField('HubSpot account', 'The account to use for this request.', available.map(candidate => String(candidate.accountId)), available.map(formatAccountChoice)),
40
+ },
41
+ required: ['account'],
42
+ }, logger);
43
+ if (elicitation?.action === 'accept' && elicitation.content) {
44
+ accountId = Number(elicitation.content.account);
45
+ }
46
+ }
47
+ if (!accountId) {
48
+ if (available.length > 0) {
49
+ return {
50
+ response: await fallbackResponse(`Several HubSpot accounts are available. Ask the user which to use, then call ${params.toolName} again with the account argument set to one of: ${available
51
+ .map(candidate => `${formatAccountChoice(candidate)} (id ${candidate.accountId})`)
52
+ .join(', ')}.`, params.absoluteCurrentWorkingDirectory),
53
+ };
54
+ }
55
+ return {
56
+ response: await fallbackResponse('No account ID found. Call the auth-account tool to authenticate a HubSpot account.', params.absoluteCurrentWorkingDirectory),
57
+ };
58
+ }
59
+ return { accountId };
60
+ }
@@ -28,4 +28,5 @@ export interface CommandResults {
28
28
  stderr: string;
29
29
  stdout: string;
30
30
  }
31
+ export declare function getCommandResultsFromError(error: unknown): CommandResults;
31
32
  export declare function runCommandInDir(directory: string, command: Command, onData?: (chunk: string, source: 'stdout' | 'stderr') => void): Promise<CommandResults>;
@@ -38,6 +38,14 @@ export class NpxHubSpotCommand {
38
38
  }
39
39
  }
40
40
  export const execAsync = util.promisify(exec);
41
+ export function getCommandResultsFromError(error) {
42
+ if (typeof error !== 'object' || error === null) {
43
+ return { stdout: '', stderr: '' };
44
+ }
45
+ const stdout = 'stdout' in error && typeof error.stdout === 'string' ? error.stdout : '';
46
+ const stderr = 'stderr' in error && typeof error.stderr === 'string' ? error.stderr : '';
47
+ return { stdout, stderr };
48
+ }
41
49
  export async function runCommandInDir(directory, command, onData) {
42
50
  if (!fs.existsSync(directory)) {
43
51
  fs.mkdirSync(directory);
@@ -1,3 +1,4 @@
1
1
  import { TextContent, McpToolResponse } from '../types.js';
2
2
  export declare function formatTextContents(...outputs: (string | undefined)[]): Promise<McpToolResponse>;
3
+ export declare function formatErrorTextContents(...outputs: (string | undefined)[]): Promise<McpToolResponse>;
3
4
  export declare function formatTextContent(text: string): TextContent;
@@ -16,6 +16,11 @@ export async function formatTextContents(...outputs) {
16
16
  content,
17
17
  };
18
18
  }
19
+ export async function formatErrorTextContents(...outputs) {
20
+ const response = await formatTextContents(...outputs);
21
+ response.isError = true;
22
+ return response;
23
+ }
19
24
  export function formatTextContent(text) {
20
25
  return {
21
26
  type: 'text',
@@ -0,0 +1,11 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { McpLogger } from './logger.js';
3
+ export type SelectionOption = {
4
+ value: string;
5
+ label: string;
6
+ };
7
+ export declare function elicitSelection(mcpServer: McpServer, logger: McpLogger, params: {
8
+ message: string;
9
+ title: string;
10
+ options: SelectionOption[];
11
+ }): Promise<string | undefined>;
@@ -0,0 +1,25 @@
1
+ import { enumField, requestElicitation } from './elicitation.js';
2
+ // Asks the client to pick one option from a runtime-discovered list. Returns
3
+ // the chosen value, or undefined when the list is empty, the client cannot
4
+ // elicit, or the user declines. When exactly one option exists it is returned
5
+ // without prompting.
6
+ export async function elicitSelection(mcpServer, logger, params) {
7
+ if (params.options.length === 0) {
8
+ return undefined;
9
+ }
10
+ if (params.options.length === 1) {
11
+ return params.options[0].value;
12
+ }
13
+ const elicitation = await requestElicitation(mcpServer, {
14
+ message: params.message,
15
+ fields: {
16
+ selection: enumField(params.title, params.message, params.options.map(option => option.value), params.options.map(option => option.label)),
17
+ },
18
+ required: ['selection'],
19
+ }, logger);
20
+ if (elicitation?.action === 'accept' &&
21
+ typeof elicitation.content?.selection === 'string') {
22
+ return elicitation.content.selection;
23
+ }
24
+ return undefined;
25
+ }
@@ -0,0 +1,9 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { ElicitResult, PrimitiveSchemaDefinition } from '@modelcontextprotocol/sdk/types.js';
3
+ import { McpLogger } from './logger.js';
4
+ export declare function enumField(title: string, description: string, values: string[], names?: string[]): PrimitiveSchemaDefinition;
5
+ export declare function requestElicitation(mcpServer: McpServer, params: {
6
+ message: string;
7
+ fields: Record<string, PrimitiveSchemaDefinition>;
8
+ required?: string[];
9
+ }, logger?: McpLogger): Promise<ElicitResult | undefined>;
@@ -0,0 +1,35 @@
1
+ export function enumField(title, description, values, names) {
2
+ return { type: 'string', title, description, enum: values, enumNames: names };
3
+ }
4
+ // Sends a JSON Schema of the required inputs to the client, pauses the tool
5
+ // call, and resumes when the client returns a response that matches the schema.
6
+ // The client collects the values from the user. The SDK checks the returned
7
+ // content against the schema before it resolves.
8
+ //
9
+ // Returns the SDK ElicitResult, or `undefined` when the client cannot elicit
10
+ // (it did not advertise form elicitation, or the request failed). Callers treat
11
+ // `undefined` and any non-`accept` action as "no answer" and fall back to text.
12
+ export async function requestElicitation(mcpServer, params, logger) {
13
+ const capabilities = mcpServer.server.getClientCapabilities();
14
+ if (!capabilities?.elicitation?.form) {
15
+ return undefined;
16
+ }
17
+ const requestedSchema = {
18
+ type: 'object',
19
+ properties: params.fields,
20
+ required: params.required,
21
+ };
22
+ try {
23
+ return await mcpServer.server.elicitInput({
24
+ message: params.message,
25
+ requestedSchema,
26
+ });
27
+ }
28
+ catch (error) {
29
+ logger?.warn('elicitation', {
30
+ message: 'Elicitation request failed',
31
+ error: error instanceof Error ? error.message : String(error),
32
+ });
33
+ return undefined;
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cli",
3
- "version": "8.15.0",
3
+ "version": "8.16.0-beta.0",
4
4
  "description": "The official CLI for developing on HubSpot",
5
5
  "license": "Apache-2.0",
6
6
  "repository": "https://github.com/HubSpot/hubspot-cli",
@@ -10,35 +10,35 @@
10
10
  "!**/__tests__/**"
11
11
  ],
12
12
  "dependencies": {
13
- "@hubspot/local-dev-lib": "5.11.0",
14
- "@hubspot/project-parsing-lib": "0.23.3",
13
+ "@hubspot/local-dev-lib": "5.12.0",
14
+ "@hubspot/project-parsing-lib": "0.23.4",
15
15
  "@hubspot/ui-extensions-dev-server": "2.2.2",
16
- "@inquirer/prompts": "7.1.0",
17
- "@modelcontextprotocol/sdk": "1.29.0",
16
+ "@inquirer/prompts": "7.10.1",
17
+ "@modelcontextprotocol/sdk": "1.30.0",
18
18
  "archiver": "7.0.1",
19
- "chalk": "5.4.1",
19
+ "chalk": "5.6.2",
20
20
  "chokidar": "3.6.0",
21
21
  "cli-cursor": "3.1.0",
22
22
  "cli-progress": "3.12.0",
23
- "express": "4.22.2",
23
+ "express": "4.22.3",
24
24
  "findup-sync": "4.0.0",
25
25
  "fs-extra": "8.1.0",
26
- "ink": "6.6.0",
26
+ "ink": "6.8.0",
27
27
  "ink-spinner": "5.0.0",
28
28
  "ink-text-input": "6.0.0",
29
- "js-yaml": "4.3.1",
30
- "minimatch": "10.2.5",
31
- "moment": "2.30.1",
29
+ "js-yaml": "4.3.2",
30
+ "minimatch": "10.2.6",
31
+ "moment": "2.31.0",
32
32
  "open": "7.4.2",
33
- "p-queue": "8.1.0",
34
- "react": "19.2.3",
35
- "semver": "7.6.3",
36
- "strip-ansi": "7.1.0",
33
+ "p-queue": "8.1.1",
34
+ "react": "19.3.0",
35
+ "semver": "7.8.5",
36
+ "strip-ansi": "7.2.0",
37
37
  "table": "6.9.0",
38
38
  "tmp": "0.2.7",
39
39
  "update-notifier": "7.3.1",
40
- "ws": "8.21.0",
41
- "yargs": "17.7.2",
40
+ "ws": "8.21.3",
41
+ "yargs": "17.7.3",
42
42
  "yargs-parser": "21.1.1",
43
43
  "zod": "^4.4.3"
44
44
  },
@@ -51,7 +51,7 @@
51
51
  "@types/fs-extra": "^11.0.4",
52
52
  "@types/js-yaml": "^4.0.9",
53
53
  "@types/node": "^24.1.0",
54
- "@types/react": "^18.3.12",
54
+ "@types/react": "^19.3.0",
55
55
  "@types/semver": "^7.5.8",
56
56
  "@types/tmp": "^0.2.6",
57
57
  "@types/update-notifier": "^6.0.8",
@@ -59,8 +59,8 @@
59
59
  "@types/yargs": "^17.0.33",
60
60
  "@typescript-eslint/eslint-plugin": "^8.30.1",
61
61
  "@typescript-eslint/parser": "^8.11.0",
62
- "@vitest/coverage-v8": "^2.1.9",
63
- "axios": "1.19.0",
62
+ "@vitest/coverage-v8": "^4.1.11",
63
+ "axios": "1.20.0",
64
64
  "eslint": "^8.56.0",
65
65
  "eslint-plugin-import": "^2.31.0",
66
66
  "husky": "^4.3.8",
@@ -71,7 +71,7 @@
71
71
  "ts-node": "^10.9.2",
72
72
  "tsx": "^4.20.3",
73
73
  "typescript": "^5.6.2",
74
- "vitest": "^2.1.9"
74
+ "vitest": "^4.1.11"
75
75
  },
76
76
  "scripts": {
77
77
  "build": "tsx ./scripts/build.ts",
@@ -126,6 +126,7 @@
126
126
  "eslint-visitor-keys": "4.2.0",
127
127
  "@eslint-community/eslint-utils": "4.9.0",
128
128
  "@opentelemetry/core": "2.10.0",
129
- "axios": "1.19.0"
129
+ "axios": "1.20.0",
130
+ "vite": "6.4.3"
130
131
  }
131
132
  }
@@ -23,15 +23,15 @@ export type TableProps<T extends ScalarDict> = {
23
23
  /**
24
24
  * Header component.
25
25
  */
26
- header: (props: React.PropsWithChildren<object>) => JSX.Element;
26
+ header: (props: React.PropsWithChildren<object>) => React.JSX.Element;
27
27
  /**
28
28
  * Component used to render a cell in the table.
29
29
  */
30
- cell: (props: CellProps) => JSX.Element;
30
+ cell: (props: CellProps) => React.JSX.Element;
31
31
  /**
32
32
  * Component used to render the skeleton of the table.
33
33
  */
34
- skeleton: (props: React.PropsWithChildren<object>) => JSX.Element;
34
+ skeleton: (props: React.PropsWithChildren<object>) => React.JSX.Element;
35
35
  /**
36
36
  * Whether to render without borders.
37
37
  */
@@ -57,11 +57,11 @@ export default class Table<T extends ScalarDict> extends React.Component<Pick<Ta
57
57
  * Returns a (data) row representing the headings.
58
58
  */
59
59
  getHeadings(): Partial<T>;
60
- getHeaderRow(): (props: RowProps<T>) => JSX.Element;
61
- getHeadingRow(): (props: RowProps<T>) => JSX.Element;
62
- getSeparatorRow(): (props: RowProps<T>) => JSX.Element;
63
- getDataRow(): (props: RowProps<T>) => JSX.Element;
64
- getFooterRow(): (props: RowProps<T>) => JSX.Element;
60
+ getHeaderRow(): (props: RowProps<T>) => React.JSX.Element;
61
+ getHeadingRow(): (props: RowProps<T>) => React.JSX.Element;
62
+ getSeparatorRow(): (props: RowProps<T>) => React.JSX.Element;
63
+ getDataRow(): (props: RowProps<T>) => React.JSX.Element;
64
+ getFooterRow(): (props: RowProps<T>) => React.JSX.Element;
65
65
  render(): React.JSX.Element;
66
66
  }
67
67
  type RowProps<T extends ScalarDict> = {