@hubspot/cli 8.3.0-experimental.0 → 8.3.1-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 (58) hide show
  1. package/bin/cli.js +2 -0
  2. package/commands/app/migrate.js +3 -3
  3. package/commands/project/migrate.js +4 -4
  4. package/lang/en.d.ts +8 -0
  5. package/lang/en.js +12 -3
  6. package/lib/accountAuth.d.ts +1 -0
  7. package/lib/accountAuth.js +8 -0
  8. package/lib/app/urls.d.ts +0 -1
  9. package/lib/app/urls.js +0 -4
  10. package/lib/constants.d.ts +6 -0
  11. package/lib/constants.js +11 -0
  12. package/lib/middleware/deprecationWarningMiddleware.d.ts +1 -0
  13. package/lib/middleware/deprecationWarningMiddleware.js +57 -0
  14. package/lib/projects/localDev/LocalDevWatcher.js +1 -1
  15. package/lib/prompts/projectProfilePrompt.d.ts +7 -0
  16. package/lib/prompts/projectProfilePrompt.js +1 -1
  17. package/lib/testUtils.d.ts +5 -0
  18. package/lib/testUtils.js +24 -0
  19. package/lib/ui/index.js +11 -1
  20. package/lib/ui/uiMessages.d.ts +1 -0
  21. package/lib/ui/uiMessages.js +1 -0
  22. package/mcp-server/server.js +9 -3
  23. package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +1 -1
  24. package/mcp-server/tools/cms/HsFunctionLogsTool.js +58 -4
  25. package/mcp-server/tools/project/AuthAccountTool.d.ts +1 -0
  26. package/mcp-server/tools/project/AuthAccountTool.js +24 -3
  27. package/mcp-server/tools/project/CreateProjectTool.js +1 -1
  28. package/mcp-server/tools/project/DeployProjectTool.d.ts +2 -2
  29. package/mcp-server/tools/project/DeployProjectTool.js +26 -16
  30. package/mcp-server/tools/project/DocFetchTool.js +1 -1
  31. package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
  32. package/mcp-server/tools/project/DocsSearchTool.js +18 -9
  33. package/mcp-server/tools/project/FindProjectsTool.js +12 -0
  34. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +3 -2
  35. package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +38 -10
  36. package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +2 -1
  37. package/mcp-server/tools/project/GetApplicationInfoTool.js +13 -14
  38. package/mcp-server/tools/project/GetBuildLogsTool.d.ts +2 -1
  39. package/mcp-server/tools/project/GetBuildLogsTool.js +12 -9
  40. package/mcp-server/tools/project/GetBuildStatusTool.js +11 -46
  41. package/mcp-server/tools/project/GetConfigValuesTool.d.ts +2 -1
  42. package/mcp-server/tools/project/GetConfigValuesTool.js +11 -8
  43. package/mcp-server/tools/project/KnowledgeSearchTool.js +6 -3
  44. package/mcp-server/tools/project/UploadProjectTools.d.ts +2 -2
  45. package/mcp-server/tools/project/UploadProjectTools.js +49 -36
  46. package/mcp-server/tools/project/apps.d.ts +8 -0
  47. package/mcp-server/tools/project/apps.js +7 -0
  48. package/mcp-server/tools/project/constants.d.ts +2 -0
  49. package/mcp-server/tools/project/constants.js +7 -0
  50. package/mcp-server/tools/project/productionConfirmation.d.ts +12 -0
  51. package/mcp-server/tools/project/productionConfirmation.js +45 -0
  52. package/mcp-server/tools/project/resolveAccount.d.ts +15 -0
  53. package/mcp-server/tools/project/resolveAccount.js +60 -0
  54. package/mcp-server/utils/elicitSelection.d.ts +11 -0
  55. package/mcp-server/utils/elicitSelection.js +25 -0
  56. package/mcp-server/utils/elicitation.d.ts +2 -0
  57. package/mcp-server/utils/elicitation.js +9 -6
  58. package/package.json +4 -4
@@ -1,17 +1,20 @@
1
1
  import { Tool } from '../../Tool.js';
2
2
  import { z } from 'zod';
