@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.
- package/bin/cli.js +2 -0
- package/commands/app/migrate.js +3 -3
- package/commands/project/migrate.js +4 -4
- package/lang/en.d.ts +8 -0
- package/lang/en.js +12 -3
- package/lib/accountAuth.d.ts +1 -0
- package/lib/accountAuth.js +8 -0
- package/lib/app/urls.d.ts +0 -1
- package/lib/app/urls.js +0 -4
- package/lib/constants.d.ts +6 -0
- package/lib/constants.js +11 -0
- package/lib/middleware/deprecationWarningMiddleware.d.ts +1 -0
- package/lib/middleware/deprecationWarningMiddleware.js +57 -0
- package/lib/projects/localDev/LocalDevWatcher.js +1 -1
- package/lib/prompts/projectProfilePrompt.d.ts +7 -0
- package/lib/prompts/projectProfilePrompt.js +1 -1
- package/lib/testUtils.d.ts +5 -0
- package/lib/testUtils.js +24 -0
- package/lib/ui/index.js +11 -1
- package/lib/ui/uiMessages.d.ts +1 -0
- package/lib/ui/uiMessages.js +1 -0
- package/mcp-server/server.js +9 -3
- package/mcp-server/tools/cms/HsFunctionLogsTool.d.ts +1 -1
- package/mcp-server/tools/cms/HsFunctionLogsTool.js +58 -4
- package/mcp-server/tools/project/AuthAccountTool.d.ts +1 -0
- package/mcp-server/tools/project/AuthAccountTool.js +24 -3
- package/mcp-server/tools/project/CreateProjectTool.js +1 -1
- package/mcp-server/tools/project/DeployProjectTool.d.ts +2 -2
- package/mcp-server/tools/project/DeployProjectTool.js +26 -16
- package/mcp-server/tools/project/DocFetchTool.js +1 -1
- package/mcp-server/tools/project/DocsSearchTool.d.ts +4 -1
- package/mcp-server/tools/project/DocsSearchTool.js +18 -9
- package/mcp-server/tools/project/FindProjectsTool.js +12 -0
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.d.ts +3 -2
- package/mcp-server/tools/project/GetApiUsagePatternsByAppIdTool.js +38 -10
- package/mcp-server/tools/project/GetApplicationInfoTool.d.ts +2 -1
- package/mcp-server/tools/project/GetApplicationInfoTool.js +13 -14
- package/mcp-server/tools/project/GetBuildLogsTool.d.ts +2 -1
- package/mcp-server/tools/project/GetBuildLogsTool.js +12 -9
- package/mcp-server/tools/project/GetBuildStatusTool.js +11 -46
- package/mcp-server/tools/project/GetConfigValuesTool.d.ts +2 -1
- package/mcp-server/tools/project/GetConfigValuesTool.js +11 -8
- package/mcp-server/tools/project/KnowledgeSearchTool.js +6 -3
- package/mcp-server/tools/project/UploadProjectTools.d.ts +2 -2
- package/mcp-server/tools/project/UploadProjectTools.js +49 -36
- package/mcp-server/tools/project/apps.d.ts +8 -0
- package/mcp-server/tools/project/apps.js +7 -0
- package/mcp-server/tools/project/constants.d.ts +2 -0
- package/mcp-server/tools/project/constants.js +7 -0
- package/mcp-server/tools/project/productionConfirmation.d.ts +12 -0
- package/mcp-server/tools/project/productionConfirmation.js +45 -0
- package/mcp-server/tools/project/resolveAccount.d.ts +15 -0
- package/mcp-server/tools/project/resolveAccount.js +60 -0
- package/mcp-server/utils/elicitSelection.d.ts +11 -0
- package/mcp-server/utils/elicitSelection.js +25 -0
- package/mcp-server/utils/elicitation.d.ts +2 -0
- package/mcp-server/utils/elicitation.js +9 -6
- package/package.json +4 -4
|
@@ -3,21 +3,25 @@ import z from 'zod';
|
|
|
3
3
|
import { getAllHsProfiles } from '@hubspot/project-parsing-lib/profiles';
|
|
4
4
|
import { getProjectConfig } from '../../../lib/projects/config.js';
|
|
5
5
|
import { Tool } from '../../Tool.js';
|
|
6
|
-
import {
|
|
7
|
-
import { formatTextContent, formatTextContents } from '../../utils/content.js';
|
|
6
|
+
import { absoluteProjectPath, confirmProductionAccount } from './constants.js';
|
|
7
|
+
import { formatErrorTextContents, formatTextContent, formatTextContents, } from '../../utils/content.js';
|
|
8
8
|
import { HubSpotCommand } from '../../utils/command.js';
|
|
9
9
|
import { setupHubSpotConfig } from '../../utils/config.js';
|
|
10
10
|
import { parseCommandJsonOutput } from '../../utils/json.js';
|
|
11
11
|
import { ProjectUploadSchema } from '../../../lib/jsonOutput/projectUpload.js';
|
|
12
|
+
import { discoverAccountTargets } from '../../../lib/accountTargetDiscovery.js';
|
|
13
|
+
import { generateProfilePromptOption } from '../../../lib/prompts/projectProfilePrompt.js';
|
|
14
|
+
import { elicitSelection } from '../../utils/elicitSelection.js';
|
|
15
|
+
import { confirmProductionTargets, setTargetAccount, } from './productionConfirmation.js';
|
|
12
16
|
const inputSchema = {
|
|
13
17
|
absoluteProjectPath,
|
|
14
|
-
absoluteCurrentWorkingDirectory,
|
|
15
18
|
uploadMessage: z
|
|
16
19
|
.string()
|
|
17
20
|
.describe('A 1 sentence message that concisely describes the changes that are being uploaded.'),
|
|
18
21
|
profile: z
|
|
19
22
|
.optional(z.string())
|
|
20
|
-
.describe('The profile to use for the upload. Only
|
|
23
|
+
.describe('The profile to use for the upload. Only set this when the user names a profile. If it is omitted and the project uses profiles, the tool asks the user to choose one. NEVER automatically choose a profile based on files you see. Profile files have the format: "hsprofile.<profile>.json".'),
|
|
24
|
+
confirmProductionAccount,
|
|
21
25
|
};
|
|
22
26
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
27
|
const inputSchemaZodObject = z.object({
|
|
@@ -28,44 +32,53 @@ export class UploadProjectTools extends Tool {
|
|
|
28
32
|
constructor(mcpServer, logger) {
|
|
29
33
|
super(mcpServer, logger, toolName);
|
|
30
34
|
}
|
|
31
|
-
async handler({ absoluteProjectPath,
|
|
32
|
-
setupHubSpotConfig(
|
|
35
|
+
async handler({ absoluteProjectPath, profile, uploadMessage, confirmProductionAccount, }, extra) {
|
|
36
|
+
setupHubSpotConfig(absoluteProjectPath);
|
|
37
|
+
const { projectDir, projectConfig } = getProjectConfig(absoluteProjectPath);
|
|
38
|
+
let selectedProfile = profile;
|
|
39
|
+
if (!selectedProfile) {
|
|
40
|
+
const profiles = await getAllHsProfiles(path.join(projectDir, projectConfig.srcDir));
|
|
41
|
+
if (profiles.length > 0) {
|
|
42
|
+
const options = profiles.map(profileName => ({
|
|
43
|
+
value: profileName,
|
|
44
|
+
label: generateProfilePromptOption(projectDir, projectConfig, profileName).name,
|
|
45
|
+
}));
|
|
46
|
+
selectedProfile = await elicitSelection(this.mcpServer, this.logger, {
|
|
47
|
+
message: 'Select the profile to use for the upload.',
|
|
48
|
+
title: 'Project profile',
|
|
49
|
+
options,
|
|
50
|
+
});
|
|
51
|
+
if (!selectedProfile) {
|
|
52
|
+
return formatErrorTextContents(`Several profiles are available. Ask the user which to use, then call ${toolName} again with the profile argument set to one of these profile names: ${options
|
|
53
|
+
.map(option => option.value)
|
|
54
|
+
.join(', ')}. The profiles target these accounts: ${options
|
|
55
|
+
.map(option => option.label)
|
|
56
|
+
.join(', ')}.`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const targets = await discoverAccountTargets({
|
|
61
|
+
projectDir,
|
|
62
|
+
projectConfig,
|
|
63
|
+
profileName: selectedProfile,
|
|
64
|
+
});
|
|
65
|
+
const blockedResponse = await confirmProductionTargets(this.mcpServer, this.logger, {
|
|
66
|
+
targets,
|
|
67
|
+
action: `Upload ${projectConfig.name}`,
|
|
68
|
+
toolName,
|
|
69
|
+
confirmedInConversation: confirmProductionAccount,
|
|
70
|
+
});
|
|
71
|
+
if (blockedResponse) {
|
|
72
|
+
return blockedResponse;
|
|
73
|
+
}
|
|
33
74
|
const command = new HubSpotCommand('project upload', [
|
|
34
75
|
{ name: 'force', value: true },
|
|
35
76
|
{ name: 'json', value: true },
|
|
36
77
|
]);
|
|
37
|
-
const content = [];
|
|
38
78
|
if (uploadMessage) {
|
|
39
79
|
command.addFlag('message', uploadMessage);
|
|
40
80
|
}
|
|
41
|
-
|
|
42
|
-
command.addFlag('profile', profile);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
let hasProfiles = false;
|
|
46
|
-
try {
|
|
47
|
-
const { projectConfig } = getProjectConfig(absoluteProjectPath);
|
|
48
|
-
const profiles = await getAllHsProfiles(path.join(absoluteProjectPath, projectConfig.srcDir));
|
|
49
|
-
hasProfiles = profiles.length > 0;
|
|
50
|
-
}
|
|
51
|
-
catch (e) {
|
|
52
|
-
this.logger.debug(toolName, {
|
|
53
|
-
message: 'Handler caught error checking for profiles',
|
|
54
|
-
error: e instanceof Error ? e.message : String(e),
|
|
55
|
-
});
|
|
56
|
-
// If any of these checks fail, the safest thing to do is to assume there are no profiles.
|
|
57
|
-
hasProfiles = false;
|
|
58
|
-
}
|
|
59
|
-
if (hasProfiles) {
|
|
60
|
-
content.push(formatTextContent(`Ask the user which profile they would like to use for the upload.`));
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (content.length > 0) {
|
|
64
|
-
return {
|
|
65
|
-
content,
|
|
66
|
-
structuredContent: {},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
81
|
+
setTargetAccount(command, targets, selectedProfile);
|
|
69
82
|
const { stdout, stderr } = await this.runCommand(absoluteProjectPath, command, extra);
|
|
70
83
|
const response = await formatTextContents(stdout, stderr);
|
|
71
84
|
// Add reminder about cards needing to be added to views
|
|
@@ -77,7 +90,7 @@ export class UploadProjectTools extends Tool {
|
|
|
77
90
|
register() {
|
|
78
91
|
return this.mcpServer.registerTool(toolName, {
|
|
79
92
|
title: 'Upload HubSpot Project',
|
|
80
|
-
description: 'DO NOT run this tool unless the user specifies they would like to upload the project, it is potentially destructive. Uploads the HubSpot project in current working directory. If the project does not exist, it will be created. MUST be ran from within the project directory. IMPORTANT: Uploading a project does NOT automatically make cards live or visible to users. Cards must be manually added to a view in HubSpot after upload to become visible. If you do not know the project path, use the find-projects tool first to locate HubSpot projects in the workspace.',
|
|
93
|
+
description: 'DO NOT run this tool unless the user specifies they would like to upload the project, it is potentially destructive. Uploads the HubSpot project in current working directory. If the project does not exist, it will be created. MUST be ran from within the project directory. IMPORTANT: Uploading a project does NOT automatically make cards live or visible to users. Cards must be manually added to a view in HubSpot after upload to become visible. Uploads to production accounts require confirmation from the user. If you do not know the project path, use the find-projects tool first to locate HubSpot projects in the workspace.',
|
|
81
94
|
inputSchema,
|
|
82
95
|
outputSchema: ProjectUploadSchema.shape,
|
|
83
96
|
annotations: {
|
|
@@ -1,6 +1,8 @@
|
|
|
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>;
|
|
5
|
+
export declare const confirmProductionAccount: z.ZodOptional<z.ZodBoolean>;
|
|
4
6
|
export declare const features: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
5
7
|
card: "card";
|
|
6
8
|
settings: "settings";
|
|
@@ -5,6 +5,13 @@ 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.');
|
|
12
|
+
export const confirmProductionAccount = z
|
|
13
|
+
.optional(z.boolean())
|
|
14
|
+
.describe('Set to true only after this tool names a production account and the user then explicitly confirms that account in the conversation. NEVER set this on your own. The tool ignores this value when the client can show a confirmation form.');
|
|
8
15
|
export const features = z
|
|
9
16
|
.array(z.enum([
|
|
10
17
|
'card',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { DiscoverAccountTargetsResult } from '../../../types/AccountTargets.js';
|
|
3
|
+
import { McpToolResponse } from '../../types.js';
|
|
4
|
+
import { HubSpotCommand } from '../../utils/command.js';
|
|
5
|
+
import { McpLogger } from '../../utils/logger.js';
|
|
6
|
+
export declare function setTargetAccount(command: HubSpotCommand, { recommended }: DiscoverAccountTargetsResult, profileName?: string): void;
|
|
7
|
+
export declare function confirmProductionTargets(mcpServer: McpServer, logger: McpLogger, { targets, action, toolName, confirmedInConversation, }: {
|
|
8
|
+
targets: DiscoverAccountTargetsResult;
|
|
9
|
+
action: string;
|
|
10
|
+
toolName: string;
|
|
11
|
+
confirmedInConversation?: boolean;
|
|
12
|
+
}): Promise<McpToolResponse | undefined>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ACCOUNT_TARGET_CATEGORIES, } from '../../../types/AccountTargets.js';
|
|
2
|
+
import { uiAccountDescription } from '../../../lib/ui/index.js';
|
|
3
|
+
import { formatErrorTextContents } from '../../utils/content.js';
|
|
4
|
+
import { canElicit, requestElicitation } from '../../utils/elicitation.js';
|
|
5
|
+
// Sets the command to run against the account that was checked. hs rejects
|
|
6
|
+
// --profile with --account, and a profile already sets the account, so a
|
|
7
|
+
// profile wins.
|
|
8
|
+
export function setTargetAccount(command, { recommended }, profileName) {
|
|
9
|
+
if (profileName) {
|
|
10
|
+
command.addFlag('profile', profileName);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (recommended) {
|
|
14
|
+
command.addFlag('account', recommended.accountId);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
// Without a recommended account the command can act on any candidate, so every
|
|
18
|
+
// production candidate is a possible target.
|
|
19
|
+
function getProductionTargets({ candidates, recommended, }) {
|
|
20
|
+
return (recommended ? [recommended] : candidates).filter(candidate => candidate.category === ACCOUNT_TARGET_CATEGORIES.PRODUCTION_WITH_CARE);
|
|
21
|
+
}
|
|
22
|
+
// Returns an error response when the action must not run, or `undefined` when
|
|
23
|
+
// it can run. `confirmedInConversation` only counts when the client cannot show
|
|
24
|
+
// a confirmation form.
|
|
25
|
+
export async function confirmProductionTargets(mcpServer, logger, { targets, action, toolName, confirmedInConversation, }) {
|
|
26
|
+
const productionTargets = getProductionTargets(targets);
|
|
27
|
+
if (productionTargets.length === 0) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
const accounts = productionTargets
|
|
31
|
+
.map(({ accountId }) => uiAccountDescription(accountId, false))
|
|
32
|
+
.join(' or ');
|
|
33
|
+
if (!canElicit(mcpServer)) {
|
|
34
|
+
return confirmedInConversation
|
|
35
|
+
? undefined
|
|
36
|
+
: formatErrorTextContents(`${action} targets production account ${accounts}, which is not a test account or sandbox. Ask the user to confirm this account. If the user confirms, call ${toolName} again with confirmProductionAccount set to true.`);
|
|
37
|
+
}
|
|
38
|
+
// A failed or timed-out request counts as a decline, so the flag cannot skip
|
|
39
|
+
// the form.
|
|
40
|
+
const elicitation = await requestElicitation(mcpServer, { message: `${action} to production account ${accounts}?`, fields: {} }, logger);
|
|
41
|
+
if (elicitation?.action === 'accept') {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
return formatErrorTextContents(`The user did not confirm production account ${accounts}, so ${toolName} did not run. Tell the user that the action was canceled. Do not ask the user to confirm again, and do not call ${toolName} again unless the user asks.`);
|
|
45
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -2,6 +2,8 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
2
2
|
import { ElicitResult, PrimitiveSchemaDefinition } from '@modelcontextprotocol/sdk/types.js';
|
|
3
3
|
import { McpLogger } from './logger.js';
|
|
4
4
|
export declare function enumField(title: string, description: string, values: string[], names?: string[]): PrimitiveSchemaDefinition;
|
|
5
|
+
export declare function booleanField(title: string, description: string, defaultValue?: boolean): PrimitiveSchemaDefinition;
|
|
6
|
+
export declare function canElicit(mcpServer: McpServer): boolean;
|
|
5
7
|
export declare function requestElicitation(mcpServer: McpServer, params: {
|
|
6
8
|
message: string;
|
|
7
9
|
fields: Record<string, PrimitiveSchemaDefinition>;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
+
import { MCP_ELICITATION_TIMEOUT } from '../../lib/constants.js';
|
|
1
2
|
export function enumField(title, description, values, names) {
|
|
2
3
|
return { type: 'string', title, description, enum: values, enumNames: names };
|
|
3
4
|
}
|
|
5
|
+
export function booleanField(title, description, defaultValue) {
|
|
6
|
+
return { type: 'boolean', title, description, default: defaultValue };
|
|
7
|
+
}
|
|
8
|
+
export function canElicit(mcpServer) {
|
|
9
|
+
return Boolean(mcpServer.server.getClientCapabilities()?.elicitation?.form);
|
|
10
|
+
}
|
|
4
11
|
// Sends a JSON Schema of the required inputs to the client, pauses the tool
|
|
5
12
|
// call, and resumes when the client returns a response that matches the schema.
|
|
6
13
|
// The client collects the values from the user. The SDK checks the returned
|
|
@@ -10,8 +17,7 @@ export function enumField(title, description, values, names) {
|
|
|
10
17
|
// (it did not advertise form elicitation, or the request failed). Callers treat
|
|
11
18
|
// `undefined` and any non-`accept` action as "no answer" and fall back to text.
|
|
12
19
|
export async function requestElicitation(mcpServer, params, logger) {
|
|
13
|
-
|
|
14
|
-
if (!capabilities?.elicitation?.form) {
|
|
20
|
+
if (!canElicit(mcpServer)) {
|
|
15
21
|
return undefined;
|
|
16
22
|
}
|
|
17
23
|
const requestedSchema = {
|
|
@@ -20,10 +26,7 @@ export async function requestElicitation(mcpServer, params, logger) {
|
|
|
20
26
|
required: params.required,
|
|
21
27
|
};
|
|
22
28
|
try {
|
|
23
|
-
return await mcpServer.server.elicitInput({
|
|
24
|
-
message: params.message,
|
|
25
|
-
requestedSchema,
|
|
26
|
-
});
|
|
29
|
+
return await mcpServer.server.elicitInput({ message: params.message, requestedSchema }, { timeout: MCP_ELICITATION_TIMEOUT });
|
|
27
30
|
}
|
|
28
31
|
catch (error) {
|
|
29
32
|
logger?.warn('elicitation', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cli",
|
|
3
|
-
"version": "8.3.
|
|
3
|
+
"version": "8.3.1-experimental.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",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@hubspot/local-dev-lib": "5.12.0",
|
|
14
|
-
"@hubspot/project-parsing-lib": "0.23.
|
|
14
|
+
"@hubspot/project-parsing-lib": "0.23.5-beta.0",
|
|
15
15
|
"@hubspot/ui-extensions-dev-server": "2.2.2",
|
|
16
16
|
"@inquirer/prompts": "7.10.1",
|
|
17
|
-
"@modelcontextprotocol/sdk": "1.
|
|
17
|
+
"@modelcontextprotocol/sdk": "1.31.0",
|
|
18
18
|
"archiver": "7.0.1",
|
|
19
19
|
"chalk": "5.6.2",
|
|
20
20
|
"chokidar": "3.6.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"table": "6.9.0",
|
|
38
38
|
"tmp": "0.2.7",
|
|
39
39
|
"update-notifier": "7.3.1",
|
|
40
|
-
"ws": "8.
|
|
40
|
+
"ws": "8.22.0",
|
|
41
41
|
"yargs": "17.7.3",
|
|
42
42
|
"yargs-parser": "21.1.1",
|
|
43
43
|
"zod": "^4.4.3"
|