@acquis-consulting/asm 1.0.15 → 1.0.16

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 (43) hide show
  1. package/dist/index.js +24 -3
  2. package/dist/index.js.map +1 -1
  3. package/dist/tools/apiRequest.d.ts +70 -0
  4. package/dist/tools/apiRequest.js +67 -0
  5. package/dist/tools/apiRequest.js.map +1 -0
  6. package/dist/tools/auditTrailDownload.d.ts +57 -0
  7. package/dist/tools/auditTrailDownload.js +128 -0
  8. package/dist/tools/auditTrailDownload.js.map +1 -0
  9. package/dist/tools/auditTrailSearch.d.ts +102 -0
  10. package/dist/tools/auditTrailSearch.js +215 -0
  11. package/dist/tools/auditTrailSearch.js.map +1 -0
  12. package/dist/tools/bulkExportResults.js +49 -10
  13. package/dist/tools/bulkExportResults.js.map +1 -1
  14. package/dist/tools/bulkImportAbort.d.ts +37 -0
  15. package/dist/tools/bulkImportAbort.js +46 -0
  16. package/dist/tools/bulkImportAbort.js.map +1 -0
  17. package/dist/tools/bulkImportResults.d.ts +51 -0
  18. package/dist/tools/bulkImportResults.js +168 -0
  19. package/dist/tools/bulkImportResults.js.map +1 -0
  20. package/dist/tools/bulkImportStart.d.ts +120 -0
  21. package/dist/tools/bulkImportStart.js +183 -0
  22. package/dist/tools/bulkImportStart.js.map +1 -0
  23. package/dist/tools/bulkImportStatus.d.ts +37 -0
  24. package/dist/tools/bulkImportStatus.js +56 -0
  25. package/dist/tools/bulkImportStatus.js.map +1 -0
  26. package/dist/tools/salesforceCliLogin.d.ts +36 -0
  27. package/dist/tools/salesforceCliLogin.js +73 -0
  28. package/dist/tools/salesforceCliLogin.js.map +1 -0
  29. package/dist/tools/salesforceCliLoginStatus.d.ts +25 -0
  30. package/dist/tools/salesforceCliLoginStatus.js +66 -0
  31. package/dist/tools/salesforceCliLoginStatus.js.map +1 -0
  32. package/dist/tools/salesforceLogin.js +2 -1
  33. package/dist/tools/salesforceLogin.js.map +1 -1
  34. package/dist/utils/auditTrailCsv.d.ts +42 -0
  35. package/dist/utils/auditTrailCsv.js +165 -0
  36. package/dist/utils/auditTrailCsv.js.map +1 -0
  37. package/dist/utils/errors.d.ts +1 -0
  38. package/dist/utils/errors.js +14 -0
  39. package/dist/utils/errors.js.map +1 -1
  40. package/dist/utils/sfCliWebLogin.d.ts +56 -0
  41. package/dist/utils/sfCliWebLogin.js +208 -0
  42. package/dist/utils/sfCliWebLogin.js.map +1 -0
  43. package/package.json +1 -1
