@hubspot/cli 8.3.1-experimental.0 → 8.3.1-experimental.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/feedback.d.ts +10 -0
- package/api/feedback.js +9 -0
- package/bin/cli.js +19 -1
- package/commands/account/auth.js +2 -2
- package/commands/account/createOverride.js +2 -0
- package/commands/account/removeOverride.js +2 -0
- package/commands/app/secret/add.js +1 -1
- package/commands/app/secret/delete.js +1 -1
- package/commands/app/secret/list.js +1 -1
- package/commands/app/secret/update.js +1 -1
- package/commands/app/secret.js +1 -1
- package/commands/auth.js +3 -2
- package/commands/cms/function/create.js +5 -37
- package/commands/cms/function/deploy.js +8 -1
- package/commands/cms/function/list.js +4 -0
- package/commands/cms/function/logs.js +2 -0
- package/commands/cms/function/server.js +6 -0
- package/commands/cms/lighthouseScore.js +1 -1
- package/commands/cms/upload.js +6 -0
- package/commands/cms/watch.js +2 -0
- package/commands/cms/webpack/create.js +5 -32
- package/commands/customObject.js +2 -2
- package/commands/feedback.d.ts +6 -2
- package/commands/feedback.js +82 -8
- package/commands/getStarted.js +4 -4
- package/commands/hubdb/list.js +2 -2
- package/commands/init.js +3 -2
- package/commands/mcp/setup.d.ts +1 -0
- package/commands/mcp/setup.js +11 -3
- package/commands/project/dev/index.js +2 -2
- package/commands/project/download.d.ts +2 -0
- package/commands/project/download.js +56 -16
- package/commands/project/logs.js +2 -2
- package/commands/project/upload.js +6 -2
- package/commands/project/watch.js +2 -2
- package/commands/sandbox/create.js +3 -3
- package/commands/sandbox/delete.js +1 -1
- package/commands/sandbox.js +1 -1
- package/lang/en.d.ts +105 -6
- package/lang/en.js +269 -51
- package/lib/accountAuth.js +12 -0
- package/lib/accountCredentials.d.ts +1 -0
- package/lib/accountCredentials.js +25 -0
- package/lib/agentHelp.d.ts +17 -0
- package/lib/agentHelp.js +90 -0
- package/lib/app/migrate.js +5 -8
- package/lib/commonOpts.js +4 -0
- package/lib/constants.d.ts +4 -0
- package/lib/constants.js +6 -0
- package/lib/errorHandlers/suppressError.js +3 -3
- package/lib/feedback.d.ts +3 -0
- package/lib/feedback.js +13 -0
- package/lib/jsonOutput/projectDownload.d.ts +1 -0
- package/lib/jsonOutput/projectDownload.js +1 -0
- package/lib/jsonOutput/projectUpload.d.ts +1 -0
- package/lib/jsonOutput/projectUpload.js +1 -0
- package/lib/mcp/clients.d.ts +2 -1
- package/lib/mcp/clients.js +7 -7
- package/lib/mcp/setup.d.ts +7 -2
- package/lib/mcp/setup.js +22 -37
- package/lib/mcp/skills.d.ts +8 -0
- package/lib/mcp/skills.js +64 -0
- package/lib/projects/archive.d.ts +8 -0
- package/lib/projects/archive.js +104 -0
- package/lib/projects/archiveDiff.d.ts +12 -0
- package/lib/projects/archiveDiff.js +68 -0
- package/lib/projects/config.js +1 -1
- package/lib/projects/download.d.ts +37 -0
- package/lib/projects/download.js +123 -0
- package/lib/projects/localDev/AppDevModeInterface.js +3 -3
- package/lib/projects/localDev/LocalDevLogger.js +5 -5
- package/lib/projects/localDev/LocalDevWatcher.js +2 -1
- package/lib/projects/localDev/helpers/project.js +3 -3
- package/lib/projects/pollProjectBuildAndDeploy.js +4 -4
- package/lib/projects/projectInfo.js +4 -4
- package/lib/projects/projectProfiles.js +3 -3
- package/lib/projects/ui.js +3 -3
- package/lib/projects/upload.d.ts +3 -1
- package/lib/projects/upload.js +23 -6
- package/lib/projects/watch.js +4 -2
- package/lib/projects/workspaces.js +4 -4
- package/lib/prompts/importDataTestAccountSelectPrompt.js +1 -1
- package/lib/prompts/personalAccessKeyPrompt.js +2 -2
- package/lib/prompts/selectPublicAppForMigrationPrompt.js +3 -3
- package/lib/serverlessSunset.d.ts +6 -0
- package/lib/serverlessSunset.js +32 -0
- package/lib/testUtils.d.ts +5 -1
- package/lib/testUtils.js +2 -2
- package/lib/ui/appLogs.js +3 -3
- package/lib/ui/git.js +3 -3
- package/lib/ui/index.d.ts +8 -10
- package/lib/ui/index.js +34 -31
- package/lib/validation.js +16 -1
- package/lib/yargs/makeWrappedYargsHandler.d.ts +1 -0
- package/lib/yargs/makeWrappedYargsHandler.js +7 -0
- package/mcp-server/Tool.d.ts +1 -0
- package/mcp-server/Tool.js +4 -1
- package/mcp-server/server.js +16 -5
- package/mcp-server/skills/hubspot-fix-build/SKILL.md +61 -0
- package/mcp-server/skills/hubspot-new-app/SKILL.md +84 -0
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +1 -1
- package/mcp-server/tools/cms/HsListFunctionsTool.js +1 -1
- package/mcp-server/tools/index.js +2 -2
- package/mcp-server/tools/project/DocFetchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocFetchTool.js +53 -12
- package/mcp-server/tools/project/DocsSearchTool.js +2 -7
- package/mcp-server/tools/project/FindProjectsTool.js +4 -1
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +2 -7
- package/mcp-server/tools/project/GetApplicationInfoTool.js +2 -7
- package/mcp-server/tools/project/GetBuildLogsTool.d.ts +1 -1
- package/mcp-server/tools/project/GetBuildLogsTool.js +2 -12
- package/mcp-server/tools/project/GetBuildStatusTool.js +2 -12
- package/mcp-server/tools/project/KnowledgeSearchTool.js +2 -5
- package/mcp-server/tools/project/SubmitFeedbackTool.d.ts +25 -0
- package/mcp-server/tools/project/SubmitFeedbackTool.js +73 -0
- package/mcp-server/utils/command.js +23 -4
- package/mcp-server/utils/errors.d.ts +1 -0
- package/mcp-server/utils/errors.js +9 -0
- package/mcp-server/utils/feedbackTracking.js +3 -1
- package/package.json +14 -14
- package/mcp-server/tools/cms/HsCreateFunctionTool.d.ts +0 -26
- package/mcp-server/tools/cms/HsCreateFunctionTool.js +0 -100
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hubspot-fix-build
|
|
3
|
+
description: Diagnose and fix a failed HubSpot project build with the HubSpot CLI MCP tools. Use when a HubSpot project build failed, an `hs project upload` or `upload-project` failed, or a project deploy is blocked by a build error. Do not use it for other builds, such as npm, CI, or local compiler builds. Also use when `upload-project` returns a build failure. The skill finds the cause, fixes the project files, and asks before it uploads again.
|
|
4
|
+
disable-model-invocation: false
|
|
5
|
+
allowed-tools: Read, Grep, Glob
|
|
6
|
+
argument-hint: '[project-path] [build-id]'
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Fix a failed HubSpot project build
|
|
10
|
+
|
|
11
|
+
Use this skill to find why a build failed and to fix it. Work from the error text. Do not guess a cause.
|
|
12
|
+
|
|
13
|
+
The tools in this skill come from the HubSpot CLI MCP server, which `hs mcp setup` adds as `HubSpotDev`. If more than one server has a tool with the same name, use the one from `HubSpotDev`.
|
|
14
|
+
|
|
15
|
+
## Task
|
|
16
|
+
|
|
17
|
+
When this skill is invoked:
|
|
18
|
+
|
|
19
|
+
### 1. Locate the project
|
|
20
|
+
|
|
21
|
+
`get-build-status` and `get-build-logs` need the project path, even when you have a build ID. Find the project before you look at any build.
|
|
22
|
+
|
|
23
|
+
1. If the user passed a project path as an argument, use it.
|
|
24
|
+
2. Otherwise call `find-projects`. If it finds several projects, ask the user which one to use.
|
|
25
|
+
3. If the user passed a build ID, keep it for step 2. A build ID does not tell you which project it belongs to.
|
|
26
|
+
|
|
27
|
+
### 2. Find the failed build
|
|
28
|
+
|
|
29
|
+
1. Call `get-build-status` with no `buildId`. It shows the recent builds.
|
|
30
|
+
2. If the user named a build, use that build. Otherwise use the latest build with a failure status.
|
|
31
|
+
3. Call `get-build-status` again with that `buildId`. Read `buildErrorMessage` and the failed subbuilds.
|
|
32
|
+
|
|
33
|
+
If the latest build succeeded, tell the user. Ask which build they mean.
|
|
34
|
+
|
|
35
|
+
### 3. Read the logs only if needed
|
|
36
|
+
|
|
37
|
+
The status output often has enough detail. Call `get-build-logs` in these cases:
|
|
38
|
+
|
|
39
|
+
- The error message is vague or empty.
|
|
40
|
+
- The user asks about warnings.
|
|
41
|
+
- The subbuild failure does not name a file or a field.
|
|
42
|
+
|
|
43
|
+
Start with `logLevel` set to `ERROR`. Use `WARN` for warnings. Use `ALL` as the last choice.
|
|
44
|
+
|
|
45
|
+
### 4. Fix the cause
|
|
46
|
+
|
|
47
|
+
1. Name the cause to the user in one or two sentences. Quote the error text.
|
|
48
|
+
2. If the error points to a `*-hsmeta.json` file, read `platformVersion` in `hsproject.json`. Call `get-feature-config-schema` with that version and the `type` field from the file. Fix the file with values the schema allows.
|
|
49
|
+
3. For other errors, fix the named file.
|
|
50
|
+
4. Do not change `distribution` or `auth` in `app-hsmeta.json` to clear an error. These values cannot change after the first upload. Tell the user and ask what they want to do.
|
|
51
|
+
5. If you cannot find the cause, show the error text to the user without changes. Say which files and logs you read.
|
|
52
|
+
|
|
53
|
+
### 5. Validate
|
|
54
|
+
|
|
55
|
+
Call `validate-project`. Fix each error and call it again. Repeat until it passes.
|
|
56
|
+
|
|
57
|
+
### 6. Ask before you upload
|
|
58
|
+
|
|
59
|
+
Say what you changed. Ask the user whether to upload again. If they say yes, call `upload-project`. If the project uses profiles, ask the user which profile to use. Never choose a profile yourself.
|
|
60
|
+
|
|
61
|
+
After the upload, call `get-build-status` to read the status of the new build. If it fails again, go back to step 2. If the same error repeats after two fixes, stop and show the user the error and what you tried.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hubspot-new-app
|
|
3
|
+
description: Plan and create a HubSpot developer-platform app project with the HubSpot CLI MCP tools. Use when the user wants to build, start, or scaffold a HubSpot developer-platform app project (an `hsproject.json` project). Also use when the user wants to add features such as cards, webhooks, workflow actions, or app functions to a project. Also use when the user has only a rough idea and needs help to choose features, distribution, and auth type. The skill ends with a local project that passes validation. It does not upload or deploy.
|
|
4
|
+
disable-model-invocation: false
|
|
5
|
+
allowed-tools: Read, Grep, Glob
|
|
6
|
+
argument-hint: '[app-idea]'
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Plan and create a HubSpot app project
|
|
10
|
+
|
|
11
|
+
Use this skill to turn an idea into a local HubSpot project that passes validation. The first upload fixes two choices: distribution and auth type. A wrong choice means a new project, so plan before you scaffold.
|
|
12
|
+
|
|
13
|
+
Never choose distribution, auth type, project name, or destination for the user. Ask.
|
|
14
|
+
|
|
15
|
+
The tools in this skill come from the HubSpot CLI MCP server, which `hs mcp setup` adds as `HubSpotDev`. If more than one server has a tool with the same name, use the one from `HubSpotDev`.
|
|
16
|
+
|
|
17
|
+
## Task
|
|
18
|
+
|
|
19
|
+
When this skill is invoked:
|
|
20
|
+
|
|
21
|
+
### 1. Find the starting point
|
|
22
|
+
|
|
23
|
+
1. If the user wants to add features to an existing project, call `find-projects` on the working directory, then skip to step 4 and use `add-feature-to-project`. If the user wants a new app, do not call `find-projects`. If you cannot tell which one the user wants, ask.
|
|
24
|
+
2. If any tool reports "No account ID found", or no account is authenticated, call `auth-account`. Tell the user that a browser tab opens and that they must click "Connect to CLI". Then retry the blocked step.
|
|
25
|
+
3. If the user wants a safe place to test, offer `create-test-account`. Follow that tool's own workflow: look for a test account config file, show it to the user, and ask before you use it. If there is no file, ask for the account name and the tier for each hub.
|
|
26
|
+
|
|
27
|
+
### 2. Plan
|
|
28
|
+
|
|
29
|
+
If the user already stated what the app does, the features, the distribution, and the auth type, skip this step.
|
|
30
|
+
|
|
31
|
+
1. If the user passed an app idea as an argument (for example `/hubspot-new-app a card that shows open tickets`), use it. Otherwise ask one question: what must the app do for its users?
|
|
32
|
+
2. Call `search-docs` for that goal. Call `fetch-doc` on the best results. Choose features from the docs. The valid feature values are:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
card, settings, app-function, app-function-endpoint, webhooks,
|
|
36
|
+
workflow-action, workflow-action-tool, app-object, app-event,
|
|
37
|
+
scim, page, crm-bulk-action
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. Keep these features apart:
|
|
41
|
+
- `app-function` is a private serverless function inside the app.
|
|
42
|
+
- `app-function-endpoint` is an app serverless function with a public endpoint.
|
|
43
|
+
- `workflow-action-tool` is an agent tool.
|
|
44
|
+
- Do not confuse any of them with a CMS serverless function. That is a different product.
|
|
45
|
+
4. If a fetched doc has a "Supported products" section, tell the user the required product and tier in plain words. For example: "This feature requires Content Hub Enterprise." Do this before you scaffold. If no fetched doc has that section, do not state a tier.
|
|
46
|
+
5. Ask for the distribution:
|
|
47
|
+
- `private`: the app is not listed on the HubSpot marketplace.
|
|
48
|
+
- `marketplace`: the app is listed on the HubSpot marketplace.
|
|
49
|
+
6. Ask for the auth type. `oauth` works for both distributions. `static` works only with `private` distribution.
|
|
50
|
+
7. Ask for the project name. Ask for the destination directory. The destination becomes the project folder itself, so use the exact path that the user gives. Do not use the current directory unless the user says so.
|
|
51
|
+
8. After the user answers, show the full plan: name, destination, project base (`app` or `empty`), distribution, auth type, and features.
|
|
52
|
+
9. Ask "Create this project?" Say that distribution and auth type cannot change after the first upload. Wait for a yes in a separate reply. Answers to your questions are not a yes. Do not call `create-project` or `add-feature-to-project` before the yes.
|
|
53
|
+
|
|
54
|
+
### 3. Create a new project
|
|
55
|
+
|
|
56
|
+
Call `create-project` with every value from the plan:
|
|
57
|
+
|
|
58
|
+
- `name`, `destination`
|
|
59
|
+
- `projectBase`: `app` for a project with an app, `empty` for a project without one
|
|
60
|
+
- `distribution` and `auth` (for base `app` only)
|
|
61
|
+
- `features`
|
|
62
|
+
|
|
63
|
+
If the tool answers with a question, ask the user. Do not guess a value.
|
|
64
|
+
|
|
65
|
+
### 4. Add features to an existing project
|
|
66
|
+
|
|
67
|
+
Call `add-feature-to-project` with `absoluteProjectPath` and `features`.
|
|
68
|
+
|
|
69
|
+
- If the project has no app, set `addApp` to `true`. A project needs an app before it can hold a feature.
|
|
70
|
+
- When `addApp` is `true`, pass `distribution` and `auth`. Ask the user for them, as in step 2. Otherwise omit them.
|
|
71
|
+
|
|
72
|
+
### 5. Configure and validate
|
|
73
|
+
|
|
74
|
+
1. Open `hsproject.json` and read `platformVersion`.
|
|
75
|
+
2. Before you edit any `*-hsmeta.json` file, call `get-feature-config-schema` with that `platformVersion` and the `type` field from the file. Use only the values the schema allows.
|
|
76
|
+
3. Edit the file.
|
|
77
|
+
4. If a feature reads or writes CRM data, add the scopes it needs to `requiredScopes` in `app-hsmeta.json`. The schema does not list scope names, so find the exact names with `search-docs` and `fetch-doc`.
|
|
78
|
+
5. Call `validate-project`. Fix each error and call it again. Repeat until it passes. If you cannot fix an error, show the error text to the user without changes.
|
|
79
|
+
|
|
80
|
+
### 6. Finish
|
|
81
|
+
|
|
82
|
+
Tell the user which files you created and which features the project has. Tell them that the project is ready to upload, and that the first upload makes distribution and auth type permanent.
|
|
83
|
+
|
|
84
|
+
Do not call `upload-project` in this skill. Stop here. If the user asks to upload later, treat it as a new request. If that build fails, use the `hubspot-fix-build` skill.
|
|
@@ -119,7 +119,7 @@ export class HsFunctionLogsTool extends Tool {
|
|
|
119
119
|
register() {
|
|
120
120
|
return this.mcpServer.registerTool(toolName, {
|
|
121
121
|
title: 'Get HubSpot CMS serverless function logs for an endpoint',
|
|
122
|
-
description: 'Retrieve logs for HubSpot CMS serverless functions. These are CMS/website functions, not developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). Use this tool to help debug issues with serverless functions by reading the production logs. Supports various options like latest, compact, and limiting results. Use after listing functions with list-cms-serverless-functions to get the endpoint path.',
|
|
122
|
+
description: 'DEPRECATED: CMS serverless functions are being sunset: creating them has ended, editing ends on November 17, 2026, and existing functions stop running on February 1, 2027. Retrieve logs for HubSpot CMS serverless functions. These are CMS/website functions, not developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). Use this tool to help debug issues with serverless functions by reading the production logs. Supports various options like latest, compact, and limiting results. Use after listing functions with list-cms-serverless-functions to get the endpoint path.',
|
|
123
123
|
inputSchema,
|
|
124
124
|
annotations: {
|
|
125
125
|
readOnlyHint: true,
|
|
@@ -54,7 +54,7 @@ export class HsListFunctionsTool extends Tool {
|
|
|
54
54
|
register() {
|
|
55
55
|
return this.mcpServer.registerTool(toolName, {
|
|
56
56
|
title: 'List HubSpot CMS Serverless Functions',
|
|
57
|
-
description: 'Lists CMS serverless functions deployed in a HubSpot account. CMS serverless functions are website endpoints served at /hs/serverless/<path>. This does NOT list developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). Shows function routes, HTTP methods, secrets, and timestamps.',
|
|
57
|
+
description: 'DEPRECATED: CMS serverless functions are being sunset: creating them has ended, editing ends on November 17, 2026, and existing functions stop running on February 1, 2027. Lists CMS serverless functions deployed in a HubSpot account. CMS serverless functions are website endpoints served at /hs/serverless/<path>. This does NOT list developer-platform app functions (the private app-function feature or the public app-function-endpoint feature). Shows function routes, HTTP methods, secrets, and timestamps.',
|
|
58
58
|
inputSchema,
|
|
59
59
|
annotations: {
|
|
60
60
|
readOnlyHint: true,
|
|
@@ -15,12 +15,12 @@ import { GetBuildStatusTool } from './project/GetBuildStatusTool.js';
|
|
|
15
15
|
import { HsListTool } from './cms/HsListTool.js';
|
|
16
16
|
import { HsCreateModuleTool } from './cms/HsCreateModuleTool.js';
|
|
17
17
|
import { HsCreateTemplateTool } from './cms/HsCreateTemplateTool.js';
|
|
18
|
-
import { HsCreateFunctionTool } from './cms/HsCreateFunctionTool.js';
|
|
19
18
|
import { HsListFunctionsTool } from './cms/HsListFunctionsTool.js';
|
|
20
19
|
import { HsFunctionLogsTool } from './cms/HsFunctionLogsTool.js';
|
|
21
20
|
import { CreateTestAccountTool } from './project/CreateTestAccountTool.js';
|
|
22
21
|
import { FindProjectsTool } from './project/FindProjectsTool.js';
|
|
23
22
|
import { AuthAccountTool } from './project/AuthAccountTool.js';
|
|
23
|
+
import { SubmitFeedbackTool } from './project/SubmitFeedbackTool.js';
|
|
24
24
|
export function registerProjectTools(mcpServer, logger) {
|
|
25
25
|
return [
|
|
26
26
|
new UploadProjectTools(mcpServer, logger).register(),
|
|
@@ -40,6 +40,7 @@ export function registerProjectTools(mcpServer, logger) {
|
|
|
40
40
|
new GetBuildStatusTool(mcpServer, logger).register(),
|
|
41
41
|
new FindProjectsTool(mcpServer, logger).register(),
|
|
42
42
|
new AuthAccountTool(mcpServer, logger).register(),
|
|
43
|
+
new SubmitFeedbackTool(mcpServer, logger).register(),
|
|
43
44
|
];
|
|
44
45
|
}
|
|
45
46
|
export function registerCmsTools(mcpServer, logger) {
|
|
@@ -47,7 +48,6 @@ export function registerCmsTools(mcpServer, logger) {
|
|
|
47
48
|
new HsListTool(mcpServer, logger).register(),
|
|
48
49
|
new HsCreateModuleTool(mcpServer, logger).register(),
|
|
49
50
|
new HsCreateTemplateTool(mcpServer, logger).register(),
|
|
50
|
-
new HsCreateFunctionTool(mcpServer, logger).register(),
|
|
51
51
|
new HsListFunctionsTool(mcpServer, logger).register(),
|
|
52
52
|
new HsFunctionLogsTool(mcpServer, logger).register(),
|
|
53
53
|
];
|
|
@@ -6,11 +6,14 @@ import { Tool } from '../../Tool.js';
|
|
|
6
6
|
declare const inputSchemaZodObject: z.ZodObject<{
|
|
7
7
|
docUrl: z.ZodString;
|
|
8
8
|
absoluteCurrentWorkingDirectory: z.ZodString;
|
|
9
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
10
|
+
maxCharacters: z.ZodDefault<z.ZodNumber>;
|
|
11
|
+
fullDocument: z.ZodDefault<z.ZodBoolean>;
|
|
9
12
|
}, z.z.core.$strip>;
|
|
10
13
|
type InputSchemaType = z.infer<typeof inputSchemaZodObject>;
|
|
11
14
|
export declare class DocFetchTool extends Tool<InputSchemaType> {
|
|
12
15
|
constructor(mcpServer: McpServer, logger: McpLogger);
|
|
13
|
-
handler({ docUrl, absoluteCurrentWorkingDirectory, }: InputSchemaType): Promise<McpToolResponse>;
|
|
16
|
+
handler({ docUrl, absoluteCurrentWorkingDirectory, offset, maxCharacters, fullDocument, }: InputSchemaType): Promise<McpToolResponse>;
|
|
14
17
|
register(): RegisteredTool;
|
|
15
18
|
}
|
|
16
19
|
export {};
|
|
@@ -1,14 +1,39 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { Tool } from '../../Tool.js';
|
|
3
|
-
import { formatTextContents } from '../../utils/content.js';
|
|
3
|
+
import { formatErrorTextContents, formatTextContents, } from '../../utils/content.js';
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
4
5
|
import { absoluteCurrentWorkingDirectory, docUrl } from './constants.js';
|
|
5
6
|
import { http } from '@hubspot/local-dev-lib/http/unauthed';
|
|
6
|
-
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
7
7
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
|
-
|
|
8
|
+
const offset = z
|
|
9
|
+
.number()
|
|
10
|
+
.int()
|
|
11
|
+
.min(0)
|
|
12
|
+
.default(0)
|
|
13
|
+
.describe('The character position to start reading from. When more content is available, the response gives the offset for the next part.');
|
|
14
|
+
const maxCharacters = z
|
|
15
|
+
.number()
|
|
16
|
+
.int()
|
|
17
|
+
.min(1000)
|
|
18
|
+
.max(40000)
|
|
19
|
+
.default(20000)
|
|
20
|
+
.describe('The maximum number of characters to return.');
|
|
21
|
+
const fullDocument = z
|
|
22
|
+
.boolean()
|
|
23
|
+
.default(false)
|
|
24
|
+
.describe('Set to true to return the whole document with no character limit. This ignores offset and maxCharacters. Set this only when the user asks for the whole page.');
|
|
9
25
|
const inputSchema = {
|
|
10
26
|
docUrl,
|
|
11
27
|
absoluteCurrentWorkingDirectory,
|
|
28
|
+
offset,
|
|
29
|
+
maxCharacters,
|
|
30
|
+
fullDocument,
|
|
31
|
+
};
|
|
32
|
+
const outputSchema = {
|
|
33
|
+
text: z.string(),
|
|
34
|
+
offset: z.number(),
|
|
35
|
+
nextOffset: z.number().optional(),
|
|
36
|
+
totalCharacters: z.number(),
|
|
12
37
|
};
|
|
13
38
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
14
39
|
const inputSchemaZodObject = z.object({
|
|
@@ -19,7 +44,7 @@ export class DocFetchTool extends Tool {
|
|
|
19
44
|
constructor(mcpServer, logger) {
|
|
20
45
|
super(mcpServer, logger, toolName);
|
|
21
46
|
}
|
|
22
|
-
async handler({ docUrl, absoluteCurrentWorkingDirectory, }) {
|
|
47
|
+
async handler({ docUrl, absoluteCurrentWorkingDirectory, offset, maxCharacters, fullDocument, }) {
|
|
23
48
|
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
24
49
|
try {
|
|
25
50
|
// Append .md extension to the URL
|
|
@@ -29,27 +54,43 @@ export class DocFetchTool extends Tool {
|
|
|
29
54
|
});
|
|
30
55
|
const content = response.data;
|
|
31
56
|
if (!content || content.trim().length === 0) {
|
|
32
|
-
return
|
|
57
|
+
return formatErrorTextContents('Document is empty or contains no content.');
|
|
58
|
+
}
|
|
59
|
+
if (!fullDocument && offset >= content.length) {
|
|
60
|
+
return formatErrorTextContents(`Offset ${offset} is past the end of the document, which has ${content.length} characters.`);
|
|
33
61
|
}
|
|
34
|
-
|
|
62
|
+
const start = fullDocument ? 0 : offset;
|
|
63
|
+
const chunkEnd = fullDocument
|
|
64
|
+
? content.length
|
|
65
|
+
: Math.min(offset + maxCharacters, content.length);
|
|
66
|
+
const nextOffset = chunkEnd < content.length ? chunkEnd : undefined;
|
|
67
|
+
const text = content.slice(start, chunkEnd);
|
|
68
|
+
const result = await formatTextContents(text, nextOffset === undefined
|
|
69
|
+
? undefined
|
|
70
|
+
: `This is part of the document (characters ${start} to ${chunkEnd} of ${content.length}). More content is available. To read the next part, call ${toolName} again with the same arguments and offset set to ${nextOffset}.`);
|
|
71
|
+
result.structuredContent = {
|
|
72
|
+
text,
|
|
73
|
+
offset: start,
|
|
74
|
+
nextOffset,
|
|
75
|
+
totalCharacters: content.length,
|
|
76
|
+
};
|
|
77
|
+
return result;
|
|
35
78
|
}
|
|
36
79
|
catch (error) {
|
|
37
80
|
this.logger.debug(toolName, {
|
|
38
81
|
message: 'Handler caught error',
|
|
39
82
|
error: error instanceof Error ? error.message : String(error),
|
|
40
83
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
const errorMessage = `Error fetching documentation: ${getErrorMessage(error)}`;
|
|
45
|
-
return formatTextContents(errorMessage);
|
|
84
|
+
const errorMessage = `Error fetching documentation: ${getToolErrorMessage(error)}`;
|
|
85
|
+
return formatErrorTextContents(errorMessage);
|
|
46
86
|
}
|
|
47
87
|
}
|
|
48
88
|
register() {
|
|
49
89
|
return this.mcpServer.registerTool(toolName, {
|
|
50
90
|
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
|
|
91
|
+
description: 'Always use this immediately after `search-docs` and before creating a plan, writing code, or answering technical questions. This tool retrieves the authoritative content of a HubSpot Developer Documentation page from its URL, ensuring responses are accurate, up-to-date, and grounded in the official docs. Long pages return in parts. The response says when more content is available and how to fetch the next part. 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
92
|
inputSchema,
|
|
93
|
+
outputSchema,
|
|
53
94
|
annotations: {
|
|
54
95
|
readOnlyHint: true,
|
|
55
96
|
openWorldHint: true,
|
|
@@ -2,11 +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 { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
6
|
import { absoluteCurrentWorkingDirectory, account, docsSearchQuery, } from './constants.js';
|
|
6
|
-
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
7
7
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
8
|
import { resolveAccountId } from './resolveAccount.js';
|
|
9
|
-
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
10
9
|
const docsSearchLimit = z
|
|
11
10
|
.number()
|
|
12
11
|
.int()
|
|
@@ -80,11 +79,7 @@ export class DocsSearchTool extends Tool {
|
|
|
80
79
|
message: 'Handler caught error',
|
|
81
80
|
error: error instanceof Error ? error.message : String(error),
|
|
82
81
|
});
|
|
83
|
-
|
|
84
|
-
// Handle different status codes
|
|
85
|
-
return formatTextContents(error.toString());
|
|
86
|
-
}
|
|
87
|
-
const errorMessage = `Error searching documentation: ${getErrorMessage(error)}`;
|
|
82
|
+
const errorMessage = `Error searching documentation: ${getToolErrorMessage(error)}`;
|
|
88
83
|
return formatTextContents(errorMessage);
|
|
89
84
|
}
|
|
90
85
|
}
|
|
@@ -30,7 +30,10 @@ export class FindProjectsTool extends Tool {
|
|
|
30
30
|
const selected = await elicitSelection(this.mcpServer, this.logger, {
|
|
31
31
|
message: 'Select the HubSpot project to use.',
|
|
32
32
|
title: 'HubSpot project',
|
|
33
|
-
options: projectDirs.map(dir => ({
|
|
33
|
+
options: projectDirs.map(dir => ({
|
|
34
|
+
value: dir,
|
|
35
|
+
label: path.relative(absoluteDirectory, dir) || '.',
|
|
36
|
+
})),
|
|
34
37
|
});
|
|
35
38
|
if (selected) {
|
|
36
39
|
return formatTextContents(`Selected project: ${selected}`);
|
|
@@ -2,11 +2,10 @@ import { Tool } from '../../Tool.js';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { http } from '@hubspot/local-dev-lib/http';
|
|
4
4
|
import { formatTextContents } from '../../utils/content.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
6
6
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
|
|
7
7
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
8
|
import { resolveAccountId } from './resolveAccount.js';
|
|
9
|
-
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
10
9
|
import { elicitSelection } from '../../utils/elicitSelection.js';
|
|
11
10
|
import { getApps } from './apps.js';
|
|
12
11
|
const inputSchema = {
|
|
@@ -83,11 +82,7 @@ export class GetApiUsagePatternsByAppIdTool extends Tool {
|
|
|
83
82
|
message: 'Handler caught error',
|
|
84
83
|
error: error instanceof Error ? error.message : String(error),
|
|
85
84
|
});
|
|
86
|
-
|
|
87
|
-
// Handle HubSpot-specific HTTP errors
|
|
88
|
-
return formatTextContents(error.toString());
|
|
89
|
-
}
|
|
90
|
-
return formatTextContents(getErrorMessage(error));
|
|
85
|
+
return formatTextContents(getToolErrorMessage(error));
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
register() {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Tool } from '../../Tool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
5
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
|
|
6
6
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
7
7
|
import { resolveAccountId } from './resolveAccount.js';
|
|
8
|
-
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
9
8
|
import { getApps } from './apps.js';
|
|
10
9
|
const inputSchema = {
|
|
11
10
|
absoluteCurrentWorkingDirectory,
|
|
@@ -39,11 +38,7 @@ export class GetApplicationInfoTool extends Tool {
|
|
|
39
38
|
message: 'Handler caught error',
|
|
40
39
|
error: error instanceof Error ? error.message : String(error),
|
|
41
40
|
});
|
|
42
|
-
|
|
43
|
-
// Handle HubSpot-specific HTTP errors
|
|
44
|
-
return formatTextContents(error.toString());
|
|
45
|
-
}
|
|
46
|
-
return formatTextContents(getErrorMessage(error));
|
|
41
|
+
return formatTextContents(getToolErrorMessage(error));
|
|
47
42
|
}
|
|
48
43
|
}
|
|
49
44
|
register() {
|
|
@@ -10,9 +10,9 @@ declare const inputSchemaZodObject: z.ZodObject<{
|
|
|
10
10
|
buildId: z.ZodNumber;
|
|
11
11
|
logLevel: z.ZodOptional<z.ZodEnum<{
|
|
12
12
|
ERROR: "ERROR";
|
|
13
|
+
ALL: "ALL";
|
|
13
14
|
WARN: "WARN";
|
|
14
15
|
INFO: "INFO";
|
|
15
|
-
ALL: "ALL";
|
|
16
16
|
}>>;
|
|
17
17
|
}, z.core.$strip>;
|
|
18
18
|
export type GetBuildLogsInputSchema = z.infer<typeof inputSchemaZodObject>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tool } from '../../Tool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
5
|
import { http } from '@hubspot/local-dev-lib/http';
|
|
6
6
|
import { getProjectConfig } from '../../../lib/projects/config.js';
|
|
7
7
|
import { absoluteCurrentWorkingDirectory, absoluteProjectPath, account, } from './constants.js';
|
|
@@ -104,17 +104,7 @@ export class GetBuildLogsTool extends Tool {
|
|
|
104
104
|
message: 'Handler caught error',
|
|
105
105
|
error: error instanceof Error ? error.message : String(error),
|
|
106
106
|
});
|
|
107
|
-
|
|
108
|
-
if (isHubSpotHttpError(error)) {
|
|
109
|
-
errorMessage = error.toString();
|
|
110
|
-
}
|
|
111
|
-
else if (error instanceof Error) {
|
|
112
|
-
errorMessage = error.message;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
errorMessage = String(error);
|
|
116
|
-
}
|
|
117
|
-
return formatTextContents(absoluteCurrentWorkingDirectory, errorMessage);
|
|
107
|
+
return formatTextContents(absoluteCurrentWorkingDirectory, getToolErrorMessage(error));
|
|
118
108
|
}
|
|
119
109
|
}
|
|
120
110
|
register() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tool } from '../../Tool.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
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';
|
|
@@ -145,17 +145,7 @@ export class GetBuildStatusTool extends Tool {
|
|
|
145
145
|
message: 'Handler caught error',
|
|
146
146
|
error: error instanceof Error ? error.message : String(error),
|
|
147
147
|
});
|
|
148
|
-
|
|
149
|
-
if (isHubSpotHttpError(error)) {
|
|
150
|
-
errorMessage = error.toString();
|
|
151
|
-
}
|
|
152
|
-
else if (error instanceof Error) {
|
|
153
|
-
errorMessage = error.message;
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
errorMessage = String(error);
|
|
157
|
-
}
|
|
158
|
-
return formatTextContents(absoluteCurrentWorkingDirectory, errorMessage);
|
|
148
|
+
return formatTextContents(absoluteCurrentWorkingDirectory, getToolErrorMessage(error));
|
|
159
149
|
}
|
|
160
150
|
}
|
|
161
151
|
register() {
|
|
@@ -2,8 +2,8 @@ import { http } from '@hubspot/local-dev-lib/http/unauthed';
|
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
import { Tool } from '../../Tool.js';
|
|
4
4
|
import { formatTextContents } from '../../utils/content.js';
|
|
5
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
6
|
import { absoluteCurrentWorkingDirectory, knowledgeSearchQuery, } from './constants.js';
|
|
6
|
-
import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
7
7
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
8
8
|
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
9
9
|
const knowledgeSearchLimit = z
|
|
@@ -61,10 +61,7 @@ export class KnowledgeSearchTool extends Tool {
|
|
|
61
61
|
message: 'Handler caught error',
|
|
62
62
|
error: getErrorMessage(error),
|
|
63
63
|
});
|
|
64
|
-
|
|
65
|
-
return formatTextContents(error.toString());
|
|
66
|
-
}
|
|
67
|
-
const errorMessage = `Error searching the knowledge base: ${getErrorMessage(error)}`;
|
|
64
|
+
const errorMessage = `Error searching the knowledge base: ${getToolErrorMessage(error)}`;
|
|
68
65
|
return formatTextContents(errorMessage);
|
|
69
66
|
}
|
|
70
67
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { McpServer, RegisteredTool } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
import { McpLogger } from '../../utils/logger.js';
|
|
4
|
+
import { McpToolResponse } from '../../types.js';
|
|
5
|
+
import { Tool } from '../../Tool.js';
|
|
6
|
+
declare const inputSchema: {
|
|
7
|
+
absoluteCurrentWorkingDirectory: z.ZodString;
|
|
8
|
+
account: z.ZodOptional<z.ZodString>;
|
|
9
|
+
feedback: z.ZodString;
|
|
10
|
+
source: z.ZodEnum<{
|
|
11
|
+
user: "user";
|
|
12
|
+
agent: "agent";
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
type InputSchemaType = z.infer<z.ZodObject<typeof inputSchema>>;
|
|
16
|
+
export declare class SubmitFeedbackTool extends Tool<InputSchemaType> {
|
|
17
|
+
constructor(mcpServer: McpServer, logger: McpLogger);
|
|
18
|
+
protected getTrackingMeta({ source, }: InputSchemaType): {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
protected getLoggableInput({ feedback, ...input }: InputSchemaType): unknown;
|
|
22
|
+
handler({ absoluteCurrentWorkingDirectory, account, feedback, source, }: InputSchemaType): Promise<McpToolResponse>;
|
|
23
|
+
register(): RegisteredTool;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { Tool } from '../../Tool.js';
|
|
3
|
+
import { formatTextContents } from '../../utils/content.js';
|
|
4
|
+
import { getToolErrorMessage } from '../../utils/errors.js';
|
|
5
|
+
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
6
|
+
import { absoluteCurrentWorkingDirectory, account } from './constants.js';
|
|
7
|
+
import { resolveAccountId } from './resolveAccount.js';
|
|
8
|
+
import { containsAccountCredentials, submitFeedback, } from '../../../lib/feedback.js';
|
|
9
|
+
import { FEEDBACK_SOURCES } from '../../../api/feedback.js';
|
|
10
|
+
import { MAX_FEEDBACK_LENGTH } from '../../../lib/constants.js';
|
|
11
|
+
import { getErrorMessage } from '../../../lib/errorHandlers/index.js';
|
|
12
|
+
const inputSchema = {
|
|
13
|
+
absoluteCurrentWorkingDirectory,
|
|
14
|
+
account,
|
|
15
|
+
feedback: z
|
|
16
|
+
.string()
|
|
17
|
+
.trim()
|
|
18
|
+
.min(1)
|
|
19
|
+
.max(MAX_FEEDBACK_LENGTH)
|
|
20
|
+
.describe('One short message that describes the problem or the request. Keep it about the HubSpot CLI, these tools, or the developer platform. Do not include secrets, access keys, file contents, or personal data.'),
|
|
21
|
+
source: z
|
|
22
|
+
.enum(FEEDBACK_SOURCES)
|
|
23
|
+
.describe('Who the feedback is from. Use "user" when you pass on feedback that the user gave you, or "agent" when the feedback is your own.'),
|
|
24
|
+
};
|
|
25
|
+
const toolName = 'submit-feedback';
|
|
26
|
+
export class SubmitFeedbackTool extends Tool {
|
|
27
|
+
constructor(mcpServer, logger) {
|
|
28
|
+
super(mcpServer, logger, toolName);
|
|
29
|
+
}
|
|
30
|
+
getTrackingMeta({ source, }) {
|
|
31
|
+
return { mode: source };
|
|
32
|
+
}
|
|
33
|
+
getLoggableInput({ feedback, ...input }) {
|
|
34
|
+
return { ...input, feedbackLength: feedback.length };
|
|
35
|
+
}
|
|
36
|
+
async handler({ absoluteCurrentWorkingDirectory, account, feedback, source, }) {
|
|
37
|
+
setupHubSpotConfig(absoluteCurrentWorkingDirectory);
|
|
38
|
+
try {
|
|
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
|
+
if (containsAccountCredentials(feedback)) {
|
|
47
|
+
return formatTextContents('Feedback cannot contain an access key, token, or secret from your HubSpot config. Remove it, then try again.');
|
|
48
|
+
}
|
|
49
|
+
await submitFeedback(resolved.accountId, feedback, source);
|
|
50
|
+
return formatTextContents('Your feedback has been successfully submitted. Tell the user that you sent feedback, and show them the message.');
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
this.logger.debug(toolName, {
|
|
54
|
+
message: 'Handler caught error',
|
|
55
|
+
error: getErrorMessage(error),
|
|
56
|
+
});
|
|
57
|
+
return formatTextContents(`Error sending feedback: ${getToolErrorMessage(error)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
register() {
|
|
61
|
+
return this.mcpServer.registerTool(toolName, {
|
|
62
|
+
title: 'Submit Feedback',
|
|
63
|
+
description: 'Sends feedback to HubSpot about the HubSpot CLI, these tools, or the HubSpot developer platform. Use it for bugs and errors you hit, things you wish you knew before you started, things that confused or frustrated the user, requests you could not complete, and tools or capabilities that would make future tasks easier. Send one short message, then continue with the task.',
|
|
64
|
+
inputSchema,
|
|
65
|
+
annotations: {
|
|
66
|
+
readOnlyHint: false,
|
|
67
|
+
destructiveHint: false,
|
|
68
|
+
idempotentHint: false,
|
|
69
|
+
openWorldHint: true,
|
|
70
|
+
},
|
|
71
|
+
}, (input, extra) => this.wrappedHandler(input, extra));
|
|
72
|
+
}
|
|
73
|
+
}
|