@countfinancial/cli 0.1.6 → 0.2.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.
Files changed (87) hide show
  1. package/README.md +9 -1
  2. package/dist/__tests__/doctor.test.d.ts +1 -0
  3. package/dist/__tests__/doctor.test.js +30 -0
  4. package/dist/__tests__/doctor.test.js.map +1 -0
  5. package/dist/__tests__/mcpInstall.test.d.ts +1 -0
  6. package/dist/__tests__/mcpInstall.test.js +25 -0
  7. package/dist/__tests__/mcpInstall.test.js.map +1 -0
  8. package/dist/__tests__/profileStore.test.d.ts +1 -0
  9. package/dist/__tests__/profileStore.test.js +53 -0
  10. package/dist/__tests__/profileStore.test.js.map +1 -0
  11. package/dist/cli.js +108 -9
  12. package/dist/cli.js.map +1 -1
  13. package/dist/commands/doctor.command.d.ts +6 -0
  14. package/dist/commands/doctor.command.js +12 -0
  15. package/dist/commands/doctor.command.js.map +1 -0
  16. package/dist/commands/init.command.d.ts +1 -0
  17. package/dist/commands/init.command.js +6 -1
  18. package/dist/commands/init.command.js.map +1 -1
  19. package/dist/commands/login.command.d.ts +1 -0
  20. package/dist/commands/login.command.js +3 -3
  21. package/dist/commands/login.command.js.map +1 -1
  22. package/dist/commands/logout.command.d.ts +5 -1
  23. package/dist/commands/logout.command.js +3 -3
  24. package/dist/commands/logout.command.js.map +1 -1
  25. package/dist/commands/mcp.command.d.ts +5 -1
  26. package/dist/commands/mcp.command.js +7 -4
  27. package/dist/commands/mcp.command.js.map +1 -1
  28. package/dist/commands/mcpInstall.command.d.ts +7 -0
  29. package/dist/commands/mcpInstall.command.js +9 -0
  30. package/dist/commands/mcpInstall.command.js.map +1 -0
  31. package/dist/commands/profiles.command.d.ts +17 -0
  32. package/dist/commands/profiles.command.js +48 -0
  33. package/dist/commands/profiles.command.js.map +1 -0
  34. package/dist/commands/setup.command.d.ts +11 -0
  35. package/dist/commands/setup.command.js +85 -0
  36. package/dist/commands/setup.command.js.map +1 -0
  37. package/dist/commands/status.command.d.ts +6 -1
  38. package/dist/commands/status.command.js +7 -4
  39. package/dist/commands/status.command.js.map +1 -1
  40. package/dist/partner-mcp/config.js +1 -1
  41. package/dist/partner-mcp/helpers/mcpKnowledge.helper.d.ts +19 -0
  42. package/dist/partner-mcp/helpers/mcpKnowledge.helper.js +293 -0
  43. package/dist/partner-mcp/helpers/mcpKnowledge.helper.js.map +1 -0
  44. package/dist/partner-mcp/helpers/mcpPayloadValidation.helper.d.ts +42 -0
  45. package/dist/partner-mcp/helpers/mcpPayloadValidation.helper.js +741 -0
  46. package/dist/partner-mcp/helpers/mcpPayloadValidation.helper.js.map +1 -0
  47. package/dist/partner-mcp/helpers/mcpPlaybooks.helper.d.ts +26 -0
  48. package/dist/partner-mcp/helpers/mcpPlaybooks.helper.js +210 -0
  49. package/dist/partner-mcp/helpers/mcpPlaybooks.helper.js.map +1 -0
  50. package/dist/partner-mcp/helpers/mcpRecoveryHint.helper.d.ts +22 -0
  51. package/dist/partner-mcp/helpers/mcpRecoveryHint.helper.js +203 -0
  52. package/dist/partner-mcp/helpers/mcpRecoveryHint.helper.js.map +1 -0
  53. package/dist/partner-mcp/helpers/mcpReferenceResolution.helper.d.ts +52 -0
  54. package/dist/partner-mcp/helpers/mcpReferenceResolution.helper.js +343 -0
  55. package/dist/partner-mcp/helpers/mcpReferenceResolution.helper.js.map +1 -0
  56. package/dist/partner-mcp/helpers/partnerErrorSanitization.helper.d.ts +18 -0
  57. package/dist/partner-mcp/helpers/partnerErrorSanitization.helper.js +63 -0
  58. package/dist/partner-mcp/helpers/partnerErrorSanitization.helper.js.map +1 -0
  59. package/dist/partner-mcp/partnerApiClient.d.ts +4 -0
  60. package/dist/partner-mcp/partnerApiClient.js +38 -1
  61. package/dist/partner-mcp/partnerApiClient.js.map +1 -1
  62. package/dist/partner-mcp/tools/definitions.js +233 -12
  63. package/dist/partner-mcp/tools/definitions.js.map +1 -1
  64. package/dist/partner-mcp/tools/registerTools.js +107 -23
  65. package/dist/partner-mcp/tools/registerTools.js.map +1 -1
  66. package/dist/partner-mcp/tools/schemas.d.ts +40 -0
  67. package/dist/partner-mcp/tools/schemas.js +55 -0
  68. package/dist/partner-mcp/tools/schemas.js.map +1 -1
  69. package/dist/services/credentialStore.service.d.ts +8 -2
  70. package/dist/services/credentialStore.service.js +22 -10
  71. package/dist/services/credentialStore.service.js.map +1 -1
  72. package/dist/services/doctor.service.d.ts +22 -0
  73. package/dist/services/doctor.service.js +186 -0
  74. package/dist/services/doctor.service.js.map +1 -0
  75. package/dist/services/mcpInstall.service.d.ts +43 -0
  76. package/dist/services/mcpInstall.service.js +117 -0
  77. package/dist/services/mcpInstall.service.js.map +1 -0
  78. package/dist/services/mcpLauncher.service.d.ts +2 -0
  79. package/dist/services/mcpLauncher.service.js +6 -3
  80. package/dist/services/mcpLauncher.service.js.map +1 -1
  81. package/dist/services/profileStore.service.d.ts +53 -0
  82. package/dist/services/profileStore.service.js +129 -0
  83. package/dist/services/profileStore.service.js.map +1 -0
  84. package/dist/services/setupPrompt.service.d.ts +25 -0
  85. package/dist/services/setupPrompt.service.js +40 -0
  86. package/dist/services/setupPrompt.service.js.map +1 -0
  87. package/package.json +1 -1