3
3
  import { HubSpotCommand } from '../../utils/command.js';
4
- import { absoluteCurrentWorkingDirectory, absoluteProjectPath, } from './constants.js';
5
- import { formatTextContents, formatTextContent } from '../../utils/content.js';
4
+ import { absoluteProjectPath, confirmProductionAccount } from './constants.js';
5
+ import { formatErrorTextContents, formatTextContents, } from '../../utils/content.js';
6
6
  import { setupHubSpotConfig } from '../../utils/config.js';
7
7
  import { parseCommandJsonOutput } from '../../utils/json.js';
8
8
  import { ProjectDeploySchema } from '../../../lib/jsonOutput/projectDeploy.js';
9
+ import { getProjectConfig } from '../../../lib/projects/config.js';
10
+ import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
11
+ import { confirmProductionTargets, setTargetAccount, } from './productionConfirmation.js';
9
12
  const inputSchema = {
10
13
  absoluteProjectPath,
11
- absoluteCurrentWorkingDirectory,
12
14
  buildNumber: z
13
15
  .optional(z.number())
14
- .describe('The build number to be deployed. This can be found in the project details page using `hs project open`. If no build number is specified, the most recent build is deployed'),
16
+ .describe('The build number to deploy. This can be found in the project details page using `hs project open`. If omitted, the tool deploys nothing and returns the recent builds, so you can ask the user which one to deploy.'),
17
+ confirmProductionAccount,
15
18
  };