@@ -0,0 +1,120 @@
1
+ import type { Connection } from 'jsforce';
2
+ import { z } from 'zod/v4';
3
+ export declare const bulkImportStartTool: {
4
+ name: string;
5
+ description: string;
6
+ inputSchema: {
7
+ type: "object";
8
+ properties: {
9
+ objectName: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ operation: {
14
+ type: string;
15
+ enum: string[];
16
+ description: string;
17
+ };
18
+ externalIdFieldName: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ filePath: {
23
+ type: string;
24
+ description: string;
25
+ };
26
+ records: {
27
+ type: string;
28
+ items: {
29
+ type: string;
30
+ };
31
+ description: string;
32
+ };
33
+ columnDelimiter: {
34
+ type: string;
35
+ enum: string[];
36
+ description: string;
37
+ };
38
+ lineEnding: {
39
+ type: string;
40
+ enum: string[];
41
+ description: string;
42
+ };
43
+ assignmentRuleId: {
44
+ type: string;
45
+ description: string;
46
+ };
47
+ };
48
+ required: string[];
49
+ };
50
+ };
51
+ export interface BulkImportStartArgs {
52
+ objectName: string;
53
+ operation: 'insert' | 'update' | 'upsert';
54
+ externalIdFieldName?: string;
55
+ filePath?: string;
56
+ records?: Record<string, unknown>[];
57
+ columnDelimiter?: 'COMMA' | 'SEMICOLON' | 'TAB' | 'PIPE' | 'CARET' | 'BACKQUOTE';
58
+ lineEnding?: 'LF' | 'CRLF';
59
+ assignmentRuleId?: string;
60
+ }
61
+ export declare function handleBulkImportStart(conn: Connection, args: BulkImportStartArgs): Promise<{
62
+ content: {
63
+ type: "text";
64
+ text: string;
65
+ }[];
66
+ isError: boolean;
67
+ }>;
68
+ export declare const bulkImportStartSchema: {
69
+ objectName: z.ZodString;
70
+ operation: z.ZodEnum<{
71
+ insert: "insert";
72
+ update: "update";
73
+ upsert: "upsert";
74
+ }>;
75
+ externalIdFieldName: z.ZodOptional<z.ZodString>;
76
+ filePath: z.ZodOptional<z.ZodString>;
77
+ records: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
78
+ columnDelimiter: z.ZodOptional<z.ZodEnum<{
79
+ BACKQUOTE: "BACKQUOTE";
80
+ CARET: "CARET";
81
+ COMMA: "COMMA";
82
+ PIPE: "PIPE";
83
+ SEMICOLON: "SEMICOLON";
84
+ TAB: "TAB";
85
+ }>>;
86
+ lineEnding: z.ZodOptional<z.ZodEnum<{
87
+ LF: "LF";
88
+ CRLF: "CRLF";
89
+ }>>;
90
+ assignmentRuleId: z.ZodOptional<z.ZodString>;
91
+ };
92
+ export declare const bulkImportStartDescriptor: {
93
+ name: string;
94
+ description: string;
95
+ schema: {
96
+ objectName: z.ZodString;
97
+ operation: z.ZodEnum<{
98
+ insert: "insert";
99
+ update: "update";
100
+ upsert: "upsert";
101
+ }>;
102
+ externalIdFieldName: z.ZodOptional<z.ZodString>;
103
+ filePath: z.ZodOptional<z.ZodString>;
104
+ records: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
105
+ columnDelimiter: z.ZodOptional<z.ZodEnum<{
106
+ BACKQUOTE: "BACKQUOTE";
107
+ CARET: "CARET";
108
+ COMMA: "COMMA";
109
+ PIPE: "PIPE";
110
+ SEMICOLON: "SEMICOLON";
111
+ TAB: "TAB";
112
+ }>>;
113
+ lineEnding: z.ZodOptional<z.ZodEnum<{
114
+ LF: "LF";
115
+ CRLF: "CRLF";
116
+ }>>;
117
+ assignmentRuleId: z.ZodOptional<z.ZodString>;
118
+ };
119
+ handler: typeof handleBulkImportStart;
120
+ };
@@ -0,0 +1,183 @@
1
+ import { z } from 'zod/v4';
2
+ import { toolResponse } from '../utils/index.js';
3
+ import * as fs from 'node:fs';
4
+ // Bulk API v2 limit is 150 MB per upload after base64 encoding; Salesforce recommends ≤100 MB raw.
5
+ const MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
6
+ const DELIMITER_CHARS = {
7
+ BACKQUOTE: '`',
8
+ CARET: '^',
9
+ COMMA: ',',
10
+ PIPE: '|',
11
+ SEMICOLON: ';',
12
+ TAB: '\t',
13
+ };
14
+ export const bulkImportStartTool = {
15
+ name: 'salesforce_bulk_import_start',
16
+ description: 'Start an asynchronous bulk data import (insert, update, or upsert) using Salesforce Bulk API v2. Ideal for large datasets (10K+ records). Provide either a local CSV file (header row = field API names) or an inline array of records. Returns a job ID — use salesforce_bulk_import_status to poll for completion, then salesforce_bulk_import_results to download success/failure CSVs.',
17
+ inputSchema: {
18
+ type: 'object',
19
+ properties: {
20
+ objectName: {
21
+ type: 'string',
22
+ description: 'The Salesforce object API name to load into (e.g. Account, Contact, CustomObj__c).',
23
+ },
24
+ operation: {
25
+ type: 'string',
26
+ enum: ['insert', 'update', 'upsert'],
27
+ description: 'The ingest operation. update requires an Id column; upsert requires externalIdFieldName.',
28
+ },
29
+ externalIdFieldName: {
30
+ type: 'string',
31
+ description: 'External ID field used to match records. Required for upsert (use "Id" to upsert on record Id).',
32
+ },
33
+ filePath: {
34
+ type: 'string',
35
+ description: 'Absolute path to a local CSV file. Header row must contain field API names. Max 100 MB. Mutually exclusive with records.',
36
+ },
37
+ records: {
38
+ type: 'array',
39
+ items: { type: 'object' },
40
+ description: 'Inline array of records (field API name → value). Use for smaller loads. Mutually exclusive with filePath.',
41
+ },
42
+ columnDelimiter: {
43
+ type: 'string',
44
+ enum: ['COMMA', 'SEMICOLON', 'TAB', 'PIPE', 'CARET', 'BACKQUOTE'],
45
+ description: 'Column delimiter used in the CSV file (filePath only). Default: COMMA.',
46
+ },
47
+ lineEnding: {
48
+ type: 'string',
49
+ enum: ['LF', 'CRLF'],
50
+ description: 'Line ending used in the CSV file (filePath only). Default: LF.',
51
+ },
52
+ assignmentRuleId: {
53
+ type: 'string',
54
+ description: 'Optional assignment rule Id to apply (Case or Lead only).',
55
+ },
56
+ },
57
+ required: ['objectName', 'operation'],
58
+ },
59
+ };
60
+ /** Reads the CSV header row and returns the column names (unquoted). */
61
+ function readHeader(content, delimiter) {
62
+ const newline = content.indexOf(0x0a);
63
+ const firstLine = content.subarray(0, newline === -1 ? content.length : newline).toString('utf8').replace(/\r$/, '');
64
+ return firstLine.split(delimiter).map((col) => col.trim().replace(/^"(.*)"$/, '$1'));
65
+ }
66
+ /** Validates args and loads the file; returns an error message or the CSV payload. */
67
+ function prepareUpload(args) {
68
+ const { operation, externalIdFieldName, filePath, records, columnDelimiter = 'COMMA' } = args;
69
+ if (!filePath === !records) {
70
+ return { error: 'Provide exactly one data source: filePath or records.' };
71
+ }
72
+ if (operation === 'upsert' && !externalIdFieldName) {
73
+ return { error: 'externalIdFieldName is required for upsert.' };
74
+ }
75
+ if (records) {
76
+ if (records.length === 0)
77
+ return { error: 'records is empty — nothing to import.' };
78
+ if (operation === 'update' && records.some((r) => !r.Id)) {
79
+ return { error: 'Every record must include Id for update.' };
80
+ }
81
+ return {};
82
+ }
83
+ if (!fs.existsSync(filePath))
84
+ return { error: `File not found: ${filePath}` };
85
+ const size = fs.statSync(filePath).size;
86
+ if (size === 0)
87
+ return { error: `File is empty: ${filePath}` };
88
+ if (size > MAX_UPLOAD_BYTES) {
89
+ return { error: `File is ${(size / (1024 * 1024)).toFixed(1)} MB; the Bulk API v2 limit is 100 MB per job. Split the file and start one job per chunk.` };
90
+ }
91
+ const csv = fs.readFileSync(filePath);
92
+ const header = readHeader(csv, DELIMITER_CHARS[columnDelimiter]);
93
+ if (operation === 'update' && !header.includes('Id')) {
94
+ return { error: `CSV header has no Id column, which update requires. Header: ${header.join(', ')}` };
95
+ }
96
+ if (operation === 'upsert' && !header.includes(externalIdFieldName)) {
97
+ return { error: `CSV header has no "${externalIdFieldName}" column, which upsert requires. Header: ${header.join(', ')}` };
98
+ }
99
+ return { csv };
100
+ }
101
+ /**
102
+ * Uploads raw CSV bytes directly (bypassing jsforce's record-stream machinery, which
103
+ * re-serializes input) so the file's delimiter and line endings reach Salesforce unchanged.
104
+ */
105
+ async function uploadCsv(conn, jobId, csv) {
106
+ const url = `${conn.instanceUrl}/services/data/v${conn.version}/jobs/ingest/${jobId}/batches`;
107
+ const response = await fetch(url, {
108
+ method: 'PUT',
109
+ headers: {
110
+ Authorization: `Bearer ${conn.accessToken}`,
111
+ 'Content-Type': 'text/csv',
112
+ },
113
+ body: new Uint8Array(csv),
114
+ });
115
+ if (!response.ok) {
116
+ const body = await response.text();
117
+ throw new Error(`Upload failed (HTTP ${response.status} ${response.statusText}): ${body}`);
118
+ }
119
+ }
120
+ export async function handleBulkImportStart(conn, args) {
121
+ const { objectName, operation, externalIdFieldName, filePath, records, columnDelimiter, lineEnding, assignmentRuleId } = args;
122
+ const prepared = prepareUpload(args);
123
+ if ('error' in prepared)
124
+ return toolResponse(prepared.error, true);
125
+ let job;
126
+ try {
127
+ job = conn.bulk2.createJob({
128
+ object: objectName,
129
+ operation,
130
+ ...(externalIdFieldName && { externalIdFieldName }),
131
+ ...(assignmentRuleId && { assignmentRuleId }),
132
+ // jsforce serializes inline records as comma-delimited LF CSV.
133
+ ...(filePath && columnDelimiter && { columnDelimiter }),
134
+ ...(filePath && lineEnding && { lineEnding }),
135
+ });
136
+ await job.open();
137
+ }
138
+ catch (error) {
139
+ return toolResponse(`Failed to create bulk import job: ${error.message}`, true);
140
+ }
141
+ try {
142
+ if (prepared.csv) {
143
+ await uploadCsv(conn, job.id, prepared.csv);
144
+ }
145
+ else {
146
+ await job.uploadData(records);
147
+ }
148
+ await job.close();
149
+ }
150
+ catch (error) {
151
+ try {
152
+ await job.abort();
153
+ }
154
+ catch {
155
+ // Best effort — the job may already be in a non-abortable state.
156
+ }
157
+ return toolResponse(`Failed to upload data to bulk import job ${job.id} (job aborted): ${error.message}`, true);
158
+ }
159
+ return toolResponse(`Bulk import job created and data uploaded.\n\n` +
160
+ `Job ID: ${job.id}\n` +
161
+ `State: UploadComplete\n` +
162
+ `Object: ${objectName}\n` +
163
+ `Operation: ${operation}${externalIdFieldName ? ` (external Id: ${externalIdFieldName})` : ''}\n` +
164
+ `Source: ${filePath ?? `${records.length} inline record(s)`}\n\n` +
165
+ `Next step: Use salesforce_bulk_import_status with jobId "${job.id}" to check progress.`);
166
+ }
167
+ export const bulkImportStartSchema = {
168
+ objectName: z.string().describe('The Salesforce object API name to load into (e.g. Account, Contact, CustomObj__c).'),
169
+ operation: z.enum(['insert', 'update', 'upsert']).describe('The ingest operation. update requires an Id column; upsert requires externalIdFieldName.'),
170
+ externalIdFieldName: z.string().describe('External ID field used to match records. Required for upsert (use "Id" to upsert on record Id).').optional(),
171
+ filePath: z.string().describe('Absolute path to a local CSV file. Header row must contain field API names. Max 100 MB. Mutually exclusive with records.').optional(),
172
+ records: z.array(z.record(z.string(), z.unknown())).describe('Inline array of records (field API name → value). Use for smaller loads. Mutually exclusive with filePath.').optional(),
173
+ columnDelimiter: z.enum(['COMMA', 'SEMICOLON', 'TAB', 'PIPE', 'CARET', 'BACKQUOTE']).describe('Column delimiter used in the CSV file (filePath only). Default: COMMA.').optional(),
174
+ lineEnding: z.enum(['LF', 'CRLF']).describe('Line ending used in the CSV file (filePath only). Default: LF.').optional(),
175
+ assignmentRuleId: z.string().describe('Optional assignment rule Id to apply (Case or Lead only).').optional(),
176
+ };
177
+ export const bulkImportStartDescriptor = {
178
+ name: 'salesforce_bulk_import_start',
179
+ description: bulkImportStartTool.description,
180
+ schema: bulkImportStartSchema,
181
+ handler: handleBulkImportStart,
182
+ };
183
+ //# sourceMappingURL=bulkImportStart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulkImportStart.js","sourceRoot":"","sources":["../../src/tools/bulkImportStart.ts"],"names":[],"mappings":"AACA,OAAO,EAA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AAC,CAAC,QAAQ,EAAE;CAC9G,CAAC;AAEF,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,IAAI,EAAE,8BAA8B;IACpC,WAAW,EAAE,mBAAmB,CAAC,WAAW;IAC5C,MAAM,EAAE,qBAAqB;IAC7B,OAAO,EAAE,qBAAqB;CAC/B,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { Connection } from 'jsforce';
2
+ import { z } from 'zod/v4';
3
+ export declare const bulkImportStatusTool: {
4
+ name: string;
5
+ description: string;
6
+ inputSchema: {
7
+ type: "object";
8
+ properties: {
9
+ jobId: {
10
+ type: string;
11
+ description: string;
12
+ };
13
+ };
14
+ required: string[];
15
+ };
16
+ };
17
+ export interface BulkImportStatusArgs {
18
+ jobId: string;
19
+ }
20
+ export declare function handleBulkImportStatus(conn: Connection, args: BulkImportStatusArgs): Promise<{
21
+ content: {
22
+ type: "text";
23
+ text: string;
24
+ }[];
25
+ isError: boolean;
26
+ }>;
27
+ export declare const bulkImportStatusSchema: {
28
+ jobId: z.ZodString;
29
+ };
30
+ export declare const bulkImportStatusDescriptor: {
31
+ name: string;
32
+ description: string;
33
+ schema: {
34
+ jobId: z.ZodString;
35
+ };
36
+ handler: typeof handleBulkImportStatus;
37
+ };
@@ -0,0 +1,56 @@
1
+ import { z } from 'zod/v4';
2
+ import { toolResponse } from '../utils/index.js';
3
+ export const bulkImportStatusTool = {
4
+ name: 'salesforce_bulk_import_status',
5
+ description: 'Check the status of a bulk import job. States progress: Open → UploadComplete → InProgress → JobComplete | Failed | Aborted. Poll this until the job reaches a terminal state, then use salesforce_bulk_import_results to download success/failure CSVs.',
6
+ inputSchema: {
7
+ type: 'object',
8
+ properties: {
9
+ jobId: {
10
+ type: 'string',
11
+ description: 'The bulk import job ID returned by salesforce_bulk_import_start.',
12
+ },
13
+ },
14
+ required: ['jobId'],
15
+ },
16
+ };
17
+ export async function handleBulkImportStatus(conn, args) {
18
+ const { jobId } = args;
19
+ try {
20
+ const job = conn.bulk2.job('ingest', { id: jobId });
21
+ const info = await job.check();
22
+ const lines = [
23
+ `Job ID: ${info.id}`,
24
+ `State: ${info.state}`,
25
+ `Object: ${info.object}`,
26
+ `Operation: ${info.operation}${info.externalIdFieldName ? ` (external Id: ${info.externalIdFieldName})` : ''}`,
27
+ `Records Processed: ${info.numberRecordsProcessed ?? 'N/A'}`,
28
+ `Records Failed: ${info.numberRecordsFailed ?? 'N/A'}`,
29
+ `Created: ${info.createdDate}`,
30
+ `System Modstamp: ${info.systemModstamp}`,
31
+ ];
32
+ if (info.errorMessage) {
33
+ lines.push(`Error: ${info.errorMessage}`);
34
+ }
35
+ if (info.state === 'JobComplete' || info.state === 'Failed' || info.state === 'Aborted') {
36
+ lines.push('', `Next step: Use salesforce_bulk_import_results with jobId "${jobId}" to download success/failure CSVs.`);
37
+ }
38
+ else {
39
+ lines.push('', `Job is still processing. Poll again with salesforce_bulk_import_status.`);
40
+ }
41
+ return toolResponse(lines.join('\n'));
42
+ }
43
+ catch (error) {
44
+ return toolResponse(`Failed to check bulk import status: ${error.message}`, true);
45
+ }
46
+ }
47
+ export const bulkImportStatusSchema = {
48
+ jobId: z.string().describe('The bulk import job ID returned by salesforce_bulk_import_start.'),
49
+ };
50
+ export const bulkImportStatusDescriptor = {
51
+ name: 'salesforce_bulk_import_status',
52
+ description: bulkImportStatusTool.description,
53
+ schema: bulkImportStatusSchema,
54
+ handler: handleBulkImportStatus,
55
+ };
56
+ //# sourceMappingURL=bulkImportStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulkImportStatus.js","sourceRoot":"","sources":["../../src/tools/bulkImportStatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI,EAAE,+BAA+B;IACrC,WAAW,EACT,0PAA0P;IAC5P,WAAW,EAA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,CAAC,EAAE,EAAE,6DAA6D,KAAK,qCAAqC,CAAC,CAAC;QAC1H,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,yEAAyE,CAAC,CAAC;QAC5F,CAAC;QAED,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,uCAAuC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;IACpF,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kEAAkE,CAAC;CAC/F,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,IAAI,EAAE,+BAA+B;IACrC,WAAW,EAAE,oBAAoB,CAAC,WAAW;IAC7C,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,sBAAsB;CAChC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { z } from 'zod/v4';
3
+ export declare const salesforceCliLoginTool: Tool;
4
+ export interface SalesforceCliLoginArgs {
5
+ environment: 'production' | 'sandbox' | 'custom';
6
+ custom_domain?: string;
7
+ }
8
+ export declare function handleSalesforceCliLogin(args: SalesforceCliLoginArgs, sessionId: string): Promise<{
9
+ content: {
10
+ type: "text";
11
+ text: string;
12
+ }[];
13
+ isError: boolean;
14
+ }>;
15
+ export declare const salesforceCliLoginSchema: {
16
+ environment: z.ZodEnum<{
17
+ custom: "custom";
18
+ production: "production";
19
+ sandbox: "sandbox";
20
+ }>;
21
+ custom_domain: z.ZodOptional<z.ZodString>;
22
+ };
23
+ export declare const salesforceCliLoginDescriptor: {
24
+ name: string;
25
+ description: string | undefined;
26
+ schema: {
27
+ environment: z.ZodEnum<{
28
+ custom: "custom";
29
+ production: "production";
30
+ sandbox: "sandbox";
31
+ }>;
32
+ custom_domain: z.ZodOptional<z.ZodString>;
33
+ };
34
+ handler: typeof handleSalesforceCliLogin;
35
+ noConnection: boolean;
36
+ };
@@ -0,0 +1,73 @@
1
+ import { z } from 'zod/v4';
2
+ import { startSfCliWebLogin } from '../utils/sfCliWebLogin.js';
3
+ import { toolResponse } from '../utils/errors.js';
4
+ export const salesforceCliLoginTool = {
5
+ name: 'salesforce_cli_login',
6
+ description: 'Starts a browser login to Salesforce using the locally installed Salesforce CLI (`sf org login web`), ' +
7
+ 'the same browser login VS Code uses — but it works from any folder, including an empty one, ' +
8
+ 'with no DX project and no Acquis Connected App required. Requires the `sf` CLI on PATH. ' +
9
+ 'This tool returns immediately, before the user has logged in: it opens the browser and hands back a session_id. ' +
10
+ 'You MUST then call salesforce_cli_login_status with that session_id to find out whether the login succeeded — ' +
11
+ 'wait for the user to say they have finished logging in, or poll every few seconds. ' +
12
+ 'This is an alternative to salesforce_login: use one or the other, not both.',
13
+ inputSchema: {
14
+ type: 'object',
15
+ properties: {
16
+ environment: {
17
+ type: 'string',
18
+ enum: ['production', 'sandbox', 'custom'],
19
+ description: 'The Salesforce environment to log in to.',
20
+ },
21
+ custom_domain: {
22
+ type: 'string',
23
+ description: 'Required when environment is "custom". Your org\'s My Domain, e.g. mycompany.my.salesforce.com',
24
+ },
25
+ },
26
+ required: ['environment'],
27
+ },
28
+ };
29
+ export async function handleSalesforceCliLogin(args, sessionId) {
30
+ try {
31
+ let loginUrl;
32
+ if (args.environment === 'production') {
33
+ loginUrl = 'https://login.salesforce.com';
34
+ }
35
+ else if (args.environment === 'sandbox') {
36
+ loginUrl = 'https://test.salesforce.com';
37
+ }
38
+ else {
39
+ if (!args.custom_domain) {
40
+ return toolResponse('custom_domain is required when environment is "custom". ' +
41
+ 'Provide your org\'s My Domain, e.g. mycompany.my.salesforce.com', true);
42
+ }
43
+ const domain = args.custom_domain.replace(/^https?:\/\//, '').replace(/\/$/, '');
44
+ loginUrl = `https://${domain}`;
45
+ }
46
+ await startSfCliWebLogin(loginUrl, sessionId);
47
+ return toolResponse(`Browser login started — a Salesforce tab should have opened at ${loginUrl}.\n` +
48
+ ` Session ID: ${sessionId}\n\n` +
49
+ `The login is NOT finished yet. Ask the user to complete it in the browser, then call ` +
50
+ `salesforce_cli_login_status with session_id="${sessionId}" to confirm before using any other Salesforce tool.\n` +
51
+ `Leave the browser tab alone until it shows a success page — closing it cancels the login.`);
52
+ }
53
+ catch (err) {
54
+ return toolResponse(`salesforce_cli_login failed: ${err.message}`, true);
55
+ }
56
+ }
57
+ export const salesforceCliLoginSchema = {
58
+ environment: z
59
+ .enum(['production', 'sandbox', 'custom'])
60
+ .describe('The Salesforce environment to log in to.'),
61
+ custom_domain: z
62
+ .string()
63
+ .describe('Required when environment is "custom". Your org\'s My Domain, e.g. mycompany.my.salesforce.com')
64
+ .optional(),
65
+ };
66
+ export const salesforceCliLoginDescriptor = {
67
+ name: 'salesforce_cli_login',
68
+ description: salesforceCliLoginTool.description,
69
+ schema: salesforceCliLoginSchema,
70
+ handler: handleSalesforceCliLogin,
71
+ noConnection: true,
72
+ };
73
+ //# sourceMappingURL=salesforceCliLogin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"salesforceCliLogin.js","sourceRoot":"","sources":["../../src/tools/salesforceCliLogin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,sBAAsB,GAAS;IAC1C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EACT,wGAAwG;QACxG,8FAA8F;QAC9F,0FAA0F;QAC1F,kHAAkH;QAClH,gHAAgH;QAChH,qFAAqF;QACrF,6EAA6E;IAC/E,WAAW,EAAE;QACX,IAAI,EAAE,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O,EAAE,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,WAAW,EAAE,CAAC;SACX,IAAI,CAAC,CAAC,YAAY,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;SACzC,QAAQ,CAAC,0CAA0C,CAAC;IACvD,aAAa,EAAE,CAAC;SACb,MAAM,EAAE;SACR,QAAQ,CAAC,gGAAgG,CAAC;SAC1G,QAAQ,EAAE;CACd,CAAC;AAEF,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,sBAAsB,CAAC,WAAW;IAC/C,MAAM,EAAE,wBAAwB;IAChC,OAAO,EAAE,wBAAwB;IACjC,YAAY,EAAE,IAAI;CACnB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { z } from 'zod/v4';
3
+ export declare const salesforceCliLoginStatusTool: Tool;
4
+ export interface SalesforceCliLoginStatusArgs {
5
+ session_id?: string;
6
+ }
7
+ export declare function handleSalesforceCliLoginStatus(args: SalesforceCliLoginStatusArgs, fallbackSessionId: string): Promise<{
8
+ content: {
9
+ type: "text";
10
+ text: string;
11
+ }[];
12
+ isError: boolean;
13
+ }>;
14
+ export declare const salesforceCliLoginStatusSchema: {
15
+ session_id: z.ZodString;
16
+ };
17
+ export declare const salesforceCliLoginStatusDescriptor: {
18
+ name: string;
19
+ description: string | undefined;
20
+ schema: {
21
+ session_id: z.ZodString;
22
+ };
23
+ handler: typeof handleSalesforceCliLoginStatus;
24
+ noConnection: boolean;
25
+ };
@@ -0,0 +1,66 @@
1
+ import { z } from 'zod/v4';
2
+ import { getSfCliLoginState } from '../utils/sfCliWebLogin.js';
3
+ import { toolResponse } from '../utils/errors.js';
4
+ export const salesforceCliLoginStatusTool = {
5
+ name: 'salesforce_cli_login_status',
6
+ description: 'Checks whether the browser login started by salesforce_cli_login has completed. ' +
7
+ 'Call this after salesforce_cli_login, once the user says they have finished logging in ' +
8
+ '(or poll every few seconds). Returns "pending" while the user is still in the browser, ' +
9
+ '"success" once the session is authenticated and ready for other Salesforce tools, ' +
10
+ 'or "error" if the login failed or was cancelled.',
11
+ inputSchema: {
12
+ type: 'object',
13
+ properties: {
14
+ session_id: {
15
+ type: 'string',
16
+ description: 'The session_id returned by salesforce_cli_login.',
17
+ },
18
+ },
19
+ required: ['session_id'],
20
+ },
21
+ };
22
+ function formatElapsed(startedAt) {
23
+ return `${Math.round((Date.now() - startedAt) / 1000)}s`;
24
+ }
25
+ export async function handleSalesforceCliLoginStatus(args, fallbackSessionId) {
26
+ // The standalone registration loop does not inject session_id, so it arrives as a
27
+ // normal argument. Fall back to the generated one only if the caller omitted it.
28
+ const sessionId = args.session_id ?? fallbackSessionId;
29
+ const state = getSfCliLoginState(sessionId);
30
+ if (!state) {
31
+ return toolResponse(`No Salesforce CLI login found for session_id="${sessionId}". ` +
32
+ `Call salesforce_cli_login first, and pass the exact session_id it returned. ` +
33
+ `(Logins are held in memory, so they are also lost if the MCP server restarts.)`, true);
34
+ }
35
+ if (state.status === 'pending') {
36
+ return toolResponse(`Login still pending (${formatElapsed(state.startedAt)} elapsed).\n` +
37
+ ` Login URL: ${state.loginUrl}\n\n` +
38
+ `The user has not finished authorizing in the browser yet. Ask them to complete the login, ` +
39
+ `then call this tool again. Do not call other Salesforce tools with this session_id yet.`);
40
+ }
41
+ if (state.status === 'error') {
42
+ return toolResponse(`Login failed after ${formatElapsed(state.startedAt)}: ${state.error}\n\n` +
43
+ `Call salesforce_cli_login again to retry.`, true);
44
+ }
45
+ const { org } = state;
46
+ return toolResponse(`Successfully authenticated to Salesforce via the Salesforce CLI.\n` +
47
+ ` Instance URL: ${org.instanceUrl}\n` +
48
+ ` Username: ${org.username}\n` +
49
+ ` Org ID: ${org.orgId}\n` +
50
+ ` CLI alias: ${org.alias ?? '(could not be set — org is still usable via this session)'}\n` +
51
+ ` Session ID: ${sessionId}\n\n` +
52
+ `IMPORTANT: Pass session_id="${sessionId}" to every Salesforce tool call in this conversation.`);
53
+ }
54
+ export const salesforceCliLoginStatusSchema = {
55
+ session_id: z
56
+ .string()
57
+ .describe('The session_id returned by salesforce_cli_login.'),
58
+ };
59
+ export const salesforceCliLoginStatusDescriptor = {
60
+ name: 'salesforce_cli_login_status',
61
+ description: salesforceCliLoginStatusTool.description,
62
+ schema: salesforceCliLoginStatusSchema,
63
+ handler: handleSalesforceCliLoginStatus,
64
+ noConnection: true,
65
+ };
66
+ //# sourceMappingURL=salesforceCliLoginStatus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"salesforceCliLoginStatus.js","sourceRoot":"","sources":["../../src/tools/salesforceCliLoginStatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,CAAC,MAAM,4BAA4B,GAAS;IAChD,IAAI,EAAE,6BAA6B;IACnC,WAAW,EACT,kFAAkF;QAClF,yFAAyF;QACzF,yFAAyF;QACzF,oFAAoF;QACpF,kDAAkD;IACpD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,kDAAkD;aAChE;SACF;QACD,QAAQ,EAAE,CAAC,YAAY,CAAC;KACzB;CACF,CAAC;AAMF,SAAS,aAAa,CAAC,SAAiB;IACtC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC;AAC3D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,IAAkC,EAClC,iBAAyB;IAEzB,kFAAkF;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WAAW,EAAE,4BAA4B,CAAC,WAAW;IACrD,MAAM,EAAE,8BAA8B;IACtC,OAAO,EAAE,8BAA8B;IACvC,YAAY,EAAE,IAAI;CACnB,CAAC"}
@@ -4,7 +4,8 @@ import { toolResponse } from '../utils/errors.js';
4
4
  const ACQUIS_CONNECTED_APP_CLIENT_ID = '3MVG9p1Q1BCe9GmCr_ATVWfyCxRkeY5yCTFwBifYdiG5GzP5VK7BPNK5d0QxAhZJVhyqV7I3vVwpXHo.87Rpv';
5
5
  export const salesforceLoginTool = {
6
6
  name: 'salesforce_login',
7
- description: 'REQUIRED FIRST STEP — call this before any other Salesforce tool when starting a new session. ' +
7
+ description: 'Call this only the first time a Salesforce tool is used in a session, or if a later tool call fails due to an expired/invalid session or missing authentication. ' +
8
+ 'Do not call this before every Salesforce tool — only once per session (or again after a session expires). ' +
8
9
  'Authenticates to Salesforce via browser OAuth2 web flow. ' +
9
10
  'Opens a browser tab where the user logs in and authorizes the Acquis MCP Connected App. ' +
10
11
  'Select the environment (production, sandbox, or custom domain) to target the correct Salesforce login page. ',
@@ -1 +1 @@
1
- {"version":3,"file":"salesforceLogin.js","sourceRoot":"","sources":["../../src/tools/salesforceLogin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,8BAA8B,GAAG,uFAAuF,CAAC;AAC/H,MAAM,CAAC,MAAM,mBAAmB,GAAS;IACvC,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACT,gGAAgG;QAChG,2DAA2D;QAC3D,0FAA0F;QAC1F,8GAA8G;IAChH,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,YAAY,EAAE,SAA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