@mcp-z/mcp-sheets 1.2.4 → 1.3.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/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/google-auth.d.cts +9 -0
- package/dist/cjs/lib/google-auth.d.ts +9 -0
- package/dist/cjs/lib/google-auth.js +16 -0
- package/dist/cjs/lib/google-auth.js.map +1 -0
- package/dist/cjs/mcp/prompts/a1-notation.d.cts +2 -3
- package/dist/cjs/mcp/prompts/a1-notation.d.ts +2 -3
- package/dist/cjs/mcp/prompts/a1-notation.js.map +1 -1
- package/dist/cjs/mcp/resources/spreadsheet.js +6 -5
- package/dist/cjs/mcp/resources/spreadsheet.js.map +1 -1
- package/dist/cjs/mcp/tools/cells-format.d.cts +1 -1
- package/dist/cjs/mcp/tools/cells-format.d.ts +1 -1
- package/dist/cjs/mcp/tools/cells-format.js +7 -6
- package/dist/cjs/mcp/tools/cells-format.js.map +1 -1
- package/dist/cjs/mcp/tools/chart-create.d.cts +1 -1
- package/dist/cjs/mcp/tools/chart-create.d.ts +1 -1
- package/dist/cjs/mcp/tools/chart-create.js +11 -10
- package/dist/cjs/mcp/tools/chart-create.js.map +1 -1
- package/dist/cjs/mcp/tools/columns-get.d.cts +1 -1
- package/dist/cjs/mcp/tools/columns-get.d.ts +1 -1
- package/dist/cjs/mcp/tools/columns-get.js +7 -6
- package/dist/cjs/mcp/tools/columns-get.js.map +1 -1
- package/dist/cjs/mcp/tools/columns-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/columns-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/columns-update.js +8 -7
- package/dist/cjs/mcp/tools/columns-update.js.map +1 -1
- package/dist/cjs/mcp/tools/csv-get-columns.d.cts +1 -1
- package/dist/cjs/mcp/tools/csv-get-columns.d.ts +1 -1
- package/dist/cjs/mcp/tools/csv-get-columns.js +2 -2
- package/dist/cjs/mcp/tools/csv-get-columns.js.map +1 -1
- package/dist/cjs/mcp/tools/dimensions-batch-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/dimensions-batch-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/dimensions-batch-update.js +12 -11
- package/dist/cjs/mcp/tools/dimensions-batch-update.js.map +1 -1
- package/dist/cjs/mcp/tools/dimensions-move.d.cts +1 -1
- package/dist/cjs/mcp/tools/dimensions-move.d.ts +1 -1
- package/dist/cjs/mcp/tools/dimensions-move.js +10 -9
- package/dist/cjs/mcp/tools/dimensions-move.js.map +1 -1
- package/dist/cjs/mcp/tools/rows-append.d.cts +1 -1
- package/dist/cjs/mcp/tools/rows-append.d.ts +1 -1
- package/dist/cjs/mcp/tools/rows-append.js +7 -6
- package/dist/cjs/mcp/tools/rows-append.js.map +1 -1
- package/dist/cjs/mcp/tools/rows-csv-append.d.cts +1 -1
- package/dist/cjs/mcp/tools/rows-csv-append.d.ts +1 -1
- package/dist/cjs/mcp/tools/rows-csv-append.js +11 -10
- package/dist/cjs/mcp/tools/rows-csv-append.js.map +1 -1
- package/dist/cjs/mcp/tools/rows-get.d.cts +1 -1
- package/dist/cjs/mcp/tools/rows-get.d.ts +1 -1
- package/dist/cjs/mcp/tools/rows-get.js +8 -7
- package/dist/cjs/mcp/tools/rows-get.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-copy-to.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-copy-to.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-copy-to.js +8 -7
- package/dist/cjs/mcp/tools/sheet-copy-to.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-copy.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-copy.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-copy.js +8 -7
- package/dist/cjs/mcp/tools/sheet-copy.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-create.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-create.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-create.js +7 -6
- package/dist/cjs/mcp/tools/sheet-create.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-delete.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-delete.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-delete.js +6 -5
- package/dist/cjs/mcp/tools/sheet-delete.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-find.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-find.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-find.js +7 -6
- package/dist/cjs/mcp/tools/sheet-find.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-rename.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-rename.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-rename.js +8 -7
- package/dist/cjs/mcp/tools/sheet-rename.js.map +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-copy.d.cts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-copy.d.ts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-copy.js +9 -7
- package/dist/cjs/mcp/tools/spreadsheet-copy.js.map +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-create.d.cts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-create.d.ts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-create.js +7 -6
- package/dist/cjs/mcp/tools/spreadsheet-create.js.map +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-find.d.cts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-find.d.ts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-find.js +9 -7
- package/dist/cjs/mcp/tools/spreadsheet-find.js.map +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-rename.d.cts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-rename.d.ts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-rename.js +6 -5
- package/dist/cjs/mcp/tools/spreadsheet-rename.js.map +1 -1
- package/dist/cjs/mcp/tools/validation-set.d.cts +1 -1
- package/dist/cjs/mcp/tools/validation-set.d.ts +1 -1
- package/dist/cjs/mcp/tools/validation-set.js +8 -7
- package/dist/cjs/mcp/tools/validation-set.js.map +1 -1
- package/dist/cjs/mcp/tools/values-batch-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-batch-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-batch-update.js +9 -8
- package/dist/cjs/mcp/tools/values-batch-update.js.map +1 -1
- package/dist/cjs/mcp/tools/values-clear.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-clear.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-clear.js +7 -6
- package/dist/cjs/mcp/tools/values-clear.js.map +1 -1
- package/dist/cjs/mcp/tools/values-csv-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-csv-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-csv-update.js +8 -7
- package/dist/cjs/mcp/tools/values-csv-update.js.map +1 -1
- package/dist/cjs/mcp/tools/values-markdown-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-markdown-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-markdown-update.js +9 -8
- package/dist/cjs/mcp/tools/values-markdown-update.js.map +1 -1
- package/dist/cjs/mcp/tools/values-replace.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-replace.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-replace.js +9 -8
- package/dist/cjs/mcp/tools/values-replace.js.map +1 -1
- package/dist/cjs/mcp/tools/values-search.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-search.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-search.js +7 -6
- package/dist/cjs/mcp/tools/values-search.js.map +1 -1
- package/dist/cjs/setup/http.d.cts +0 -2
- package/dist/cjs/setup/http.d.ts +0 -2
- package/dist/cjs/setup/http.js +18 -11
- package/dist/cjs/setup/http.js.map +1 -1
- package/dist/cjs/setup/stdio.d.cts +0 -2
- package/dist/cjs/setup/stdio.d.ts +0 -2
- package/dist/cjs/setup/stdio.js +18 -11
- package/dist/cjs/setup/stdio.js.map +1 -1
- package/dist/cjs/spreadsheet/data-operations.d.cts +1 -1
- package/dist/cjs/spreadsheet/data-operations.d.ts +1 -1
- package/dist/cjs/spreadsheet/data-operations.js.map +1 -1
- package/dist/cjs/spreadsheet/markdown-runs.d.cts +1 -31
- package/dist/cjs/spreadsheet/markdown-runs.d.ts +1 -31
- package/dist/cjs/spreadsheet/markdown-runs.js +31 -31
- package/dist/cjs/spreadsheet/markdown-runs.js.map +1 -1
- package/dist/cjs/spreadsheet/sheet-operations.d.cts +1 -1
- package/dist/cjs/spreadsheet/sheet-operations.d.ts +1 -1
- package/dist/cjs/spreadsheet/sheet-operations.js.map +1 -1
- package/dist/cjs/spreadsheet/spreadsheet-management.d.cts +2 -1
- package/dist/cjs/spreadsheet/spreadsheet-management.d.ts +2 -1
- package/dist/cjs/spreadsheet/spreadsheet-management.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/google-auth.d.ts +9 -0
- package/dist/esm/lib/google-auth.js +11 -0
- package/dist/esm/lib/google-auth.js.map +1 -0
- package/dist/esm/mcp/prompts/a1-notation.d.ts +2 -3
- package/dist/esm/mcp/prompts/a1-notation.js.map +1 -1
- package/dist/esm/mcp/resources/spreadsheet.js +5 -4
- package/dist/esm/mcp/resources/spreadsheet.js.map +1 -1
- package/dist/esm/mcp/tools/cells-format.d.ts +1 -1
- package/dist/esm/mcp/tools/cells-format.js +7 -6
- package/dist/esm/mcp/tools/cells-format.js.map +1 -1
- package/dist/esm/mcp/tools/chart-create.d.ts +1 -1
- package/dist/esm/mcp/tools/chart-create.js +11 -10
- package/dist/esm/mcp/tools/chart-create.js.map +1 -1
- package/dist/esm/mcp/tools/columns-get.d.ts +1 -1
- package/dist/esm/mcp/tools/columns-get.js +8 -7
- package/dist/esm/mcp/tools/columns-get.js.map +1 -1
- package/dist/esm/mcp/tools/columns-update.d.ts +1 -1
- package/dist/esm/mcp/tools/columns-update.js +8 -7
- package/dist/esm/mcp/tools/columns-update.js.map +1 -1
- package/dist/esm/mcp/tools/csv-get-columns.d.ts +1 -1
- package/dist/esm/mcp/tools/csv-get-columns.js +2 -2
- package/dist/esm/mcp/tools/csv-get-columns.js.map +1 -1
- package/dist/esm/mcp/tools/dimensions-batch-update.d.ts +1 -1
- package/dist/esm/mcp/tools/dimensions-batch-update.js +12 -11
- package/dist/esm/mcp/tools/dimensions-batch-update.js.map +1 -1
- package/dist/esm/mcp/tools/dimensions-move.d.ts +1 -1
- package/dist/esm/mcp/tools/dimensions-move.js +10 -9
- package/dist/esm/mcp/tools/dimensions-move.js.map +1 -1
- package/dist/esm/mcp/tools/rows-append.d.ts +1 -1
- package/dist/esm/mcp/tools/rows-append.js +7 -6
- package/dist/esm/mcp/tools/rows-append.js.map +1 -1
- package/dist/esm/mcp/tools/rows-csv-append.d.ts +1 -1
- package/dist/esm/mcp/tools/rows-csv-append.js +12 -11
- package/dist/esm/mcp/tools/rows-csv-append.js.map +1 -1
- package/dist/esm/mcp/tools/rows-get.d.ts +1 -1
- package/dist/esm/mcp/tools/rows-get.js +8 -7
- package/dist/esm/mcp/tools/rows-get.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-copy-to.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-copy-to.js +8 -7
- package/dist/esm/mcp/tools/sheet-copy-to.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-copy.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-copy.js +8 -7
- package/dist/esm/mcp/tools/sheet-copy.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-create.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-create.js +7 -6
- package/dist/esm/mcp/tools/sheet-create.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-delete.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-delete.js +6 -5
- package/dist/esm/mcp/tools/sheet-delete.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-find.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-find.js +7 -6
- package/dist/esm/mcp/tools/sheet-find.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-rename.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-rename.js +8 -7
- package/dist/esm/mcp/tools/sheet-rename.js.map +1 -1
- package/dist/esm/mcp/tools/spreadsheet-copy.d.ts +1 -1
- package/dist/esm/mcp/tools/spreadsheet-copy.js +9 -7
- package/dist/esm/mcp/tools/spreadsheet-copy.js.map +1 -1
- package/dist/esm/mcp/tools/spreadsheet-create.d.ts +1 -1
- package/dist/esm/mcp/tools/spreadsheet-create.js +7 -6
- package/dist/esm/mcp/tools/spreadsheet-create.js.map +1 -1
- package/dist/esm/mcp/tools/spreadsheet-find.d.ts +1 -1
- package/dist/esm/mcp/tools/spreadsheet-find.js +9 -7
- package/dist/esm/mcp/tools/spreadsheet-find.js.map +1 -1
- package/dist/esm/mcp/tools/spreadsheet-rename.d.ts +1 -1
- package/dist/esm/mcp/tools/spreadsheet-rename.js +6 -5
- package/dist/esm/mcp/tools/spreadsheet-rename.js.map +1 -1
- package/dist/esm/mcp/tools/validation-set.d.ts +1 -1
- package/dist/esm/mcp/tools/validation-set.js +8 -7
- package/dist/esm/mcp/tools/validation-set.js.map +1 -1
- package/dist/esm/mcp/tools/values-batch-update.d.ts +1 -1
- package/dist/esm/mcp/tools/values-batch-update.js +9 -8
- package/dist/esm/mcp/tools/values-batch-update.js.map +1 -1
- package/dist/esm/mcp/tools/values-clear.d.ts +1 -1
- package/dist/esm/mcp/tools/values-clear.js +7 -6
- package/dist/esm/mcp/tools/values-clear.js.map +1 -1
- package/dist/esm/mcp/tools/values-csv-update.d.ts +1 -1
- package/dist/esm/mcp/tools/values-csv-update.js +9 -8
- package/dist/esm/mcp/tools/values-csv-update.js.map +1 -1
- package/dist/esm/mcp/tools/values-markdown-update.d.ts +1 -1
- package/dist/esm/mcp/tools/values-markdown-update.js +9 -8
- package/dist/esm/mcp/tools/values-markdown-update.js.map +1 -1
- package/dist/esm/mcp/tools/values-replace.d.ts +1 -1
- package/dist/esm/mcp/tools/values-replace.js +9 -8
- package/dist/esm/mcp/tools/values-replace.js.map +1 -1
- package/dist/esm/mcp/tools/values-search.d.ts +1 -1
- package/dist/esm/mcp/tools/values-search.js +7 -6
- package/dist/esm/mcp/tools/values-search.js.map +1 -1
- package/dist/esm/setup/http.d.ts +0 -2
- package/dist/esm/setup/http.js +18 -11
- package/dist/esm/setup/http.js.map +1 -1
- package/dist/esm/setup/stdio.d.ts +0 -2
- package/dist/esm/setup/stdio.js +18 -11
- package/dist/esm/setup/stdio.js.map +1 -1
- package/dist/esm/spreadsheet/data-operations.d.ts +1 -1
- package/dist/esm/spreadsheet/data-operations.js.map +1 -1
- package/dist/esm/spreadsheet/markdown-runs.d.ts +1 -31
- package/dist/esm/spreadsheet/markdown-runs.js.map +1 -1
- package/dist/esm/spreadsheet/sheet-operations.d.ts +1 -1
- package/dist/esm/spreadsheet/sheet-operations.js.map +1 -1
- package/dist/esm/spreadsheet/spreadsheet-management.d.ts +2 -1
- package/dist/esm/spreadsheet/spreadsheet-management.js.map +1 -1
- package/package.json +9 -10
|
@@ -8,10 +8,11 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return createTool;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
var _sheets = require("@googleapis/sheets");
|
|
11
12
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
13
|
-
var _googleapis = require("googleapis");
|
|
13
|
+
var _server = require("@mcp-z/server");
|
|
14
14
|
var _zod = require("zod");
|
|
15
|
+
var _googleauthts = require("../../lib/google-auth.js");
|
|
15
16
|
var _indexts = require("../../schemas/index.js");
|
|
16
17
|
var _markdownrunsts = require("../../spreadsheet/markdown-runs.js");
|
|
17
18
|
var _rangeoperationsts = require("../../spreadsheet/range-operations.js");
|
|
@@ -206,9 +207,9 @@ function handler(_0, _1) {
|
|
|
206
207
|
,
|
|
207
208
|
5
|
|
208
209
|
]);
|
|
209
|
-
sheets =
|
|
210
|
+
sheets = (0, _sheets.sheets)({
|
|
210
211
|
version: 'v4',
|
|
211
|
-
auth: extra.authContext.auth
|
|
212
|
+
auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
|
|
212
213
|
});
|
|
213
214
|
return [
|
|
214
215
|
4,
|
|
@@ -230,7 +231,7 @@ function handler(_0, _1) {
|
|
|
230
231
|
gid: gid,
|
|
231
232
|
requestCount: requests.length
|
|
232
233
|
});
|
|
233
|
-
throw new
|
|
234
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Sheet not found: ".concat(gid));
|
|
234
235
|
}
|
|
235
236
|
sheetTitle = (_sheet_properties_title = sheet.properties.title) !== null && _sheet_properties_title !== void 0 ? _sheet_properties_title : gid;
|
|
236
237
|
// googleapis types sheetId as `number | null | undefined`; coerce for rangeReferenceToGridRange below (same pattern as values-batch-update.ts's sheetGid).
|
|
@@ -376,8 +377,8 @@ function handler(_0, _1) {
|
|
|
376
377
|
];
|
|
377
378
|
case 4:
|
|
378
379
|
error = _state.sent();
|
|
379
|
-
// Re-throw
|
|
380
|
-
if (_instanceof(error,
|
|
380
|
+
// Re-throw ProtocolError as-is
|
|
381
|
+
if (_instanceof(error, _server.ProtocolError)) {
|
|
381
382
|
throw error;
|
|
382
383
|
}
|
|
383
384
|
message1 = _instanceof(error, Error) ? error.message : String(error);
|
|
@@ -387,7 +388,7 @@ function handler(_0, _1) {
|
|
|
387
388
|
requestCount: requests.length,
|
|
388
389
|
error: message1
|
|
389
390
|
});
|
|
390
|
-
throw new
|
|
391
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error writing markdown to cells: ".concat(message1), {
|
|
391
392
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
392
393
|
});
|
|
393
394
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-markdown-update.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google, type sheets_v4 } from 'googleapis';\nimport { z } from 'zod';\nimport { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { buildTextFormatRuns, parseInlineMarkdown } from '../../spreadsheet/markdown-runs.ts';\nimport { parseA1Notation, rangeReferenceToGridRange } from '../../spreadsheet/range-operations.ts';\n\n// Input schema for a single markdown-cell request\nconst MarkdownCellRequestSchema = z.object({\n cell: z.string().min(1).describe('Single-cell A1 reference (e.g., \"I2\"). Multi-cell ranges (e.g., \"A1:B2\") are rejected as a per-request failure.'),\n text: z.string().describe('Cell content as inline markdown: [label](url) links, bare URLs, **bold**, *italic*, ~~strikethrough~~. Block syntax and other unsupported markdown is written as literal text.'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(MarkdownCellRequestSchema).min(1).max(50).describe('Array of cell markdown requests. Batch multiple cells for efficiency.'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n sheetTitle: z.string().describe('Title of the updated sheet'),\n sheetUrl: z.string().describe('URL of the updated sheet'),\n successCount: z.number().int().nonnegative().describe('Number of cells successfully written'),\n cells: z\n .array(\n z.object({\n cell: z.string().describe('A1 reference of the cell that was written'),\n text: z.string().describe('Resolved plain text written to the cell (markdown syntax stripped/literalized)'),\n linkCount: z.number().int().nonnegative().describe('Number of clickable links written into the cell'),\n })\n )\n .describe('Cells successfully written'),\n failedCells: z\n .array(\n z.object({\n cell: z.string().describe('A1 reference that failed'),\n error: z.string().describe('Why the cell failed (e.g., not a single-cell reference)'),\n })\n )\n .optional()\n .describe('Only populated if some cells failed'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description:\n 'Replace cell content with text parsed from inline markdown. Supports [label](url) links, bare URLs, **bold**, *italic*, ~~strikethrough~~ — the only way to put MULTIPLE clickable links in one cell. Block syntax (headers, lists, tables) and other unsupported markdown is written as literal text. Writes text cells only — no formula or number coercion. For whole-cell formatting (colors, borders, number formats) use cells-format.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, requests }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.markdownUpdate called', {\n id,\n gid,\n requestCount: requests.length,\n });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n // Find sheet by gid\n const sheet = spreadsheetResponse.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for markdown update', { id, gid, requestCount: requests.length });\n throw new McpError(ErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? gid;\n // googleapis types sheetId as `number | null | undefined`; coerce for rangeReferenceToGridRange below (same pattern as values-batch-update.ts's sheetGid).\n const sheetId = sheet.properties.sheetId ?? 0;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetId}`;\n\n // Build one updateCells request per cell\n const batchRequests: sheets_v4.Schema$Request[] = [];\n const cells: Array<{ cell: string; text: string; linkCount: number }> = [];\n const failedCells: Array<{ cell: string; error: string }> = [];\n\n for (const request of requests) {\n try {\n // Parse A1 notation and reject anything that isn't a single cell\n const rangeRef = parseA1Notation(request.cell);\n if (rangeRef.type !== 'cell') {\n throw new Error(`Not a single-cell reference: \"${request.cell}\"`);\n }\n\n const gridRange = rangeReferenceToGridRange(rangeRef, sheetId);\n const parsed = parseInlineMarkdown(request.text);\n const runs = buildTextFormatRuns(parsed);\n\n batchRequests.push({\n updateCells: {\n range: gridRange,\n rows: [\n {\n values: [\n {\n userEnteredValue: { stringValue: parsed.text },\n textFormatRuns: runs,\n },\n ],\n },\n ],\n fields: 'userEnteredValue,textFormatRuns',\n },\n });\n cells.push({ cell: request.cell, text: parsed.text, linkCount: parsed.linkCount });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.info('Failed to parse cell for markdown update', {\n cell: request.cell,\n error: message,\n });\n failedCells.push({\n cell: request.cell,\n error: `Failed to parse cell: ${message}`,\n });\n }\n }\n\n // Early return if all cells failed\n if (batchRequests.length === 0) {\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: 0,\n cells: [],\n failedCells: failedCells.length > 0 ? failedCells : undefined,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n }\n\n logger.info('sheets.values.markdownUpdate executing batch request', {\n spreadsheetId: id,\n sheetTitle,\n batchRequestsCount: batchRequests.length,\n });\n\n // Execute the batch update\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: batchRequests,\n },\n });\n\n logger.info('sheets.values.markdownUpdate completed successfully', {\n successCount: cells.length,\n failedCount: failedCells.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: cells.length,\n cells,\n failedCells: failedCells.length > 0 ? failedCells : undefined,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n // Re-throw McpError as-is\n if (error instanceof McpError) {\n throw error;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Markdown update operation failed', {\n id,\n gid,\n requestCount: requests.length,\n error: message,\n });\n\n throw new McpError(ErrorCode.InternalError, `Error writing markdown to cells: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-markdown-update',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","MarkdownCellRequestSchema","z","object","cell","string","min","describe","text","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","array","max","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","sheetTitle","sheetUrl","successCount","number","int","nonnegative","cells","linkCount","failedCells","error","optional","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","sheet","spreadsheetResponse","sheets","sheetId","batchRequests","request","rangeRef","gridRange","parsed","runs","message","info","requestCount","length","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","String","properties","McpError","ErrorCode","InvalidParams","title","parseA1Notation","Error","rangeReferenceToGridRange","parseInlineMarkdown","buildTextFormatRuns","push","updateCells","range","rows","values","userEnteredValue","stringValue","textFormatRuns","undefined","content","JSON","stringify","structuredContent","batchRequestsCount","batchUpdate","requestBody","failedCount","InternalError","stack","name"],"mappings":";;;;+BAwNA;;;eAAwBA;;;2BAvNA;qBAMY;0BACG;mBACrB;uBACuE;8BAChC;iCACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAT3D,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAWR,kDAAkD;AAClD,IAAME,4BAA4BC,MAAC,CAACC,MAAM,CAAC;IACzCC,MAAMF,MAA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O;4BACLC,OAAO;gCAAG;oCAAEpE,MAAM;oCAAiBV,MAAM+E,KAAKC,SAAS,CAACnD;gCAAQ;;4BAChEoD,mBAAmB;gCAAEpD,QAAAA;4BAAO;wBAC9B;;;oBACON;oBACP,0BAA0B;oBAC1B,IAAIA,AAAK,YAALA,OAAiBqC,eAAQ,GAAE;wBAC7B,MAAMrC;oBACR;oBAEMoB,WAAUpB,AAAK,YAALA,OAAiB0C,SAAQ1C,MAAMoB,OAAO,GAAGe,OAAOnC;oBAChES,OAAOT,KAAK,CAAC,oCAAoC;wBAC/CrB,IAAAA;wBACAE,KAAAA;wBACAyC,cAAcvC,SAASwC,MAAM;wBAC7BvB,OAAOoB;oBACT;oBAEA,MAAM,IAAIiB,eAAQ,CAACC,gBAAS,CAACyB,aAAa,EAAE,AAAC,oCAA2C,OAAR3C,WAAW;wBACzF4C,OAAOhE,AAAK,YAALA,OAAiB0C,SAAQ1C,MAAMgE,KAAK,GAAGV;oBAChD;;;;;;;IAEJ;;AAEe,SAASvF;IACtB,OAAO;QACLkG,MAAM;QACN7D,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-markdown-update.ts"],"sourcesContent":["import { type sheets_v4, sheets as sheetsApi } from '@googleapis/sheets';\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { CallToolResult, ToolModule } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\nimport { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { buildTextFormatRuns, parseInlineMarkdown } from '../../spreadsheet/markdown-runs.ts';\nimport { parseA1Notation, rangeReferenceToGridRange } from '../../spreadsheet/range-operations.ts';\n\n// Input schema for a single markdown-cell request\nconst MarkdownCellRequestSchema = z.object({\n cell: z.string().min(1).describe('Single-cell A1 reference (e.g., \"I2\"). Multi-cell ranges (e.g., \"A1:B2\") are rejected as a per-request failure.'),\n text: z.string().describe('Cell content as inline markdown: [label](url) links, bare URLs, **bold**, *italic*, ~~strikethrough~~. Block syntax and other unsupported markdown is written as literal text.'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(MarkdownCellRequestSchema).min(1).max(50).describe('Array of cell markdown requests. Batch multiple cells for efficiency.'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n sheetTitle: z.string().describe('Title of the updated sheet'),\n sheetUrl: z.string().describe('URL of the updated sheet'),\n successCount: z.number().int().nonnegative().describe('Number of cells successfully written'),\n cells: z\n .array(\n z.object({\n cell: z.string().describe('A1 reference of the cell that was written'),\n text: z.string().describe('Resolved plain text written to the cell (markdown syntax stripped/literalized)'),\n linkCount: z.number().int().nonnegative().describe('Number of clickable links written into the cell'),\n })\n )\n .describe('Cells successfully written'),\n failedCells: z\n .array(\n z.object({\n cell: z.string().describe('A1 reference that failed'),\n error: z.string().describe('Why the cell failed (e.g., not a single-cell reference)'),\n })\n )\n .optional()\n .describe('Only populated if some cells failed'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description:\n 'Replace cell content with text parsed from inline markdown. Supports [label](url) links, bare URLs, **bold**, *italic*, ~~strikethrough~~ — the only way to put MULTIPLE clickable links in one cell. Block syntax (headers, lists, tables) and other unsupported markdown is written as literal text. Writes text cells only — no formula or number coercion. For whole-cell formatting (colors, borders, number formats) use cells-format.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, requests }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.markdownUpdate called', {\n id,\n gid,\n requestCount: requests.length,\n });\n\n try {\n const sheets = sheetsApi({ version: 'v4', auth: googleAuth(extra.authContext.auth) });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n // Find sheet by gid\n const sheet = spreadsheetResponse.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for markdown update', { id, gid, requestCount: requests.length });\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? gid;\n // googleapis types sheetId as `number | null | undefined`; coerce for rangeReferenceToGridRange below (same pattern as values-batch-update.ts's sheetGid).\n const sheetId = sheet.properties.sheetId ?? 0;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetId}`;\n\n // Build one updateCells request per cell\n const batchRequests: sheets_v4.Schema$Request[] = [];\n const cells: Array<{ cell: string; text: string; linkCount: number }> = [];\n const failedCells: Array<{ cell: string; error: string }> = [];\n\n for (const request of requests) {\n try {\n // Parse A1 notation and reject anything that isn't a single cell\n const rangeRef = parseA1Notation(request.cell);\n if (rangeRef.type !== 'cell') {\n throw new Error(`Not a single-cell reference: \"${request.cell}\"`);\n }\n\n const gridRange = rangeReferenceToGridRange(rangeRef, sheetId);\n const parsed = parseInlineMarkdown(request.text);\n const runs = buildTextFormatRuns(parsed);\n\n batchRequests.push({\n updateCells: {\n range: gridRange,\n rows: [\n {\n values: [\n {\n userEnteredValue: { stringValue: parsed.text },\n textFormatRuns: runs,\n },\n ],\n },\n ],\n fields: 'userEnteredValue,textFormatRuns',\n },\n });\n cells.push({ cell: request.cell, text: parsed.text, linkCount: parsed.linkCount });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.info('Failed to parse cell for markdown update', {\n cell: request.cell,\n error: message,\n });\n failedCells.push({\n cell: request.cell,\n error: `Failed to parse cell: ${message}`,\n });\n }\n }\n\n // Early return if all cells failed\n if (batchRequests.length === 0) {\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: 0,\n cells: [],\n failedCells: failedCells.length > 0 ? failedCells : undefined,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n }\n\n logger.info('sheets.values.markdownUpdate executing batch request', {\n spreadsheetId: id,\n sheetTitle,\n batchRequestsCount: batchRequests.length,\n });\n\n // Execute the batch update\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: batchRequests,\n },\n });\n\n logger.info('sheets.values.markdownUpdate completed successfully', {\n successCount: cells.length,\n failedCount: failedCells.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: cells.length,\n cells,\n failedCells: failedCells.length > 0 ? failedCells : undefined,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n // Re-throw ProtocolError as-is\n if (error instanceof ProtocolError) {\n throw error;\n }\n\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Markdown update operation failed', {\n id,\n gid,\n requestCount: requests.length,\n error: message,\n });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error writing markdown to cells: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-markdown-update',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","MarkdownCellRequestSchema","z","object","cell","string","min","describe","text","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","array","max","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","sheetTitle","sheetUrl","successCount","number","int","nonnegative","cells","linkCount","failedCells","error","optional","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","sheet","spreadsheetResponse","sheets","sheetId","batchRequests","request","rangeRef","gridRange","parsed","runs","message","info","requestCount","length","sheetsApi","version","auth","googleAuth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","String","properties","ProtocolError","ProtocolErrorCode","InvalidParams","title","parseA1Notation","Error","rangeReferenceToGridRange","parseInlineMarkdown","buildTextFormatRuns","push","updateCells","range","rows","values","userEnteredValue","stringValue","textFormatRuns","undefined","content","JSON","stringify","structuredContent","batchRequestsCount","batchUpdate","requestBody","failedCount","InternalError","stack","name"],"mappings":";;;;+BAwNA;;;eAAwBA;;;sBAxN4B;2BAE5B;sBAKyB;mBAC/B;4BACS;uBAC8D;8BAChC;iCACE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAR3D,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAUR,kDAAkD;AAClD,IAAME,4BAA4BC,MAAC,CAACC,MAAM,CAAC;IACzCC,MAAMF,MAAC,CAACG,MAAM,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;IACjCC,MAAMN,MAAC,CAACG,MAAM,GAAGE,QAAQ,CAAC;AAC5B;AAEA,IAAME,cAAcP,MAAC,CAACC,MAAM,CAAC;IAC3BO,IAAIC,4BAAmB;IACvBC,KAAKC,uBAAc;IACnBC,UAAUZ,MAAC,CAACa,KAAK,CAACd,2BAA2BK,GAAG,CAAC,GAAGU,GAAG,CAAC,IAAIT,QAAQ,CAAC;AACvE;AAEA,IAAMU,sBAAsBf,MAAC,CAACC,MAAM,CAAC;IACnCe,MAAMhB,MAAC,CAACiB,OAAO,CAAC;IAChBT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,SAASwC,MAAM;wBAC7BvB,OAAOoB;oBACT;oBAEA,MAAM,IAAIkB,qBAAa,CAACC,yBAAiB,CAACyB,aAAa,EAAE,AAAC,oCAA2C,OAAR5C,WAAW;wBACtG6C,OAAOjE,AAAK,YAALA,OAAiB2C,SAAQ3C,MAAMiE,KAAK,GAAGV;oBAChD;;;;;;;IAEJ;;AAEe,SAASxF;IACtB,OAAO;QACLmG,MAAM;QACN9D,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -8,10 +8,11 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return createTool;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
var _sheets = require("@googleapis/sheets");
|
|
11
12
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
13
|
-
var _googleapis = require("googleapis");
|
|
13
|
+
var _server = require("@mcp-z/server");
|
|
14
14
|
var _zod = require("zod");
|
|
15
|
+
var _googleauthts = require("../../lib/google-auth.js");
|
|
15
16
|
var _indexts = require("../../schemas/index.js");
|
|
16
17
|
var _rangeoperationsts = require("../../spreadsheet/range-operations.js");
|
|
17
18
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -233,9 +234,9 @@ function handler(_0, _1) {
|
|
|
233
234
|
,
|
|
234
235
|
7
|
|
235
236
|
]);
|
|
236
|
-
sheets =
|
|
237
|
+
sheets = (0, _sheets.sheets)({
|
|
237
238
|
version: 'v4',
|
|
238
|
-
auth: extra.authContext.auth
|
|
239
|
+
auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
|
|
239
240
|
});
|
|
240
241
|
// Build FindReplaceRequest - only include defined options
|
|
241
242
|
findReplaceRequest = _object_spread({
|
|
@@ -275,12 +276,12 @@ function handler(_0, _1) {
|
|
|
275
276
|
return String((_s_properties = s.properties) === null || _s_properties === void 0 ? void 0 : _s_properties.sheetId) === gid;
|
|
276
277
|
});
|
|
277
278
|
if (!sheet) {
|
|
278
|
-
throw new
|
|
279
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Sheet not found: ".concat(gid));
|
|
279
280
|
}
|
|
280
281
|
// Note: sheetId can be 0 which is falsy, so check explicitly for undefined/null
|
|
281
282
|
sheetId = (_sheet_properties = sheet.properties) === null || _sheet_properties === void 0 ? void 0 : _sheet_properties.sheetId;
|
|
282
283
|
if (sheetId === undefined || sheetId === null) {
|
|
283
|
-
throw new
|
|
284
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, 'Sheet properties not available');
|
|
284
285
|
}
|
|
285
286
|
if (!range) {
|
|
286
287
|
// gid but no range = search specific sheet
|
|
@@ -339,7 +340,7 @@ function handler(_0, _1) {
|
|
|
339
340
|
];
|
|
340
341
|
case 6:
|
|
341
342
|
error = _state.sent();
|
|
342
|
-
if (_instanceof(error,
|
|
343
|
+
if (_instanceof(error, _server.ProtocolError)) {
|
|
343
344
|
throw error;
|
|
344
345
|
}
|
|
345
346
|
message = _instanceof(error, Error) ? error.message : String(error);
|
|
@@ -351,7 +352,7 @@ function handler(_0, _1) {
|
|
|
351
352
|
range: range,
|
|
352
353
|
error: message
|
|
353
354
|
});
|
|
354
|
-
throw new
|
|
355
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error replacing values: ".concat(message), {
|
|
355
356
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
356
357
|
});
|
|
357
358
|
case 7:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-replace.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google, type sheets_v4 } from 'googleapis';\nimport { z } from 'zod';\nimport { A1NotationSchema, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { parseA1Notation, rangeReferenceToGridRange } from '../../spreadsheet/range-operations.ts';\n\nconst inputSchema = z\n .object({\n id: SpreadsheetIdSchema,\n find: z.string().min(1).describe('Text or regex pattern to find'),\n replacement: z.string().describe('Replacement text. Use $1, $2 for regex capture groups. Empty string deletes matches.'),\n\n // Scope - defaults to all sheets if neither specified\n gid: SheetGidSchema.optional().describe('Limit to specific sheet. If omitted, searches all sheets.'),\n range: A1NotationSchema.optional().describe('Limit to specific A1 range within the sheet (requires gid)'),\n\n // Match options\n matchCase: z.boolean().optional().describe('Case-sensitive matching'),\n matchEntireCell: z.boolean().optional().describe('Only match entire cell content'),\n searchByRegex: z.boolean().optional().describe('Treat find as RE2 regex'),\n includeFormulas: z.boolean().optional().describe('Search within formula text'),\n })\n .refine((data) => !(data.range && !data.gid), { message: 'range requires gid' });\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n spreadsheetUrl: z.string().describe('URL of the spreadsheet'),\n occurrencesChanged: z.number().int().nonnegative().describe('Total replacements made'),\n valuesChanged: z.number().int().nonnegative().describe('Number of non-formula cells changed'),\n formulasChanged: z.number().int().nonnegative().describe('Number of formula cells changed'),\n rowsChanged: z.number().int().nonnegative().describe('Number of rows with replacements'),\n sheetsChanged: z.number().int().nonnegative().describe('Number of sheets with replacements'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Find and replace text across a spreadsheet. Searches all sheets by default, or limit with gid/range. Supports regex with capture groups ($1, $2).',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, find, replacement, gid, range, matchCase, matchEntireCell, searchByRegex, includeFormulas }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values-replace called', { id, find, replacement, gid, range });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Build FindReplaceRequest - only include defined options\n const findReplaceRequest: sheets_v4.Schema$FindReplaceRequest = {\n find,\n replacement,\n ...(matchCase !== undefined && { matchCase }),\n ...(matchEntireCell !== undefined && { matchEntireCell }),\n ...(searchByRegex !== undefined && { searchByRegex }),\n ...(includeFormulas !== undefined && { includeFormulas }),\n };\n\n // Set scope based on gid/range\n if (!gid) {\n // No gid = search all sheets\n findReplaceRequest.allSheets = true;\n } else {\n // Need to resolve sheet to get numeric sheetId\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n const sheet = spreadsheetResponse.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet) {\n throw new McpError(ErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n // Note: sheetId can be 0 which is falsy, so check explicitly for undefined/null\n const sheetId = sheet.properties?.sheetId;\n if (sheetId === undefined || sheetId === null) {\n throw new McpError(ErrorCode.InternalError, 'Sheet properties not available');\n }\n\n if (!range) {\n // gid but no range = search specific sheet\n findReplaceRequest.sheetId = sheetId;\n } else {\n // gid + range = search specific range\n const rangeRef = parseA1Notation(range);\n findReplaceRequest.range = rangeReferenceToGridRange(rangeRef, sheetId);\n }\n }\n\n // Execute batchUpdate\n const response = await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: [{ findReplace: findReplaceRequest }],\n },\n });\n\n const findReplaceResponse = response.data.replies?.[0]?.findReplace;\n const spreadsheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit`;\n\n logger.info('sheets.values-replace completed', {\n occurrencesChanged: findReplaceResponse?.occurrencesChanged ?? 0,\n sheetsChanged: findReplaceResponse?.sheetsChanged ?? 0,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n spreadsheetUrl,\n occurrencesChanged: findReplaceResponse?.occurrencesChanged ?? 0,\n valuesChanged: findReplaceResponse?.valuesChanged ?? 0,\n formulasChanged: findReplaceResponse?.formulasChanged ?? 0,\n rowsChanged: findReplaceResponse?.rowsChanged ?? 0,\n sheetsChanged: findReplaceResponse?.sheetsChanged ?? 0,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n if (error instanceof McpError) {\n throw error;\n }\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Replace operation failed', {\n id,\n find,\n replacement,\n gid,\n range,\n error: message,\n });\n\n throw new McpError(ErrorCode.InternalError, `Error replacing values: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-replace',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","inputSchema","z","object","id","SpreadsheetIdSchema","find","string","min","describe","replacement","gid","SheetGidSchema","optional","range","A1NotationSchema","matchCase","boolean","matchEntireCell","searchByRegex","includeFormulas","refine","data","message","successBranchSchema","type","literal","SpreadsheetIdOutput","spreadsheetUrl","occurrencesChanged","number","int","nonnegative","valuesChanged","formulasChanged","rowsChanged","sheetsChanged","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","response","sheets","findReplaceRequest","spreadsheetResponse","sheet","sheetId","rangeRef","findReplaceResponse","error","info","google","version","auth","authContext","undefined","allSheets","spreadsheets","get","spreadsheetId","fields","s","String","properties","McpError","ErrorCode","InvalidParams","InternalError","parseA1Notation","rangeReferenceToGridRange","batchUpdate","requestBody","requests","findReplace","replies","content","text","JSON","stringify","structuredContent","Error","stack","name"],"mappings":";;;;+BA2JA;;;eAAwBA;;;2BA1JA;qBAMY;0BACG;mBACrB;uBACyE;iCAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAR3D,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAUR,IAAME,cAAcC,MAAC,CAClBC,MAAM,CAAC;IACNC,IAAIC,4BAAmB;IACvBC,MAAMJ,MAAC,CAACK,MAAM,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;IACjCC,aAAaR,MAAC,CAACK,MAAM,GAAGE,QAAQ,CAAC;IAEjC,sDAAsD;IACtDE,KAAKC,uBAAc,CAACC,QAAQ,GAAGJ,QAAQ,CAAC;IACxCK,OAAOC,yBAAgB,CAACF,QAAQ,GAAGJ,QAAQ,CAAC;IAE5C,gBAAgB;IAChBO,WAAWd,MAAC,CAACe,OAAO,GAAGJ,QAAQ,GAAGJ,QAAQ,CAAC;IAC3CS,iBAAiBhB,MAAC,CAACe,OAAO,GAAGJ,QAAQ,GAAGJ,QAAQ,CAAC;IACjDU,eAAejB,MAAC,CAACe,OAAO,GAAGJ,QAAQ,GAAGJ,QAAQ,CAAC;IAC/CW,iBAAiBlB,MAAC,CAACe,OAAO,GAA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yCAAI;wBACjDC,aAAa,WAAEgB,gCAAAA,0CAAAA,oBAAqBhB,aAAa,yCAAI;oBACvD;oBAEA;;wBAAO;4BACL2C,OAAO;gCAAG;oCAAEtD,MAAM;oCAAiBuD,MAAMC,KAAKC,SAAS,CAACzC;gCAAQ;;4BAChE0C,mBAAmB;gCAAE1C,QAAAA;4BAAO;wBAC9B;;;oBACOY;oBACP,IAAIA,AAAK,YAALA,OAAiBe,eAAQ,GAAE;wBAC7B,MAAMf;oBACR;oBACM9B,UAAU8B,AAAK,YAALA,OAAiB+B,SAAQ/B,MAAM9B,OAAO,GAAG2C,OAAOb;oBAChET,OAAOS,KAAK,CAAC,4BAA4B;wBACvCjD,IAAAA;wBACAE,MAAAA;wBACAI,aAAAA;wBACAC,KAAAA;wBACAG,OAAAA;wBACAuC,OAAO9B;oBACT;oBAEA,MAAM,IAAI6C,eAAQ,CAACC,gBAAS,CAACE,aAAa,EAAE,AAAC,2BAAkC,OAARhD,UAAW;wBAChF8D,OAAOhC,AAAK,YAALA,OAAiB+B,SAAQ/B,MAAMgC,KAAK,GAAG1B;oBAChD;;;;;;;IAEJ;;AAEe,SAAS7D;IACtB,OAAO;QACLwF,MAAM;QACN/C,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-replace.ts"],"sourcesContent":["import { type sheets_v4, sheets as sheetsApi } from '@googleapis/sheets';\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { CallToolResult, ToolModule } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\nimport { A1NotationSchema, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { parseA1Notation, rangeReferenceToGridRange } from '../../spreadsheet/range-operations.ts';\n\nconst inputSchema = z\n .object({\n id: SpreadsheetIdSchema,\n find: z.string().min(1).describe('Text or regex pattern to find'),\n replacement: z.string().describe('Replacement text. Use $1, $2 for regex capture groups. Empty string deletes matches.'),\n\n // Scope - defaults to all sheets if neither specified\n gid: SheetGidSchema.optional().describe('Limit to specific sheet. If omitted, searches all sheets.'),\n range: A1NotationSchema.optional().describe('Limit to specific A1 range within the sheet (requires gid)'),\n\n // Match options\n matchCase: z.boolean().optional().describe('Case-sensitive matching'),\n matchEntireCell: z.boolean().optional().describe('Only match entire cell content'),\n searchByRegex: z.boolean().optional().describe('Treat find as RE2 regex'),\n includeFormulas: z.boolean().optional().describe('Search within formula text'),\n })\n .refine((data) => !(data.range && !data.gid), { message: 'range requires gid' });\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n spreadsheetUrl: z.string().describe('URL of the spreadsheet'),\n occurrencesChanged: z.number().int().nonnegative().describe('Total replacements made'),\n valuesChanged: z.number().int().nonnegative().describe('Number of non-formula cells changed'),\n formulasChanged: z.number().int().nonnegative().describe('Number of formula cells changed'),\n rowsChanged: z.number().int().nonnegative().describe('Number of rows with replacements'),\n sheetsChanged: z.number().int().nonnegative().describe('Number of sheets with replacements'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Find and replace text across a spreadsheet. Searches all sheets by default, or limit with gid/range. Supports regex with capture groups ($1, $2).',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, find, replacement, gid, range, matchCase, matchEntireCell, searchByRegex, includeFormulas }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values-replace called', { id, find, replacement, gid, range });\n\n try {\n const sheets = sheetsApi({ version: 'v4', auth: googleAuth(extra.authContext.auth) });\n\n // Build FindReplaceRequest - only include defined options\n const findReplaceRequest: sheets_v4.Schema$FindReplaceRequest = {\n find,\n replacement,\n ...(matchCase !== undefined && { matchCase }),\n ...(matchEntireCell !== undefined && { matchEntireCell }),\n ...(searchByRegex !== undefined && { searchByRegex }),\n ...(includeFormulas !== undefined && { includeFormulas }),\n };\n\n // Set scope based on gid/range\n if (!gid) {\n // No gid = search all sheets\n findReplaceRequest.allSheets = true;\n } else {\n // Need to resolve sheet to get numeric sheetId\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n const sheet = spreadsheetResponse.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet) {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n // Note: sheetId can be 0 which is falsy, so check explicitly for undefined/null\n const sheetId = sheet.properties?.sheetId;\n if (sheetId === undefined || sheetId === null) {\n throw new ProtocolError(ProtocolErrorCode.InternalError, 'Sheet properties not available');\n }\n\n if (!range) {\n // gid but no range = search specific sheet\n findReplaceRequest.sheetId = sheetId;\n } else {\n // gid + range = search specific range\n const rangeRef = parseA1Notation(range);\n findReplaceRequest.range = rangeReferenceToGridRange(rangeRef, sheetId);\n }\n }\n\n // Execute batchUpdate\n const response = await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: [{ findReplace: findReplaceRequest }],\n },\n });\n\n const findReplaceResponse = response.data.replies?.[0]?.findReplace;\n const spreadsheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit`;\n\n logger.info('sheets.values-replace completed', {\n occurrencesChanged: findReplaceResponse?.occurrencesChanged ?? 0,\n sheetsChanged: findReplaceResponse?.sheetsChanged ?? 0,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n spreadsheetUrl,\n occurrencesChanged: findReplaceResponse?.occurrencesChanged ?? 0,\n valuesChanged: findReplaceResponse?.valuesChanged ?? 0,\n formulasChanged: findReplaceResponse?.formulasChanged ?? 0,\n rowsChanged: findReplaceResponse?.rowsChanged ?? 0,\n sheetsChanged: findReplaceResponse?.sheetsChanged ?? 0,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n if (error instanceof ProtocolError) {\n throw error;\n }\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Replace operation failed', {\n id,\n find,\n replacement,\n gid,\n range,\n error: message,\n });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error replacing values: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-replace',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","inputSchema","z","object","id","SpreadsheetIdSchema","find","string","min","describe","replacement","gid","SheetGidSchema","optional","range","A1NotationSchema","matchCase","boolean","matchEntireCell","searchByRegex","includeFormulas","refine","data","message","successBranchSchema","type","literal","SpreadsheetIdOutput","spreadsheetUrl","occurrencesChanged","number","int","nonnegative","valuesChanged","formulasChanged","rowsChanged","sheetsChanged","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","response","sheets","findReplaceRequest","spreadsheetResponse","sheet","sheetId","rangeRef","findReplaceResponse","error","info","sheetsApi","version","auth","googleAuth","authContext","undefined","allSheets","spreadsheets","get","spreadsheetId","fields","s","String","properties","ProtocolError","ProtocolErrorCode","InvalidParams","InternalError","parseA1Notation","rangeReferenceToGridRange","batchUpdate","requestBody","requests","findReplace","replies","content","text","JSON","stringify","structuredContent","Error","stack","name"],"mappings":";;;;+BA2JA;;;eAAwBA;;;sBA3J4B;2BAE5B;sBAKyB;mBAC/B;4BACS;uBACgE;iCAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A;wBACAG,OAAAA;wBACAuC,OAAO9B;oBACT;oBAEA,MAAM,IAAI8C,qBAAa,CAACC,yBAAiB,CAACE,aAAa,EAAE,AAAC,2BAAkC,OAARjD,UAAW;wBAC7F+D,OAAOjC,AAAK,YAALA,OAAiBgC,SAAQhC,MAAMiC,KAAK,GAAG1B;oBAChD;;;;;;;IAEJ;;AAEe,SAAS9D;IACtB,OAAO;QACLyF,MAAM;QACNhD,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -8,10 +8,11 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return createTool;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
var _sheets = require("@googleapis/sheets");
|
|
11
12
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
13
|
-
var _googleapis = require("googleapis");
|
|
13
|
+
var _server = require("@mcp-z/server");
|
|
14
14
|
var _zod = require("zod");
|
|
15
|
+
var _googleauthts = require("../../lib/google-auth.js");
|
|
15
16
|
var _indexts = require("../../schemas/index.js");
|
|
16
17
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
18
|
try {
|
|
@@ -246,9 +247,9 @@ function handler(_0, _1) {
|
|
|
246
247
|
,
|
|
247
248
|
5
|
|
248
249
|
]);
|
|
249
|
-
sheets =
|
|
250
|
+
sheets = (0, _sheets.sheets)({
|
|
250
251
|
version: 'v4',
|
|
251
|
-
auth: extra.authContext.auth
|
|
252
|
+
auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
|
|
252
253
|
});
|
|
253
254
|
return [
|
|
254
255
|
4,
|
|
@@ -269,7 +270,7 @@ function handler(_0, _1) {
|
|
|
269
270
|
gid: gid,
|
|
270
271
|
query: query
|
|
271
272
|
});
|
|
272
|
-
throw new
|
|
273
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, 'Sheet not found');
|
|
273
274
|
}
|
|
274
275
|
sheetTitle = (_ref = (_sheet_properties = sheet.properties) === null || _sheet_properties === void 0 ? void 0 : _sheet_properties.title) !== null && _ref !== void 0 ? _ref : '';
|
|
275
276
|
// Use actual sheet dimensions from gridProperties, with sensible defaults
|
|
@@ -443,7 +444,7 @@ function handler(_0, _1) {
|
|
|
443
444
|
logger.error('sheets.values-search error', {
|
|
444
445
|
error: message
|
|
445
446
|
});
|
|
446
|
-
throw new
|
|
447
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error searching spreadsheet: ".concat(message), {
|
|
447
448
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
448
449
|
});
|
|
449
450
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-search.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport { SheetCellSchema, SheetGidSchema, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\n// Helper to convert column index to letter (0 = A, 1 = B, etc.)\nfunction columnIndexToLetter(index: number): string {\n let letter = '';\n let num = index + 1;\n while (num > 0) {\n const remainder = (num - 1) % 26;\n letter = String.fromCharCode(65 + remainder) + letter;\n num = Math.floor((num - 1) / 26);\n }\n return letter;\n}\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n query: z.coerce.string().trim().optional().describe('Text to search for in sheet cells. If empty, returns all data at specified granularity.'),\n select: z.enum(['cells', 'rows', 'columns']).describe('Granularity: cells (individual matches), rows (full matching rows), columns (columns with matching headers)'),\n values: z.boolean().optional().describe('Include cell values in response'),\n a1s: z.boolean().optional().describe('Include A1 notation references in response'),\n render: z.enum(['FORMATTED_VALUE', 'UNFORMATTED_VALUE', 'FORMULA']).optional().describe('How to render cell values. FORMATTED_VALUE (default): calculated with formatting. UNFORMATTED_VALUE: calculated without formatting. FORMULA: show formula text instead of result.'),\n matchCase: z.boolean().optional().describe('Case-sensitive matching. Default is false (case-insensitive).'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n count: z.number().int().nonnegative().describe('Number of matches found'),\n a1s: z.array(z.string()).optional().describe('A1 notation references for matches (e.g., \"B5\", \"A5:D5\", \"B:B\")'),\n values: z\n .array(z.union([z.array(SheetCellSchema), SheetCellSchema]))\n .optional()\n .describe('Cell values for matches (arrays for rows/columns, single values for cells)'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Search spreadsheet and return matches at cell, row, or column granularity. Use a1-notation prompt for range syntax.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, query, select, values = false, a1s = false, render, matchCase = false }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values-search called', { id, gid, query, select, values, a1s, render, matchCase });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Get sheet details including grid dimensions\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title,sheets.properties.gridProperties',\n });\n\n const sheet = spreadsheetResponse.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n\n if (!sheet) {\n logger.info('sheets.values-search sheet not found', { id, gid, query });\n throw new McpError(ErrorCode.InvalidParams, 'Sheet not found');\n }\n\n const sheetTitle = sheet.properties?.title ?? '';\n\n // Use actual sheet dimensions from gridProperties, with sensible defaults\n // Google Sheets default for new sheets is 1000 rows x 26 columns\n const rowCount = sheet.properties?.gridProperties?.rowCount ?? 1000;\n const columnCount = sheet.properties?.gridProperties?.columnCount ?? 26;\n const endColumn = columnIndexToLetter(columnCount - 1);\n const fullRange = `${sheetTitle}!A1:${endColumn}${rowCount}`;\n\n logger.debug?.('sheets.values-search fetching range', { fullRange, rowCount, columnCount });\n\n const response = await sheets.spreadsheets.values.get({\n spreadsheetId: id,\n range: fullRange,\n valueRenderOption: render || 'FORMATTED_VALUE',\n });\n const res = response.data;\n const allRows = Array.isArray(res.values) ? (res.values as (string | number | boolean | null)[][]) : [];\n\n // Prepare query for matching (case-insensitive by default)\n const searchQuery = query ? (matchCase ? query : query.toLowerCase()) : null;\n\n let count = 0;\n const a1Array: string[] = [];\n const valuesArray: (string | number | boolean | null | (string | number | boolean | null)[])[] = [];\n\n // Helper to check if a cell matches the query\n const cellMatches = (cell: string | number | boolean | null): boolean => {\n if (!searchQuery) return true; // If no query, match all\n if (typeof cell !== 'string') return false;\n const cellValue = matchCase ? cell : cell.toLowerCase();\n return cellValue.includes(searchQuery);\n };\n\n if (select === 'cells') {\n for (let rowIdx = 0; rowIdx < allRows.length; rowIdx++) {\n const row = allRows[rowIdx];\n if (!row) continue;\n\n for (let colIdx = 0; colIdx < row.length; colIdx++) {\n const cell = row[colIdx];\n if (cellMatches(cell)) {\n count++;\n if (a1s) {\n const colLetter = columnIndexToLetter(colIdx);\n const rowNum = rowIdx + 1;\n a1Array.push(`${colLetter}${rowNum}`);\n }\n if (values) {\n valuesArray.push(cell ?? null);\n }\n }\n }\n }\n } else if (select === 'rows') {\n const matchingRows: number[] = [];\n for (let rowIdx = 0; rowIdx < allRows.length; rowIdx++) {\n const row = allRows[rowIdx];\n if (!row) continue;\n\n const matches = row.some((cell) => cellMatches(cell));\n if (matches) {\n matchingRows.push(rowIdx);\n }\n }\n\n count = matchingRows.length;\n for (const rowIdx of matchingRows) {\n const row = allRows[rowIdx];\n if (!row) continue; // Skip if row is undefined\n const rowNum = rowIdx + 1;\n\n if (a1s) {\n const colEnd = columnIndexToLetter(Math.max(0, row.length - 1));\n a1Array.push(`A${rowNum}:${colEnd}${rowNum}`);\n }\n if (values) {\n valuesArray.push(row);\n }\n }\n } else if (select === 'columns') {\n const headerRow = allRows[0] || [];\n const matchingCols: number[] = [];\n\n for (let colIdx = 0; colIdx < headerRow.length; colIdx++) {\n const header = headerRow[colIdx];\n if (cellMatches(header)) {\n matchingCols.push(colIdx);\n }\n }\n\n count = matchingCols.length;\n for (const colIdx of matchingCols) {\n const colLetter = columnIndexToLetter(colIdx);\n\n if (a1s) {\n a1Array.push(`${colLetter}:${colLetter}`);\n }\n if (values) {\n const columnValues = allRows.map((row) => (row && row[colIdx] !== undefined ? row[colIdx] : null));\n valuesArray.push(columnValues);\n }\n }\n }\n\n logger.info('sheets.values-search results', { count, select, hasA1s: a1s, hasValues: values });\n\n const result: Output = {\n type: 'success' as const,\n count,\n ...(a1s && a1Array.length > 0 && { a1s: a1Array }),\n ...(values && valuesArray.length > 0 && { values: valuesArray }),\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('sheets.values-search error', { error: message });\n\n throw new McpError(ErrorCode.InternalError, `Error searching spreadsheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-search',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","columnIndexToLetter","index","letter","num","remainder","String","fromCharCode","Math","floor","inputSchema","z","object","id","SpreadsheetIdSchema","gid","SheetGidSchema","query","coerce","string","trim","optional","describe","select","enum","values","boolean","a1s","render","matchCase","successBranchSchema","type","literal","count","number","int","nonnegative","array","union","SheetCellSchema","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetResponse","sheet","sheets","sheetTitle","rowCount","columnCount","endColumn","fullRange","response","res","allRows","searchQuery","a1Array","valuesArray","cellMatches","rowIdx","row","colIdx","cell","colLetter","rowNum","matchingRows","matches","colEnd","headerRow","matchingCols","header","error","message","info","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","properties","sheetId","McpError","ErrorCode","InvalidParams","title","gridProperties","debug","range","valueRenderOption","Array","isArray","toLowerCase","cellValue","includes","length","push","some","max","columnValues","map","undefined","hasA1s","hasValues","content","text","JSON","stringify","structuredContent","Error","InternalError","stack","name"],"mappings":";;;;+BA8MA;;;eAAwBA;;;2BA7MA;qBAMY;0BACb;mBACL;uBACmD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAPrE,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AASR,gEAAgE;AAChE,SAASE,oBAAoBC,KAAa;IACxC,IAAIC,SAAS;IACb,IAAIC,MAAMF,QAAQ;IAClB,MAAOE,MAAM,EAAG;QACd,IAAMC,YAAY,AAACD,CAAAA,MAAM,CAAA,IAAK;QAC9BD,SAASG,O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A;;;;oBAWP;oBAEA1B,OAAO8B,IAAI,CAAC,gCAAgC;wBAAE5C,OAAAA;wBAAOV,QAAAA;wBAAQwF,QAAQpF;wBAAKqF,WAAWvF;oBAAO;oBAEtFmB,SAAiB;wBACrBb,MAAM;wBACNE,OAAAA;uBACIN,OAAOiC,QAAQ4C,MAAM,GAAG,KAAK;wBAAE7E,KAAKiC;oBAAQ,GAC5CnC,UAAUoC,YAAY2C,MAAM,GAAG,KAAK;wBAAE/E,QAAQoC;oBAAY;oBAGhE;;wBAAO;4BACLoD,OAAO;gCAAG;oCAAElF,MAAM;oCAAiBmF,MAAMC,KAAKC,SAAS,CAACxE;gCAAQ;;4BAChEyE,mBAAmB;gCAAEzE,QAAAA;4BAAO;wBAC9B;;;oBACO+B;oBACDC,UAAUD,AAAK,YAALA,OAAiB2C,SAAQ3C,MAAMC,OAAO,GAAGtE,OAAOqE;oBAChE5B,OAAO4B,KAAK,CAAC,8BAA8B;wBAAEA,OAAOC;oBAAQ;oBAE5D,MAAM,IAAIe,eAAQ,CAACC,gBAAS,CAAC2B,aAAa,EAAE,AAAC,gCAAuC,OAAR3C,UAAW;wBACrF4C,OAAO7C,AAAK,YAALA,OAAiB2C,SAAQ3C,MAAM6C,KAAK,GAAGV;oBAChD;;;;;;;IAEJ;;AAEe,SAAShH;IACtB,OAAO;QACL2H,MAAM;QACN/E,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-search.ts"],"sourcesContent":["import { sheets as sheetsApi } from '@googleapis/sheets';\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { CallToolResult, ToolModule } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\nimport { SheetCellSchema, SheetGidSchema, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\n// Helper to convert column index to letter (0 = A, 1 = B, etc.)\nfunction columnIndexToLetter(index: number): string {\n let letter = '';\n let num = index + 1;\n while (num > 0) {\n const remainder = (num - 1) % 26;\n letter = String.fromCharCode(65 + remainder) + letter;\n num = Math.floor((num - 1) / 26);\n }\n return letter;\n}\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n query: z.coerce.string().trim().optional().describe('Text to search for in sheet cells. If empty, returns all data at specified granularity.'),\n select: z.enum(['cells', 'rows', 'columns']).describe('Granularity: cells (individual matches), rows (full matching rows), columns (columns with matching headers)'),\n values: z.boolean().optional().describe('Include cell values in response'),\n a1s: z.boolean().optional().describe('Include A1 notation references in response'),\n render: z.enum(['FORMATTED_VALUE', 'UNFORMATTED_VALUE', 'FORMULA']).optional().describe('How to render cell values. FORMATTED_VALUE (default): calculated with formatting. UNFORMATTED_VALUE: calculated without formatting. FORMULA: show formula text instead of result.'),\n matchCase: z.boolean().optional().describe('Case-sensitive matching. Default is false (case-insensitive).'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n count: z.number().int().nonnegative().describe('Number of matches found'),\n a1s: z.array(z.string()).optional().describe('A1 notation references for matches (e.g., \"B5\", \"A5:D5\", \"B:B\")'),\n values: z\n .array(z.union([z.array(SheetCellSchema), SheetCellSchema]))\n .optional()\n .describe('Cell values for matches (arrays for rows/columns, single values for cells)'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Search spreadsheet and return matches at cell, row, or column granularity. Use a1-notation prompt for range syntax.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, query, select, values = false, a1s = false, render, matchCase = false }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values-search called', { id, gid, query, select, values, a1s, render, matchCase });\n\n try {\n const sheets = sheetsApi({ version: 'v4', auth: googleAuth(extra.authContext.auth) });\n\n // Get sheet details including grid dimensions\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title,sheets.properties.gridProperties',\n });\n\n const sheet = spreadsheetResponse.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n\n if (!sheet) {\n logger.info('sheets.values-search sheet not found', { id, gid, query });\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, 'Sheet not found');\n }\n\n const sheetTitle = sheet.properties?.title ?? '';\n\n // Use actual sheet dimensions from gridProperties, with sensible defaults\n // Google Sheets default for new sheets is 1000 rows x 26 columns\n const rowCount = sheet.properties?.gridProperties?.rowCount ?? 1000;\n const columnCount = sheet.properties?.gridProperties?.columnCount ?? 26;\n const endColumn = columnIndexToLetter(columnCount - 1);\n const fullRange = `${sheetTitle}!A1:${endColumn}${rowCount}`;\n\n logger.debug?.('sheets.values-search fetching range', { fullRange, rowCount, columnCount });\n\n const response = await sheets.spreadsheets.values.get({\n spreadsheetId: id,\n range: fullRange,\n valueRenderOption: render || 'FORMATTED_VALUE',\n });\n const res = response.data;\n const allRows = Array.isArray(res.values) ? (res.values as (string | number | boolean | null)[][]) : [];\n\n // Prepare query for matching (case-insensitive by default)\n const searchQuery = query ? (matchCase ? query : query.toLowerCase()) : null;\n\n let count = 0;\n const a1Array: string[] = [];\n const valuesArray: (string | number | boolean | null | (string | number | boolean | null)[])[] = [];\n\n // Helper to check if a cell matches the query\n const cellMatches = (cell: string | number | boolean | null): boolean => {\n if (!searchQuery) return true; // If no query, match all\n if (typeof cell !== 'string') return false;\n const cellValue = matchCase ? cell : cell.toLowerCase();\n return cellValue.includes(searchQuery);\n };\n\n if (select === 'cells') {\n for (let rowIdx = 0; rowIdx < allRows.length; rowIdx++) {\n const row = allRows[rowIdx];\n if (!row) continue;\n\n for (let colIdx = 0; colIdx < row.length; colIdx++) {\n const cell = row[colIdx];\n if (cellMatches(cell)) {\n count++;\n if (a1s) {\n const colLetter = columnIndexToLetter(colIdx);\n const rowNum = rowIdx + 1;\n a1Array.push(`${colLetter}${rowNum}`);\n }\n if (values) {\n valuesArray.push(cell ?? null);\n }\n }\n }\n }\n } else if (select === 'rows') {\n const matchingRows: number[] = [];\n for (let rowIdx = 0; rowIdx < allRows.length; rowIdx++) {\n const row = allRows[rowIdx];\n if (!row) continue;\n\n const matches = row.some((cell) => cellMatches(cell));\n if (matches) {\n matchingRows.push(rowIdx);\n }\n }\n\n count = matchingRows.length;\n for (const rowIdx of matchingRows) {\n const row = allRows[rowIdx];\n if (!row) continue; // Skip if row is undefined\n const rowNum = rowIdx + 1;\n\n if (a1s) {\n const colEnd = columnIndexToLetter(Math.max(0, row.length - 1));\n a1Array.push(`A${rowNum}:${colEnd}${rowNum}`);\n }\n if (values) {\n valuesArray.push(row);\n }\n }\n } else if (select === 'columns') {\n const headerRow = allRows[0] || [];\n const matchingCols: number[] = [];\n\n for (let colIdx = 0; colIdx < headerRow.length; colIdx++) {\n const header = headerRow[colIdx];\n if (cellMatches(header)) {\n matchingCols.push(colIdx);\n }\n }\n\n count = matchingCols.length;\n for (const colIdx of matchingCols) {\n const colLetter = columnIndexToLetter(colIdx);\n\n if (a1s) {\n a1Array.push(`${colLetter}:${colLetter}`);\n }\n if (values) {\n const columnValues = allRows.map((row) => (row && row[colIdx] !== undefined ? row[colIdx] : null));\n valuesArray.push(columnValues);\n }\n }\n }\n\n logger.info('sheets.values-search results', { count, select, hasA1s: a1s, hasValues: values });\n\n const result: Output = {\n type: 'success' as const,\n count,\n ...(a1s && a1Array.length > 0 && { a1s: a1Array }),\n ...(values && valuesArray.length > 0 && { values: valuesArray }),\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('sheets.values-search error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error searching spreadsheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-search',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","columnIndexToLetter","index","letter","num","remainder","String","fromCharCode","Math","floor","inputSchema","z","object","id","SpreadsheetIdSchema","gid","SheetGidSchema","query","coerce","string","trim","optional","describe","select","enum","values","boolean","a1s","render","matchCase","successBranchSchema","type","literal","count","number","int","nonnegative","array","union","SheetCellSchema","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetResponse","sheet","sheets","sheetTitle","rowCount","columnCount","endColumn","fullRange","response","res","allRows","searchQuery","a1Array","valuesArray","cellMatches","rowIdx","row","colIdx","cell","colLetter","rowNum","matchingRows","matches","colEnd","headerRow","matchingCols","header","error","message","info","sheetsApi","version","auth","googleAuth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","properties","sheetId","ProtocolError","ProtocolErrorCode","InvalidParams","title","gridProperties","debug","range","valueRenderOption","Array","isArray","toLowerCase","cellValue","includes","length","push","some","max","columnValues","map","undefined","hasA1s","hasValues","content","text","JSON","stringify","structuredContent","Error","InternalError","stack","name"],"mappings":";;;;+BA8MA;;;eAAwBA;;;sBA9MY;2BAEZ;sBAKyB;mBAC/B;4BACS;uBAC0C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AANrE,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAQR,gEAAgE;AAChE,SAASE,oBAAoBC,KAAa;IACxC,IAAIC,SAAS;IACb,IAAIC,MAAMF,QAA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AVA,IAAK,aAAgBpC,mCAAhB,8BAAA,SAAA,0BAAA;;4BAAA;4BAAA;;;qCAAA,8BAAA;oCAAA;;;oCAAA;0CAAA;;;;oBAWP;oBAEA1B,OAAO8B,IAAI,CAAC,gCAAgC;wBAAE5C,OAAAA;wBAAOV,QAAAA;wBAAQyF,QAAQrF;wBAAKsF,WAAWxF;oBAAO;oBAEtFmB,SAAiB;wBACrBb,MAAM;wBACNE,OAAAA;uBACIN,OAAOiC,QAAQ6C,MAAM,GAAG,KAAK;wBAAE9E,KAAKiC;oBAAQ,GAC5CnC,UAAUoC,YAAY4C,MAAM,GAAG,KAAK;wBAAEhF,QAAQoC;oBAAY;oBAGhE;;wBAAO;4BACLqD,OAAO;gCAAG;oCAAEnF,MAAM;oCAAiBoF,MAAMC,KAAKC,SAAS,CAACzE;gCAAQ;;4BAChE0E,mBAAmB;gCAAE1E,QAAAA;4BAAO;wBAC9B;;;oBACO+B;oBACDC,UAAUD,AAAK,YAALA,OAAiB4C,SAAQ5C,MAAMC,OAAO,GAAGtE,OAAOqE;oBAChE5B,OAAO4B,KAAK,CAAC,8BAA8B;wBAAEA,OAAOC;oBAAQ;oBAE5D,MAAM,IAAIgB,qBAAa,CAACC,yBAAiB,CAAC2B,aAAa,EAAE,AAAC,gCAAuC,OAAR5C,UAAW;wBAClG6C,OAAO9C,AAAK,YAALA,OAAiB4C,SAAQ5C,MAAM8C,KAAK,GAAGV;oBAChD;;;;;;;IAEJ;;AAEe,SAASjH;IACtB,OAAO;QACL4H,MAAM;QACNhF,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
1
|
import type { RuntimeOverrides, ServerConfig } from '../types.js';
|
|
3
2
|
export declare function createHTTPServer(config: ServerConfig, overrides?: RuntimeOverrides): Promise<{
|
|
4
3
|
httpServer: import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>;
|
|
5
|
-
mcpServer: McpServer;
|
|
6
4
|
logger: import("@mcp-z/server").Logger;
|
|
7
5
|
close: () => Promise<void>;
|
|
8
6
|
}>;
|
package/dist/cjs/setup/http.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
1
|
import type { RuntimeOverrides, ServerConfig } from '../types.js';
|
|
3
2
|
export declare function createHTTPServer(config: ServerConfig, overrides?: RuntimeOverrides): Promise<{
|
|
4
3
|
httpServer: import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>;
|
|
5
|
-
mcpServer: McpServer;
|
|
6
4
|
logger: import("@mcp-z/server").Logger;
|
|
7
5
|
close: () => Promise<void>;
|
|
8
6
|
}>;
|
package/dist/cjs/setup/http.js
CHANGED
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "createHTTPServer", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _server = require("@mcp-z/server");
|
|
12
|
-
var _mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
13
12
|
var _cors = /*#__PURE__*/ _interop_require_default(require("cors"));
|
|
14
13
|
var _express = /*#__PURE__*/ _interop_require_default(require("express"));
|
|
15
14
|
var _runtimets = require("./runtime.js");
|
|
@@ -172,7 +171,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
172
171
|
}
|
|
173
172
|
function createHTTPServer(config, overrides) {
|
|
174
173
|
return _async_to_generator(function() {
|
|
175
|
-
var runtime, modules, layers, composed, logger, port, tools, prompts,
|
|
174
|
+
var runtime, modules, layers, composed, logger, port, tools, prompts, buildServer, app, publicUrl, _ref, close, httpServer;
|
|
176
175
|
return _ts_generator(this, function(_state) {
|
|
177
176
|
switch(_state.label){
|
|
178
177
|
case 0:
|
|
@@ -192,13 +191,22 @@ function createHTTPServer(config, overrides) {
|
|
|
192
191
|
if (!port) throw new Error('Port is required for HTTP transport');
|
|
193
192
|
tools = _to_consumable_array(composed.tools).concat(_to_consumable_array(runtime.deps.oauthAdapters.accountTools));
|
|
194
193
|
prompts = _to_consumable_array(composed.prompts).concat(_to_consumable_array(runtime.deps.oauthAdapters.accountPrompts));
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
(
|
|
200
|
-
|
|
201
|
-
|
|
194
|
+
// Built per request (HTTP) and per connection (stdio), not shared. The SDK caches the
|
|
195
|
+
// negotiated protocol revision on the McpServer instance - its own docs say a negotiated
|
|
196
|
+
// session never re-routes a method onto the other era - so one shared instance pins itself
|
|
197
|
+
// to whichever revision reaches it first and answers the other with -32601.
|
|
198
|
+
buildServer = function buildServer() {
|
|
199
|
+
var mcpServer = new _server.McpServer({
|
|
200
|
+
name: config.name,
|
|
201
|
+
version: config.version
|
|
202
|
+
}, {
|
|
203
|
+
cacheHints: _server.defaultCacheHints
|
|
204
|
+
});
|
|
205
|
+
(0, _server.registerTools)(mcpServer, tools);
|
|
206
|
+
(0, _server.registerResources)(mcpServer, composed.resources);
|
|
207
|
+
(0, _server.registerPrompts)(mcpServer, prompts);
|
|
208
|
+
return mcpServer;
|
|
209
|
+
};
|
|
202
210
|
app = (0, _express.default)();
|
|
203
211
|
app.use(_express.default.json({
|
|
204
212
|
limit: '10mb'
|
|
@@ -209,7 +217,7 @@ function createHTTPServer(config, overrides) {
|
|
|
209
217
|
logger.info("Starting ".concat(config.name, " MCP server (http)"));
|
|
210
218
|
return [
|
|
211
219
|
4,
|
|
212
|
-
(0, _server.connectHttp)(
|
|
220
|
+
(0, _server.connectHttp)(buildServer, {
|
|
213
221
|
logger: logger,
|
|
214
222
|
app: app,
|
|
215
223
|
port: port,
|
|
@@ -239,7 +247,6 @@ function createHTTPServer(config, overrides) {
|
|
|
239
247
|
2,
|
|
240
248
|
{
|
|
241
249
|
httpServer: httpServer,
|
|
242
|
-
mcpServer: mcpServer,
|
|
243
250
|
logger: logger,
|
|
244
251
|
close: function close1() {
|
|
245
252
|
return _async_to_generator(function() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/http.ts"],"sourcesContent":["import { composeMiddleware, connectHttp, registerPrompts, registerResources, registerTools } from '@mcp-z/server';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/setup/http.ts"],"sourcesContent":["import { composeMiddleware, connectHttp, defaultCacheHints, McpServer, registerPrompts, registerResources, registerTools } from '@mcp-z/server';\nimport cors from 'cors';\nimport express from 'express';\nimport type { RuntimeOverrides, ServerConfig } from '../types.ts';\nimport { createDefaultRuntime } from './runtime.ts';\n\nexport async function createHTTPServer(config: ServerConfig, overrides?: RuntimeOverrides) {\n const runtime = await createDefaultRuntime(config, overrides);\n const modules = runtime.createDomainModules();\n const layers = runtime.middlewareFactories.map((factory) => factory(runtime.deps));\n const composed = composeMiddleware(modules, layers);\n const logger = runtime.deps.logger;\n const port = config.transport.port;\n if (!port) throw new Error('Port is required for HTTP transport');\n\n const tools = [...composed.tools, ...runtime.deps.oauthAdapters.accountTools];\n const prompts = [...composed.prompts, ...runtime.deps.oauthAdapters.accountPrompts];\n\n // Built per request (HTTP) and per connection (stdio), not shared. The SDK caches the\n // negotiated protocol revision on the McpServer instance - its own docs say a negotiated\n // session never re-routes a method onto the other era - so one shared instance pins itself\n // to whichever revision reaches it first and answers the other with -32601.\n const buildServer = () => {\n const mcpServer = new McpServer({ name: config.name, version: config.version }, { cacheHints: defaultCacheHints });\n registerTools(mcpServer, tools);\n registerResources(mcpServer, composed.resources);\n registerPrompts(mcpServer, prompts);\n return mcpServer;\n };\n\n const app = express();\n app.use(express.json({ limit: '10mb' }));\n\n // Must mount '/mcp' before any permissive app-level cors(), or that layer answers its\n // preflight first; pass baseUrl's origin/host below or a public deployment 403s itself.\n const publicUrl = config.baseUrl ? new URL(config.baseUrl) : undefined;\n logger.info(`Starting ${config.name} MCP server (http)`);\n const { close, httpServer } = await connectHttp(buildServer, {\n logger,\n app,\n port,\n allowedOrigins: publicUrl ? [publicUrl.origin] : undefined,\n allowedHosts: publicUrl ? [publicUrl.host] : undefined,\n });\n\n // The loopback OAuth callback and the DCR discovery/registration endpoints are\n // meant to be reached from a browser on another origin. Keep cors() for them,\n // scoped to their own routes - never in front of '/mcp'.\n if (runtime.deps.oauthAdapters.loopbackRouter) {\n app.use('/', cors(), runtime.deps.oauthAdapters.loopbackRouter);\n logger.info('Mounted loopback OAuth callback router');\n }\n\n if (runtime.deps.oauthAdapters.dcrRouter) {\n app.use('/', cors(), runtime.deps.oauthAdapters.dcrRouter);\n logger.info('Mounted DCR router with OAuth endpoints');\n }\n\n logger.info('http transport ready');\n\n return {\n httpServer,\n logger,\n close: async () => {\n await close();\n await runtime.close();\n },\n };\n}\n"],"names":["createHTTPServer","config","overrides","runtime","modules","layers","composed","logger","port","tools","prompts","buildServer","app","publicUrl","close","httpServer","createDefaultRuntime","createDomainModules","middlewareFactories","map","factory","deps","composeMiddleware","transport","Error","oauthAdapters","accountTools","accountPrompts","mcpServer","McpServer","name","version","cacheHints","defaultCacheHints","registerTools","registerResources","resources","registerPrompts","express","use","json","limit","baseUrl","URL","undefined","info","connectHttp","allowedOrigins","origin","allowedHosts","host","loopbackRouter","cors","dcrRouter"],"mappings":";;;;+BAMsBA;;;eAAAA;;;sBAN0G;2DAC/G;8DACG;yBAEiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9B,SAAeA,iBAAiBC,MAAoB,EAAEC,SAA4B;;YACjFC,SACAC,SACAC,QACAC,UACAC,QACAC,MAGAC,OACAC,SAMAC,aAQAC,KAKAC,WAEwB,MAAtB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,EAAC;oBACN;;wBAAMgB,IAAAA,mBAAW,EAACnC,aAAa;4BAC3DJ,QAAAA;4BACAK,KAAAA;4BACAJ,MAAAA;4BACAuC,gBAAgBlC;gCAAaA,UAAUmC,MAAM;gCAAIJ;4BACjDK,cAAcpC;gCAAaA,UAAUqC,IAAI;gCAAIN;wBAC/C;;;oBAN8B,OAAA,eAAtB9B,QAAsB,KAAtBA,OAAOC,aAAe,KAAfA;oBAQf,+EAA+E;oBAC/E,8EAA8E;oBAC9E,yDAAyD;oBACzD,IAAIZ,QAAQkB,IAAI,CAACI,aAAa,CAAC0B,cAAc,EAAE;wBAC7CvC,IAAI2B,GAAG,CAAC,KAAKa,IAAAA,aAAI,KAAIjD,QAAQkB,IAAI,CAACI,aAAa,CAAC0B,cAAc;wBAC9D5C,OAAOsC,IAAI,CAAC;oBACd;oBAEA,IAAI1C,QAAQkB,IAAI,CAACI,aAAa,CAAC4B,SAAS,EAAE;wBACxCzC,IAAI2B,GAAG,CAAC,KAAKa,IAAAA,aAAI,KAAIjD,QAAQkB,IAAI,CAACI,aAAa,CAAC4B,SAAS;wBACzD9C,OAAOsC,IAAI,CAAC;oBACd;oBAEAtC,OAAOsC,IAAI,CAAC;oBAEZ;;wBAAO;4BACL9B,YAAAA;4BACAR,QAAAA;4BACAO,OAAO,SAAPA;;;;;gDACE;;oDAAMA;;;gDAAN;gDACA;;oDAAMX,QAAQW,KAAK;;;gDAAnB;;;;;;gCACF;;wBACF;;;;IACF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
1
|
import type { RuntimeOverrides, ServerConfig } from '../types.js';
|
|
3
2
|
export declare function createStdioServer(config: ServerConfig, overrides?: RuntimeOverrides): Promise<{
|
|
4
|
-
mcpServer: McpServer;
|
|
5
3
|
logger: import("@mcp-z/server").Logger;
|
|
6
4
|
close: () => Promise<void>;
|
|
7
5
|
}>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
1
|
import type { RuntimeOverrides, ServerConfig } from '../types.js';
|
|
3
2
|
export declare function createStdioServer(config: ServerConfig, overrides?: RuntimeOverrides): Promise<{
|
|
4
|
-
mcpServer: McpServer;
|
|
5
3
|
logger: import("@mcp-z/server").Logger;
|
|
6
4
|
close: () => Promise<void>;
|
|
7
5
|
}>;
|