@@ -0,0 +1,11 @@
1
+ interface RunSetupCommandParams {
2
+ profileName?: string;
3
+ skipLogin?: boolean;
4
+ skipInstall?: boolean;
5
+ nonInteractive?: boolean;
6
+ clientId?: string;
7
+ clientSecret?: string;
8
+ apiBaseUrl?: string;
9
+ }
10
+ export declare function runSetupCommand(params?: RunSetupCommandParams): Promise<number>;
11
+ export {};
@@ -0,0 +1,85 @@
1
+ import { DEFAULT_API_BASE_URL, DEFAULT_CALLBACK_HOST, DEFAULT_CALLBACK_PATH, DEFAULT_CALLBACK_PORT, PARTNERS_PORTAL_URL, } from '../constants.js';
2
+ import { runDoctorCommand } from './doctor.command.js';
3
+ import { runInitCommand } from './init.command.js';
4
+ import { runLoginCommand } from './login.command.js';
5
+ import { runMcpInstallCommand } from './mcpInstall.command.js';
6
+ import { getConfigFilePath, loadCredentials } from '../services/credentialStore.service.js';
7
+ import { DEFAULT_PROFILE_NAME, ensureProfileDirectory, setActiveProfileName, } from '../services/profileStore.service.js';
8
+ import { createPromptInterface, promptChoice, promptLine, promptYesNo, } from '../services/setupPrompt.service.js';
9
+ export async function runSetupCommand(params = {}) {
10
+ const readlineInterface = createPromptInterface();
11
+ try {
12
+ process.stdout.write('COUNT CLI setup\n');
13
+ process.stdout.write('This wizard saves partner credentials, signs you in, installs MCP config, and runs health checks.\n\n');
14
+ const profileName = params.profileName ??
15
+ (params.nonInteractive
16
+ ? DEFAULT_PROFILE_NAME
17
+ : await promptLine({
18
+ readlineInterface,
19
+ question: 'Profile name',
20
+ defaultValue: DEFAULT_PROFILE_NAME,
21
+ }));
22
+ await ensureProfileDirectory({ profileName });
23
+ await setActiveProfileName({ profileName });
24
+ const existingCredentials = await loadCredentials({ profileName });
25
+ let clientId = params.clientId ?? existingCredentials?.clientId;
26
+ let clientSecret = params.clientSecret ?? existingCredentials?.clientSecret;
27
+ let apiBaseUrl = params.apiBaseUrl ?? existingCredentials?.apiBaseUrl ?? DEFAULT_API_BASE_URL;
28
+ if (!clientId || !clientSecret) {
29
+ if (params.nonInteractive) {
30
+ throw new Error('Partner credentials are required. Pass --client-id and --client-secret for non-interactive setup.');
31
+ }
32
+ process.stdout.write(`Create a partner app at ${PARTNERS_PORTAL_URL} if you have not already.\n\n`);
33
+ clientId = await promptLine({ readlineInterface, question: 'Partner client ID' });
34
+ clientSecret = await promptLine({ readlineInterface, question: 'Partner client secret' });
35
+ apiBaseUrl = await promptLine({
36
+ readlineInterface,
37
+ question: 'API base URL',
38
+ defaultValue: apiBaseUrl,
39
+ });
40
+ }
41
+ if (!clientId || !clientSecret) {
42
+ throw new Error('Partner client ID and client secret are required.');
43
+ }
44
+ await runInitCommand({
45
+ clientId,
46
+ clientSecret,
47
+ apiBaseUrl,
48
+ profileName,
49
+ });
50
+ const redirectUri = `http://${DEFAULT_CALLBACK_HOST}:${DEFAULT_CALLBACK_PORT}${DEFAULT_CALLBACK_PATH}`;
51
+ process.stdout.write(`\nEnsure this redirect URI is registered on your partner app:\n ${redirectUri}\n\n`);
52
+ const shouldLogin = !params.skipLogin &&
53
+ (params.nonInteractive
54
+ ? !(await loadCredentials({ profileName }))?.accessToken
55
+ : await promptYesNo({
56
+ readlineInterface,
57
+ question: 'Sign in to COUNT now?',
58
+ defaultYes: true,
59
+ }));
60
+ if (shouldLogin) {
61
+ await runLoginCommand({ profileName });
62
+ }
63
+ if (!params.skipInstall && !params.nonInteractive) {
64
+ const installChoice = await promptChoice({
65
+ readlineInterface,
66
+ question: 'Install MCP config for',
67
+ choices: ['skip', 'cursor', 'claude-code', 'claude-desktop', 'all'],
68
+ defaultChoice: 'cursor',
69
+ });
70
+ if (installChoice !== 'skip') {
71
+ await runMcpInstallCommand({ target: installChoice });
72
+ }
73
+ }
74
+ process.stdout.write('\nRunning health checks...\n\n');
75
+ const doctorExitCode = await runDoctorCommand({ profileName });
76
+ process.stdout.write(`\nSetup complete for profile "${profileName}".\n`);
77
+ process.stdout.write(`Credentials: ${getConfigFilePath({ profileName })}\n`);
78
+ process.stdout.write('Run `count mcp` to start the local MCP server.\n');
79
+ return doctorExitCode;
80
+ }
81
+ finally {
82
+ readlineInterface.close();
83
+ }
84
+ }
85
+ //# sourceMappingURL=setup.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.command.js","sourceRoot":"","sources":["../../src/commands/setup.command.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,oBAAo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AAE,WAAW,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;YAClD,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC;gBACvC,iBAAiB;gBACjB,QAAQ,EAAE,wBAAwB;gBAClC,OAAO,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,CAAC;gBACnE,aAAa,EAAE,QAAQ;aACxB,CAAC,CAAC;YAEH,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;gBAC7B,MAAM,oBAAoB,CAAC,EAAE,MAAM,EAAE,aAAoE,EAAE,CAAC,CAAC;YAC/G,CAAC;QACH,CAAC;QAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACvD,MAAM,cAAc,GAAG,MAAM,gBAAgB,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QAE/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iCAAiC,WAAW,MAAM,CAAC,CAAC;QACzE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,iBAAiB,CAAC,EAAE,WAAW,EAAE,CAAC,IAAI,CAAC,CAAC;QAC7E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;QAEzE,OAAO,cAAc,CAAC;IACxB,CAAC;YAAS,CAAC;QACT,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -1 +1,6 @@
1
- export declare function runStatusCommand(): Promise<void>;
1
+ interface RunStatusCommandParams {
2
+ profileName?: string;
3
+ json?: boolean;
4
+ }
5
+ export declare function runStatusCommand(params?: RunStatusCommandParams): Promise<void>;
6
+ export {};
@@ -1,13 +1,16 @@
1
1
  import { getConfigFilePath, loadCredentials } from '../services/credentialStore.service.js';
