@mcp-z/mcp-sheets 1.2.3 → 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.
Files changed (216) hide show
  1. package/dist/cjs/index.js.map +1 -1
  2. package/dist/cjs/mcp/prompts/a1-notation.d.cts +2 -3
  3. package/dist/cjs/mcp/prompts/a1-notation.d.ts +2 -3
  4. package/dist/cjs/mcp/prompts/a1-notation.js.map +1 -1
  5. package/dist/cjs/mcp/resources/spreadsheet.js +2 -2
  6. package/dist/cjs/mcp/resources/spreadsheet.js.map +1 -1
  7. package/dist/cjs/mcp/tools/cells-format.d.cts +1 -1
  8. package/dist/cjs/mcp/tools/cells-format.d.ts +1 -1
  9. package/dist/cjs/mcp/tools/cells-format.js +3 -3
  10. package/dist/cjs/mcp/tools/cells-format.js.map +1 -1
  11. package/dist/cjs/mcp/tools/chart-create.d.cts +1 -1
  12. package/dist/cjs/mcp/tools/chart-create.d.ts +1 -1
  13. package/dist/cjs/mcp/tools/chart-create.js +7 -7
  14. package/dist/cjs/mcp/tools/chart-create.js.map +1 -1
  15. package/dist/cjs/mcp/tools/columns-get.d.cts +1 -1
  16. package/dist/cjs/mcp/tools/columns-get.d.ts +1 -1
  17. package/dist/cjs/mcp/tools/columns-get.js +3 -3
  18. package/dist/cjs/mcp/tools/columns-get.js.map +1 -1
  19. package/dist/cjs/mcp/tools/columns-update.d.cts +1 -1
  20. package/dist/cjs/mcp/tools/columns-update.d.ts +1 -1
  21. package/dist/cjs/mcp/tools/columns-update.js +4 -4
  22. package/dist/cjs/mcp/tools/columns-update.js.map +1 -1
  23. package/dist/cjs/mcp/tools/csv-get-columns.d.cts +1 -1
  24. package/dist/cjs/mcp/tools/csv-get-columns.d.ts +1 -1
  25. package/dist/cjs/mcp/tools/csv-get-columns.js +2 -2
  26. package/dist/cjs/mcp/tools/csv-get-columns.js.map +1 -1
  27. package/dist/cjs/mcp/tools/dimensions-batch-update.d.cts +1 -1
  28. package/dist/cjs/mcp/tools/dimensions-batch-update.d.ts +1 -1
  29. package/dist/cjs/mcp/tools/dimensions-batch-update.js +8 -8
  30. package/dist/cjs/mcp/tools/dimensions-batch-update.js.map +1 -1
  31. package/dist/cjs/mcp/tools/dimensions-move.d.cts +1 -1
  32. package/dist/cjs/mcp/tools/dimensions-move.d.ts +1 -1
  33. package/dist/cjs/mcp/tools/dimensions-move.js +6 -6
  34. package/dist/cjs/mcp/tools/dimensions-move.js.map +1 -1
  35. package/dist/cjs/mcp/tools/rows-append.d.cts +1 -1
  36. package/dist/cjs/mcp/tools/rows-append.d.ts +1 -1
  37. package/dist/cjs/mcp/tools/rows-append.js +3 -3
  38. package/dist/cjs/mcp/tools/rows-append.js.map +1 -1
  39. package/dist/cjs/mcp/tools/rows-csv-append.d.cts +1 -1
  40. package/dist/cjs/mcp/tools/rows-csv-append.d.ts +1 -1
  41. package/dist/cjs/mcp/tools/rows-csv-append.js +7 -7
  42. package/dist/cjs/mcp/tools/rows-csv-append.js.map +1 -1
  43. package/dist/cjs/mcp/tools/rows-get.d.cts +1 -1
  44. package/dist/cjs/mcp/tools/rows-get.d.ts +1 -1
  45. package/dist/cjs/mcp/tools/rows-get.js +4 -4
  46. package/dist/cjs/mcp/tools/rows-get.js.map +1 -1
  47. package/dist/cjs/mcp/tools/sheet-copy-to.d.cts +1 -1
  48. package/dist/cjs/mcp/tools/sheet-copy-to.d.ts +1 -1
  49. package/dist/cjs/mcp/tools/sheet-copy-to.js +4 -4
  50. package/dist/cjs/mcp/tools/sheet-copy-to.js.map +1 -1
  51. package/dist/cjs/mcp/tools/sheet-copy.d.cts +1 -1
  52. package/dist/cjs/mcp/tools/sheet-copy.d.ts +1 -1
  53. package/dist/cjs/mcp/tools/sheet-copy.js +4 -4
  54. package/dist/cjs/mcp/tools/sheet-copy.js.map +1 -1
  55. package/dist/cjs/mcp/tools/sheet-create.d.cts +1 -1
  56. package/dist/cjs/mcp/tools/sheet-create.d.ts +1 -1
  57. package/dist/cjs/mcp/tools/sheet-create.js +3 -3
  58. package/dist/cjs/mcp/tools/sheet-create.js.map +1 -1
  59. package/dist/cjs/mcp/tools/sheet-delete.d.cts +1 -1
  60. package/dist/cjs/mcp/tools/sheet-delete.d.ts +1 -1
  61. package/dist/cjs/mcp/tools/sheet-delete.js +2 -2
  62. package/dist/cjs/mcp/tools/sheet-delete.js.map +1 -1
  63. package/dist/cjs/mcp/tools/sheet-find.d.cts +1 -1
  64. package/dist/cjs/mcp/tools/sheet-find.d.ts +1 -1
  65. package/dist/cjs/mcp/tools/sheet-find.js +3 -3
  66. package/dist/cjs/mcp/tools/sheet-find.js.map +1 -1
  67. package/dist/cjs/mcp/tools/sheet-rename.d.cts +1 -1
  68. package/dist/cjs/mcp/tools/sheet-rename.d.ts +1 -1
  69. package/dist/cjs/mcp/tools/sheet-rename.js +4 -4
  70. package/dist/cjs/mcp/tools/sheet-rename.js.map +1 -1
  71. package/dist/cjs/mcp/tools/spreadsheet-copy.d.cts +1 -1
  72. package/dist/cjs/mcp/tools/spreadsheet-copy.d.ts +1 -1
  73. package/dist/cjs/mcp/tools/spreadsheet-copy.js +2 -2
  74. package/dist/cjs/mcp/tools/spreadsheet-copy.js.map +1 -1
  75. package/dist/cjs/mcp/tools/spreadsheet-create.d.cts +1 -1
  76. package/dist/cjs/mcp/tools/spreadsheet-create.d.ts +1 -1
  77. package/dist/cjs/mcp/tools/spreadsheet-create.js +3 -3
  78. package/dist/cjs/mcp/tools/spreadsheet-create.js.map +1 -1
  79. package/dist/cjs/mcp/tools/spreadsheet-find.d.cts +1 -1
  80. package/dist/cjs/mcp/tools/spreadsheet-find.d.ts +1 -1
  81. package/dist/cjs/mcp/tools/spreadsheet-find.js +2 -2
  82. package/dist/cjs/mcp/tools/spreadsheet-find.js.map +1 -1
  83. package/dist/cjs/mcp/tools/spreadsheet-rename.d.cts +1 -1
  84. package/dist/cjs/mcp/tools/spreadsheet-rename.d.ts +1 -1
  85. package/dist/cjs/mcp/tools/spreadsheet-rename.js +2 -2
  86. package/dist/cjs/mcp/tools/spreadsheet-rename.js.map +1 -1
  87. package/dist/cjs/mcp/tools/validation-set.d.cts +1 -1
  88. package/dist/cjs/mcp/tools/validation-set.d.ts +1 -1
  89. package/dist/cjs/mcp/tools/validation-set.js +4 -4
  90. package/dist/cjs/mcp/tools/validation-set.js.map +1 -1
  91. package/dist/cjs/mcp/tools/values-batch-update.d.cts +1 -1
  92. package/dist/cjs/mcp/tools/values-batch-update.d.ts +1 -1
  93. package/dist/cjs/mcp/tools/values-batch-update.js +5 -5
  94. package/dist/cjs/mcp/tools/values-batch-update.js.map +1 -1
  95. package/dist/cjs/mcp/tools/values-clear.d.cts +1 -1
  96. package/dist/cjs/mcp/tools/values-clear.d.ts +1 -1
  97. package/dist/cjs/mcp/tools/values-clear.js +3 -3
  98. package/dist/cjs/mcp/tools/values-clear.js.map +1 -1
  99. package/dist/cjs/mcp/tools/values-csv-update.d.cts +1 -1
  100. package/dist/cjs/mcp/tools/values-csv-update.d.ts +1 -1
  101. package/dist/cjs/mcp/tools/values-csv-update.js +4 -4
  102. package/dist/cjs/mcp/tools/values-csv-update.js.map +1 -1
  103. package/dist/cjs/mcp/tools/values-markdown-update.d.cts +1 -1
  104. package/dist/cjs/mcp/tools/values-markdown-update.d.ts +1 -1
  105. package/dist/cjs/mcp/tools/values-markdown-update.js +5 -5
  106. package/dist/cjs/mcp/tools/values-markdown-update.js.map +1 -1
  107. package/dist/cjs/mcp/tools/values-replace.d.cts +1 -1
  108. package/dist/cjs/mcp/tools/values-replace.d.ts +1 -1
  109. package/dist/cjs/mcp/tools/values-replace.js +5 -5
  110. package/dist/cjs/mcp/tools/values-replace.js.map +1 -1
  111. package/dist/cjs/mcp/tools/values-search.d.cts +1 -1
  112. package/dist/cjs/mcp/tools/values-search.d.ts +1 -1
  113. package/dist/cjs/mcp/tools/values-search.js +3 -3
  114. package/dist/cjs/mcp/tools/values-search.js.map +1 -1
  115. package/dist/cjs/setup/http.d.cts +1 -1
  116. package/dist/cjs/setup/http.d.ts +1 -1
  117. package/dist/cjs/setup/http.js +1 -2
  118. package/dist/cjs/setup/http.js.map +1 -1
  119. package/dist/cjs/setup/stdio.d.cts +1 -1
  120. package/dist/cjs/setup/stdio.d.ts +1 -1
  121. package/dist/cjs/setup/stdio.js +1 -2
  122. package/dist/cjs/setup/stdio.js.map +1 -1
  123. package/dist/esm/index.js +1 -1
  124. package/dist/esm/index.js.map +1 -1
  125. package/dist/esm/mcp/prompts/a1-notation.d.ts +2 -3
  126. package/dist/esm/mcp/prompts/a1-notation.js.map +1 -1
  127. package/dist/esm/mcp/resources/spreadsheet.js +1 -1
  128. package/dist/esm/mcp/resources/spreadsheet.js.map +1 -1
  129. package/dist/esm/mcp/tools/cells-format.d.ts +1 -1
  130. package/dist/esm/mcp/tools/cells-format.js +3 -3
  131. package/dist/esm/mcp/tools/cells-format.js.map +1 -1
  132. package/dist/esm/mcp/tools/chart-create.d.ts +1 -1
  133. package/dist/esm/mcp/tools/chart-create.js +7 -7
  134. package/dist/esm/mcp/tools/chart-create.js.map +1 -1
  135. package/dist/esm/mcp/tools/columns-get.d.ts +1 -1
  136. package/dist/esm/mcp/tools/columns-get.js +3 -3
  137. package/dist/esm/mcp/tools/columns-get.js.map +1 -1
  138. package/dist/esm/mcp/tools/columns-update.d.ts +1 -1
  139. package/dist/esm/mcp/tools/columns-update.js +4 -4
  140. package/dist/esm/mcp/tools/columns-update.js.map +1 -1
  141. package/dist/esm/mcp/tools/csv-get-columns.d.ts +1 -1
  142. package/dist/esm/mcp/tools/csv-get-columns.js +2 -2
  143. package/dist/esm/mcp/tools/csv-get-columns.js.map +1 -1
  144. package/dist/esm/mcp/tools/dimensions-batch-update.d.ts +1 -1
  145. package/dist/esm/mcp/tools/dimensions-batch-update.js +8 -8
  146. package/dist/esm/mcp/tools/dimensions-batch-update.js.map +1 -1
  147. package/dist/esm/mcp/tools/dimensions-move.d.ts +1 -1
  148. package/dist/esm/mcp/tools/dimensions-move.js +6 -6
  149. package/dist/esm/mcp/tools/dimensions-move.js.map +1 -1
  150. package/dist/esm/mcp/tools/rows-append.d.ts +1 -1
  151. package/dist/esm/mcp/tools/rows-append.js +3 -3
  152. package/dist/esm/mcp/tools/rows-append.js.map +1 -1
  153. package/dist/esm/mcp/tools/rows-csv-append.d.ts +1 -1
  154. package/dist/esm/mcp/tools/rows-csv-append.js +7 -7
  155. package/dist/esm/mcp/tools/rows-csv-append.js.map +1 -1
  156. package/dist/esm/mcp/tools/rows-get.d.ts +1 -1
  157. package/dist/esm/mcp/tools/rows-get.js +4 -4
  158. package/dist/esm/mcp/tools/rows-get.js.map +1 -1
  159. package/dist/esm/mcp/tools/sheet-copy-to.d.ts +1 -1
  160. package/dist/esm/mcp/tools/sheet-copy-to.js +4 -4
  161. package/dist/esm/mcp/tools/sheet-copy-to.js.map +1 -1
  162. package/dist/esm/mcp/tools/sheet-copy.d.ts +1 -1
  163. package/dist/esm/mcp/tools/sheet-copy.js +4 -4
  164. package/dist/esm/mcp/tools/sheet-copy.js.map +1 -1
  165. package/dist/esm/mcp/tools/sheet-create.d.ts +1 -1
  166. package/dist/esm/mcp/tools/sheet-create.js +3 -3
  167. package/dist/esm/mcp/tools/sheet-create.js.map +1 -1
  168. package/dist/esm/mcp/tools/sheet-delete.d.ts +1 -1
  169. package/dist/esm/mcp/tools/sheet-delete.js +2 -2
  170. package/dist/esm/mcp/tools/sheet-delete.js.map +1 -1
  171. package/dist/esm/mcp/tools/sheet-find.d.ts +1 -1
  172. package/dist/esm/mcp/tools/sheet-find.js +3 -3
  173. package/dist/esm/mcp/tools/sheet-find.js.map +1 -1
  174. package/dist/esm/mcp/tools/sheet-rename.d.ts +1 -1
  175. package/dist/esm/mcp/tools/sheet-rename.js +4 -4
  176. package/dist/esm/mcp/tools/sheet-rename.js.map +1 -1
  177. package/dist/esm/mcp/tools/spreadsheet-copy.d.ts +1 -1
  178. package/dist/esm/mcp/tools/spreadsheet-copy.js +2 -2
  179. package/dist/esm/mcp/tools/spreadsheet-copy.js.map +1 -1
  180. package/dist/esm/mcp/tools/spreadsheet-create.d.ts +1 -1
  181. package/dist/esm/mcp/tools/spreadsheet-create.js +3 -3
  182. package/dist/esm/mcp/tools/spreadsheet-create.js.map +1 -1
  183. package/dist/esm/mcp/tools/spreadsheet-find.d.ts +1 -1
  184. package/dist/esm/mcp/tools/spreadsheet-find.js +2 -2
  185. package/dist/esm/mcp/tools/spreadsheet-find.js.map +1 -1
  186. package/dist/esm/mcp/tools/spreadsheet-rename.d.ts +1 -1
  187. package/dist/esm/mcp/tools/spreadsheet-rename.js +2 -2
  188. package/dist/esm/mcp/tools/spreadsheet-rename.js.map +1 -1
  189. package/dist/esm/mcp/tools/validation-set.d.ts +1 -1
  190. package/dist/esm/mcp/tools/validation-set.js +4 -4
  191. package/dist/esm/mcp/tools/validation-set.js.map +1 -1
  192. package/dist/esm/mcp/tools/values-batch-update.d.ts +1 -1
  193. package/dist/esm/mcp/tools/values-batch-update.js +5 -5
  194. package/dist/esm/mcp/tools/values-batch-update.js.map +1 -1
  195. package/dist/esm/mcp/tools/values-clear.d.ts +1 -1
  196. package/dist/esm/mcp/tools/values-clear.js +3 -3
  197. package/dist/esm/mcp/tools/values-clear.js.map +1 -1
  198. package/dist/esm/mcp/tools/values-csv-update.d.ts +1 -1
  199. package/dist/esm/mcp/tools/values-csv-update.js +4 -4
  200. package/dist/esm/mcp/tools/values-csv-update.js.map +1 -1
  201. package/dist/esm/mcp/tools/values-markdown-update.d.ts +1 -1
  202. package/dist/esm/mcp/tools/values-markdown-update.js +5 -5
  203. package/dist/esm/mcp/tools/values-markdown-update.js.map +1 -1
  204. package/dist/esm/mcp/tools/values-replace.d.ts +1 -1
  205. package/dist/esm/mcp/tools/values-replace.js +5 -5
  206. package/dist/esm/mcp/tools/values-replace.js.map +1 -1
  207. package/dist/esm/mcp/tools/values-search.d.ts +1 -1
  208. package/dist/esm/mcp/tools/values-search.js +3 -3
  209. package/dist/esm/mcp/tools/values-search.js.map +1 -1
  210. package/dist/esm/setup/http.d.ts +1 -1
  211. package/dist/esm/setup/http.js +1 -2
  212. package/dist/esm/setup/http.js.map +1 -1
  213. package/dist/esm/setup/stdio.d.ts +1 -1
  214. package/dist/esm/setup/stdio.js +1 -2
  215. package/dist/esm/setup/stdio.js.map +1 -1
  216. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/sheet-delete.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 { SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\nconst MAX_BATCH_SIZE = 1000;\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gids: z.array(SheetGidSchema).min(1).max(MAX_BATCH_SIZE).describe('Sheet grid IDs to permanently delete'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Human-readable summary of the operation'),\n itemsProcessed: z.number().describe('Total sheets attempted to delete'),\n itemsChanged: z.number().describe('Number of sheets successfully deleted'),\n completedAt: z.string().describe('ISO timestamp when operation completed'),\n recoverable: z.literal(false).describe('Whether deletion can be undone (always false)'),\n id: SpreadsheetIdOutput,\n spreadsheetUrl: z.string().optional().describe('URL to view the spreadsheet'),\n failures: z\n .array(\n z.object({\n gid: z.string().describe('Grid ID of sheet that failed to delete'),\n error: z.string().describe('Error message explaining the failure'),\n })\n )\n .optional()\n .describe('Details of any sheets that failed to delete'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Permanently delete sheets from a spreadsheet. Cannot delete the last remaining sheet.',\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, gids }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.sheet.delete called', { id, count: gids.length });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n const results = await Promise.allSettled(\n gids.map(async (gid) => {\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: [{ deleteSheet: { sheetId: Number(gid) } }],\n },\n });\n return gid;\n })\n );\n\n // Separate successes and failures\n const failures: Array<{ gid: string; error: string }> = [];\n\n results.forEach((result, index) => {\n const gid = gids[index];\n if (!gid) return;\n\n if (result.status === 'rejected') {\n const errorMessage = result.reason instanceof Error ? result.reason.message : String(result.reason);\n failures.push({ gid, error: errorMessage });\n }\n });\n\n const successCount = gids.length - failures.length;\n const failureCount = failures.length;\n const totalCount = gids.length;\n\n const summary = failureCount === 0 ? `Permanently deleted ${successCount} sheet${successCount === 1 ? '' : 's'}` : `Deleted ${successCount} of ${totalCount} sheet${totalCount === 1 ? '' : 's'} (${failureCount} failed)`;\n\n logger.info('sheets.sheet.delete completed', {\n totalCount,\n successCount,\n failureCount,\n });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: summary,\n itemsProcessed: totalCount,\n itemsChanged: successCount,\n completedAt: new Date().toISOString(),\n recoverable: false as const,\n id,\n spreadsheetUrl: `https://docs.google.com/spreadsheets/d/${id}`,\n ...(failures.length > 0 && { failures }),\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.sheet.delete error', { error: message });\n\n throw new McpError(ErrorCode.InternalError, `Error deleting sheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'sheet-delete',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","SheetGidSchema","SpreadsheetIdOutput","SpreadsheetIdSchema","MAX_BATCH_SIZE","inputSchema","object","id","gids","array","min","max","describe","successBranchSchema","type","literal","operationSummary","string","itemsProcessed","number","itemsChanged","completedAt","recoverable","spreadsheetUrl","optional","failures","gid","error","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","count","length","sheets","version","auth","authContext","results","Promise","allSettled","map","spreadsheets","batchUpdate","spreadsheetId","requestBody","requests","deleteSheet","sheetId","Number","forEach","index","status","errorMessage","reason","Error","message","String","push","successCount","failureCount","totalCount","summary","Date","toISOString","content","text","JSON","stringify","structuredContent","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAIrC,SAASE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AACzE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAyB;AAElG,MAAMC,iBAAiB;AAEvB,MAAMC,cAAcL,EAAEM,MAAM,CAAC;IAC3BC,IAAIJ;IACJK,MAAMR,EAAES,KAAK,CAACR,gBAAgBS,GAAG,CAAC,GAAGC,GAAG,CAACP,gBAAgBQ,QAAQ,CAAC;AACpE;AAEA,MAAMC,sBAAsBb,EAAEM,MAAM,CAAC;IACnCQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,kBAAkBhB,EAAEiB,MAAM,GAAGL,QAAQ,CAAC;IACtCM,gBAAgBlB,EAAEmB,MAAM,GAAGP,QAAQ,CAAC;IACpCQ,cAAcpB,EAAEmB,MAAM,GAAGP,QAAQ,CAAC;IAClC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E3D,MAAM,IAAI/D,SAASD,UAAU8E,aAAa,EAAE,CAAC,sBAAsB,EAAEd,SAAS,EAAE;YAC9Ee,OAAOjD,iBAAiBiC,QAAQjC,MAAMiD,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACNjD;QACAG;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/sheet-delete.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 { SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\nconst MAX_BATCH_SIZE = 1000;\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gids: z.array(SheetGidSchema).min(1).max(MAX_BATCH_SIZE).describe('Sheet grid IDs to permanently delete'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Human-readable summary of the operation'),\n itemsProcessed: z.number().describe('Total sheets attempted to delete'),\n itemsChanged: z.number().describe('Number of sheets successfully deleted'),\n completedAt: z.string().describe('ISO timestamp when operation completed'),\n recoverable: z.literal(false).describe('Whether deletion can be undone (always false)'),\n id: SpreadsheetIdOutput,\n spreadsheetUrl: z.string().optional().describe('URL to view the spreadsheet'),\n failures: z\n .array(\n z.object({\n gid: z.string().describe('Grid ID of sheet that failed to delete'),\n error: z.string().describe('Error message explaining the failure'),\n })\n )\n .optional()\n .describe('Details of any sheets that failed to delete'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Permanently delete sheets from a spreadsheet. Cannot delete the last remaining sheet.',\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, gids }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.sheet.delete called', { id, count: gids.length });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n const results = await Promise.allSettled(\n gids.map(async (gid) => {\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: [{ deleteSheet: { sheetId: Number(gid) } }],\n },\n });\n return gid;\n })\n );\n\n // Separate successes and failures\n const failures: Array<{ gid: string; error: string }> = [];\n\n results.forEach((result, index) => {\n const gid = gids[index];\n if (!gid) return;\n\n if (result.status === 'rejected') {\n const errorMessage = result.reason instanceof Error ? result.reason.message : String(result.reason);\n failures.push({ gid, error: errorMessage });\n }\n });\n\n const successCount = gids.length - failures.length;\n const failureCount = failures.length;\n const totalCount = gids.length;\n\n const summary = failureCount === 0 ? `Permanently deleted ${successCount} sheet${successCount === 1 ? '' : 's'}` : `Deleted ${successCount} of ${totalCount} sheet${totalCount === 1 ? '' : 's'} (${failureCount} failed)`;\n\n logger.info('sheets.sheet.delete completed', {\n totalCount,\n successCount,\n failureCount,\n });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: summary,\n itemsProcessed: totalCount,\n itemsChanged: successCount,\n completedAt: new Date().toISOString(),\n recoverable: false as const,\n id,\n spreadsheetUrl: `https://docs.google.com/spreadsheets/d/${id}`,\n ...(failures.length > 0 && { failures }),\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.sheet.delete error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error deleting sheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'sheet-delete',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","SheetGidSchema","SpreadsheetIdOutput","SpreadsheetIdSchema","MAX_BATCH_SIZE","inputSchema","object","id","gids","array","min","max","describe","successBranchSchema","type","literal","operationSummary","string","itemsProcessed","number","itemsChanged","completedAt","recoverable","spreadsheetUrl","optional","failures","gid","error","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","count","length","sheets","version","auth","authContext","results","Promise","allSettled","map","spreadsheets","batchUpdate","spreadsheetId","requestBody","requests","deleteSheet","sheetId","Number","forEach","index","status","errorMessage","reason","Error","message","String","push","successCount","failureCount","totalCount","summary","Date","toISOString","content","text","JSON","stringify","structuredContent","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAyB;AAElG,MAAMC,iBAAiB;AAEvB,MAAMC,cAAcL,EAAEM,MAAM,CAAC;IAC3BC,IAAIJ;IACJK,MAAMR,EAAES,KAAK,CAACR,gBAAgBS,GAAG,CAAC,GAAGC,GAAG,CAACP,gBAAgBQ,QAAQ,CAAC;AACpE;AAEA,MAAMC,sBAAsBb,EAAEM,MAAM,CAAC;IACnCQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,kBAAkBhB,EAAEiB,MAAM,GAAGL,QAAQ,CAAC;IACtCM,gBAAgBlB,EAAEmB,MAAM,GAAGP,QAAQ,CAAC;IACpCQ,cAAcpB,EAAEmB,MAAM,GAAGP,QAAQ,CAAC;IAClCS,aAAarB,EAAEiB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E,cAAcC,kBAAkB6E,aAAa,EAAE,CAAC,sBAAsB,EAAEd,SAAS,EAAE;YAC3Fe,OAAOjD,iBAAiBiC,QAAQjC,MAAMiD,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACNjD;QACAG;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
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,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  import { SheetGidOutput, SheetRefSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.js';
@@ -43,7 +43,7 @@ async function handler({ id, sheetRef }, extra) {
43
43
  // Find sheet within the known spreadsheet
44
44
  const sheet = await findSheetByRef(sheets, id, sheetRef, logger);
45
45
  if (!sheet) {
46
- throw new McpError(ErrorCode.InvalidParams, 'Sheet not found');
46
+ throw new ProtocolError(ProtocolErrorCode.InvalidParams, 'Sheet not found');
47
47
  }
48
48
  const title = (_ref = sheet === null || sheet === void 0 ? void 0 : (_sheet_properties = sheet.properties) === null || _sheet_properties === void 0 ? void 0 : _sheet_properties.title) !== null && _ref !== void 0 ? _ref : String(sheetRef);
49
49
  const gid = (sheet === null || sheet === void 0 ? void 0 : (_sheet_properties1 = sheet.properties) === null || _sheet_properties1 === void 0 ? void 0 : _sheet_properties1.sheetId) != null ? String(sheet.properties.sheetId) : '';
@@ -76,7 +76,7 @@ async function handler({ id, sheetRef }, extra) {
76
76
  logger.error('sheets.sheet.find error', {
77
77
  error: message
78
78
  });
79
- throw new McpError(ErrorCode.InternalError, `Error finding sheet: ${message}`, {
79
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error finding sheet: ${message}`, {
80
80
  stack: error instanceof Error ? error.stack : undefined
81
81
  });
82
82
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/sheet-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 type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport { SheetGidOutput, SheetRefSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { findSheetByRef } from '../../spreadsheet/sheet-operations.ts';\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n sheetRef: SheetRefSchema,\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n title: z.string().describe('Sheet tab name'),\n sheetUrl: z.string().optional().describe('URL to view the sheet'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Find an existing sheet/tab within a known spreadsheet by title or GUID',\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, sheetRef }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.sheet.find called', { id, sheetRef });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Find sheet within the known spreadsheet\n const sheet = await findSheetByRef(sheets, id, sheetRef, logger);\n if (!sheet) {\n throw new McpError(ErrorCode.InvalidParams, 'Sheet not found');\n }\n\n const title = sheet?.properties?.title ?? String(sheetRef);\n const gid = sheet?.properties?.sheetId != null ? String(sheet.properties.sheetId) : '';\n const sheetUrl = gid ? `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${gid}` : `https://docs.google.com/spreadsheets/d/${id}`;\n\n logger.info('sheets.sheet.find success', { id, gid, title });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid,\n title,\n sheetUrl,\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.sheet.find error', { error: message });\n\n throw new McpError(ErrorCode.InternalError, `Error finding sheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'sheet-find',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","SheetGidOutput","SheetRefSchema","SpreadsheetIdOutput","SpreadsheetIdSchema","findSheetByRef","inputSchema","object","id","sheetRef","successBranchSchema","type","literal","gid","title","string","describe","sheetUrl","optional","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","sheet","sheets","version","auth","authContext","InvalidParams","properties","String","sheetId","content","text","JSON","stringify","structuredContent","error","message","Error","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAIrC,SAASE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AACzE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAyB;AAClH,SAAS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MAAM,CAAC,uCAAuC,EAAEL,GAAG,UAAU,EAAEK,KAAK,GAAG,CAAC,uCAAuC,EAAEL,IAAI;QAEtIkB,OAAOC,IAAI,CAAC,6BAA6B;YAAEnB;YAAIK;YAAKC;QAAM;QAE1D,MAAMS,SAAiB;YACrBZ,MAAM;YACNH;YACAK;YACAC;YACAG;QACF;QAEA,OAAO;YACLoB,SAAS;gBAAC;oBAAE1B,MAAM;oBAAiB2B,MAAMC,KAAKC,SAAS,CAACjB;gBAAQ;aAAE;YAClEkB,mBAAmB;gBAAElB;YAAO;QAC9B;IACF,EAAE,OAAOmB,OAAO;QACd,MAAMC,UAAUD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAGR,OAAOO;QAChEhB,OAAOgB,KAAK,CAAC,2BAA2B;YAAEA,OAAOC;QAAQ;QAEzD,MAAM,IAAI7C,SAASD,UAAUgD,aAAa,EAAE,CAAC,qBAAqB,EAAEF,SAAS,EAAE;YAC7EG,OAAOJ,iBAAiBE,QAAQF,MAAMI,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACN5B;QACAG;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/sheet-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, SheetRefSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { findSheetByRef } from '../../spreadsheet/sheet-operations.ts';\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n sheetRef: SheetRefSchema,\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n title: z.string().describe('Sheet tab name'),\n sheetUrl: z.string().optional().describe('URL to view the sheet'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Find an existing sheet/tab within a known spreadsheet by title or GUID',\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, sheetRef }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.sheet.find called', { id, sheetRef });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Find sheet within the known spreadsheet\n const sheet = await findSheetByRef(sheets, id, sheetRef, logger);\n if (!sheet) {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, 'Sheet not found');\n }\n\n const title = sheet?.properties?.title ?? String(sheetRef);\n const gid = sheet?.properties?.sheetId != null ? String(sheet.properties.sheetId) : '';\n const sheetUrl = gid ? `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${gid}` : `https://docs.google.com/spreadsheets/d/${id}`;\n\n logger.info('sheets.sheet.find success', { id, gid, title });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid,\n title,\n sheetUrl,\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.sheet.find error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error finding sheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'sheet-find',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","SheetGidOutput","SheetRefSchema","SpreadsheetIdOutput","SpreadsheetIdSchema","findSheetByRef","inputSchema","object","id","sheetRef","successBranchSchema","type","literal","gid","title","string","describe","sheetUrl","optional","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","sheet","sheets","version","auth","authContext","InvalidParams","properties","String","sheetId","content","text","JSON","stringify","structuredContent","error","message","Error","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAyB;AAClH,SAASC,cAAc,QAAQ,wCAAwC;AAEvE,MAAMC,cAAcN,EAAEO,MAAM,CAAC;IAC3BC,IAAIJ;IACJK,UAAUP;AACZ;AAEA,MAAMQ,sBAAsBV,EAAEO,MAAM,CAAC;IACnCI,MAAMX,EAAEY,OAAO,CAAC;IAChBJ,IAAIL;IACJU,KAAKZ;IACLa,OAAOd,EAAEe,MAAM,GAAGC,QAAQ,CAAC;IAC3BC,UAAUjB,EAAEe,MAAM,GAAGG,QAAQ,GAAGF,QAAQ,CAAC;AAC3C;AAEA,MAAMG,eAAenB,EAAEoB,kBAAkB,CAAC,QAAQ;IAACV;IAAqBd;CAAyB;AAEjG,MAAMyB,SAAS;IACbC,aAAa;IACbhB;IACAa,cAAcnB,EAAEO,MAAM,CAAC;QACrBgB,QAAQJ;IACV;AACF;AAKA,eAAeK,QAAQ,EAAEhB,EAAE,EAAEC,QAAQ,EAAS,EAAEgB,KAAoB;IAClE,MAAMC,SAASD,MAAMC,MAAM;IAC3BA,OAAOC,IAAI,CAAC,4BAA4B;QAAEnB;QAAIC;IAAS;IAEvD,IAAI;;YASYmB,mBACFA;QATZ,MAAMC,SAAS9B,OAAO8B,MAAM,CA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}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
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,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  import { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.js';
@@ -57,7 +57,7 @@ async function handler({ id, gid, newTitle }, extra) {
57
57
  return String((_s_properties = s.properties) === null || _s_properties === void 0 ? void 0 : _s_properties.sheetId) === gid;
58
58
  });
59
59
  if (!(sheetInfo === null || sheetInfo === void 0 ? void 0 : sheetInfo.properties)) {
60
- throw new McpError(ErrorCode.InvalidParams, `Sheet with gid "${gid}" not found in spreadsheet`);
60
+ throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet with gid "${gid}" not found in spreadsheet`);
61
61
  }
62
62
  const oldTitle = sheetInfo.properties.title || '';
63
63
  // Rename the sheet
@@ -107,14 +107,14 @@ async function handler({ id, gid, newTitle }, extra) {
107
107
  }
108
108
  };
109
109
  } catch (error) {
110
- if (error instanceof McpError) {
110
+ if (error instanceof ProtocolError) {
111
111
  throw error;
112
112
  }
113
113
  const message = error instanceof Error ? error.message : String(error);
114
114
  logger.error('sheets.sheet.rename error', {
115
115
  error: message
116
116
  });
117
- throw new McpError(ErrorCode.InternalError, `Error renaming sheet: ${message}`, {
117
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error renaming sheet: ${message}`, {
118
118
  stack: error instanceof Error ? error.stack : undefined
119
119
  });
120
120
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/sheet-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 type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n newTitle: z.coerce.string().trim().min(1).describe('New name for the sheet tab'),\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 for single sheet)'),\n itemsChanged: z.number().describe('Successfully renamed sheets (always 1 on success)'),\n completedAt: z.string().describe('ISO datetime when operation completed'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n sheetUrl: z.string().describe('URL of the renamed sheet'),\n oldTitle: z.string().describe('Previous title of the sheet'),\n newTitle: z.string().describe('New title of the sheet'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Rename a sheet within a spreadsheet.',\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, newTitle }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.sheet.rename called', { id, gid, newTitle });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // First, get the current sheet title\n const spreadsheetInfo = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n const sheetInfo = spreadsheetInfo.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheetInfo?.properties) {\n throw new McpError(ErrorCode.InvalidParams, `Sheet with gid \"${gid}\" not found in spreadsheet`);\n }\n\n const oldTitle = sheetInfo.properties.title || '';\n\n // Rename the sheet\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: [\n {\n updateSheetProperties: {\n properties: { sheetId: Number(gid), title: newTitle },\n fields: 'title',\n },\n },\n ],\n },\n });\n\n logger.info('sheets.sheet.rename success', { id, gid, oldTitle, newTitle });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Renamed sheet \"${oldTitle}\" to \"${newTitle}\"`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n id,\n gid,\n sheetUrl: `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${gid}`,\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 if (error instanceof McpError) {\n throw error;\n }\n const message = error instanceof Error ? error.message : String(error);\n logger.error('sheets.sheet.rename error', { error: message });\n\n throw new McpError(ErrorCode.InternalError, `Error renaming sheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'sheet-rename',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","SheetGidOutput","SheetGidSchema","SpreadsheetIdOutput","SpreadsheetIdSchema","inputSchema","object","id","gid","newTitle","coerce","string","trim","min","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","sheetUrl","oldTitle","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","spreadsheetInfo","sheets","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","sheetInfo","data","find","s","String","properties","sheetId","InvalidParams","title","batchUpdate","requestBody","requests","updateSheetProperties","Number","Date","toISOString","content","text","JSON","stringify","structuredContent","error","message","Error","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAIrC,SAASE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AACzE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAyB;AAElH,MAAMC,cAAcL,EAAEM,MAAM,CAAC;IAC3BC,IAAIH;IACJI,KAAKN;IACLO,UAAUT,EAAEU,MAAM,CAACC,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;AACrD;AAEA,wBAAwB;AACxB,MAAMC,sBAAsBf,EAAEM,MAAM,CAAC;IACnCU,MAAMhB,EAAEiB,OAAO,CAAC;IAChBC,kBAAkBlB,EAAEW,MAAM,GAAGG,QAAQ,CAAC;IACtCK,gBAAgBnB,EAAEoB,MAAM,GAAGN,QAAQ,CAAC;IACpCO,cAAcrB,EAAEoB,MAAM,GAAGN,QAAQ,CAAC;IAClCQ,aAAatB,EAAEW,MAAM,GAAGG,QAAQ,CAAC;IACjCP,IAAIJ;IACJK,KAAKP;IACLsB,UAAUvB,EAAEW,MAAM,GAAGG,QAAQ,CAAC;IAC9BU,UAAUxB,EAAEW,MAAM,GAAGG,QAAQ,CAAC;IAC9BL,UAAUT,EAAEW,MAAM,GAAGG,QAAQ,CAAC;AAChC;AAEA,2CAA2C;AAC3C,MAAMW,eAAezB,EAAE0B,kBAAkB,CAAC,QAAQ;IAACX;IAAqBnB;CAAyB;AAEjG,MAAM+B,SAAS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BAAkB,CAAC,eAAe,EAAEM,SAAS,MAAM,EAAEf,SAAS,CAAC,CAAC;YAChEU,gBAAgB;YAChBE,cAAc;YACdC,aAAa,IAAImC,OAAOC,WAAW;YACnCnD;YACAC;YACAe,UAAU,CAAC,uCAAuC,EAAEhB,GAAG,UAAU,EAAEC,KAAK;YACxEgB;YACAf;QACF;QAEA,OAAO;YACLkD,SAAS;gBACP;oBACE3C,MAAM;oBACN4C,MAAMC,KAAKC,SAAS,CAACjC;gBACvB;aACD;YACDkC,mBAAmB;gBAAElC;YAAO;QAC9B;IACF,EAAE,OAAOmC,OAAO;QACd,IAAIA,iBAAiBlE,UAAU;YAC7B,MAAMkE;QACR;QACA,MAAMC,UAAUD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAGlB,OAAOiB;QAChEhC,OAAOgC,KAAK,CAAC,6BAA6B;YAAEA,OAAOC;QAAQ;QAE3D,MAAM,IAAInE,SAASD,UAAUsE,aAAa,EAAE,CAAC,sBAAsB,EAAEF,SAAS,EAAE;YAC9EG,OAAOJ,iBAAiBE,QAAQF,MAAMI,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACN5C;QACAG;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/sheet-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 { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n newTitle: z.coerce.string().trim().min(1).describe('New name for the sheet tab'),\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 for single sheet)'),\n itemsChanged: z.number().describe('Successfully renamed sheets (always 1 on success)'),\n completedAt: z.string().describe('ISO datetime when operation completed'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n sheetUrl: z.string().describe('URL of the renamed sheet'),\n oldTitle: z.string().describe('Previous title of the sheet'),\n newTitle: z.string().describe('New title of the sheet'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Rename a sheet within a spreadsheet.',\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, newTitle }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.sheet.rename called', { id, gid, newTitle });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // First, get the current sheet title\n const spreadsheetInfo = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n const sheetInfo = spreadsheetInfo.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheetInfo?.properties) {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet with gid \"${gid}\" not found in spreadsheet`);\n }\n\n const oldTitle = sheetInfo.properties.title || '';\n\n // Rename the sheet\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: [\n {\n updateSheetProperties: {\n properties: { sheetId: Number(gid), title: newTitle },\n fields: 'title',\n },\n },\n ],\n },\n });\n\n logger.info('sheets.sheet.rename success', { id, gid, oldTitle, newTitle });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Renamed sheet \"${oldTitle}\" to \"${newTitle}\"`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n id,\n gid,\n sheetUrl: `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${gid}`,\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 if (error instanceof ProtocolError) {\n throw error;\n }\n const message = error instanceof Error ? error.message : String(error);\n logger.error('sheets.sheet.rename error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error renaming sheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'sheet-rename',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","SheetGidOutput","SheetGidSchema","SpreadsheetIdOutput","SpreadsheetIdSchema","inputSchema","object","id","gid","newTitle","coerce","string","trim","min","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","sheetUrl","oldTitle","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","spreadsheetInfo","sheets","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","sheetInfo","data","find","s","String","properties","sheetId","InvalidParams","title","batchUpdate","requestBody","requests","updateSheetProperties","Number","Date","toISOString","content","text","JSON","stringify","structuredContent","error","message","Error","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAyB;AAElH,MAAM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AAOiB;QAChEhC,OAAOgC,KAAK,CAAC,6BAA6B;YAAEA,OAAOC;QAAQ;QAE3D,MAAM,IAAIpE,cAAcC,kBAAkBqE,aAAa,EAAE,CAAC,sBAAsB,EAAEF,SAAS,EAAE;YAC3FG,OAAOJ,iBAAiBE,QAAQF,MAAMI,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACN5C;QACAG;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
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,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  import { SpreadsheetIdSchema } from '../../schemas/index.js';
@@ -103,7 +103,7 @@ async function handler({ id, newTitle }, extra) {
103
103
  logger.error('sheets.spreadsheet.copy error', {
104
104
  error: message
105
105
  });
106
- throw new McpError(ErrorCode.InternalError, `Error copying spreadsheet: ${message}`, {
106
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error copying spreadsheet: ${message}`, {
107
107
  stack: error instanceof Error ? error.stack : undefined
108
108
  });
109
109
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/spreadsheet-copy.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 { SpreadsheetIdSchema } from '../../schemas/index.ts';\n\n// Note: Using contextual descriptions for sourceId/newId since they describe different spreadsheets\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n newTitle: z.coerce.string().trim().min(1).optional().describe('Name for the copy (optional, defaults to \"Copy of [original]\")'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Summary of the copy operation'),\n itemsProcessed: z.number().describe('Total items attempted (always 1)'),\n itemsChanged: z.number().describe('Successfully copied (always 1 on success)'),\n completedAt: z.string().describe('ISO datetime when operation completed'),\n sourceId: z.string().describe('Source spreadsheet ID'),\n sourceTitle: z.string().describe('Source spreadsheet title'),\n newId: z.string().describe('Copied spreadsheet ID'),\n newTitle: z.string().describe('Title of the copied spreadsheet'),\n spreadsheetUrl: z.string().describe('URL of the copied spreadsheet'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Copy an entire spreadsheet/workbook (all sheets, formatting, charts, named ranges, etc.). Creates in the same folder as the original. Uses Google Drive API.',\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.copy called', { id, newTitle });\n\n try {\n const drive = google.drive({ version: 'v3', auth: extra.authContext.auth });\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Get the original spreadsheet title\n const sourceInfo = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'properties.title',\n });\n\n const sourceTitle = sourceInfo.data.properties?.title || '';\n\n // Copy the spreadsheet using Drive API\n const copyResponse = await drive.files.copy({\n fileId: id,\n requestBody: {\n ...(newTitle && { name: newTitle }),\n },\n });\n\n const newId = copyResponse.data.id;\n const resultTitle = copyResponse.data.name || '';\n\n if (!newId) {\n throw new Error('Failed to retrieve new spreadsheet ID from API response');\n }\n\n logger.info('sheets.spreadsheet.copy success', { sourceId: id, newId, newTitle: resultTitle });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Copied spreadsheet \"${sourceTitle}\" to \"${resultTitle}\"`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n sourceId: id,\n sourceTitle,\n newId,\n newTitle: resultTitle,\n spreadsheetUrl: `https://docs.google.com/spreadsheets/d/${newId}`,\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.copy error', { error: message });\n\n throw new McpError(ErrorCode.InternalError, `Error copying spreadsheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'spreadsheet-copy',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","SpreadsheetIdSchema","inputSchema","object","id","newTitle","coerce","string","trim","min","optional","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","sourceId","sourceTitle","newId","spreadsheetUrl","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","sourceInfo","drive","version","auth","authContext","sheets","spreadsheets","get","spreadsheetId","fields","data","properties","title","copyResponse","files","copy","fileId","requestBody","name","resultTitle","Error","Date","toISOString","content","text","JSON","stringify","structuredContent","error","message","String","InternalError","stack","undefined","createTool"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE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B;gBAAEhC;YAAO;QAC9B;IACF,EAAE,OAAOiC,OAAO;QACd,MAAMC,UAAUD,iBAAiBR,QAAQQ,MAAMC,OAAO,GAAGC,OAAOF;QAChE9B,OAAO8B,KAAK,CAAC,iCAAiC;YAAEA,OAAOC;QAAQ;QAE/D,MAAM,IAAIhE,SAASD,UAAUmE,aAAa,EAAE,CAAC,2BAA2B,EAAEF,SAAS,EAAE;YACnFG,OAAOJ,iBAAiBR,QAAQQ,MAAMI,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLhB,MAAM;QACNzB;QACAG;IACF;AACF"}
1
+ {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/spreadsheet-copy.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 { SpreadsheetIdSchema } from '../../schemas/index.ts';\n\n// Note: Using contextual descriptions for sourceId/newId since they describe different spreadsheets\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n newTitle: z.coerce.string().trim().min(1).optional().describe('Name for the copy (optional, defaults to \"Copy of [original]\")'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Summary of the copy operation'),\n itemsProcessed: z.number().describe('Total items attempted (always 1)'),\n itemsChanged: z.number().describe('Successfully copied (always 1 on success)'),\n completedAt: z.string().describe('ISO datetime when operation completed'),\n sourceId: z.string().describe('Source spreadsheet ID'),\n sourceTitle: z.string().describe('Source spreadsheet title'),\n newId: z.string().describe('Copied spreadsheet ID'),\n newTitle: z.string().describe('Title of the copied spreadsheet'),\n spreadsheetUrl: z.string().describe('URL of the copied spreadsheet'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Copy an entire spreadsheet/workbook (all sheets, formatting, charts, named ranges, etc.). Creates in the same folder as the original. Uses Google Drive API.',\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.copy called', { id, newTitle });\n\n try {\n const drive = google.drive({ version: 'v3', auth: extra.authContext.auth });\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Get the original spreadsheet title\n const sourceInfo = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'properties.title',\n });\n\n const sourceTitle = sourceInfo.data.properties?.title || '';\n\n // Copy the spreadsheet using Drive API\n const copyResponse = await drive.files.copy({\n fileId: id,\n requestBody: {\n ...(newTitle && { name: newTitle }),\n },\n });\n\n const newId = copyResponse.data.id;\n const resultTitle = copyResponse.data.name || '';\n\n if (!newId) {\n throw new Error('Failed to retrieve new spreadsheet ID from API response');\n }\n\n logger.info('sheets.spreadsheet.copy success', { sourceId: id, newId, newTitle: resultTitle });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Copied spreadsheet \"${sourceTitle}\" to \"${resultTitle}\"`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n sourceId: id,\n sourceTitle,\n newId,\n newTitle: resultTitle,\n spreadsheetUrl: `https://docs.google.com/spreadsheets/d/${newId}`,\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.copy error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error copying spreadsheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'spreadsheet-copy',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","SpreadsheetIdSchema","inputSchema","object","id","newTitle","coerce","string","trim","min","optional","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","sourceId","sourceTitle","newId","spreadsheetUrl","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","sourceInfo","drive","version","auth","authContext","sheets","spreadsheets","get","spreadsheetId","fields","data","properties","title","copyResponse","files","copy","fileId","requestBody","name","resultTitle","Error","Date","toISOString","content","text","JSON","stringify","structuredContent","error","message","String","InternalError","stack","undefined","createTool"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,mBAAmB,QAAQ,yBAAyB;AAE7D,oGAAoG;AAEpG,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAC3BC,IAAIH;IACJI,UAAUL,EAAEM,MAAM,CAACC,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,GAAGC,QAAQ,CAAC;AAChE;AAEA,wBAAwB;AACxB,MAAMC,sBAAsBZ,EAAEG,MAAM,CAAC;IACnCU,MAAMb,EAAEc,OAAO,CAAC;IAChBC,kBAAkBf,EAAEO,MAAM,GAAGI,QAAQ,CAAC;IACtCK,gBAAgBhB,EAAEiB,MAAM,GAAGN,QAAQ,CAAC;IACpCO,cAAclB,EAAEiB,MAAM,GAAGN,QAAQ,CAAC;IAClCQ,aAAanB,EAAEO,MAAM,GAAGI,QAAQ,CA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B,aAAaH,IAAI,CAACvC,EAAE;QAClC,MAAMgD,cAAcN,aAAaH,IAAI,CAACQ,IAAI,IAAI;QAE9C,IAAI,CAAC7B,OAAO;YACV,MAAM,IAAI+B,MAAM;QAClB;QAEAtB,OAAOC,IAAI,CAAC,mCAAmC;YAAEZ,UAAUhB;YAAIkB;YAAOjB,UAAU+C;QAAY;QAE5F,MAAMxB,SAAiB;YACrBf,MAAM;YACNE,kBAAkB,CAAC,oBAAoB,EAAEM,YAAY,MAAM,EAAE+B,YAAY,CAAC,CAAC;YAC3EpC,gBAAgB;YAChBE,cAAc;YACdC,aAAa,IAAImC,OAAOC,WAAW;YACnCnC,UAAUhB;YACViB;YACAC;YACAjB,UAAU+C;YACV7B,gBAAgB,CAAC,uCAAuC,EAAED,OAAO;QACnE;QAEA,OAAO;YACLkC,SAAS;gBACP;oBACE3C,MAAM;oBACN4C,MAAMC,KAAKC,SAAS,CAAC/B;gBACvB;aACD;YACDgC,mBAAmB;gBAAEhC;YAAO;QAC9B;IACF,EAAE,OAAOiC,OAAO;QACd,MAAMC,UAAUD,iBAAiBR,QAAQQ,MAAMC,OAAO,GAAGC,OAAOF;QAChE9B,OAAO8B,KAAK,CAAC,iCAAiC;YAAEA,OAAOC;QAAQ;QAE/D,MAAM,IAAIjE,cAAcC,kBAAkBkE,aAAa,EAAE,CAAC,2BAA2B,EAAEF,SAAS,EAAE;YAChGG,OAAOJ,iBAAiBR,QAAQQ,MAAMI,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLhB,MAAM;QACNzB;QACAG;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { CallToolResult } from '@mcp-z/server';
3
3
  import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  title: z.ZodCoercedString<unknown>;
@@ -1,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  import { SpreadsheetIdOutput } from '../../schemas/index.js';
@@ -82,8 +82,8 @@ async function handler({ title }, extra) {
82
82
  logger.error('sheets.spreadsheet.create error', {
83
83
  error: message
84
84
  });
85
- // Throw McpError for proper MCP error handling
86
- throw new McpError(ErrorCode.InternalError, `Error creating spreadsheet: ${message}`, {
85
+ // Throw ProtocolError for proper MCP error handling
86
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error creating spreadsheet: ${message}`, {
87
87
  stack: error instanceof Error ? error.stack : undefined
88
88
  });
89
89
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/spreadsheet-create.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 { SpreadsheetIdOutput } from '../../schemas/index.ts';\n\nconst inputSchema = z.object({\n title: z.coerce.string().trim().min(1).describe('Title for the new spreadsheet'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Summary of the spreadsheet creation operation'),\n itemsProcessed: z.number().describe('Total items attempted (always 1 for single spreadsheet)'),\n itemsChanged: z.number().describe('Successfully created spreadsheets (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 created spreadsheet'),\n title: z.string().describe('Title of the created spreadsheet'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Create a new spreadsheet',\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({ title }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.spreadsheet.create called', { title });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n const response = await sheets.spreadsheets.create({\n requestBody: {\n properties: {\n title: title,\n },\n },\n });\n const res = response.data;\n const id = res.spreadsheetId ?? '';\n const url = res.spreadsheetUrl ?? '';\n\n logger.info('sheets.spreadsheet.create success', { id, title, url });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Created spreadsheet \"${title}\"`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n id,\n spreadsheetUrl: url,\n title,\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.create error', { error: message });\n\n // Throw McpError for proper MCP error handling\n throw new McpError(ErrorCode.InternalError, `Error creating spreadsheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'spreadsheet-create',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","SpreadsheetIdOutput","inputSchema","object","title","coerce","string","trim","min","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","id","spreadsheetUrl","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","res","sheets","version","auth","authContext","response","spreadsheets","create","requestBody","properties","data","spreadsheetId","url","Date","toISOString","content","text","JSON","stringify","structuredContent","error","message","Error","String","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAIrC,SAASE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AACzE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,mBAAmB,QAAQ,yBAAyB;AAE7D,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAC3BC,OAAOJ,EAAEK,MAAM,CAACC,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;AAClD;AAEA,wBAAwB;AACxB,MAAMC,sBAAsBV,EAAEG,MAAM,CAAC;IACnCQ,MAAMX,EAAEY,OAAO,CAAC;IAChBC,kBAAkBb,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IACtCK,gBAAgBd,EAAEe,MAAM,GAAGN,QAAQ,CAAC;IACpCO,cAAchB,EAAEe,MAAM,GAAGN,QAAQ,CAAC;IAClCQ,aAAajB,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IACjCS,IAAIjB;IACJkB,gBAAgBnB,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IACpCL,OAAOJ,EAAEM,MAAM,GAAGG,QAAQ,CAAC;AAC7B;AAEA,2CAA2C;AAC3C,MAAMW,eAAepB,EAAEqB,kBAAkB,CAAC,QAAQ;IAACX;IAAqBd;CAAyB;AAEjG,MAAM0B,SAAS;IACbC,aAAa;IACbrB;IACAkB,cAAcpB,EAAEG,MAAM,CAAC;QACrBqB,QAAQJ;IACV;AACF;AAKA,eAAeK,QAAQ,EAAErB,KAAK,EAAS,EAAEsB,KAAoB;IAC3D,MAAMC,SAASD,MAAMC,MAAM;IAC3BA,OAAOC,IAAI,CAAC,oCAAoC;QAAExB;IAAM;IAExD,IAAI;YAUS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/spreadsheet-create.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 } from '../../schemas/index.ts';\n\nconst inputSchema = z.object({\n title: z.coerce.string().trim().min(1).describe('Title for the new spreadsheet'),\n});\n\n// Success branch schema\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n operationSummary: z.string().describe('Summary of the spreadsheet creation operation'),\n itemsProcessed: z.number().describe('Total items attempted (always 1 for single spreadsheet)'),\n itemsChanged: z.number().describe('Successfully created spreadsheets (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 created spreadsheet'),\n title: z.string().describe('Title of the created spreadsheet'),\n});\n\n// Output schema with auth_required support\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Create a new spreadsheet',\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({ title }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.spreadsheet.create called', { title });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n const response = await sheets.spreadsheets.create({\n requestBody: {\n properties: {\n title: title,\n },\n },\n });\n const res = response.data;\n const id = res.spreadsheetId ?? '';\n const url = res.spreadsheetUrl ?? '';\n\n logger.info('sheets.spreadsheet.create success', { id, title, url });\n\n const result: Output = {\n type: 'success' as const,\n operationSummary: `Created spreadsheet \"${title}\"`,\n itemsProcessed: 1,\n itemsChanged: 1,\n completedAt: new Date().toISOString(),\n id,\n spreadsheetUrl: url,\n title,\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.create error', { error: message });\n\n // Throw ProtocolError for proper MCP error handling\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error creating spreadsheet: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'spreadsheet-create',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","SpreadsheetIdOutput","inputSchema","object","title","coerce","string","trim","min","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","id","spreadsheetUrl","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","res","sheets","version","auth","authContext","response","spreadsheets","create","requestBody","properties","data","spreadsheetId","url","Date","toISOString","content","text","JSON","stringify","structuredContent","error","message","Error","String","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,mBAAmB,QAAQ,yBAAyB;AAE7D,MAAMC,cAAcF,EAAEG,MAAM,CAAC;IAC3BC,OAAOJ,EAAEK,MAAM,CAACC,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;AAClD;AAEA,wBAAwB;AACxB,MAAMC,sBAAsBV,EAAEG,MAAM,CAAC;IACnCQ,MAAMX,EAAEY,OAAO,CAAC;IAChBC,kBAAkBb,EAAEM,MAAM,GAAGG,QAAQ,CAAC;IACtCK,gBAA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gBAAgBsB;YAChBrC;QACF;QAEA,OAAO;YACLwC,SAAS;gBACP;oBACEjC,MAAM;oBACNkC,MAAMC,KAAKC,SAAS,CAACvB;gBACvB;aACD;YACDwB,mBAAmB;gBAAExB;YAAO;QAC9B;IACF,EAAE,OAAOyB,OAAO;QACd,MAAMC,UAAUD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAGE,OAAOH;QAChEtB,OAAOsB,KAAK,CAAC,mCAAmC;YAAEA,OAAOC;QAAQ;QAEjE,oDAAoD;QACpD,MAAM,IAAIrD,cAAcC,kBAAkBuD,aAAa,EAAE,CAAC,4BAA4B,EAAEH,SAAS,EAAE;YACjGI,OAAOL,iBAAiBE,QAAQF,MAAMK,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACNnC;QACAG;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
2
+ import type { CallToolResult } from '@mcp-z/server';
3
3
  import { z } from 'zod';
4
4
  declare const inputSchema: z.ZodObject<{
5
5
  spreadsheetRef: z.ZodString;
@@ -1,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  import { SheetGidOutput, SpreadsheetIdOutput, SpreadsheetRefSchema } from '../../schemas/index.js';
@@ -99,7 +99,7 @@ async function handler({ spreadsheetRef }, extra) {
99
99
  logger.error('sheets.spreadsheet.find error', {
100
100
  error: message
101
101
  });
102
- throw new McpError(ErrorCode.InternalError, `Error finding spreadsheet: ${message}`, {
102
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error finding spreadsheet: ${message}`, {
103
103
  stack: error instanceof Error ? error.stack : undefined
104
104
  });
105
105
  }
@@ -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 type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\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 McpError(ErrorCode.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":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","SheetGidOutput","SpreadsheetIdOutput","SpreadsheetRefSchema","findSpreadsheetsByRef","inputSchema","object","spreadsheetRef","successBranchSchema","type","literal","items","array","id","spreadsheetTitle","string","describe","spreadsheetUrl","optional","modifiedTime","sheets","gid","sheetTitle","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","version","auth","authContext","drive","matches","sorted","slice","sort","a","b","Date","getTime","Promise","all","map","m","spreadsheetResponse","spreadsheets","get","spreadsheetId","fields","sheetsData","data","sheet","String","properties","sheetId","title","url","count","length","content","text","JSON","stringify","structuredContent","error","message","Error","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAIrC,SAASE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AACzE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,oBAAoB,QAAQ,yBAAyB;AACnG,SAASC,qBAAqB,QAAQ,8CAA8C;AAUpF,MAAMC,cAAcL,EAAEM,MAAM,CAAC;IAC3BC,gBAAgBJ;AAClB;AAEA,MAAMK,sBAAsBR,EAAEM,MAAM,CAAC;IACnCG,MAAMT,EAAEU,OAAO,CAAC;IAChBC,OAAOX,EACJY,KAAK,CACJZ,EAAEM,MAAM,CAAC;QACPO,IAAIX;QACJY,kBAAkBd,EAAEe,MAAM,GAAGC,QAAQ,CAAC;QACtCC,gBAAgBjB,EAAEe,MAAM,GAAGG,QAAQ,GAAGF,QAAQ,CAAC;QAC/CG,cAAcnB,EAAEe,MAAM,GAAGG,QAAQ,GAAGF,QAAQ,CAAC;QAC7CI,QAAQpB,EACLY,KAAK,CACJZ,EAAEM,MAAM,CAAC;YACPe,KAAKpB;YACLqB,YAAYtB,EAAEe,MAAM,GAAGC,QAAQ,CAAC;QAClC,IAEDA,QAAQ,CAAC;IACd,IAEDA,Q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esContent":["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":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","SheetGidOutput","SpreadsheetIdOutput","SpreadsheetRefSchema","findSpreadsheetsByRef","inputSchema","object","spreadsheetRef","successBranchSchema","type","literal","items","array","id","spreadsheetTitle","string","describe","spreadsheetUrl","optional","modifiedTime","sheets","gid","sheetTitle","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","version","auth","authContext","drive","matches","sorted","slice","sort","a","b","Date","getTime","Promise","all","map","m","spreadsheetResponse","spreadsheets","get","spreadsheetId","fields","sheetsData","data","sheet","String","properties","sheetId","title","url","count","length","content","text","JSON","stringify","structuredContent","error","message","Error","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,oBAAoB,QAAQ,yBAAyB;AACnG,SAASC,qBAAqB,QAAQ,8CAA8C;AAUpF,MAAMC,cAAcL,EAAEM,MAAM,CAAC;IAC3BC,gBAAgBJ;AAClB;AAEA,MAAMK,sBAAsBR,EAAEM,MAAM,CAAC;IACnCG,MAAMT,EAAEU,OAAO,CAAC;IAChBC,OAAOX,EACJY,KAAK,CACJZ,EAAEM,MAAM,CAAC;QACPO,IAAIX;QACJY,kBAAkBd,EAAEe,MAAM,GAAGC,QAAQ,CAAC;QACtCC,gBAAgBjB,EAAEe,MAAM,GAAGG,QAAQ,GAAGF,QAAQ,CAAC;QAC/CG,cAAcnB,EAAEe,MAAM,GAAGG,QAAQ,GAAGF,QAAQ,CAAC;QAC7CI,QAAQpB,EACLY,KAAK,CACJZ,EAAEM,MAAM,CAAC;YACPe,KAAKpB;YACLqB,YAAYtB,EAAEe,MAAM,GAAGC,QAAQ,CAAC;QAClC,IAEDA,QAAQ,CAAC;IACd,IAEDA,QAAQ,CAAC;AACd;AAEA,MAAMO,eAAevB,EAAEwB,kBAAkB,CAAC,QAAQ;IAAChB;IAAqBZ;CAAyB;AAEjG,MAAM6B,SAAS;IACbC,aAAa;IACbrB;IACAkB,cAAcvB,EAAEM,MAAM,CAAC;QAC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AAAA,mBAAkBI,KAAK,yCAAI;gBACzC;YACF;YAEA,OAAO;gBACL9C,IAAIkC,EAAElC,EAAE;gBACRC,gBAAgB,GAAEiC,sBAAAA,EAAEjC,gBAAgB,cAAlBiC,iCAAAA,sBAAsB;gBACxC3B,QAAQiC;gBACR,GAAIN,EAAEa,GAAG,IAAI;oBAAE3C,gBAAgB8B,EAAEa,GAAG;gBAAC,CAAC;gBACtC,GAAIb,EAAE5B,YAAY,IAAI;oBAAEA,cAAc4B,EAAE5B,YAAY;gBAAC,CAAC;YACxD;QACF;QAGFW,OAAOC,IAAI,CAAC,mCAAmC;YAAE8B,OAAOlD,MAAMmD,MAAM;QAAC;QAErE,MAAMnC,SAAiB;YACrBlB,MAAM;YACNE;QACF;QAEA,OAAO;YACLoD,SAAS;gBAAC;oBAAEtD,MAAM;oBAAiBuD,MAAMC,KAAKC,SAAS,CAACvC;gBAAQ;aAAE;YAClEwC,mBAAmB;gBAAExC;YAAO;QAC9B;IACF,EAAE,OAAOyC,OAAO;QACd,MAAMC,UAAUD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAGb,OAAOY;QAChEtC,OAAOsC,KAAK,CAAC,iCAAiC;YAAEA,OAAOC;QAAQ;QAE/D,MAAM,IAAIxE,cAAcC,kBAAkByE,aAAa,EAAE,CAAC,2BAA2B,EAAEF,SAAS,EAAE;YAChGG,OAAOJ,iBAAiBE,QAAQF,MAAMI,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACNlD;QACAG;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
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,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  import { SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.js';
@@ -98,7 +98,7 @@ async function handler({ id, newTitle }, extra) {
98
98
  logger.error('sheets.spreadsheet.rename error', {
99
99
  error: message
100
100
  });
101
- throw new McpError(ErrorCode.InternalError, `Error renaming spreadsheet: ${message}`, {
101
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error renaming spreadsheet: ${message}`, {
102
102
  stack: error instanceof Error ? error.stack : undefined
103
103
  });
104
104
  }
@@ -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 type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\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 McpError(ErrorCode.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":["schemas","AuthRequiredBranchSchema","ErrorCode","McpError","google","z","SpreadsheetIdOutput","SpreadsheetIdSchema","inputSchema","object","id","newTitle","coerce","string","trim","min","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","spreadsheetUrl","oldTitle","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","spreadsheetInfo","sheets","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","batchUpdate","requestBody","requests","updateSpreadsheetProperties","Date","toISOString","content","text","JSON","stringify","structuredContent","error","message","Error","String","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAIrC,SAASE,SAAS,EAAEC,QAAQ,QAAQ,qCAAqC;AACzE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAyB;AAElF,MAAMC,cAAcH,EAAEI,MAAM,CAAC;IAC3BC,IAAIH;IACJI,UAAUN,EAAEO,MAAM,CAACC,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;AACrD;AAEA,wBAAwB;AACxB,MAAMC,sBAAsBZ,EAAEI,MAAM,CAAC;IACnCS,MAAMb,EAAEc,OAAO,CAAC;IAChBC,kBAAkBf,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;IACtCK,gBAAgBhB,EAAEiB,MAAM,GAAGN,QAAQ,CAAC;IACpCO,cAAclB,EAAEiB,MAAM,GAAGN,QAAQ,CAAC;IAClCQ,aAAanB,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;IACjCN,IAAIJ;IACJmB,gBAAgBpB,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;IACpCU,UAAUrB,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;IAC9BL,UAAUN,EAAEQ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ACF;QAEA,OAAO;YACL2C,SAAS;gBACP;oBACEpC,MAAM;oBACNqC,MAAMC,KAAKC,SAAS,CAAC1B;gBACvB;aACD;YACD2B,mBAAmB;gBAAE3B;YAAO;QAC9B;IACF,EAAE,OAAO4B,OAAO;QACd,MAAMC,UAAUD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAGE,OAAOH;QAChEzB,OAAOyB,KAAK,CAAC,mCAAmC;YAAEA,OAAOC;QAAQ;QAEjE,MAAM,IAAIzD,SAASD,UAAU6D,aAAa,EAAE,CAAC,4BAA4B,EAAEH,SAAS,EAAE;YACpFI,OAAOL,iBAAiBE,QAAQF,MAAMK,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACNtC;QACAG;IACF;AACF"}
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":["schemas","AuthRequiredBranchSchema","ProtocolError","ProtocolErrorCode","google","z","SpreadsheetIdOutput","SpreadsheetIdSchema","inputSchema","object","id","newTitle","coerce","string","trim","min","describe","successBranchSchema","type","literal","operationSummary","itemsProcessed","number","itemsChanged","completedAt","spreadsheetUrl","oldTitle","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","info","spreadsheetInfo","sheets","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","batchUpdate","requestBody","requests","updateSpreadsheetProperties","Date","toISOString","content","text","JSON","stringify","structuredContent","error","message","Error","String","InternalError","stack","undefined","createTool","name"],"mappings":"AACA,SAASA,OAAO,QAAQ,sBAAsB;AAE9C,MAAM,EAAEC,wBAAwB,EAAE,GAAGD;AAGrC,SAASE,aAAa,EAAEC,iBAAiB,QAAQ,gBAAgB;AACjE,SAASC,MAAM,QAAQ,aAAa;AACpC,SAASC,CAAC,QAAQ,MAAM;AACxB,SAASC,mBAAmB,EAAEC,mBAAmB,QAAQ,yBAAyB;AAElF,MAAMC,cAAcH,EAAEI,MAAM,CAAC;IAC3BC,IAAIH;IACJI,UAAUN,EAAEO,MAAM,CAACC,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;AACrD;AAEA,wBAAwB;AACxB,MAAMC,sBAAsBZ,EAAEI,MAAM,CAAC;IACnCS,MAAMb,EAAEc,OAAO,CAAC;IAChBC,kBAAkBf,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;IACtCK,gBAAgBhB,EAAEiB,MAAM,GAAGN,QAAQ,CAAC;IACpCO,cAAclB,EAAEiB,MAAM,GAAGN,QAAQ,CAAC;IAClCQ,aAAanB,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;IACjCN,IAAIJ;IACJmB,gBAAgBpB,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;IACpCU,UAAUrB,EAAEQ,MAAM,GAAGG,QAAQ,CAAC;IAC9BL,UAAUN,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ACAf;QACF;QAEA,OAAO;YACL2C,SAAS;gBACP;oBACEpC,MAAM;oBACNqC,MAAMC,KAAKC,SAAS,CAAC1B;gBACvB;aACD;YACD2B,mBAAmB;gBAAE3B;YAAO;QAC9B;IACF,EAAE,OAAO4B,OAAO;QACd,MAAMC,UAAUD,iBAAiBE,QAAQF,MAAMC,OAAO,GAAGE,OAAOH;QAChEzB,OAAOyB,KAAK,CAAC,mCAAmC;YAAEA,OAAOC;QAAQ;QAEjE,MAAM,IAAI1D,cAAcC,kBAAkB4D,aAAa,EAAE,CAAC,4BAA4B,EAAEH,SAAS,EAAE;YACjGI,OAAOL,iBAAiBE,QAAQF,MAAMK,KAAK,GAAGC;QAChD;IACF;AACF;AAEA,eAAe,SAASC;IACtB,OAAO;QACLC,MAAM;QACNtC;QACAG;IACF;AACF"}
@@ -1,5 +1,5 @@
1
1
  import type { EnrichedExtra } from '@mcp-z/oauth-google';
2
- import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
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,6 +1,6 @@
1
1
  import { schemas } from '@mcp-z/oauth-google';
2
2
  const { AuthRequiredBranchSchema } = schemas;
3
- import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';
4
4
  import { google } from 'googleapis';
5
5
  import { z } from 'zod';
6
6
  import { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.js';
@@ -234,7 +234,7 @@ async function handler({ id, gid, requests }, extra) {
234
234
  gid,
235
235
  requestCount: requests.length
236
236
  });
237
- throw new McpError(ErrorCode.InvalidParams, `Sheet not found: ${gid}`);
237
+ throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet not found: ${gid}`);
238
238
  }
239
239
  const sheetTitle = (_sheet_properties_title = sheet.properties.title) !== null && _sheet_properties_title !== void 0 ? _sheet_properties_title : gid;
240
240
  const sheetId = sheet.properties.sheetId;
@@ -246,7 +246,7 @@ async function handler({ id, gid, requests }, extra) {
246
246
  gid,
247
247
  sheetTitle
248
248
  });
249
- throw new McpError(ErrorCode.InternalError, `Sheet ID not available for ${gid}. Cannot perform validation operations without valid sheet ID.`);
249
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Sheet ID not available for ${gid}. Cannot perform validation operations without valid sheet ID.`);
250
250
  }
251
251
  // Build batch update requests
252
252
  const batchRequests = [];
@@ -352,7 +352,7 @@ async function handler({ id, gid, requests }, extra) {
352
352
  requestCount: requests.length,
353
353
  error: message
354
354
  });
355
- throw new McpError(ErrorCode.InternalError, `Error setting validation: ${message}`, {
355
+ throw new ProtocolError(ProtocolErrorCode.InternalError, `Error setting validation: ${message}`, {
356
356
  stack: error instanceof Error ? error.stack : undefined
357
357
  });
358
358
  }