@mcp-z/mcp-sheets 1.2.2 → 2.0.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/README.md +5 -1
- package/dist/cjs/index.js.map +1 -1
- 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 +2 -2
- 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 +3 -3
- 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 +7 -7
- 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 +3 -3
- 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 +4 -4
- 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 +8 -8
- 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 +6 -6
- 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 +3 -3
- 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 +7 -7
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +3 -3
- 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 +2 -2
- 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 +3 -3
- 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 +4 -4
- 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 +2 -2
- 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 +3 -3
- 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 +2 -2
- 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 +2 -2
- 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 +4 -4
- 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 +5 -5
- 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 +3 -3
- 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 +4 -4
- 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 +5 -5
- 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 +5 -5
- 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 +3 -3
- package/dist/cjs/mcp/tools/values-search.js.map +1 -1
- package/dist/cjs/setup/http.d.cts +1 -1
- package/dist/cjs/setup/http.d.ts +1 -1
- package/dist/cjs/setup/http.js +23 -13
- package/dist/cjs/setup/http.js.map +1 -1
- package/dist/cjs/setup/stdio.d.cts +1 -1
- package/dist/cjs/setup/stdio.d.ts +1 -1
- package/dist/cjs/setup/stdio.js +1 -2
- package/dist/cjs/setup/stdio.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- 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 +1 -1
- 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 +3 -3
- 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 +7 -7
- 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 +3 -3
- 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 +4 -4
- 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 +8 -8
- 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 +6 -6
- 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 +3 -3
- 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 +7 -7
- 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 +4 -4
- 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 +4 -4
- 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 +4 -4
- 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 +3 -3
- 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 +2 -2
- 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 +3 -3
- 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 +4 -4
- 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 +2 -2
- 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 +3 -3
- 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 +2 -2
- 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 +2 -2
- 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 +4 -4
- 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 +5 -5
- 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 +3 -3
- 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 +4 -4
- 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 +5 -5
- 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 +5 -5
- 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 +3 -3
- package/dist/esm/mcp/tools/values-search.js.map +1 -1
- package/dist/esm/setup/http.d.ts +1 -1
- package/dist/esm/setup/http.js +21 -11
- package/dist/esm/setup/http.js.map +1 -1
- package/dist/esm/setup/stdio.d.ts +1 -1
- package/dist/esm/setup/stdio.js +1 -2
- package/dist/esm/setup/stdio.js.map +1 -1
- package/package.json +7 -13
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
12
|
+
var _server = require("@mcp-z/server");
|
|
13
13
|
var _googleapis = require("googleapis");
|
|
14
14
|
var _zod = require("zod");
|
|
15
15
|
var _indexts = require("../../schemas/index.js");
|
|
@@ -307,7 +307,7 @@ function handler(_0, _1) {
|
|
|
307
307
|
logger.error('sheets.spreadsheet.find error', {
|
|
308
308
|
error: message
|
|
309
309
|
});
|
|
310
|
-
throw new
|
|
310
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error finding spreadsheet: ".concat(message), {
|
|
311
311
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
312
312
|
});
|
|
313
313
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/spreadsheet-find.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
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/spreadsheet-find.ts"],"sourcesContent":["import 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 { google } from 'googleapis';\nimport { z } from 'zod';\nimport { SheetGidOutput, SpreadsheetIdOutput, SpreadsheetRefSchema } from '../../schemas/index.ts';\nimport { findSpreadsheetsByRef } from '../../spreadsheet/spreadsheet-management.ts';\n\n/** Spreadsheet match result from findSpreadsheetsByRef */\ninterface SpreadsheetMatch {\n id: string;\n spreadsheetTitle: string | undefined;\n url: string | undefined;\n modifiedTime: string | null | undefined;\n}\n\nconst inputSchema = z.object({\n spreadsheetRef: SpreadsheetRefSchema,\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n items: z\n .array(\n z.object({\n id: SpreadsheetIdOutput,\n spreadsheetTitle: z.string().describe('Name of the spreadsheet'),\n spreadsheetUrl: z.string().optional().describe('URL to view the spreadsheet'),\n modifiedTime: z.string().optional().describe('Last modified timestamp (ISO format)'),\n sheets: z\n .array(\n z.object({\n gid: SheetGidOutput,\n sheetTitle: z.string().describe('Sheet tab name'),\n })\n )\n .describe('All sheets/tabs in this spreadsheet'),\n })\n )\n .describe('Matching spreadsheets sorted by modification time'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Find spreadsheet by ID, URL, or name. Returns all sheets/tabs in response.',\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({ spreadsheetRef }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.spreadsheet.find called', { spreadsheetRef });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n const drive = google.drive({ version: 'v3', auth: extra.authContext.auth });\n\n const matches = (await findSpreadsheetsByRef(sheets, drive, spreadsheetRef)) as SpreadsheetMatch[];\n\n const sorted = (matches || []).slice().sort((a: SpreadsheetMatch, b: SpreadsheetMatch) => (b.modifiedTime ? new Date(b.modifiedTime).getTime() : 0) - (a.modifiedTime ? new Date(a.modifiedTime).getTime() : 0));\n\n const items = await Promise.all(\n sorted.map(async (m: SpreadsheetMatch) => {\n // Fetch sheet metadata for each spreadsheet\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: m.id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n const sheetsData = (spreadsheetResponse.data.sheets || []).map((sheet) => {\n const gid = String(sheet.properties?.sheetId ?? '');\n return {\n gid,\n sheetTitle: sheet.properties?.title ?? '',\n };\n });\n\n return {\n id: m.id,\n spreadsheetTitle: m.spreadsheetTitle ?? '',\n sheets: sheetsData,\n ...(m.url && { spreadsheetUrl: m.url }),\n ...(m.modifiedTime && { modifiedTime: m.modifiedTime }),\n };\n })\n );\n\n logger.info('sheets.spreadsheet.find success', { count: items.length });\n\n const result: Output = {\n type: 'success' as const,\n items,\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.spreadsheet.find error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error finding spreadsheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'spreadsheet-find',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","inputSchema","z","object","spreadsheetRef","SpreadsheetRefSchema","successBranchSchema","type","literal","items","array","id","SpreadsheetIdOutput","spreadsheetTitle","string","describe","spreadsheetUrl","optional","modifiedTime","sheets","gid","SheetGidOutput","sheetTitle","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","drive","matches","sorted","error","message","info","google","version","auth","authContext","findSpreadsheetsByRef","slice","sort","a","b","Date","getTime","Promise","all","map","m","spreadsheetResponse","sheetsData","spreadsheets","get","spreadsheetId","fields","data","sheet","String","properties","sheetId","title","url","count","length","content","text","JSON","stringify","structuredContent","Error","ProtocolError","ProtocolErrorCode","InternalError","stack","undefined","name"],"mappings":";;;;+BAsHA;;;eAAwBA;;;2BArHA;sBAKyB;0BAC1B;mBACL;uBACwD;uCACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAPtC,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAiBR,IAAME,cAAcC,MAAC,CAACC,MAAM,CAAC;IAC3BC,gBAAgBC,6BAAoB;AACtC;AAEA,IAAMC,sBAAsBJ,MAAC,CAACC,MAAM,CAAC;IACnCI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MAAM;wBACNE,OAAAA;oBACF;oBAEA;;wBAAO;4BACL0D,OAAO;gCAAG;oCAAE5D,MAAM;oCAAiB6D,MAAMC,KAAKC,SAAS,CAAC3C;gCAAQ;;4BAChE4C,mBAAmB;gCAAE5C,QAAAA;4BAAO;wBAC9B;;;oBACOO;oBACDC,UAAUD,AAAK,YAALA,OAAiBsC,SAAQtC,MAAMC,OAAO,GAAGyB,OAAO1B;oBAChEJ,OAAOI,KAAK,CAAC,iCAAiC;wBAAEA,OAAOC;oBAAQ;oBAE/D,MAAM,IAAIsC,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE,AAAC,8BAAqC,OAARxC,UAAW;wBAChGyC,OAAO1C,AAAK,YAALA,OAAiBsC,SAAQtC,MAAM0C,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAAS/E;IACtB,OAAO;QACLgF,MAAM;QACNrD,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;
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
12
|
+
var _server = require("@mcp-z/server");
|
|
13
13
|
var _googleapis = require("googleapis");
|
|
14
14
|
var _zod = require("zod");
|
|
15
15
|
var _indexts = require("../../schemas/index.js");
|
|
@@ -264,7 +264,7 @@ function handler(_0, _1) {
|
|
|
264
264
|
logger.error('sheets.spreadsheet.rename error', {
|
|
265
265
|
error: message
|
|
266
266
|
});
|
|
267
|
-
throw new
|
|
267
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error renaming spreadsheet: ".concat(message), {
|
|
268
268
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
269
269
|
});
|
|
270
270
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/spreadsheet-rename.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
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/spreadsheet-rename.ts"],"sourcesContent":["import 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 { google } from 'googleapis';\nimport { z } from 'zod';\nimport { SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n newTitle: z.coerce.string().trim().min(1).describe('New name for the spreadsheet'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Summary of the rename operation'),\n itemsProcessed: z.number().describe('Total items attempted (always 1)'),\n itemsChanged: z.number().describe('Successfully renamed (always 1 on success)'),\n completedAt: z.string().describe('ISO datetime when operation completed'),\n id: SpreadsheetIdOutput,\n spreadsheetUrl: z.string().describe('URL of the renamed spreadsheet'),\n oldTitle: z.string().describe('Previous title of the spreadsheet'),\n newTitle: z.string().describe('New title of the spreadsheet'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Rename a spreadsheet/workbook (the entire document, not individual sheets/tabs)',\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, newTitle }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.spreadsheet.rename called', { id, newTitle });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // First, get the current spreadsheet title\n const spreadsheetInfo = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'properties.title',\n });\n\n const oldTitle = spreadsheetInfo.data.properties?.title || '';\n\n // Rename the spreadsheet\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: [\n {\n updateSpreadsheetProperties: {\n properties: { title: newTitle },\n fields: 'title',\n },\n },\n ],\n },\n });\n\n logger.info('sheets.spreadsheet.rename success', { id, oldTitle, newTitle });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Renamed spreadsheet \"${oldTitle}\" to \"${newTitle}\"`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n id,\n spreadsheetUrl: `https://docs.google.com/spreadsheets/d/${id}`,\n oldTitle,\n newTitle,\n };\n\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result),\n },\n ],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('sheets.spreadsheet.rename error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error renaming spreadsheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'spreadsheet-rename',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","inputSchema","z","object","id","SpreadsheetIdSchema","newTitle","coerce","string","trim","min","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","SpreadsheetIdOutput","spreadsheetUrl","oldTitle","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetInfo","sheets","error","message","info","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","batchUpdate","requestBody","requests","updateSpreadsheetProperties","Date","toISOString","content","text","JSON","stringify","structuredContent","Error","String","ProtocolError","ProtocolErrorCode","InternalError","stack","undefined","name"],"mappings":";;;;+BA0GA;;;eAAwBA;;;2BAzGA;sBAKyB;0BAC1B;mBACL;uBACuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AANzD,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAQR,IAAME,cAAcC,MAAC,CAACC,MAAM,CAAC;IAC3BC,IAAIC,4BAAmB;IACvBC,UAAUJ,MAAC,CAACK,MAAM,CAACC,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;AACrD;AAEA,wBAAwB;AACxB,IAAMC,sBAAsBV,MAAC,CAACC,MAAM,CAAC;IACnCU,MAAMX,MAAC,CAACY,OAAO,CAAC;IAChBC,kBAAkBb,MAAC,CAACM,MAAM,GAAGG,QAAQ,CAAC;IACtCK,gBAAgBd,MAAC,CAACe,MAAM,GAAGN,QAAQ,CAAC;IACpCO,cAAchB,MAAC,CAACe,MAAM,GAAGN,QAAQ,CAAC;IAClCQ,aAAajB,MAAC,CA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ACF;;4BAEJ;wBACF;;;oBAZA;oBAcAb,OAAOK,IAAI,CAAC,qCAAqC;wBAAE/B,IAAAA;wBAAIkB,UAAAA;wBAAUhB,UAAAA;oBAAS;oBAEpEqB,SAAiB;wBACrBd,MAAM;wBACNE,kBAAkB,AAAC,wBAAwCT,OAAjBgB,UAAS,UAAiB,OAAThB,UAAS;wBACpEU,gBAAgB;wBAChBE,cAAc;wBACdC,aAAa,IAAIgC,OAAOC,WAAW;wBACnChD,IAAAA;wBACAiB,gBAAgB,AAAC,0CAA4C,OAAHjB;wBAC1DkB,UAAAA;wBACAhB,UAAAA;oBACF;oBAEA;;wBAAO;4BACL+C,OAAO;gCACL;oCACExC,MAAM;oCACNyC,MAAMC,KAAKC,SAAS,CAAC7B;gCACvB;;4BAEF8B,mBAAmB;gCAAE9B,QAAAA;4BAAO;wBAC9B;;;oBACOM;oBACDC,UAAUD,AAAK,YAALA,OAAiByB,SAAQzB,MAAMC,OAAO,GAAGyB,OAAO1B;oBAChEH,OAAOG,KAAK,CAAC,mCAAmC;wBAAEA,OAAOC;oBAAQ;oBAEjE,MAAM,IAAI0B,qBAAa,CAACC,yBAAiB,CAACC,aAAa,EAAE,AAAC,+BAAsC,OAAR5B,UAAW;wBACjG6B,OAAO9B,AAAK,YAALA,OAAiByB,SAAQzB,MAAM8B,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAASlE;IACtB,OAAO;QACLmE,MAAM;QACNxC,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;
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
12
|
+
var _server = require("@mcp-z/server");
|
|
13
13
|
var _googleapis = require("googleapis");
|
|
14
14
|
var _zod = require("zod");
|
|
15
15
|
var _indexts = require("../../schemas/index.js");
|
|
@@ -392,7 +392,7 @@ function handler(_0, _1) {
|
|
|
392
392
|
gid: gid,
|
|
393
393
|
requestCount: requests.length
|
|
394
394
|
});
|
|
395
|
-
throw new
|
|
395
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Sheet not found: ".concat(gid));
|
|
396
396
|
}
|
|
397
397
|
sheetTitle = (_sheet_properties_title = sheet.properties.title) !== null && _sheet_properties_title !== void 0 ? _sheet_properties_title : gid;
|
|
398
398
|
sheetId = sheet.properties.sheetId;
|
|
@@ -404,7 +404,7 @@ function handler(_0, _1) {
|
|
|
404
404
|
gid: gid,
|
|
405
405
|
sheetTitle: sheetTitle
|
|
406
406
|
});
|
|
407
|
-
throw new
|
|
407
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Sheet ID not available for ".concat(gid, ". Cannot perform validation operations without valid sheet ID."));
|
|
408
408
|
}
|
|
409
409
|
// Build batch update requests
|
|
410
410
|
batchRequests = [];
|
|
@@ -539,7 +539,7 @@ function handler(_0, _1) {
|
|
|
539
539
|
requestCount: requests.length,
|
|
540
540
|
error: message1
|
|
541
541
|
});
|
|
542
|
-
throw new
|
|
542
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error setting validation: ".concat(message1), {
|
|
543
543
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
544
544
|
});
|
|
545
545
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/validation-set.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 { parseA1Notation, rangeReferenceToGridRange } from '../../spreadsheet/range-operations.ts';\n\n// Discriminated union for validation rule types\nconst ValidationRuleSchema = z.discriminatedUnion('conditionType', [\n // Dropdown with hardcoded list\n z.object({\n conditionType: z.literal('ONE_OF_LIST'),\n values: z.array(z.string()).min(1).describe('Hardcoded dropdown options'),\n showDropdown: z.boolean().default(true).describe('Show dropdown UI in cells'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Dropdown from range\n z.object({\n conditionType: z.literal('ONE_OF_RANGE'),\n sourceRange: z.string().min(1).describe('A1 notation range containing dropdown options (e.g., \"Options!A1:A10\")'),\n showDropdown: z.boolean().default(true).describe('Show dropdown UI in cells'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Numeric constraints\n z.object({\n conditionType: z.enum(['NUMBER_GREATER', 'NUMBER_LESS', 'NUMBER_BETWEEN']),\n values: z.array(z.number()).min(1).max(2).describe('1 value for GREATER/LESS, 2 values for BETWEEN'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Text constraints\n z.object({\n conditionType: z.enum(['TEXT_CONTAINS', 'TEXT_IS_EMAIL', 'TEXT_IS_URL']),\n values: z.array(z.string()).optional().describe('Text to match (for TEXT_CONTAINS only)'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Date constraints\n z.object({\n conditionType: z.enum(['DATE_AFTER', 'DATE_BEFORE', 'DATE_BETWEEN']),\n values: z.array(z.string()).min(1).max(2).describe('ISO date strings (YYYY-MM-DD)'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Custom formula\n z.object({\n conditionType: z.literal('CUSTOM_FORMULA'),\n formula: z.string().min(1).describe('Custom validation formula (e.g., \"=A1>0\")'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n]);\n\n// Input schema for validation requests\nconst ValidationRequestSchema = z.object({\n range: z.string().min(1).describe('A1 notation range for validation (e.g., \"B2:B100\")'),\n rule: ValidationRuleSchema,\n inputMessage: z.string().optional().describe('Help text shown when cell is selected'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(ValidationRequestSchema).min(1).max(50).describe('Array of validation rules. Batch multiple ranges 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 sheet with validation'),\n sheetUrl: z.string().describe('URL of the sheet with validation'),\n successCount: z.number().int().nonnegative().describe('Number of validation rules successfully applied'),\n failedRanges: z\n .array(\n z.object({\n range: z.string().describe('A1 notation of range that failed validation setup'),\n error: z.string().describe('Why validation failed for this range'),\n })\n )\n .optional()\n .describe('Only populated if some validation rules failed'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Add data validation rules including dropdowns, numeric constraints, text patterns, date ranges, custom formulas. Supports batch operations for efficiency. Use discriminated conditionType to specify rule type. Best for enforcing data integrity and providing user-friendly input controls.',\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\n// Map condition types to Google Sheets API format\nfunction buildCondition(rule: z.infer<typeof ValidationRuleSchema>) {\n switch (rule.conditionType) {\n case 'ONE_OF_LIST':\n return {\n type: 'ONE_OF_LIST',\n values: rule.values.map((value) => ({ userEnteredValue: value })),\n };\n case 'ONE_OF_RANGE':\n return {\n type: 'ONE_OF_RANGE',\n values: [{ userEnteredValue: `=${rule.sourceRange}` }],\n };\n case 'NUMBER_GREATER':\n return {\n type: 'NUMBER_GREATER',\n values: [{ userEnteredValue: String(rule.values[0]) }],\n };\n case 'NUMBER_LESS':\n return {\n type: 'NUMBER_LESS',\n values: [{ userEnteredValue: String(rule.values[0]) }],\n };\n case 'NUMBER_BETWEEN':\n return {\n type: 'NUMBER_BETWEEN',\n values: [{ userEnteredValue: String(rule.values[0]) }, { userEnteredValue: String(rule.values[1]) }],\n };\n case 'TEXT_CONTAINS':\n return {\n type: 'TEXT_CONTAINS',\n values: rule.values ? [{ userEnteredValue: rule.values[0] }] : [],\n };\n case 'TEXT_IS_EMAIL':\n return {\n type: 'TEXT_IS_EMAIL',\n values: [],\n };\n case 'TEXT_IS_URL':\n return {\n type: 'TEXT_IS_URL',\n values: [],\n };\n case 'DATE_AFTER':\n return {\n type: 'DATE_AFTER',\n values: [{ userEnteredValue: rule.values[0] }],\n };\n case 'DATE_BEFORE':\n return {\n type: 'DATE_BEFORE',\n values: [{ userEnteredValue: rule.values[0] }],\n };\n case 'DATE_BETWEEN':\n return {\n type: 'DATE_BETWEEN',\n values: [{ userEnteredValue: rule.values[0] }, { userEnteredValue: rule.values[1] }],\n };\n case 'CUSTOM_FORMULA':\n return {\n type: 'CUSTOM_FORMULA',\n values: [{ userEnteredValue: rule.formula.startsWith('=') ? rule.formula : `=${rule.formula}` }],\n };\n default:\n // Exhaustive check - all valid conditionType values should be handled above\n throw new Error(`Unknown condition type: ${(rule as { conditionType: string }).conditionType}`);\n }\n}\n\nasync function handler({ id, gid, requests }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.validation.set 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 validation set', { 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 const sheetId = sheet.properties.sheetId;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetId}`;\n\n // Validate sheetId exists\n if (sheetId === undefined || sheetId === null) {\n logger.error('Sheet ID not available for validation set', { id, gid, sheetTitle });\n throw new McpError(ErrorCode.InternalError, `Sheet ID not available for ${gid}. Cannot perform validation operations without valid sheet ID.`);\n }\n\n // Build batch update requests\n const batchRequests: sheets_v4.Schema$Request[] = [];\n const failedRanges: Array<{ range: string; error: string }> = [];\n\n for (const request of requests) {\n try {\n // Parse A1 notation to range reference\n const rangeRef = parseA1Notation(request.range);\n\n // Build grid range from range reference using helper function\n const gridRange = rangeReferenceToGridRange(rangeRef, sheetId);\n\n // Build validation rule\n const condition = buildCondition(request.rule);\n\n // Build data validation rule - structure matches Schema$DataValidationRule\n const dataValidationRule = {\n condition,\n strict: request.rule.strict,\n showCustomUi: 'showDropdown' in request.rule ? request.rule.showDropdown : undefined,\n inputMessage: request.inputMessage,\n } as sheets_v4.Schema$DataValidationRule;\n\n // Add setDataValidation request\n batchRequests.push({\n setDataValidation: {\n range: gridRange,\n rule: dataValidationRule,\n },\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.info('Failed to build validation rule', {\n range: request.range,\n error: message,\n });\n failedRanges.push({\n range: request.range,\n error: `Failed to build validation rule: ${message}`,\n });\n }\n }\n\n // Early return if all ranges 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 failedRanges: failedRanges.length > 0 ? failedRanges : 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.validation.set 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.validation.set completed successfully', {\n successCount: requests.length - failedRanges.length,\n failedCount: failedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: requests.length - failedRanges.length,\n failedRanges: failedRanges.length > 0 ? failedRanges : undefined,\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('Validation set operation failed', {\n id,\n gid,\n requestCount: requests.length,\n error: message,\n });\n\n throw new McpError(ErrorCode.InternalError, `Error setting validation: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'validation-set',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","ValidationRuleSchema","z","discriminatedUnion","object","conditionType","literal","values","array","string","min","describe","showDropdown","boolean","default","strict","sourceRange","enum","number","max","optional","formula","ValidationRequestSchema","range","rule","inputMessage","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","successBranchSchema","type","SpreadsheetIdOutput","SheetGidOutput","sheetTitle","sheetUrl","successCount","int","nonnegative","failedRanges","error","outputSchema","config","description","result","buildCondition","map","value","userEnteredValue","String","startsWith","Error","handler","extra","logger","sheet","spreadsheetResponse","sheets","sheetId","batchRequests","request","rangeRef","gridRange","condition","dataValidationRule","message","info","requestCount","length","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","properties","McpError","ErrorCode","InvalidParams","title","undefined","InternalError","parseA1Notation","rangeReferenceToGridRange","showCustomUi","push","setDataValidation","content","text","JSON","stringify","structuredContent","batchRequestsCount","batchUpdate","requestBody","failedCount","stack","name"],"mappings":";;;;+BAuTA;;;eAAwBA;;;2BAtTA;qBAMY;0BACG;mBACrB;uBACuE;iCAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAR3D,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAUR,gDAAgD;AAChD,IAAME,uBAAuBC,MAAC,CAACC,kBAAkB,CAAC,iBAAiB;IACjE,+BAA+B;IAC/BD,MAAC,CAACE,MAAM,CAAC;QACPC,eAAeH,MAAC,CAACI,OAAO,CAAC;QACzBC,QAAQL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACO,MAAM,IAAIC,GAAG,CAAC,GAAGC,QAAQ,CAAC;QAC5CC,cAAcV,MAAC,CAACW,OAAO,GAAGC,OAAO,CAAC,MAAMH,QAAQ,CAAC;QACjDI,QAAQb,MAAC,CAACW,OAAO,GAAGC,OAAO,CAAC,MAAMH,QAAQ,CAAC;IAC7C;IACA,sBAAsB;IACtBT,MAAC,CAACE,MAAM,CAAC;QACPC,eAAeH,MAAC,CAACI,OAAO,CAAC;QACzBU,aAAad,MAAC,CAACO,MAAM,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;QACxCC,cAAcV,MAAC,CAACW,OAAO,GAAGC,OAAO,CAAC,MAAMH,Q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W,CAAC;4BACpCvB,eAAelD;4BACf0E,aAAa;gCACXtE,UAAU8B;4BACZ;wBACF;;;oBALA;oBAOAL,OAAOY,IAAI,CAAC,gDAAgD;wBAC1D9B,cAAcP,SAASuC,MAAM,GAAG7B,aAAa6B,MAAM;wBACnDgC,aAAa7D,aAAa6B,MAAM;oBAClC;oBAEMxB,UAAiB;wBACrBb,MAAM;wBACNN,IAAAA;wBACAE,KAAKsB,OAAOS;wBACZxB,YAAAA;wBACAC,UAAAA;wBACAC,cAAcP,SAASuC,MAAM,GAAG7B,aAAa6B,MAAM;wBACnD7B,cAAcA,aAAa6B,MAAM,GAAG,IAAI7B,eAAe8C;oBACzD;oBAEA;;wBAAO;4BACLO,OAAO;gCAAG;oCAAE7D,MAAM;oCAAiB8D,MAAMC,KAAKC,SAAS,CAACnD;gCAAQ;;4BAChEoD,mBAAmB;gCAAEpD,QAAAA;4BAAO;wBAC9B;;;oBACOJ;oBACDyB,WAAUzB,AAAK,YAALA,OAAiBW,SAAQX,MAAMyB,OAAO,GAAGhB,OAAOT;oBAChEc,OAAOd,KAAK,CAAC,mCAAmC;wBAC9Cf,IAAAA;wBACAE,KAAAA;wBACAwC,cAActC,SAASuC,MAAM;wBAC7B5B,OAAOyB;oBACT;oBAEA,MAAM,IAAIgB,eAAQ,CAACC,gBAAS,CAACI,aAAa,EAAE,AAAC,6BAAoC,OAARrB,WAAW;wBAClFoC,OAAO7D,AAAK,YAALA,OAAiBW,SAAQX,MAAM6D,KAAK,GAAGhB;oBAChD;;;;;;;IAEJ;;AAEe,SAASzF;IACtB,OAAO;QACL0G,MAAM;QACN5D,QAAAA;QACAU,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/validation-set.ts"],"sourcesContent":["import 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 { google, type sheets_v4 } from 'googleapis';\nimport { z } from 'zod';\nimport { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { parseA1Notation, rangeReferenceToGridRange } from '../../spreadsheet/range-operations.ts';\n\n// Discriminated union for validation rule types\nconst ValidationRuleSchema = z.discriminatedUnion('conditionType', [\n // Dropdown with hardcoded list\n z.object({\n conditionType: z.literal('ONE_OF_LIST'),\n values: z.array(z.string()).min(1).describe('Hardcoded dropdown options'),\n showDropdown: z.boolean().default(true).describe('Show dropdown UI in cells'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Dropdown from range\n z.object({\n conditionType: z.literal('ONE_OF_RANGE'),\n sourceRange: z.string().min(1).describe('A1 notation range containing dropdown options (e.g., \"Options!A1:A10\")'),\n showDropdown: z.boolean().default(true).describe('Show dropdown UI in cells'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Numeric constraints\n z.object({\n conditionType: z.enum(['NUMBER_GREATER', 'NUMBER_LESS', 'NUMBER_BETWEEN']),\n values: z.array(z.number()).min(1).max(2).describe('1 value for GREATER/LESS, 2 values for BETWEEN'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Text constraints\n z.object({\n conditionType: z.enum(['TEXT_CONTAINS', 'TEXT_IS_EMAIL', 'TEXT_IS_URL']),\n values: z.array(z.string()).optional().describe('Text to match (for TEXT_CONTAINS only)'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Date constraints\n z.object({\n conditionType: z.enum(['DATE_AFTER', 'DATE_BEFORE', 'DATE_BETWEEN']),\n values: z.array(z.string()).min(1).max(2).describe('ISO date strings (YYYY-MM-DD)'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Custom formula\n z.object({\n conditionType: z.literal('CUSTOM_FORMULA'),\n formula: z.string().min(1).describe('Custom validation formula (e.g., \"=A1>0\")'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n]);\n\n// Input schema for validation requests\nconst ValidationRequestSchema = z.object({\n range: z.string().min(1).describe('A1 notation range for validation (e.g., \"B2:B100\")'),\n rule: ValidationRuleSchema,\n inputMessage: z.string().optional().describe('Help text shown when cell is selected'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(ValidationRequestSchema).min(1).max(50).describe('Array of validation rules. Batch multiple ranges 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 sheet with validation'),\n sheetUrl: z.string().describe('URL of the sheet with validation'),\n successCount: z.number().int().nonnegative().describe('Number of validation rules successfully applied'),\n failedRanges: z\n .array(\n z.object({\n range: z.string().describe('A1 notation of range that failed validation setup'),\n error: z.string().describe('Why validation failed for this range'),\n })\n )\n .optional()\n .describe('Only populated if some validation rules failed'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Add data validation rules including dropdowns, numeric constraints, text patterns, date ranges, custom formulas. Supports batch operations for efficiency. Use discriminated conditionType to specify rule type. Best for enforcing data integrity and providing user-friendly input controls.',\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\n// Map condition types to Google Sheets API format\nfunction buildCondition(rule: z.infer<typeof ValidationRuleSchema>) {\n switch (rule.conditionType) {\n case 'ONE_OF_LIST':\n return {\n type: 'ONE_OF_LIST',\n values: rule.values.map((value) => ({ userEnteredValue: value })),\n };\n case 'ONE_OF_RANGE':\n return {\n type: 'ONE_OF_RANGE',\n values: [{ userEnteredValue: `=${rule.sourceRange}` }],\n };\n case 'NUMBER_GREATER':\n return {\n type: 'NUMBER_GREATER',\n values: [{ userEnteredValue: String(rule.values[0]) }],\n };\n case 'NUMBER_LESS':\n return {\n type: 'NUMBER_LESS',\n values: [{ userEnteredValue: String(rule.values[0]) }],\n };\n case 'NUMBER_BETWEEN':\n return {\n type: 'NUMBER_BETWEEN',\n values: [{ userEnteredValue: String(rule.values[0]) }, { userEnteredValue: String(rule.values[1]) }],\n };\n case 'TEXT_CONTAINS':\n return {\n type: 'TEXT_CONTAINS',\n values: rule.values ? [{ userEnteredValue: rule.values[0] }] : [],\n };\n case 'TEXT_IS_EMAIL':\n return {\n type: 'TEXT_IS_EMAIL',\n values: [],\n };\n case 'TEXT_IS_URL':\n return {\n type: 'TEXT_IS_URL',\n values: [],\n };\n case 'DATE_AFTER':\n return {\n type: 'DATE_AFTER',\n values: [{ userEnteredValue: rule.values[0] }],\n };\n case 'DATE_BEFORE':\n return {\n type: 'DATE_BEFORE',\n values: [{ userEnteredValue: rule.values[0] }],\n };\n case 'DATE_BETWEEN':\n return {\n type: 'DATE_BETWEEN',\n values: [{ userEnteredValue: rule.values[0] }, { userEnteredValue: rule.values[1] }],\n };\n case 'CUSTOM_FORMULA':\n return {\n type: 'CUSTOM_FORMULA',\n values: [{ userEnteredValue: rule.formula.startsWith('=') ? rule.formula : `=${rule.formula}` }],\n };\n default:\n // Exhaustive check - all valid conditionType values should be handled above\n throw new Error(`Unknown condition type: ${(rule as { conditionType: string }).conditionType}`);\n }\n}\n\nasync function handler({ id, gid, requests }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.validation.set 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 validation set', { 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 const sheetId = sheet.properties.sheetId;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetId}`;\n\n // Validate sheetId exists\n if (sheetId === undefined || sheetId === null) {\n logger.error('Sheet ID not available for validation set', { id, gid, sheetTitle });\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Sheet ID not available for ${gid}. Cannot perform validation operations without valid sheet ID.`);\n }\n\n // Build batch update requests\n const batchRequests: sheets_v4.Schema$Request[] = [];\n const failedRanges: Array<{ range: string; error: string }> = [];\n\n for (const request of requests) {\n try {\n // Parse A1 notation to range reference\n const rangeRef = parseA1Notation(request.range);\n\n // Build grid range from range reference using helper function\n const gridRange = rangeReferenceToGridRange(rangeRef, sheetId);\n\n // Build validation rule\n const condition = buildCondition(request.rule);\n\n // Build data validation rule - structure matches Schema$DataValidationRule\n const dataValidationRule = {\n condition,\n strict: request.rule.strict,\n showCustomUi: 'showDropdown' in request.rule ? request.rule.showDropdown : undefined,\n inputMessage: request.inputMessage,\n } as sheets_v4.Schema$DataValidationRule;\n\n // Add setDataValidation request\n batchRequests.push({\n setDataValidation: {\n range: gridRange,\n rule: dataValidationRule,\n },\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.info('Failed to build validation rule', {\n range: request.range,\n error: message,\n });\n failedRanges.push({\n range: request.range,\n error: `Failed to build validation rule: ${message}`,\n });\n }\n }\n\n // Early return if all ranges 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 failedRanges: failedRanges.length > 0 ? failedRanges : 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.validation.set 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.validation.set completed successfully', {\n successCount: requests.length - failedRanges.length,\n failedCount: failedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: requests.length - failedRanges.length,\n failedRanges: failedRanges.length > 0 ? failedRanges : undefined,\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('Validation set operation failed', {\n id,\n gid,\n requestCount: requests.length,\n error: message,\n });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error setting validation: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'validation-set',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","ValidationRuleSchema","z","discriminatedUnion","object","conditionType","literal","values","array","string","min","describe","showDropdown","boolean","default","strict","sourceRange","enum","number","max","optional","formula","ValidationRequestSchema","range","rule","inputMessage","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","successBranchSchema","type","SpreadsheetIdOutput","SheetGidOutput","sheetTitle","sheetUrl","successCount","int","nonnegative","failedRanges","error","outputSchema","config","description","result","buildCondition","map","value","userEnteredValue","String","startsWith","Error","handler","extra","logger","sheet","spreadsheetResponse","sheets","sheetId","batchRequests","request","rangeRef","gridRange","condition","dataValidationRule","message","info","requestCount","length","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","properties","ProtocolError","ProtocolErrorCode","InvalidParams","title","undefined","InternalError","parseA1Notation","rangeReferenceToGridRange","showCustomUi","push","setDataValidation","content","text","JSON","stringify","structuredContent","batchRequestsCount","batchUpdate","requestBody","failedCount","stack","name"],"mappings":";;;;+BAsTA;;;eAAwBA;;;2BArTA;sBAKyB;0BACV;mBACrB;uBACuE;iCAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAP3D,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AASR,gDAAgD;AAChD,IAAME,uBAAuBC,MAAC,CAACC,kBAAkB,CAAC,iBAAiB;IACjE,+BAA+B;IAC/BD,MAAC,CAACE,MAAM,CAAC;QACPC,eAAeH,MAAC,CAACI,OAAO,CAAC;QACzBC,QAAQL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACO,MAAM,IAAIC,GAAG,CAAC,GAAGC,QAAQ,CAAC;QAC5CC,cAAcV,MAAC,CAACW,OAAO,GAAGC,OAAO,CAAC,MAAMH,QAAQ,CAAC;QACjDI,QAAQb,MAAC,CAACW,OAAO,GAAGC,OAAO,CAAC,MAAMH,QAAQ,CAAC;IAC7C;IACA,sBAAsB;IACtBT,MAAC,CAACE,MAAM,CAAC;QACPC,eAAeH,MAAC,CAACI,OAAO,CAAC;QACzBU,aAAad,MAAC,CAACO,MAAM,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;QACxCC,cAAcV,MAAC,CAACW,OAAO,GAAGC,OAAO,CAAC,MAAMH,QAAQ,CAAC;QACjDI,QAAQb,MAAC,CAACW,OAAO,GAAGC,OAAO,CAAC,MAAMH,QAAQ,CAAC;IAC7C;IACA,sBAAsB;IACtBT,MAAC,CAACE,MAAM,CAAC;QACPC,eAAeH,MAAC,CAACe,IAAI,CAAC;YAAC;YAAkB;YAAe;SAAiB;QACzEV,QAAQL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACgB,MAAM,IAAIR,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,KAAKsB,OAAOS;wBACZxB,YAAAA;wBACAC,UAAAA;wBACAC,cAAcP,SAASuC,MAAM,GAAG7B,aAAa6B,MAAM;wBACnD7B,cAAcA,aAAa6B,MAAM,GAAG,IAAI7B,eAAe8C;oBACzD;oBAEA;;wBAAO;4BACLO,OAAO;gCAAG;oCAAE7D,MAAM;oCAAiB8D,MAAMC,KAAKC,SAAS,CAACnD;gCAAQ;;4BAChEoD,mBAAmB;gCAAEpD,QAAAA;4BAAO;wBAC9B;;;oBACOJ;oBACDyB,WAAUzB,AAAK,YAALA,OAAiBW,SAAQX,MAAMyB,OAAO,GAAGhB,OAAOT;oBAChEc,OAAOd,KAAK,CAAC,mCAAmC;wBAC9Cf,IAAAA;wBACAE,KAAAA;wBACAwC,cAActC,SAASuC,MAAM;wBAC7B5B,OAAOyB;oBACT;oBAEA,MAAM,IAAIgB,qBAAa,CAACC,yBAAiB,CAACI,aAAa,EAAE,AAAC,6BAAoC,OAARrB,WAAW;wBAC/FoC,OAAO7D,AAAK,YAALA,OAAiBW,SAAQX,MAAM6D,KAAK,GAAGhB;oBAChD;;;;;;;IAEJ;;AAEe,SAASzF;IACtB,OAAO;QACL0G,MAAM;QACN5D,QAAAA;QACAU,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;
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
12
|
+
var _server = require("@mcp-z/server");
|
|
13
13
|
var _googleapis = require("googleapis");
|
|
14
14
|
var _zod = require("zod");
|
|
15
15
|
var _indexts = require("../../schemas/index.js");
|
|
@@ -246,7 +246,7 @@ function handler(_0, _1) {
|
|
|
246
246
|
gid: gid,
|
|
247
247
|
requestCount: requests.length
|
|
248
248
|
});
|
|
249
|
-
throw new
|
|
249
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Sheet not found: ".concat(gid));
|
|
250
250
|
}
|
|
251
251
|
sheetTitle = (_sheet_properties_title = sheet.properties.title) !== null && _sheet_properties_title !== void 0 ? _sheet_properties_title : gid;
|
|
252
252
|
sheetGid = (_sheet_properties_sheetId = sheet.properties.sheetId) !== null && _sheet_properties_sheetId !== void 0 ? _sheet_properties_sheetId : 0;
|
|
@@ -291,7 +291,7 @@ function handler(_0, _1) {
|
|
|
291
291
|
spreadsheetId: id,
|
|
292
292
|
sheetTitle: sheetTitle
|
|
293
293
|
});
|
|
294
|
-
throw new
|
|
294
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Batch operation partially failed: ".concat(actualCount, "/").concat(expectedCount, " operations completed"));
|
|
295
295
|
}
|
|
296
296
|
// Check for any failed operations (empty or null responses)
|
|
297
297
|
failedOperations = responses.filter(function(response, index) {
|
|
@@ -308,7 +308,7 @@ function handler(_0, _1) {
|
|
|
308
308
|
return false;
|
|
309
309
|
});
|
|
310
310
|
if (failedOperations.length > 0) {
|
|
311
|
-
throw new
|
|
311
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "".concat(failedOperations.length, " operations failed to update ranges"));
|
|
312
312
|
}
|
|
313
313
|
// Extract updated ranges and calculate totals
|
|
314
314
|
updatedRanges = responses.map(function(response) {
|
|
@@ -384,7 +384,7 @@ function handler(_0, _1) {
|
|
|
384
384
|
valueInputOption: valueInputOption,
|
|
385
385
|
error: message
|
|
386
386
|
});
|
|
387
|
-
throw new
|
|
387
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error batch updating values: ".concat(message), {
|
|
388
388
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
389
389
|
});
|
|
390
390
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-batch-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 } from 'googleapis';\nimport { z } from 'zod';\nimport { A1NotationSchema, SheetCellSchema, SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\n// Types for updated data response\ninterface UpdatedDataItem {\n range: string;\n majorDimension: 'ROWS' | 'COLUMNS';\n values?: (string | number | boolean | null)[][];\n}\n\n// Input schema for values batch update requests\nconst ValuesBatchUpdateRequestSchema = z.object({\n range: A1NotationSchema.describe('A1 notation range defining the bounded target area. Data dimensions must match range dimensions. Example: D1:D100 requires exactly 100 rows of data. Use open-ended ranges like D1:D to write any number of rows.'),\n values: z.array(z.array(SheetCellSchema)).min(1).describe('2D array of values. Row count must match range height, column count must match range width. Use null to skip a cell (preserve existing value), empty string \"\" to clear it.'),\n majorDimension: z.enum(['ROWS', 'COLUMNS']).describe('Whether values represent rows or columns'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(ValuesBatchUpdateRequestSchema).min(1).describe('Array of value update requests'),\n valueInputOption: z.enum(['RAW', 'USER_ENTERED']).describe('How input data should be interpreted (RAW = exact values, USER_ENTERED = parsed like user input)'),\n includeData: z.boolean().describe('Whether to include updated cell values in the response'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n spreadsheetTitle: z.string().describe('Title of the updated spreadsheet'),\n spreadsheetUrl: z.string().describe('URL of the updated spreadsheet'),\n sheetTitle: z.string().describe('Title of the updated sheet'),\n sheetUrl: z.string().describe('URL of the updated sheet'),\n totalUpdatedRows: z.number().int().nonnegative().describe('Total number of rows updated across all requests'),\n totalUpdatedColumns: z.number().int().nonnegative().describe('Total number of columns updated across all requests'),\n totalUpdatedCells: z.number().int().nonnegative().describe('Total number of cells updated across all requests'),\n updatedRanges: z.array(z.string()).describe('A1 notation ranges that were updated'),\n updatedData: z\n .array(\n z.object({\n range: z.string().describe('A1 notation range that was updated'),\n majorDimension: z.enum(['ROWS', 'COLUMNS']).describe('Dimension of the updated data'),\n values: z.array(z.array(SheetCellSchema)).optional().describe('Updated values (if includeData was true)'),\n })\n )\n .optional()\n .describe('Detailed information about updated data (if includeData was true)'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Batch update multiple cell ranges. RAW=exact values, USER_ENTERED=parsed like user input. Use a1-notation prompt for range syntax. For multiple clickable links or rich text inside a single cell, use values-markdown-update.',\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, valueInputOption = 'USER_ENTERED', includeData = false }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.batchUpdate called', {\n id,\n gid,\n requestCount: requests.length,\n valueInputOption,\n includeData,\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: 'properties.title,spreadsheetUrl,sheets.properties.sheetId,sheets.properties.title',\n });\n\n const spreadsheetData = spreadsheetResponse.data;\n const spreadsheetTitle = spreadsheetData.properties?.title ?? '';\n const spreadsheetUrl = spreadsheetData.spreadsheetUrl ?? '';\n\n // Find sheet by gid\n const sheet = spreadsheetData.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for batch 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 const sheetGid = sheet.properties.sheetId ?? 0;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetGid}`;\n\n // Build batch update request with prefixed ranges\n const batchUpdateData = requests.map((req) => ({\n range: `${sheetTitle}!${req.range}`,\n values: req.values,\n majorDimension: req.majorDimension || 'ROWS',\n }));\n\n logger.info('sheets.values.batchUpdate executing batch request', {\n spreadsheetId: id,\n sheetTitle,\n batchUpdateDataCount: batchUpdateData.length,\n });\n\n // Execute the batch update\n const batchUpdateResponse = await sheets.spreadsheets.values.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n valueInputOption,\n data: batchUpdateData,\n includeValuesInResponse: includeData,\n responseDateTimeRenderOption: 'FORMATTED_STRING',\n responseValueRenderOption: 'FORMATTED_VALUE',\n },\n });\n\n const updateResult = batchUpdateResponse.data;\n\n // Validate batch operation results and detect partial failures\n const responses = updateResult.responses || [];\n const expectedCount = requests.length;\n const actualCount = responses.length;\n\n if (actualCount !== expectedCount) {\n logger.error('Partial batch failure detected', {\n expectedOperations: expectedCount,\n completedOperations: actualCount,\n spreadsheetId: id,\n sheetTitle,\n });\n\n throw new McpError(ErrorCode.InternalError, `Batch operation partially failed: ${actualCount}/${expectedCount} operations completed`);\n }\n\n // Check for any failed operations (empty or null responses)\n const failedOperations = responses.filter((response, index) => {\n if (!response || !response.updatedRange) {\n logger.error('Failed operation detected', {\n operationIndex: index,\n requestedRange: requests[index]?.range,\n spreadsheetId: id,\n sheetTitle,\n });\n return true;\n }\n return false;\n });\n\n if (failedOperations.length > 0) {\n throw new McpError(ErrorCode.InternalError, `${failedOperations.length} operations failed to update ranges`);\n }\n\n // Extract updated ranges and calculate totals\n const updatedRanges = responses.map((response) => response.updatedRange || '').filter((range) => range);\n const totalUpdatedRows = updateResult.totalUpdatedRows || 0;\n const totalUpdatedColumns = updateResult.totalUpdatedColumns || 0;\n const totalUpdatedCells = updateResult.totalUpdatedCells || 0;\n\n // Build updated data response if requested\n let updatedData: UpdatedDataItem[] | undefined;\n if (includeData && updateResult.responses) {\n updatedData = updateResult.responses\n .filter((response) => response.updatedData)\n .map((response) => {\n const item: UpdatedDataItem = {\n range: response.updatedRange || '',\n majorDimension: (response.updatedData?.majorDimension as 'ROWS' | 'COLUMNS' | undefined) || 'ROWS',\n };\n const values = response.updatedData?.values as (string | number | boolean | null | undefined)[][] | undefined;\n if (values !== undefined) {\n // Map undefined values to null for JSON Schema compatibility\n item.values = values.map((row) => row.map((cell) => (cell === undefined ? null : cell)));\n }\n return item;\n });\n }\n\n logger.info('sheets.values.batchUpdate completed successfully', {\n totalUpdatedRows,\n totalUpdatedColumns,\n totalUpdatedCells,\n updatedRangesCount: updatedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetGid),\n spreadsheetTitle: spreadsheetTitle || '',\n spreadsheetUrl: spreadsheetUrl || '',\n sheetTitle,\n sheetUrl,\n totalUpdatedRows,\n totalUpdatedColumns,\n totalUpdatedCells,\n updatedRanges,\n updatedData,\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('Batch update operation failed', {\n id,\n gid,\n requestCount: requests.length,\n valueInputOption,\n error: message,\n });\n\n throw new McpError(ErrorCode.InternalError, `Error batch updating values: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-batch-update',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","ValuesBatchUpdateRequestSchema","z","object","range","A1NotationSchema","describe","values","array","SheetCellSchema","min","majorDimension","enum","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","valueInputOption","includeData","boolean","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","spreadsheetTitle","string","spreadsheetUrl","sheetTitle","sheetUrl","totalUpdatedRows","number","int","nonnegative","totalUpdatedColumns","totalUpdatedCells","updatedRanges","updatedData","optional","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetData","sheet","sheets","spreadsheetResponse","sheetGid","batchUpdateData","batchUpdateResponse","updateResult","responses","expectedCount","actualCount","failedOperations","error","message","info","requestCount","length","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","find","s","String","sheetId","McpError","ErrorCode","InvalidParams","map","req","batchUpdateDataCount","batchUpdate","requestBody","includeValuesInResponse","responseDateTimeRenderOption","responseValueRenderOption","expectedOperations","completedOperations","InternalError","filter","response","index","updatedRange","operationIndex","requestedRange","item","undefined","row","cell","updatedRangesCount","content","text","JSON","stringify","structuredContent","Error","stack","name"],"mappings":";;;;+BAyOA;;;eAAwBA;;;2BAxOA;qBAMY;0BACb;mBACL;uBAC0G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAP5H,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAgBR,gDAAgD;AAChD,IAAME,iCAAiCC,MAAC,CAACC,MAAM,CAAC;IA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kBAAAA;wBACAI,qBAAAA;wBACAC,mBAAAA;wBACAC,eAAAA;wBACAC,aAAAA;oBACF;oBAEA;;wBAAO;4BACLmE,OAAO;gCAAG;oCAAEnF,MAAM;oCAAiBoF,MAAMC,KAAKC,SAAS,CAAChE;gCAAQ;;4BAChEiE,mBAAmB;gCAAEjE,QAAAA;4BAAO;wBAC9B;;;oBACOgB;oBACDC,UAAUD,AAAK,YAALA,OAAiBkD,SAAQlD,MAAMC,OAAO,GAAGiB,OAAOlB;oBAChEb,OAAOa,KAAK,CAAC,iCAAiC;wBAC5C/C,IAAAA;wBACAE,KAAAA;wBACAgD,cAAc9C,SAAS+C,MAAM;wBAC7B9C,kBAAAA;wBACA0C,OAAOC;oBACT;oBAEA,MAAM,IAAImB,eAAQ,CAACC,gBAAS,CAACY,aAAa,EAAE,AAAC,gCAAuC,OAARhC,UAAW;wBACrFkD,OAAOnD,AAAK,YAALA,OAAiBkD,SAAQlD,MAAMmD,KAAK,GAAGV;oBAChD;;;;;;;IAEJ;;AAEe,SAASxG;IACtB,OAAO;QACLmH,MAAM;QACNtE,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-batch-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 { CallToolResult, ToolModule } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport { A1NotationSchema, SheetCellSchema, SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\n// Types for updated data response\ninterface UpdatedDataItem {\n range: string;\n majorDimension: 'ROWS' | 'COLUMNS';\n values?: (string | number | boolean | null)[][];\n}\n\n// Input schema for values batch update requests\nconst ValuesBatchUpdateRequestSchema = z.object({\n range: A1NotationSchema.describe('A1 notation range defining the bounded target area. Data dimensions must match range dimensions. Example: D1:D100 requires exactly 100 rows of data. Use open-ended ranges like D1:D to write any number of rows.'),\n values: z.array(z.array(SheetCellSchema)).min(1).describe('2D array of values. Row count must match range height, column count must match range width. Use null to skip a cell (preserve existing value), empty string \"\" to clear it.'),\n majorDimension: z.enum(['ROWS', 'COLUMNS']).describe('Whether values represent rows or columns'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(ValuesBatchUpdateRequestSchema).min(1).describe('Array of value update requests'),\n valueInputOption: z.enum(['RAW', 'USER_ENTERED']).describe('How input data should be interpreted (RAW = exact values, USER_ENTERED = parsed like user input)'),\n includeData: z.boolean().describe('Whether to include updated cell values in the response'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n spreadsheetTitle: z.string().describe('Title of the updated spreadsheet'),\n spreadsheetUrl: z.string().describe('URL of the updated spreadsheet'),\n sheetTitle: z.string().describe('Title of the updated sheet'),\n sheetUrl: z.string().describe('URL of the updated sheet'),\n totalUpdatedRows: z.number().int().nonnegative().describe('Total number of rows updated across all requests'),\n totalUpdatedColumns: z.number().int().nonnegative().describe('Total number of columns updated across all requests'),\n totalUpdatedCells: z.number().int().nonnegative().describe('Total number of cells updated across all requests'),\n updatedRanges: z.array(z.string()).describe('A1 notation ranges that were updated'),\n updatedData: z\n .array(\n z.object({\n range: z.string().describe('A1 notation range that was updated'),\n majorDimension: z.enum(['ROWS', 'COLUMNS']).describe('Dimension of the updated data'),\n values: z.array(z.array(SheetCellSchema)).optional().describe('Updated values (if includeData was true)'),\n })\n )\n .optional()\n .describe('Detailed information about updated data (if includeData was true)'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Batch update multiple cell ranges. RAW=exact values, USER_ENTERED=parsed like user input. Use a1-notation prompt for range syntax. For multiple clickable links or rich text inside a single cell, use values-markdown-update.',\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, valueInputOption = 'USER_ENTERED', includeData = false }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.batchUpdate called', {\n id,\n gid,\n requestCount: requests.length,\n valueInputOption,\n includeData,\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: 'properties.title,spreadsheetUrl,sheets.properties.sheetId,sheets.properties.title',\n });\n\n const spreadsheetData = spreadsheetResponse.data;\n const spreadsheetTitle = spreadsheetData.properties?.title ?? '';\n const spreadsheetUrl = spreadsheetData.spreadsheetUrl ?? '';\n\n // Find sheet by gid\n const sheet = spreadsheetData.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for batch 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 const sheetGid = sheet.properties.sheetId ?? 0;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetGid}`;\n\n // Build batch update request with prefixed ranges\n const batchUpdateData = requests.map((req) => ({\n range: `${sheetTitle}!${req.range}`,\n values: req.values,\n majorDimension: req.majorDimension || 'ROWS',\n }));\n\n logger.info('sheets.values.batchUpdate executing batch request', {\n spreadsheetId: id,\n sheetTitle,\n batchUpdateDataCount: batchUpdateData.length,\n });\n\n // Execute the batch update\n const batchUpdateResponse = await sheets.spreadsheets.values.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n valueInputOption,\n data: batchUpdateData,\n includeValuesInResponse: includeData,\n responseDateTimeRenderOption: 'FORMATTED_STRING',\n responseValueRenderOption: 'FORMATTED_VALUE',\n },\n });\n\n const updateResult = batchUpdateResponse.data;\n\n // Validate batch operation results and detect partial failures\n const responses = updateResult.responses || [];\n const expectedCount = requests.length;\n const actualCount = responses.length;\n\n if (actualCount !== expectedCount) {\n logger.error('Partial batch failure detected', {\n expectedOperations: expectedCount,\n completedOperations: actualCount,\n spreadsheetId: id,\n sheetTitle,\n });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Batch operation partially failed: ${actualCount}/${expectedCount} operations completed`);\n }\n\n // Check for any failed operations (empty or null responses)\n const failedOperations = responses.filter((response, index) => {\n if (!response || !response.updatedRange) {\n logger.error('Failed operation detected', {\n operationIndex: index,\n requestedRange: requests[index]?.range,\n spreadsheetId: id,\n sheetTitle,\n });\n return true;\n }\n return false;\n });\n\n if (failedOperations.length > 0) {\n throw new ProtocolError(ProtocolErrorCode.InternalError, `${failedOperations.length} operations failed to update ranges`);\n }\n\n // Extract updated ranges and calculate totals\n const updatedRanges = responses.map((response) => response.updatedRange || '').filter((range) => range);\n const totalUpdatedRows = updateResult.totalUpdatedRows || 0;\n const totalUpdatedColumns = updateResult.totalUpdatedColumns || 0;\n const totalUpdatedCells = updateResult.totalUpdatedCells || 0;\n\n // Build updated data response if requested\n let updatedData: UpdatedDataItem[] | undefined;\n if (includeData && updateResult.responses) {\n updatedData = updateResult.responses\n .filter((response) => response.updatedData)\n .map((response) => {\n const item: UpdatedDataItem = {\n range: response.updatedRange || '',\n majorDimension: (response.updatedData?.majorDimension as 'ROWS' | 'COLUMNS' | undefined) || 'ROWS',\n };\n const values = response.updatedData?.values as (string | number | boolean | null | undefined)[][] | undefined;\n if (values !== undefined) {\n // Map undefined values to null for JSON Schema compatibility\n item.values = values.map((row) => row.map((cell) => (cell === undefined ? null : cell)));\n }\n return item;\n });\n }\n\n logger.info('sheets.values.batchUpdate completed successfully', {\n totalUpdatedRows,\n totalUpdatedColumns,\n totalUpdatedCells,\n updatedRangesCount: updatedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetGid),\n spreadsheetTitle: spreadsheetTitle || '',\n spreadsheetUrl: spreadsheetUrl || '',\n sheetTitle,\n sheetUrl,\n totalUpdatedRows,\n totalUpdatedColumns,\n totalUpdatedCells,\n updatedRanges,\n updatedData,\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('Batch update operation failed', {\n id,\n gid,\n requestCount: requests.length,\n valueInputOption,\n error: message,\n });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error batch updating values: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-batch-update',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","ValuesBatchUpdateRequestSchema","z","object","range","A1NotationSchema","describe","values","array","SheetCellSchema","min","majorDimension","enum","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","valueInputOption","includeData","boolean","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","spreadsheetTitle","string","spreadsheetUrl","sheetTitle","sheetUrl","totalUpdatedRows","number","int","nonnegative","totalUpdatedColumns","totalUpdatedCells","updatedRanges","updatedData","optional","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetData","sheet","sheets","spreadsheetResponse","sheetGid","batchUpdateData","batchUpdateResponse","updateResult","responses","expectedCount","actualCount","failedOperations","error","message","info","requestCount","length","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","find","s","String","sheetId","ProtocolError","ProtocolErrorCode","InvalidParams","map","req","batchUpdateDataCount","batchUpdate","requestBody","includeValuesInResponse","responseDateTimeRenderOption","responseValueRenderOption","expectedOperations","completedOperations","InternalError","filter","response","index","updatedRange","operationIndex","requestedRange","item","undefined","row","cell","updatedRangesCount","content","text","JSON","stringify","structuredContent","Error","stack","name"],"mappings":";;;;+BAwOA;;;eAAwBA;;;2BAvOA;sBAKyB;0BAC1B;mBACL;uBAC0G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAN5H,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAeR,gDAAgD;AAChD,IAAME,iCAAiCC,MAAC,CAACC,MAAM,CAAC;IAC9CC,OAAOC,yBAAgB,CAACC,QAAQ,CAAC;IACjCC,QAAQL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACM,KAAK,CAACC,wBAAe,GAAGC,GAAG,CAAC,GAAGJ,QAAQ,CAAC;IAC1DK,gBAAgBT,MAAC,CAACU,IAAI,CAAC;QAAC;QAAQ;KAAU,EAAEN,QAAQ,CAAC;AACvD;AAEA,IAAMO,cAAcX,MAAC,CAACC,MAAM,CAAC;IAC3BW,IAAIC,4BAAmB;IACvBC,KAAKC,uBAAc;IACnBC,UAAUhB,MAAC,CAACM,KAAK,CAACP,gCAAgCS,GAAG,CAAC,GAAGJ,QAAQ,CAAC;IAClEa,kBAAkBjB,MAAC,CAACU,IAAI,CAAC;QAAC;QAAO;KAAe,EAAEN,QAAQ,CAAC;IAC3Dc,aAAalB,MAAC,CAACmB,OAAO,GAAGf,QAAQ,CAAC;AACpC;AAEA,IAAMgB,sBAAsBpB,MAAC,CAACC,MAAM,CAAC;IACnCoB,MAAMrB,MAAC,CAACsB,OAAO,CAAC;IAChBV,IAAIW,4BAAmB;IACvBT,KAAKU,uBAAc;IACnBC,kBAAkBzB,MAAC,CAAC0B,MAAM,GAAGtB,QAAQ,CAAC;IACtCuB,gBAAgB3B,MAAC,CAAC0B,MAAM,GAAGt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
-
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;
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "default", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
12
|
+
var _server = require("@mcp-z/server");
|
|
13
13
|
var _googleapis = require("googleapis");
|
|
14
14
|
var _zod = require("zod");
|
|
15
15
|
var _indexts = require("../../schemas/index.js");
|
|
@@ -219,7 +219,7 @@ function handler(_0, _1) {
|
|
|
219
219
|
gid: gid,
|
|
220
220
|
rangeCount: ranges.length
|
|
221
221
|
});
|
|
222
|
-
throw new
|
|
222
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Sheet not found: ".concat(gid));
|
|
223
223
|
}
|
|
224
224
|
sheetTitle = (_sheet_properties_title = sheet.properties.title) !== null && _sheet_properties_title !== void 0 ? _sheet_properties_title : gid;
|
|
225
225
|
sheetGid = (_sheet_properties_sheetId = sheet.properties.sheetId) !== null && _sheet_properties_sheetId !== void 0 ? _sheet_properties_sheetId : 0;
|
|
@@ -283,7 +283,7 @@ function handler(_0, _1) {
|
|
|
283
283
|
rangeCount: ranges.length,
|
|
284
284
|
error: message
|
|
285
285
|
});
|
|
286
|
-
throw new
|
|
286
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error clearing values: ".concat(message), {
|
|
287
287
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
288
288
|
});
|
|
289
289
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-clear.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
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-clear.ts"],"sourcesContent":["import 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 { google } from 'googleapis';\nimport { z } from 'zod';\nimport { A1NotationSchema, SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n ranges: z.array(A1NotationSchema).min(1).describe('A1 notation ranges to clear (e.g., [\"A1:B5\", \"D3:D10\"]). Clears values only, preserves formatting.'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n spreadsheetTitle: z.string().describe('Title of the spreadsheet'),\n spreadsheetUrl: z.string().describe('URL of the spreadsheet'),\n sheetTitle: z.string().describe('Title of the sheet'),\n sheetUrl: z.string().describe('URL of the sheet'),\n clearedRanges: z.array(z.string()).describe('A1 notation ranges that were cleared'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Clear cell values from one or more ranges. Clears values only - preserves formatting, validation, and other cell properties. 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, ranges }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.clear called', { id, gid, rangeCount: ranges.length });\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: 'properties.title,spreadsheetUrl,sheets.properties.sheetId,sheets.properties.title',\n });\n\n const spreadsheetData = spreadsheetResponse.data;\n const spreadsheetTitle = spreadsheetData.properties?.title ?? '';\n const spreadsheetUrl = spreadsheetData.spreadsheetUrl ?? '';\n\n // Find sheet by gid\n const sheet = spreadsheetData.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for clear', { id, gid, rangeCount: ranges.length });\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? gid;\n const sheetGid = sheet.properties.sheetId ?? 0;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetGid}`;\n\n // Prefix ranges with sheet title\n const prefixedRanges = ranges.map((range) => `${sheetTitle}!${range}`);\n\n logger.info('sheets.values.clear executing', { spreadsheetId: id, sheetTitle, prefixedRanges });\n\n // Use batchClear for efficiency (works for single or multiple ranges)\n const clearResponse = await sheets.spreadsheets.values.batchClear({\n spreadsheetId: id,\n requestBody: {\n ranges: prefixedRanges,\n },\n });\n\n const clearedRanges = clearResponse.data.clearedRanges || [];\n\n logger.info('sheets.values.clear completed successfully', {\n spreadsheetId: id,\n sheetTitle,\n clearedRangesCount: clearedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetGid),\n spreadsheetTitle: spreadsheetTitle || '',\n spreadsheetUrl: spreadsheetUrl || '',\n sheetTitle,\n sheetUrl,\n clearedRanges,\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('Clear operation failed', { id, gid, rangeCount: ranges.length, error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error clearing values: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-clear',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","inputSchema","z","object","id","SpreadsheetIdSchema","gid","SheetGidSchema","ranges","array","A1NotationSchema","min","describe","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","spreadsheetTitle","string","spreadsheetUrl","sheetTitle","sheetUrl","clearedRanges","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetData","sheet","sheets","spreadsheetResponse","sheetGid","prefixedRanges","clearResponse","error","message","info","rangeCount","length","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","find","s","String","sheetId","ProtocolError","ProtocolErrorCode","InvalidParams","map","range","values","batchClear","requestBody","clearedRangesCount","content","text","JSON","stringify","structuredContent","Error","InternalError","stack","undefined","name"],"mappings":";;;;+BAmHA;;;eAAwBA;;;2BAlHA;sBAKyB;0BAC1B;mBACL;uBACyF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAN3G,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAQR,IAAME,cAAcC,MAAC,CAACC,MAAM,CAAC;IAC3BC,IAAIC,4BAAmB;IACvBC,KAAKC,uBAAc;IACnBC,QAAQN,MAAC,CAACO,K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AAM,CAACC,UAAU,CAAC;4BAChEf,eAAe9C;4BACf8D,aAAa;gCACX1D,QAAQ6B;4BACV;wBACF;;;oBALMC,gBAAgB;oBAOhBf,gBAAgBe,cAAcc,IAAI,CAAC7B,aAAa;oBAEtDQ,OAAOU,IAAI,CAAC,8CAA8C;wBACxDS,eAAe9C;wBACfiB,YAAAA;wBACA8C,oBAAoB5C,cAAcoB,MAAM;oBAC1C;oBAEMf,SAAiB;wBACrBd,MAAM;wBACNV,IAAAA;wBACAE,KAAKmD,OAAOrB;wBACZlB,kBAAkBA,oBAAoB;wBACtCE,gBAAgBA,kBAAkB;wBAClCC,YAAAA;wBACAC,UAAAA;wBACAC,eAAAA;oBACF;oBAEA;;wBAAO;4BACL6C,OAAO;gCAAG;oCAAEtD,MAAM;oCAAiBuD,MAAMC,KAAKC,SAAS,CAAC3C;gCAAQ;;4BAChE4C,mBAAmB;gCAAE5C,QAAAA;4BAAO;wBAC9B;;;oBACOW;oBACDC,UAAUD,AAAK,YAALA,OAAiBkC,SAAQlC,MAAMC,OAAO,GAAGiB,OAAOlB;oBAChER,OAAOQ,KAAK,CAAC,0BAA0B;wBAAEnC,IAAAA;wBAAIE,KAAAA;wBAAKoC,YAAYlC,OAAOmC,MAAM;wBAAEJ,OAAOC;oBAAQ;oBAE5F,MAAM,IAAImB,qBAAa,CAACC,yBAAiB,CAACc,aAAa,EAAE,AAAC,0BAAiC,OAARlC,UAAW;wBAC5FmC,OAAOpC,AAAK,YAALA,OAAiBkC,SAAQlC,MAAMoC,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAAS9E;IACtB,OAAO;QACL+E,MAAM;QACNnD,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Import CSV data to Google Sheets with range-based update (no deduplication) */
|
|
2
2
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
3
|
-
import type { CallToolResult } from '@
|
|
3
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
declare const inputSchema: z.ZodObject<{
|
|
6
6
|
id: z.ZodString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Import CSV data to Google Sheets with range-based update (no deduplication) */
|
|
2
2
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
3
|
-
import type { CallToolResult } from '@
|
|
3
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
declare const inputSchema: z.ZodObject<{
|
|
6
6
|
id: z.ZodString;
|