2
- export async function runStatusCommand() {
3
- const credentials = await loadCredentials();
4
- const configFilePath = getConfigFilePath();
2
+ import { getActiveProfileName } from '../services/profileStore.service.js';
3
+ export async function runStatusCommand(params = {}) {
4
+ const credentials = await loadCredentials({ profileName: params.profileName });
5
+ const configFilePath = getConfigFilePath({ profileName: params.profileName });
6
+ const activeProfileName = await getActiveProfileName();
5
7
  if (!credentials) {
6
8
  process.stdout.write(`No credentials file at ${configFilePath}\n`);
7
- process.stdout.write('Run `count init` then `count login`.\n');
9
+ process.stdout.write('Run `count init` then `count login`, or run `count setup`.\n');
8
10
  return;
9
11
  }
10
12
  const status = {
13
+ activeProfile: params.profileName ?? activeProfileName,
11
14
  configFilePath,
12
15
  apiBaseUrl: credentials.apiBaseUrl,
13
16
  hasClientId: Boolean(credentials.clientId),
@@ -1 +1 @@
1
- {"version":3,"file":"status.command.js","sourceRoot":"","sources":["../../src/commands/status.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAE5F,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,MAAM,WAAW,GAAG,MAAM,eAAe,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;IAE3C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,cAAc,IAAI,CAAC,CAAC;QACnE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC/D,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG;QACb,cAAc;QACd,UAAU,EAAE,WAAW,CAAC,UAAU;QAClC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC;QAC1C,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC;QAClD,cAAc,EAAE,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC;QAChD,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC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,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC;QAClD,WAAW,EAAE,WAAW,CAAC,WAAW,IAAI,IAAI;QAC5C,aAAa,EAAE,WAAW,CAAC,aAAa,IAAI,IAAI;KACjD,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
@@ -6,7 +6,7 @@ const environmentSchema = z.object({
6
6
  COUNT_CLIENT_SECRET: z.string().trim().min(1),
7
7
  COUNT_ACCESS_TOKEN: optionalNonEmptyString,
8
8
  COUNT_REFRESH_TOKEN: optionalNonEmptyString,
9
- COUNT_REQUEST_TIMEOUT_MS: z.coerce.number().int().positive().default(30000),
9
+ COUNT_REQUEST_TIMEOUT_MS: z.coerce.number().int().positive().default(60000),
10
10
  COUNT_CREDENTIALS_FILE: optionalNonEmptyString,
11
11
  });
12
12
  export function loadConfig(params = {}) {
@@ -0,0 +1,19 @@
1
+ export interface McpKnowledgeTopic {
2
+ id: string;
3
+ title: string;
4
+ summary: string;
5
+ content: string;
6
+ relatedTopicIds: string[];
7
+ keywords: string[];
8
+ }
9
+ export declare const MCP_KNOWLEDGE_TOPICS: McpKnowledgeTopic[];
10
+ interface LookupMcpKnowledgeParams {
11
+ topic?: string;
12
+ search?: string;
13
+ }
14
+ interface LookupMcpKnowledgeResult {
15
+ topics: McpKnowledgeTopic[];
16
+ availableTopicIds: string[];
17
+ }
18
+ export declare function lookupMcpKnowledge(params: LookupMcpKnowledgeParams): LookupMcpKnowledgeResult;
19
+ export {};
@@ -0,0 +1,293 @@
1
+ export const MCP_KNOWLEDGE_TOPICS = [
2
+ {
3
+ id: 'authorize_additional_workspaces',
4
+ title: 'Can I authorize additional workspaces?',
5
+ summary: 'Authorized workspaces are fixed at connect time. Disconnect the COUNT connector and reconnect to pick a wider workspace set on the consent screen.',
6
+ relatedTopicIds: ['reconnect_count_connector', 'multiple_workspaces', 'auth_status_vs_count_app'],
7
+ keywords: [
8
+ 'workspace',
9
+ 'authorize',
10
+ 'additional',
11
+ 'reconnect',
12
+ 'consent',
13
+ 'scope',
14
+ 'client',
15
+ 'firm',
16
+ 'access',
17
+ ],
18
+ content: [
19
+ 'Yes — but only by reconnecting the COUNT MCP connector and completing the consent flow again.',
20
+ '',
21
+ 'How it works:',
22
+ '- The workspaces this connection can use are captured when you first connect (OAuth consent).',
23
+ '- They do NOT update automatically when you later gain access to more client workspaces in the COUNT web app.',
24
+ '- Refreshing tokens does NOT add workspaces. Call COUNT_auth_status or COUNT_list_workspaces to see the current authorized set for this connection only.',
25
+ '',
26
+ 'To authorize more workspaces:',
27
+ '1. Disconnect the COUNT connector in your AI client (see topic reconnect_count_connector).',
28
+ '2. Connect COUNT again and sign in with your COUNT account.',
29
+ '3. On the workspace selection step, choose every client workspace you want this connection to access (multiple selections or “all accessible workspaces” when offered).',
30
+ '4. Finish consent, then call COUNT_list_workspaces to confirm the new authorized list.',
31
+ '',
32
+ 'Firm staff: you can only authorize workspaces you already have access to in COUNT at reconnect time — the consent screen never grants access beyond your firm membership.',
33
+ ].join('\n'),
34
+ },
35
+ {
36
+ id: 'reconnect_count_connector',
37
+ title: 'How do I disconnect and reconnect the COUNT MCP connector?',
38
+ summary: 'Remove the COUNT connector in your AI app settings, then add it again to run through sign-in and workspace selection.',
39
+ relatedTopicIds: ['authorize_additional_workspaces', 'multiple_workspaces'],
40
+ keywords: ['disconnect', 'reconnect', 'connector', 'claude', 'chatgpt', 'oauth', 'integration'],
41
+ content: [
42
+ 'Claude (claude.ai or Claude Desktop):',
43
+ '1. Open Settings → Connectors (wording may be “Integrations”).',
44
+ '2. Find COUNT in the list and disconnect or remove it.',
45
+ '3. Add / connect COUNT again and complete sign-in when redirected to COUNT.',
46
+ '4. Select the workspace(s) to authorize, then approve access.',
47
+ '',
48
+ 'ChatGPT:',
49
+ '1. Open Settings → Connectors / Apps.',
50
+ '2. Remove the COUNT connector.',
51
+ '3. Re-add COUNT and complete the OAuth sign-in and workspace selection flow.',
52
+ '',
53
+ 'After reconnecting, call COUNT_auth_status and COUNT_list_workspaces before other tools so you know which workspace UUIDs are in scope.',
54
+ '',
55
+ 'Standalone COUNT CLI MCP (developer token): workspace scope is configured in your environment — reconnecting the hosted connector does not apply.',
56
+ ].join('\n'),
57
+ },
58
+ {
59
+ id: 'multiple_workspaces',
60
+ title: 'How do I work with multiple authorized workspaces?',
61
+ summary: 'Call COUNT_list_workspaces, pass workspace_id on every read/write tool when more than one workspace is authorized, and optionally COUNT_set_active_workspace for session context.',
62
+ relatedTopicIds: ['authorize_additional_workspaces', 'external_uuids'],
63
+ keywords: ['workspace_id', 'list_workspaces', 'set_active_workspace', 'multi', 'switch'],
64
+ content: [
65
+ 'When this connection has more than one authorized workspace:',
66
+ '- COUNT_list_workspaces — lists every workspace UUID, name, currency, and (for firm connections) whether it is a firm client workspace.',
67
+ '- COUNT_auth_status — shows authorizedWorkspaces and which workspace is active for echo/context.',
68
+ '- Pass workspace_id (external COUNT workspace UUID) on every partner read/write tool when multiple workspaces are authorized.',
69
+ '- COUNT_set_active_workspace — updates the session default for auth_status and the “Workspace:” echo line only; it does NOT replace workspace_id on API calls.',
70
+ '',
71
+ 'When only one workspace is authorized, workspace_id is optional on partner tools.',
72
+ ].join('\n'),
73
+ },
74
+ {
75
+ id: 'auth_status_vs_count_app',
76
+ title: 'Why does auth_status show fewer workspaces than I see in COUNT?',
77
+ summary: 'auth_status lists workspaces authorized for this MCP connection at consent time, not every workspace visible in the COUNT web app.',
78
+ relatedTopicIds: ['authorize_additional_workspaces', 'reconnect_count_connector'],
79
+ keywords: ['auth_status', 'missing', 'workspace', 'token', 'scope'],
80
+ content: [
81
+ 'COUNT_auth_status and COUNT_list_workspaces reflect this connector’s authorized workspace set, not your full COUNT account access.',
82
+ '',
83
+ 'Common reasons for a mismatch:',
84
+ '- You connected before gaining access to additional firm client workspaces → reconnect to expand the set.',
85
+ '- You selected only a subset on the consent screen → reconnect and select the missing workspaces.',
86
+ '- You are comparing to workspaces visible in the COUNT web app that were never included in this connection’s consent.',
87
+ '',
88
+ 'The scope field on auth_status may be null; rely on authorizedWorkspaces / COUNT_list_workspaces as the source of truth for this connection.',
89
+ ].join('\n'),
90
+ },
91
+ {
92
+ id: 'create_chart_of_accounts_account',
93
+ title: 'How do I create a new chart-of-accounts account (e.g. credit card)?',
94
+ summary: 'Call COUNT_list_account_sub_types first, pick the matching sub-type id, then COUNT_create_account. Never guess subTypeId values.',
95
+ relatedTopicIds: ['external_uuids', 'describe_endpoint'],
96
+ keywords: [
97
+ 'create account',
98
+ 'chart of accounts',
99
+ 'subTypeId',
100
+ 'sub type',
101
+ 'credit card',
102
+ 'liability',
103
+ 'list_account_sub_types',
104
+ ],
105
+ content: [
106
+ 'To create a new account (bank, credit card, expense category, etc.):',
107
+ '1. COUNT_list_account_sub_types — optional query.type filter (e.g. "Liabilities" for a credit card). Pick the row whose name matches what you need and copy its integer id.',
108
+ '2. COUNT_create_account — body.name plus body.subTypeId set to that id.',
109
+ '3. If a similar account already exists, you may instead COUNT_list_accounts with query.type and reuse subType.id from an existing row.',
110
+ '',
111
+ 'Never guess or sequentially probe subTypeId numbers — they are sparse global ids, not a predictable sequence.',
112
+ 'If create_account fails, tell the user COUNT could not create the account and share requestId when present. Do not quote stack traces, file paths, or internal database fields.',
113
+ ].join('\n'),
114
+ },
115
+ {
116
+ id: 'partner_error_hygiene',
117
+ title: 'What should I tell the user when a COUNT tool fails?',
118
+ summary: 'Use plain business language plus requestId when available. Never expose stack traces, source files, or internal implementation details.',
119
+ relatedTopicIds: ['describe_endpoint'],
120
+ keywords: ['error', '500', 'stack', 'internal', 'requestId', 'failure'],
121
+ content: [
122
+ 'When a COUNT partner or MCP tool returns an error:',
123
+ '- Tell the user what you were trying to do and that COUNT could not complete it.',
124
+ '- Include requestId from the error payload when present so support can trace the call.',
125
+ '- Read _mcpRecoveryHint for suggested next tools (list_account_sub_types, validate_payload, knowledge topics).',
126
+ '',
127
+ 'Never include in user-visible text:',
128
+ '- Stack traces or line numbers (e.g. accounts.service.js:141)',
129
+ '- Source file paths, function names, or ORM/SQL internals',
130
+ '- Internal database column names (accountTypeId, subTypeId probing commentary, etc.)',
131
+ '- Narration of your debugging process ("let me probe subtype 14")',
132
+ ].join('\n'),
133
+ },
134
+ {
135
+ id: 'external_uuids',
136
+ title: 'Which IDs should I pass to COUNT tools?',
137
+ summary: 'Always use external COUNT UUIDs from list/get tool results. Never pass internal numeric database ids.',
138
+ relatedTopicIds: ['report_category_filters', 'describe_endpoint'],
139
+ keywords: ['uuid', 'id', 'numeric', 'list_accounts', 'partner'],
140
+ content: [
141
+ 'Partner and MCP tools expose external UUIDs as id in responses.',
142
+ '- Get UUIDs from the matching COUNT_list_* or COUNT_get_* tool (accounts, customers, vendors, bills, etc.).',
143
+ '- Pass that UUID as id in path parameters and as vendorUuid, customerUuid, categoryAccountUuid, and similar UUID fields in bodies/queries.',
144
+ '- Internal numeric ids are workspace-local and are rejected or silently ignored on many partner endpoints.',
145
+ '',
146
+ 'Before an unfamiliar create/update call, use COUNT_describe_endpoint with the tool name for field-level guidance.',
147
+ ].join('\n'),
148
+ },
149
+ {
150
+ id: 'report_category_filters',
151
+ title: 'How do I filter a P&L or report to one expense category?',
152
+ summary: 'Pass the account UUID from COUNT_list_accounts as categoryAccount or categoryAccountUuid in the report query.',
153
+ relatedTopicIds: ['external_uuids'],
154
+ keywords: ['pnl', 'profit', 'loss', 'category', 'shipping', 'freight', 'report', 'filter'],
155
+ content: [
156
+ 'Use COUNT_generate_profit_and_loss with query filters, not a numeric account id.',
157
+ '',
158
+ 'Example — spending on “Freight & Courier” for calendar 2025:',
159
+ '1. COUNT_list_accounts — find the expense account (e.g. Freight & Courier) and copy its id UUID.',
160
+ '2. COUNT_generate_profit_and_loss with query: { startDate: "2025-01-01", endDate: "2025-12-31", categoryAccount: "<account-uuid>" }.',
161
+ '',
162
+ 'Aliases accepted: categoryAccount, categoryAccountUuid, categoryAccountUuids (comma-separated).',
163
+ 'Trial balance / balance sheet: use accounts or accountUuids the same way.',
164
+ 'Report filters belong under the top-level query key, not body.',
165
+ ].join('\n'),
166
+ },
167
+ {
168
+ id: 'bulk_operations',
169
+ title: 'How should I run bulk imports (transactions, customers, etc.)?',
170
+ summary: 'Use bulk MCP tools with partial-success envelopes; recommended ~25 rows per call for large historical imports.',
171
+ relatedTopicIds: ['external_uuids'],
172
+ keywords: ['bulk', 'batch', 'import', 'migration', 'partial', 'success'],
173
+ content: [
174
+ 'Bulk tools (COUNT_bulk_create_transactions, COUNT_bulk_create_customers, COUNT_bulk_update_customers, COUNT_bulk_update_budget_cells, etc.) return:',
175
+ '{ successCount, errorCount, results: [{ index, success, ... | error }] } with HTTP 201 when the batch is accepted.',
176
+ '',
177
+ 'Best practices:',
178
+ '- Read errorCount first; retry only rows where success is false.',
179
+ '- Hard cap: 100 rows per call.',
180
+ '- Recommended batch size: ~25 rows for large backfills (billing-system migrations) to reduce timeout risk.',
181
+ '- Each row is isolated — one failure does not roll back other rows in the same batch.',
182
+ '- Call COUNT_validate_payload before each bulk batch and COUNT_playbooks (migration_import or budget_import) for the full workflow.',
183
+ ].join('\n'),
184
+ },
185
+ {
186
+ id: 'budget_export_import',
187
+ title: 'How do I export or import budgets for Excel editing?',
188
+ summary: 'Use get_budget_grid to export JSON, edit offline, then bulk_update_budget_cells in ~25-row batches on a draft version.',
189
+ relatedTopicIds: ['bulk_operations', 'external_uuids'],
190
+ keywords: ['budget', 'excel', 'export', 'import', 'grid', 'forecast'],
191
+ content: [
192
+ 'Partner budget tools are JSON-only (no CSV upload). Typical Excel round-trip:',
193
+ '1. COUNT_get_budget_grid with includeActuals=false for budget amounts only.',
194
+ '2. Edit amounts in Excel externally — keep accountUuid + periodStart + amount columns aligned with the grid.',
195
+ '3. COUNT_bulk_update_budget_cells on a draft versionNumber (~25 rows per call; hard cap 100).',
196
+ '4. Optional COUNT_publish_budget when ready.',
197
+ '',
198
+ 'Rows require accountUuid (from list_accounts / resolve_references) and periodStart (YYYY-MM-DD from grid columns).',
199
+ 'See COUNT_playbooks playbook budget_import for the ordered workflow.',
200
+ ].join('\n'),
201
+ },
202
+ {
203
+ id: 'legacy_numeric_fields_rejected',
204
+ title: 'Why were numeric vendorId, tags, or vendors query params rejected?',
205
+ summary: 'Partner bill and list endpoints require UUID fields (vendorUuid, tagUuids, vendorUuids). Numeric legacy fields return 400, not silent ignore.',
206
+ relatedTopicIds: ['external_uuids', 'describe_endpoint'],
207
+ keywords: ['numeric', 'vendorId', 'tags', 'vendors', 'rejected', '400', 'legacy'],
208
+ content: [
209
+ 'Partner MCP tools expose external UUIDs only. Numeric internal database ids are rejected on many endpoints.',
210
+ '',
211
+ 'Common 400 cases:',
212
+ '- Bill list: use query.vendorUuids (comma-separated), not query.vendors.',
213
+ '- Bill create/update: use vendorUuid, tagUuids, projectUuid — not vendorId, tags, projectId.',
214
+ '- Line items: use categoryAccountUuid — not categoryAccountId.',
215
+ '',
216
+ 'Use COUNT_resolve_references to map names to UUIDs, or COUNT_list_* tools to copy id values from responses.',
217
+ 'Call COUNT_validate_payload before bulk imports to catch these issues early.',
218
+ ].join('\n'),
219
+ },
220
+ {
221
+ id: 'partner_warnings',
222
+ title: 'What does _partnerWarnings mean on a successful response?',
223
+ summary: 'Some fields you sent were ignored. Read _partnerWarnings before assuming the update applied every field.',
224
+ relatedTopicIds: ['describe_endpoint', 'external_uuids'],
225
+ keywords: ['warnings', 'ignored', 'internal_only', 'unknown_field', 'partnerWarnings'],
226
+ content: [
227
+ 'Create/update responses may include _partnerWarnings: [{ field, reason, message }].',
228
+ '',
229
+ 'reason values:',
230
+ '- internal_only — field is managed by COUNT internally (e.g. billId on transaction update). Use the dedicated tool instead.',
231
+ '- unknown_field — typo or field not on the model. Call COUNT_describe_endpoint for the tool you used.',
232
+ '',
233
+ 'HTTP 200 with warnings does NOT mean every field you sent was applied. Always read _partnerWarnings.',
234
+ ].join('\n'),
235
+ },
236
+ {
237
+ id: 'describe_endpoint',
238
+ title: 'How do I learn the request shape for a COUNT tool?',
239
+ summary: 'Call COUNT_describe_endpoint with the exact tool name before unfamiliar create/update operations.',
240
+ relatedTopicIds: ['external_uuids'],
241
+ keywords: ['describe', 'documentation', 'schema', 'fields', 'body', 'query'],
242
+ content: [
243
+ 'COUNT_describe_endpoint returns:',
244
+ '- Partner API path the tool calls',
245
+ '- Tool description and readOnly/destructive flags',
246
+ '- Tips for body vs query placement',
247
+ '- Link to https://developers.getcount.com/ for canonical field names',
248
+ '',
249
+ 'COUNT_knowledge (this tool) answers connector and workflow FAQs; COUNT_describe_endpoint answers per-tool API shape questions.',
250
+ 'COUNT_playbooks provides ordered multi-step workflows (bill pay, migration import, month-end review).',
251
+ ].join('\n'),
252
+ },
253
+ ];
254
+ export function lookupMcpKnowledge(params) {
255
+ const { topic, search } = params;
256
+ const availableTopicIds = MCP_KNOWLEDGE_TOPICS.map((_entry) => _entry.id);
257
+ if (topic && topic.trim() !== '') {
258
+ const normalizedTopic = topic.trim().toLowerCase();
259
+ const matchedTopic = MCP_KNOWLEDGE_TOPICS.find((_entry) => _entry.id.toLowerCase() === normalizedTopic || _entry.id.toLowerCase().replace(/_/g, ' ') === normalizedTopic);
260
+ return {
261
+ topics: matchedTopic ? [matchedTopic] : [],
262
+ availableTopicIds,
263
+ };
264
+ }
265
+ if (search && search.trim() !== '') {
266
+ const normalizedSearch = search.trim().toLowerCase();
267
+ const matchedTopics = MCP_KNOWLEDGE_TOPICS.filter((_entry) => {
268
+ const haystack = [
269
+ _entry.id,
270
+ _entry.title,
271
+ _entry.summary,
272
+ _entry.content,
273
+ ..._entry.keywords,
274
+ ]
275
+ .join(' ')
276
+ .toLowerCase();
277
+ return haystack.includes(normalizedSearch);
278
+ });
279
+ return { topics: matchedTopics, availableTopicIds };
280
+ }
281
+ return {
282
+ topics: MCP_KNOWLEDGE_TOPICS.map((_entry) => ({
283
+ id: _entry.id,
284
+ title: _entry.title,
285
+ summary: _entry.summary,
286
+ content: _entry.content,
287
+ relatedTopicIds: _entry.relatedTopicIds,
288
+ keywords: _entry.keywords,
289
+ })),
290
+ availableTopicIds,
291
+ };
292
+ }
293
+ //# sourceMappingURL=mcpKnowledge.helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcpKnowledge.helper.js","sourceRoot":"","sources":["../../../src/partner-mcp/helpers/mcpKnowledge.helper.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,oBAAoB,GAAwB;IACvD;QACE,EAAE,EAAE,iCAAiC;QACrC,KAAK,EAAE,wCAAwC;QAC/C,OAAO,EACL,oJAAoJ;QACtJ,eAAe,EAAE,CAAC,2BAA2B,EAAE,qBAAqB,EAAE,0BAA0B,CAAC;QACjG,QAAQ,EAAE;YACR,WAAW;YACX,WAAW;YACX,YAAY;YACZ,WAAW;YACX,SAAS;YACT,OAAO;YACP,QAAQ;YACR,MAAM;YACN,QAAQ;SACT;QACD,OAAO,EAAE;YACP,+FAA+F;YAC/F,EAAE;YACF,eAAe;YACf,+FAA+F;YAC/F,+GAA+G;YAC/G,0JAA0J;YAC1J,EAAE;YACF,+BAA+B;YAC/B,4FAA4F;YAC5F,6DAA6D;YAC7D,yKAAyK;YACzK,wFAAwF;YACxF,EAAE;YACF,2KAA2K;SAC5K,CAAC,IAAI,CAAC,IAAI,CAAC;KACb;IACD;QACE,EAAE,EAAE,2BAA2B;QAC/B,KAAK,EAAE,4DAA4D;QACnE,OAAO,EACL,uHAAuH;QACzH,eAAe,EAAE,CAAC,iCAAiC,EAAE,qBAAqB,CAAC;QAC3E,QAAQ,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC;QAC/F,OAAO,EAAE;YACP,uCAAuC;YACvC,gEAAgE;YAChE,wDAAwD;YACxD,6EAA6E;YAC7E,+DAA+D;YAC/D,EAAE;YACF,UAAU;YACV,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e;YACvC,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;QACH,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { buildMcpRecoveryHint } from './mcpRecoveryHint.helper.js';
2
+ import type { McpReferenceResolutionPartnerClient } from './mcpReferenceResolution.helper.js';
3
+ export interface McpPayloadValidationIssue {
4
+ path: string;
5
+ code: 'missing_required' | 'legacy_numeric_field' | 'invalid_tool' | 'bulk_envelope' | 'reference_not_found';
6
+ message: string;
7
+ }
8
+ export interface ValidateMcpPayloadParams {
9
+ toolName: string;
10
+ body?: Record<string, unknown>;
11
+ query?: Record<string, unknown>;
12
+ verifyReferences?: boolean;
13
+ client?: McpReferenceResolutionPartnerClient;
14
+ }
15
+ export interface ValidateMcpPayloadResult {
16
+ valid: boolean;
17
+ toolName: string;
18
+ issueCount: number;
19
+ issues: McpPayloadValidationIssue[];
20
+ suggestedPlaybook?: string;
21
+ _mcpRecoveryHint?: ReturnType<typeof buildMcpRecoveryHint>;
22
+ }
23
+ export declare function validateMcpPayload(params: ValidateMcpPayloadParams): ValidateMcpPayloadResult;
24
+ /** Walk a payload tree and collect string values on UUID-shaped field names for optional existence checks. */
25
+ export declare function collectUuidReferencesFromPayload(params: {
26
+ body?: Record<string, unknown>;
27
+ query?: Record<string, unknown>;
28
+ }): Array<{
29
+ path: string;
30
+ uuid: string;
31
+ }>;
32
+ interface VerifyUuidReferencesExistParams {
33
+ client: McpReferenceResolutionPartnerClient;
34
+ references: Array<{
35
+ path: string;
36
+ uuid: string;
37
+ }>;
38
+ }
39
+ /** Path-aware UUID existence checks using partner routes that actually exist. */
40
+ export declare function verifyUuidReferencesExist(params: VerifyUuidReferencesExistParams): Promise<McpPayloadValidationIssue[]>;
41
+ export declare function validateMcpPayloadAsync(params: ValidateMcpPayloadParams): Promise<ValidateMcpPayloadResult>;
42
+ export {};