16
19
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
20
  const inputSchemaZodObject = z.object({
@@ -22,25 +25,32 @@ export class DeployProjectTool extends Tool {
22
25
  constructor(mcpServer, logger) {
23
26
  super(mcpServer, logger, toolName);
24
27
  }
25
- async handler({ absoluteProjectPath, absoluteCurrentWorkingDirectory, buildNumber, }, extra) {
26
- setupHubSpotConfig(absoluteCurrentWorkingDirectory);
27
- const content = [];
28
+ async handler({ absoluteProjectPath, buildNumber, confirmProductionAccount, }, extra) {
29
+ setupHubSpotConfig(absoluteProjectPath);
30
+ const { projectDir, projectConfig } = getProjectConfig(absoluteProjectPath);
31
+ const targets = await discoverAccountTargets({ projectDir, projectConfig });
28
32
  if (!buildNumber) {
29
- const { stdout } = await this.runCommand(absoluteProjectPath, new HubSpotCommand('project list-builds', [
33
+ const listBuildsCommand = new HubSpotCommand('project list-builds', [
30
34
  { name: 'limit', value: 100 },
31
- ]), extra);
32
- content.push(formatTextContent(`Ask the user which build number they would like to deploy? Build information: ${stdout}`));
35
+ ]);
36
+ setTargetAccount(listBuildsCommand, targets);
37
+ const { stdout } = await this.runCommand(absoluteProjectPath, listBuildsCommand, extra);
38
+ return formatErrorTextContents(`Ask the user which build number they would like to deploy? Build information: ${stdout}`);
33
39
  }
34
- if (content.length) {
35
- return {
36
- content,
37
- structuredContent: {},
38
- };
40
+ const blockedResponse = await confirmProductionTargets(this.mcpServer, this.logger, {
41
+ targets,
42
+ action: `Deploy build #${buildNumber}`,
43
+ toolName,
44
+ confirmedInConversation: confirmProductionAccount,
45
+ });
46
+ if (blockedResponse) {
47
+ return blockedResponse;
39
48
  }
40
49
  const command = new HubSpotCommand('project deploy', [
41
50
  { name: 'build', value: buildNumber },
42
51
  { name: 'json', value: true },
43
52
  ]);
53
+ setTargetAccount(command, targets);
44
54
  const { stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra);
45
55
  const response = await formatTextContents(stdout, stderr);
46
56
  response.structuredContent =
@@ -50,7 +60,7 @@ export class DeployProjectTool extends Tool {
50
60
  register() {
51
61
  return this.mcpServer.registerTool(toolName, {
52
62
  title: 'Deploy a build of HubSpot Project',
53
- description: 'Takes a build number and a project name and deploys that build of the project. DO NOT run this tool unless the user specifies they would like to deploy the project. If you do not know the project path, use the find-projects tool first to locate HubSpot projects in the workspace.',
63
+ description: 'Takes a build number and a project name and deploys that build of the project. DO NOT run this tool unless the user specifies they would like to deploy the project. Deploys 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.',
54
64
  inputSchema,
55
65
  outputSchema: ProjectDeploySchema.shape,
56
66
  annotations: {
@@ -48,7 +48,7 @@ export class DocFetchTool extends Tool {
48
48
  register() {
49
49
  return this.mcpServer.registerTool(toolName, {
50
50
  title: 'Fetch HubSpot Developer Documentation (single file)',
51
- description: 'Always use this immediately after `search-docs` and before creating a plan, writing code, or answering technical questions. This tool retrieves the full, authoritative content of a HubSpot Developer Documentation page from its URL, ensuring responses are accurate, up-to-date, and grounded in the official docs.',
51
+ description: 'Always use this immediately after `search-docs` and before creating a plan, writing code, or answering technical questions. This tool retrieves the full, authoritative content of a HubSpot Developer Documentation page from its URL, ensuring responses are accurate, up-to-date, and grounded in the official docs. Some pages include a "Supported products" section (a `<SupportedProducts .../>` tag) listing the products and subscription tiers a feature requires. Read it to tell the user whether a feature is available on their plan, stated plainly (for example "requires Content Hub Enterprise") rather than by quoting raw spec fields.',
52
52
  inputSchema,
53
53
  annotations: {
54
54
  readOnlyHint: true,
@@ -5,8 +5,10 @@ import { McpToolResponse } from '../../types.js';
5
5
  import { Tool } from '../../Tool.js';
6
6
  declare const inputSchemaZodObject: z.ZodObject<{
7
7
  absoluteCurrentWorkingDirectory: z.ZodString;
8
+ account: z.ZodOptional<z.ZodString>;
8
9
  docsSearchQuery: z.ZodString;
9
10
  docsSearchLimit: z.ZodDefault<z.ZodNumber>;
11
+ docsSearchVersion: z.ZodDefault<z.ZodString>;
10
12
  }, z.z.core.$strip>;
11
13
  export interface DocsSearchResponse {
12
14
  results: {
@@ -15,6 +17,7 @@ export interface DocsSearchResponse {
15
17
  description: string;
16
18
  url: string;
17
19
  score: number;
20
+ version?: string;
18
21
  }[];
19
22
  }
20
23
  type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
@@ -23,7 +26,7 @@ export declare class DocsSearchTool extends Tool<InputSchemaType> {
23
26
  protected getTrackingMeta({ docsSearchQuery, }: InputSchemaType): {
24
27
  [key: string]: string;
25
28
  } | undefined;
26
- handler({ docsSearchQuery, docsSearchLimit, absoluteCurrentWorkingDirectory, }: InputSchemaType): Promise<McpToolResponse>;
29
+ handler({ docsSearchQuery, docsSearchLimit, docsSearchVersion, account, absoluteCurrentWorkingDirectory, }: InputSchemaType): Promise<McpToolResponse>;
27
30
  register(): RegisteredTool;
28
31
  }
29
32
  export {};
@@ -2,10 +2,10 @@ import { http } from '@hubspot/local-dev-lib/http';
2
2
  import z from 'zod';
3
3
  import { Tool } from '../../Tool.js';
4
4
  import { formatTextContents } from '../../utils/content.js';
5
- import { absoluteCurrentWorkingDirectory, docsSearchQuery, } from './constants.js';
5
+ import { absoluteCurrentWorkingDirectory, account, docsSearchQuery, } from './constants.js';
6
6
  import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
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
10
  const docsSearchLimit = z
11
11
  .number()
@@ -14,10 +14,16 @@ const docsSearchLimit = z
14
14
  .max(20)
15
15
  .default(5)
16
16
  .describe('Maximum number of results to return.');
17
+ const docsSearchVersion = z
18
+ .string()
19
+ .default('latest')
20
+ .describe('API documentation version to search. Defaults to "latest" for current docs, which is almost always what you want. Only override when the user explicitly asks about a specific or legacy version, using a date-based version like "2026-03" or "legacy". Versionless docs such as guides and CMS pages are always included regardless of this value.');
17
21
  const inputSchema = {
18
22
  absoluteCurrentWorkingDirectory,
23
+ account,
19
24
  docsSearchQuery,
20
25
  docsSearchLimit,
26
+ docsSearchVersion,
21
27
  };
22
28
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
29
  const inputSchemaZodObject = z.object({
@@ -31,19 +37,22 @@ export class DocsSearchTool extends Tool {
31
37
  getTrackingMeta({ docsSearchQuery, }) {
32
38
  return { mode: docsSearchQuery };
33
39
  }
34
- async handler({ docsSearchQuery, docsSearchLimit, absoluteCurrentWorkingDirectory, }) {
40
+ async handler({ docsSearchQuery, docsSearchLimit, docsSearchVersion, account, absoluteCurrentWorkingDirectory, }) {
35
41
  setupHubSpotConfig(absoluteCurrentWorkingDirectory);
36
42
  try {
37
- const { recommended } = await discoverAccountTargets();
38
- const accountId = recommended?.accountId;
39
- if (!accountId) {
40
- const authErrorMessage = `No account ID found. Call the auth-account tool to authenticate a HubSpot account.`;
41
- return formatTextContents(authErrorMessage);
43
+ const resolved = await resolveAccountId(this.mcpServer, this.logger, {
44
+ toolName,
45
+ account,
46
+ });
47
+ if ('response' in resolved) {
48
+ return resolved.response;
42
49
  }
50
+ const { accountId } = resolved;
43
51
  const response = await http.post(accountId, {
44
52
  url: 'dev/docs/llms/v1/docs-search',
45
53
  data: {
46
54
  query: docsSearchQuery,
55
+ version: docsSearchVersion,
47
56
  },
48
57
  });
49
58
  const results = response.data.results;
@@ -82,7 +91,7 @@ export class DocsSearchTool extends Tool {
82
91
  register() {
83
92
  return this.mcpServer.registerTool(toolName, {
84
93
  title: 'Search HubSpot Developer Documentation',
85
- description: 'Use this first whenever you need details about HubSpot APIs, SDKs, integrations, or developer platform features. This searches the official HubSpot Developer Documentation and returns the most relevant pages, each with a URL for use in `fetch-doc`. Always follow this with a fetch to get the full, authoritative content before making plans or writing answers.',
94
+ description: 'Use this first for any HubSpot developer question, including whether an API or feature is available on a subscription tier or plan (for example "is the content audit API available on Content Hub Professional"). The doc you fetch next states the required product and tier; report it in plain terms (for example "requires Content Hub Enterprise") rather than quoting raw spec fields. This searches the official HubSpot Developer Documentation and returns the most relevant pages, each with a URL for use in `fetch-doc`. Always follow this with a fetch to get the full, authoritative content before making plans or writing answers.',
86
95
  inputSchema,
87
96
  annotations: {
88
97
  readOnlyHint: true,
@@ -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}`,
@@ -5,26 +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';
11
- import { enumField } from '../../utils/elicitation.js';
10
+ import { resolveAccountId } from './resolveAccount.js';
12
11
  const TOOL_NAME = 'get-build-status';
13
- function formatAccountChoice(candidate) {
14
- const name = candidate.accountName || String(candidate.accountId);
15
- const parts = [`${name} (${candidate.category})`];
16
- if (candidate.profileName) {
17
- parts.push(`[profile: ${candidate.profileName}]`);
18
- }
19
- return parts.join(' ');
20
- }
21
12
  const inputSchema = {
22
13
  absoluteProjectPath,
23
14
  absoluteCurrentWorkingDirectory,
24
- account: z
25
- .string()
26
- .optional()
27
- .describe('Optional: the HubSpot account ID or name to inspect. If omitted and several accounts are available, you will be asked to choose.'),
15
+ account,
28
16
  buildId: z
29
17
  .number()
30
18
  .optional()
@@ -123,39 +111,16 @@ export class GetBuildStatusTool extends Tool {
123
111
  setupHubSpotConfig(absoluteProjectPath);
124
112
  try {
125
113
  const { projectConfig, projectDir } = getProjectConfig(absoluteProjectPath);
126
- const { candidates, recommended } = await discoverAccountTargets({
127
- projectDir,
128
- projectConfig,
129
- explicitAccount: account,
114
+ const resolved = await resolveAccountId(this.mcpServer, this.logger, {
115
+ toolName: TOOL_NAME,
116
+ absoluteCurrentWorkingDirectory,
117
+ account,
118
+ discoverOptions: { projectDir, projectConfig },
130
119
  });
131
- let accountId = recommended?.accountId;
132
- // discoverAccountTargets ignores explicitAccount when the project has
133
- // profiles, so resolve a re-supplied account against the candidates here.
134
- if (!accountId && account) {
135
- const match = candidates.find(candidate => String(candidate.accountId) === account ||
136
- candidate.accountName === account);
137
- accountId = match?.accountId;
138
- }
139
- if (!accountId && candidates.length > 0) {
140
- const elicitation = await this.elicit({
141
- message: 'Select the HubSpot account to use for this project.',
142
- fields: {
143
- account: enumField('HubSpot account', 'The account to inspect builds for.', candidates.map(candidate => String(candidate.accountId)), candidates.map(formatAccountChoice)),
144
- },
145
- required: ['account'],
146
- });
147
- if (elicitation?.action === 'accept' && elicitation.content) {
148
- accountId = Number(elicitation.content.account);
149
- }
150
- }
151
- if (!accountId) {
152
- if (candidates.length > 0) {
153
- return formatTextContents(absoluteCurrentWorkingDirectory, `Several HubSpot accounts are available. Ask the user which to use, then call get-build-status again with the account argument set to one of: ${candidates
154
- .map(candidate => `${formatAccountChoice(candidate)} (id ${candidate.accountId})`)
155
- .join(', ')}.`);
156
- }
157
- 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;
158
122
  }
123
+ const { accountId } = resolved;
159
124
  const projectName = projectConfig.name;
160
125
  let output;
161
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: '',
@@ -23,6 +23,9 @@ const toolName = 'search-knowledge-base';
23
23
  // system in HubSpot's own portal, so results are scoped by domain and portal.
24
24
  const KNOWLEDGE_BASE_DOMAIN = 'knowledge.hubspot.com';
25
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.';
26
29
  export class KnowledgeSearchTool extends Tool {
27
30
  constructor(mcpServer, logger) {
28
31
  super(mcpServer, logger, toolName);
@@ -45,13 +48,13 @@ export class KnowledgeSearchTool extends Tool {
45
48
  });
46
49
  const { total, results } = response.data;
47
50
  if (!results || results.length === 0) {
48
- return formatTextContents('No knowledge base articles found for your query.');
51
+ return formatTextContents('No knowledge base articles found for your query.', DEV_TIER_ROUTING_HINT);
49
52
  }
50
53
  const formattedResults = results
51
54
  .map(result => `**${result.title}**\n${result.description}\nURL: ${result.url}\nScore: ${result.score}\n---\n`)
52
55
  .join('\n');
53
56
  const successMessage = `Found ${total} results, showing top ${results.length}:\n\n${formattedResults}`;
54
- return formatTextContents(successMessage);
57
+ return formatTextContents(successMessage, DEV_TIER_ROUTING_HINT);
55
58
  }
56
59
  catch (error) {
57
60
  this.logger.debug(toolName, {
@@ -68,7 +71,7 @@ export class KnowledgeSearchTool extends Tool {
68
71
  register() {
69
72
  return this.mcpServer.registerTool(toolName, {
70
73
  title: 'Search HubSpot Knowledge Base',
71
- description: 'Use this for questions about how to use HubSpot products and features, account and subscription settings, and general product how-to guidance. This searches the HubSpot Knowledge Base (knowledge.hubspot.com) and returns the most relevant help articles, each with a URL. Use `search-docs` instead for developer APIs, SDKs, and platform reference.',
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.',
72
75
  inputSchema,
73
76
  annotations: {
74
77
  readOnlyHint: true,
@@ -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 {};