@loopops/mcp-server 3.9.0 → 3.9.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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper for tools that accept "either CSV content as text, or a path to
|
|
3
|
+
* a CSV file." The MCP server runs locally as a subprocess on the user's
|
|
4
|
+
* machine, so file IO is available; this lets operators say "process the
|
|
5
|
+
* file at ~/Downloads/foo.csv" without a separate Read step in chat.
|
|
6
|
+
*
|
|
7
|
+
* Both `import_accounts_csv` and `process_approvals_csv` use this. The
|
|
8
|
+
* tRPC procedures behind them still take CSV content — this is purely
|
|
9
|
+
* a wrapper convenience.
|
|
10
|
+
*/
|
|
11
|
+
export type CsvInput = {
|
|
12
|
+
/** CSV content as a string (when operator pastes it inline). */
|
|
13
|
+
csv?: string;
|
|
14
|
+
/** Filesystem path (absolute, ~-prefixed, or relative to cwd). */
|
|
15
|
+
csvPath?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Resolve to CSV content. Throws with operator-friendly messages on
|
|
19
|
+
* misuse (both unset, both set, file missing, file empty).
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveCsvInput(input: CsvInput): Promise<string>;
|
|
22
|
+
/**
|
|
23
|
+
* Common Zod-friendly description for the csvPath field. Tool authors
|
|
24
|
+
* pass this as the `.describe()` argument so the wording stays
|
|
25
|
+
* consistent across tools.
|
|
26
|
+
*/
|
|
27
|
+
export declare const CSV_PATH_DESCRIPTION = "Path to a CSV file on the operator's machine. Absolute, ~-prefixed (e.g. `~/Downloads/foo.csv`), or relative to the MCP subprocess's working directory. Either `csv` or `csvPath` is required (not both).";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper for tools that accept "either CSV content as text, or a path to
|
|
3
|
+
* a CSV file." The MCP server runs locally as a subprocess on the user's
|
|
4
|
+
* machine, so file IO is available; this lets operators say "process the
|
|
5
|
+
* file at ~/Downloads/foo.csv" without a separate Read step in chat.
|
|
6
|
+
*
|
|
7
|
+
* Both `import_accounts_csv` and `process_approvals_csv` use this. The
|
|
8
|
+
* tRPC procedures behind them still take CSV content — this is purely
|
|
9
|
+
* a wrapper convenience.
|
|
10
|
+
*/
|
|
11
|
+
import { readFile } from "node:fs/promises";
|
|
12
|
+
import { homedir } from "node:os";
|
|
13
|
+
import { isAbsolute, resolve } from "node:path";
|
|
14
|
+
/**
|
|
15
|
+
* Resolve to CSV content. Throws with operator-friendly messages on
|
|
16
|
+
* misuse (both unset, both set, file missing, file empty).
|
|
17
|
+
*/
|
|
18
|
+
export async function resolveCsvInput(input) {
|
|
19
|
+
const hasContent = input.csv !== undefined && input.csv.length > 0;
|
|
20
|
+
const hasPath = input.csvPath !== undefined && input.csvPath.length > 0;
|
|
21
|
+
if (!hasContent && !hasPath) {
|
|
22
|
+
throw new Error("Provide either `csv` (the CSV content as text) or `csvPath` (a path to a CSV file).");
|
|
23
|
+
}
|
|
24
|
+
if (hasContent && hasPath) {
|
|
25
|
+
throw new Error("Provide either `csv` or `csvPath`, not both. Pick one — content for paste-in, path for an on-disk file.");
|
|
26
|
+
}
|
|
27
|
+
if (hasContent)
|
|
28
|
+
return input.csv;
|
|
29
|
+
// Path branch. Expand `~` to $HOME, resolve relative paths from
|
|
30
|
+
// the current working directory of the MCP subprocess.
|
|
31
|
+
let path = input.csvPath;
|
|
32
|
+
if (path.startsWith("~/")) {
|
|
33
|
+
path = resolve(homedir(), path.slice(2));
|
|
34
|
+
}
|
|
35
|
+
else if (!isAbsolute(path)) {
|
|
36
|
+
path = resolve(process.cwd(), path);
|
|
37
|
+
}
|
|
38
|
+
let content;
|
|
39
|
+
try {
|
|
40
|
+
content = await readFile(path, "utf-8");
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
44
|
+
throw new Error(`Could not read CSV file at \`${path}\`: ${reason}`);
|
|
45
|
+
}
|
|
46
|
+
if (content.length === 0) {
|
|
47
|
+
throw new Error(`File at \`${path}\` is empty.`);
|
|
48
|
+
}
|
|
49
|
+
return content;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Common Zod-friendly description for the csvPath field. Tool authors
|
|
53
|
+
* pass this as the `.describe()` argument so the wording stays
|
|
54
|
+
* consistent across tools.
|
|
55
|
+
*/
|
|
56
|
+
export const CSV_PATH_DESCRIPTION = "Path to a CSV file on the operator's machine. Absolute, ~-prefixed (e.g. `~/Downloads/foo.csv`), or relative to the MCP subprocess's working directory. Either `csv` or `csvPath` is required (not both).";
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { z } from "zod";
|
|
18
18
|
import { trpcMutation, trpcQuery } from "../api-client.js";
|
|
19
|
+
import { CSV_PATH_DESCRIPTION, resolveCsvInput } from "./_csv-input.js";
|
|
19
20
|
import { safeTool } from "./_helpers.js";
|
|
20
21
|
export function registerAccountMasterTools(server, allowed) {
|
|
21
22
|
if (allowed.has("account_lookup")) {
|
|
@@ -82,8 +83,9 @@ export function registerAccountMasterTools(server, allowed) {
|
|
|
82
83
|
].join(" "), {
|
|
83
84
|
csv: z
|
|
84
85
|
.string()
|
|
85
|
-
.
|
|
86
|
-
.describe("CSV content as text. First row must be the header. Accepts the same header aliases as the account-master-csv-import.mjs script."),
|
|
86
|
+
.optional()
|
|
87
|
+
.describe("CSV content as text. First row must be the header. Accepts the same header aliases as the account-master-csv-import.mjs script. Provide this OR csvPath, not both."),
|
|
88
|
+
csvPath: z.string().optional().describe(CSV_PATH_DESCRIPTION),
|
|
87
89
|
source: z
|
|
88
90
|
.string()
|
|
89
91
|
.min(1)
|
|
@@ -99,7 +101,12 @@ export function registerAccountMasterTools(server, allowed) {
|
|
|
99
101
|
.boolean()
|
|
100
102
|
.optional()
|
|
101
103
|
.describe("If true, drain the queue via the matcher immediately after insert."),
|
|
102
|
-
}, safeTool(async (input) =>
|
|
104
|
+
}, safeTool(async (input) => {
|
|
105
|
+
const csv = await resolveCsvInput(input);
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
107
|
+
const { csv: _csv, csvPath: _csvPath, ...rest } = input;
|
|
108
|
+
return trpcMutation("mcp.importAccountsCsv", { csv, ...rest });
|
|
109
|
+
}));
|
|
103
110
|
}
|
|
104
111
|
if (allowed.has("override_account_attribute")) {
|
|
105
112
|
server.tool("override_account_attribute", [
|
package/dist/tools/sfdc-sync.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
import { trpcMutation, trpcQuery } from "../api-client.js";
|
|
14
|
+
import { CSV_PATH_DESCRIPTION, resolveCsvInput } from "./_csv-input.js";
|
|
14
15
|
import { safeTool } from "./_helpers.js";
|
|
15
16
|
const accountIdentifierShape = {
|
|
16
17
|
accountId: z
|
|
@@ -88,6 +89,10 @@ export function registerSfdcSyncTools(server, allowed) {
|
|
|
88
89
|
"writes the same lifecycle event (with reason + snapshot payload) as a single-account",
|
|
89
90
|
"approval would.",
|
|
90
91
|
"",
|
|
92
|
+
"Provide EITHER `csv` (paste content inline) OR `csvPath` (path to a file on the",
|
|
93
|
+
"operator's machine; absolute or `~/`-prefixed). The MCP subprocess reads files locally,",
|
|
94
|
+
"so `csvPath` works for both Claude Code and Claude Desktop.",
|
|
95
|
+
"",
|
|
91
96
|
"Validation:",
|
|
92
97
|
" - account_id must currently be in pending_initial_deployment_review (else row fails)",
|
|
93
98
|
" - reason must be ≥3 chars on approve=yes rows (else row fails)",
|
|
@@ -101,9 +106,13 @@ export function registerSfdcSyncTools(server, allowed) {
|
|
|
101
106
|
].join("\n"), {
|
|
102
107
|
csv: z
|
|
103
108
|
.string()
|
|
104
|
-
.
|
|
105
|
-
.describe("CSV content (header row + data rows). Required headers: account_id, approve, reason. Other columns from export_pending_approvals are tolerated."),
|
|
106
|
-
|
|
109
|
+
.optional()
|
|
110
|
+
.describe("CSV content (header row + data rows). Required headers: account_id, approve, reason. Other columns from export_pending_approvals are tolerated. Provide this OR csvPath, not both."),
|
|
111
|
+
csvPath: z.string().optional().describe(CSV_PATH_DESCRIPTION),
|
|
112
|
+
}, safeTool(async (input) => {
|
|
113
|
+
const csv = await resolveCsvInput(input);
|
|
114
|
+
return trpcMutation("mcp.processApprovalsCsv", { csv });
|
|
115
|
+
}));
|
|
107
116
|
}
|
|
108
117
|
if (allowed.has("deployment_status")) {
|
|
109
118
|
server.tool("deployment_status", "Top-line counts of accounts in each deployment lifecycle state (pending review, pending update, deployed, deployment_failed, sync_drift). Includes a sample of the initial-review queue so ops can spot-check what's waiting for approval.", {
|