google-tools-mcp 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,6 +13,7 @@ Most Google MCP servers split functionality across separate packages. This serve
13
13
  - **146 tools** across 8 categories, all available immediately
14
14
  - **Single auth token** — one OAuth flow covers Drive, Docs, Sheets, Gmail, and Calendar
15
15
  - **Lazy-loading auth** — no browser popup until your first tool call
16
+ - **No lazy tool loading** — all 146 tools are registered eagerly at startup since most MCP clients (including Claude Code) don't support `notifications/tools/list_changed`
16
17
  - **Multi-profile support** — separate tokens per Google account
17
18
  - **No telemetry**
18
19
 
package/dist/auth.js CHANGED
@@ -48,6 +48,10 @@ const SCOPES = [
48
48
  'https://www.googleapis.com/auth/gmail.settings.sharing',
49
49
  // Calendar
50
50
  'https://www.googleapis.com/auth/calendar',
51
+ // Forms
52
+ 'https://www.googleapis.com/auth/forms.body',
53
+ 'https://www.googleapis.com/auth/forms.body.readonly',
54
+ 'https://www.googleapis.com/auth/forms.responses.readonly',
51
55
  ];
52
56
 
53
57
  // ---------------------------------------------------------------------------
package/dist/clients.js CHANGED
@@ -12,6 +12,7 @@ let googleSheets = null;
12
12
  let googleScript = null;
13
13
  let gmailClient = null;
14
14
  let calendarClient = null;
15
+ let formsClient = null;
15
16
 
16
17
  async function ensureAuth() {
17
18
  if (authClient) return;
@@ -58,6 +59,14 @@ export async function initializeCalendarClient() {
58
59
  return { authClient, calendarClient };
59
60
  }
60
61
 
62
+ // --- Forms client ---
63
+ export async function initializeFormsClient() {
64
+ if (formsClient) return { authClient, formsClient };
65
+ await ensureAuth();
66
+ if (!formsClient) formsClient = google.forms({ version: 'v1', auth: authClient });
67
+ return { authClient, formsClient };
68
+ }
69
+
61
70
  // --- Reset all clients (used by logout) ---
62
71
  export function resetClients() {
63
72
  authClient = null;
@@ -67,6 +76,7 @@ export function resetClients() {
67
76
  googleScript = null;
68
77
  gmailClient = null;
69
78
  calendarClient = null;
79
+ formsClient = null;
70
80
  }
71
81
 
72
82
  // --- Individual client getters ---
@@ -111,3 +121,9 @@ export async function getCalendarClient() {
111
121
  if (!calendar) throw new UserError('Google Calendar client is not initialized.');
112
122
  return calendar;
113
123
  }
124
+
125
+ export async function getFormsClient() {
126
+ const { formsClient: forms } = await initializeFormsClient();
127
+ if (!forms) throw new UserError('Google Forms client is not initialized.');
128
+ return forms;
129
+ }
@@ -1,6 +1,4 @@
1
- import { register as applyTextStyle } from './applyTextStyle.js';
2
1
  import { register as applyParagraphStyle } from './applyParagraphStyle.js';
3
2
  export function registerFormattingTools(server) {
4
- applyTextStyle(server);
5
3
  applyParagraphStyle(server);
6
4
  }
@@ -4,7 +4,6 @@ import { register as listDocumentTabs } from './listDocumentTabs.js';
4
4
  import { register as renameTab } from './renameTab.js';
5
5
  import { register as addTab } from './addTab.js';
6
6
  import { register as appendToGoogleDoc } from './appendToGoogleDoc.js';
7
- import { register as insertText } from './insertText.js';
8
7
  import { register as deleteRange } from './deleteRange.js';
9
8
  import { register as modifyText } from './modifyText.js';
10
9
  import { register as findAndReplace } from './findAndReplace.js';
@@ -23,7 +22,6 @@ export function registerDocsTools(server) {
23
22
  renameTab(server);
24
23
  addTab(server);
25
24
  appendToGoogleDoc(server);
26
- insertText(server);
27
25
  deleteRange(server);
28
26
  modifyText(server);
29
27
  findAndReplace(server);
@@ -0,0 +1,48 @@
1
+ import { UserError } from 'fastmcp';
2
+ import { z } from 'zod';
3
+ import { getDriveClient } from '../../clients.js';
4
+ export function register(server) {
5
+ server.addTool({
6
+ name: 'getFileInfo',
7
+ description: 'Gets metadata about any Drive file (document, spreadsheet, PDF, etc.) including its name, type, owner, sharing status, and modification history.',
8
+ parameters: z.object({
9
+ fileId: z.string().describe('The ID of the file to get information about.'),
10
+ }),
11
+ execute: async (args, { log }) => {
12
+ const drive = await getDriveClient();
13
+ log.info(`Getting info for file: ${args.fileId}`);
14
+ try {
15
+ const response = await drive.files.get({
16
+ fileId: args.fileId,
17
+ fields: 'id,name,description,mimeType,size,createdTime,modifiedTime,webViewLink,owners(displayName,emailAddress),lastModifyingUser(displayName,emailAddress),shared,parents,version',
18
+ supportsAllDrives: true,
19
+ });
20
+ const file = response.data;
21
+ if (!file) {
22
+ throw new UserError(`File with ID ${args.fileId} not found.`);
23
+ }
24
+ const info = {
25
+ id: file.id,
26
+ name: file.name,
27
+ mimeType: file.mimeType,
28
+ createdTime: file.createdTime,
29
+ modifiedTime: file.modifiedTime,
30
+ owner: file.owners?.[0]?.displayName || null,
31
+ lastModifyingUser: file.lastModifyingUser?.displayName || null,
32
+ shared: file.shared || false,
33
+ url: file.webViewLink,
34
+ description: file.description || null,
35
+ };
36
+ return JSON.stringify(info, null, 2);
37
+ }
38
+ catch (error) {
39
+ log.error(`Error getting file info: ${error.message || error}`);
40
+ if (error.code === 404)
41
+ throw new UserError(`File not found (ID: ${args.fileId}).`);
42
+ if (error.code === 403)
43
+ throw new UserError('Permission denied. Make sure you have access to this file.');
44
+ throw new UserError(`Failed to get file info: ${error.message || 'Unknown error'}`);
45
+ }
46
+ },
47
+ });
48
+ }
@@ -1,6 +1,6 @@
1
- import { register as listGoogleDocs } from './listGoogleDocs.js';
1
+ import { register as listDriveFiles } from './listDriveFiles.js';
2
2
  import { register as searchGoogleDocs } from './searchGoogleDocs.js';
3
- import { register as getDocumentInfo } from './getDocumentInfo.js';
3
+ import { register as getFileInfo } from './getFileInfo.js';
4
4
  import { register as createFolder } from './createFolder.js';
5
5
  import { register as listFolderContents } from './listFolderContents.js';
6
6
  import { register as getFolderInfo } from './getFolderInfo.js';
@@ -13,9 +13,9 @@ import { register as createFromTemplate } from './createFromTemplate.js';
13
13
  import { register as listSharedDrives } from './listSharedDrives.js';
14
14
  import { register as listSharedWithMe } from './listSharedWithMe.js';
15
15
  export function registerDriveTools(server) {
16
- listGoogleDocs(server);
16
+ listDriveFiles(server);
17
17
  searchGoogleDocs(server);
18
- getDocumentInfo(server);
18
+ getFileInfo(server);
19
19
  createFolder(server);
20
20
  listFolderContents(server);
21
21
  getFolderInfo(server);
@@ -0,0 +1,106 @@
1
+ import { UserError } from 'fastmcp';
2
+ import { z } from 'zod';
3
+ import { getDriveClient } from '../../clients.js';
4
+
5
+ const MIME_TYPES = {
6
+ document: 'application/vnd.google-apps.document',
7
+ spreadsheet: 'application/vnd.google-apps.spreadsheet',
8
+ presentation: 'application/vnd.google-apps.presentation',
9
+ form: 'application/vnd.google-apps.form',
10
+ pdf: 'application/pdf',
11
+ };
12
+
13
+ export function register(server) {
14
+ server.addTool({
15
+ name: 'listDriveFiles',
16
+ description:
17
+ 'Lists files in your Drive, optionally filtered by type (document, spreadsheet, presentation, form, pdf), name/content query, or modification date.',
18
+ parameters: z.object({
19
+ fileType: z
20
+ .enum(['document', 'spreadsheet', 'presentation', 'form', 'pdf', 'all'])
21
+ .optional()
22
+ .default('all')
23
+ .describe('Filter by file type. Defaults to all types.'),
24
+ maxResults: z
25
+ .number()
26
+ .int()
27
+ .min(1)
28
+ .max(100)
29
+ .optional()
30
+ .default(20)
31
+ .describe('Maximum number of files to return (1-100).'),
32
+ query: z
33
+ .string()
34
+ .optional()
35
+ .describe('Search query to filter files by name or content.'),
36
+ orderBy: z
37
+ .enum(['name', 'modifiedTime', 'createdTime'])
38
+ .optional()
39
+ .default('modifiedTime')
40
+ .describe('Sort order for results.'),
41
+ modifiedAfter: z
42
+ .string()
43
+ .optional()
44
+ .describe(
45
+ 'Only return files modified after this date (ISO 8601 format, e.g., "2024-01-01").'
46
+ ),
47
+ }),
48
+ execute: async (args, { log }) => {
49
+ const drive = await getDriveClient();
50
+ log.info(
51
+ `Listing Drive files. Type: ${args.fileType}, Query: ${args.query || 'none'}, Max: ${args.maxResults}, Order: ${args.orderBy}`
52
+ );
53
+ try {
54
+ let queryParts = ['trashed=false'];
55
+
56
+ // Filter by mime type
57
+ if (args.fileType !== 'all') {
58
+ queryParts.push(`mimeType='${MIME_TYPES[args.fileType]}'`);
59
+ } else {
60
+ // Exclude folders from "all" results
61
+ queryParts.push("mimeType!='application/vnd.google-apps.folder'");
62
+ }
63
+
64
+ if (args.query) {
65
+ queryParts.push(
66
+ `(name contains '${args.query}' or fullText contains '${args.query}')`
67
+ );
68
+ }
69
+
70
+ if (args.modifiedAfter) {
71
+ const cutoffDate = new Date(args.modifiedAfter).toISOString();
72
+ queryParts.push(`modifiedTime > '${cutoffDate}'`);
73
+ }
74
+
75
+ const response = await drive.files.list({
76
+ q: queryParts.join(' and '),
77
+ pageSize: args.maxResults,
78
+ orderBy: args.orderBy === 'name' ? 'name' : args.orderBy,
79
+ fields: 'files(id,name,mimeType,modifiedTime,createdTime,size,webViewLink,owners(displayName,emailAddress))',
80
+ supportsAllDrives: true,
81
+ includeItemsFromAllDrives: true,
82
+ });
83
+
84
+ const files = (response.data.files || []).map((file) => ({
85
+ id: file.id,
86
+ name: file.name,
87
+ mimeType: file.mimeType,
88
+ modifiedTime: file.modifiedTime,
89
+ owner: file.owners?.[0]?.displayName || null,
90
+ url: file.webViewLink,
91
+ }));
92
+
93
+ return JSON.stringify({ files }, null, 2);
94
+ } catch (error) {
95
+ log.error(`Error listing Drive files: ${error.message || error}`);
96
+ if (error.code === 403)
97
+ throw new UserError(
98
+ 'Permission denied. Make sure you have granted Google Drive access to the application.'
99
+ );
100
+ throw new UserError(
101
+ `Failed to list files: ${error.message || 'Unknown error'}`
102
+ );
103
+ }
104
+ },
105
+ });
106
+ }
@@ -0,0 +1,80 @@
1
+ import { UserError } from 'fastmcp';
2
+ import { z } from 'zod';
3
+ import { getFormsClient } from '../../clients.js';
4
+
5
+ export function register(server) {
6
+ server.addTool({
7
+ name: 'batch_update_form',
8
+ description:
9
+ 'Applies one or more updates to a Google Form. Supports creating, updating, deleting, and moving items, as well as updating form info and settings. ' +
10
+ 'Each request in the array should be an object with exactly one key: createItem, updateItem, deleteItem, moveItem, updateFormInfo, or updateSettings. ' +
11
+ 'See the Google Forms API batchUpdate documentation for the full request schema.',
12
+ parameters: z.object({
13
+ formId: z.string().describe('The ID of the Google Form to update'),
14
+ requests: z
15
+ .array(z.record(z.any()))
16
+ .min(1)
17
+ .describe(
18
+ 'Array of update requests. Each object should have one key: createItem, updateItem, deleteItem, moveItem, updateFormInfo, or updateSettings',
19
+ ),
20
+ }),
21
+ execute: async (args, { log }) => {
22
+ const forms = await getFormsClient();
23
+ log.info(`Batch updating form ${args.formId} with ${args.requests.length} request(s)`);
24
+
25
+ const validKeys = new Set([
26
+ 'createItem',
27
+ 'updateItem',
28
+ 'deleteItem',
29
+ 'moveItem',
30
+ 'updateFormInfo',
31
+ 'updateSettings',
32
+ ]);
33
+
34
+ for (const req of args.requests) {
35
+ const keys = Object.keys(req);
36
+ if (keys.length !== 1 || !validKeys.has(keys[0])) {
37
+ throw new UserError(
38
+ `Invalid request object. Each request must have exactly one key from: ${[...validKeys].join(', ')}. Got: ${keys.join(', ')}`,
39
+ );
40
+ }
41
+ }
42
+
43
+ try {
44
+ const response = await forms.forms.batchUpdate({
45
+ formId: args.formId,
46
+ requestBody: { requests: args.requests },
47
+ });
48
+ const data = response.data;
49
+ const replies = data.replies || [];
50
+
51
+ const result = {
52
+ requestsApplied: args.requests.length,
53
+ repliesReceived: replies.length,
54
+ };
55
+
56
+ const createdItems = [];
57
+ for (const reply of replies) {
58
+ if (reply.createItem) {
59
+ const ci = reply.createItem;
60
+ createdItems.push({
61
+ itemId: ci.itemId,
62
+ questionId: ci.questionId?.[0] || null,
63
+ });
64
+ }
65
+ }
66
+ if (createdItems.length > 0) {
67
+ result.createdItems = createdItems;
68
+ }
69
+
70
+ return JSON.stringify(result, null, 2);
71
+ } catch (error) {
72
+ log.error(`Error batch updating form: ${error.message || error}`);
73
+ if (error.code === 401)
74
+ throw new UserError('Authentication failed. Try logging out and re-authenticating.');
75
+ if (error.code === 404) throw new UserError(`Form not found: ${args.formId}`);
76
+ throw new UserError(`Failed to batch update form: ${error.message || 'Unknown error'}`);
77
+ }
78
+ },
79
+ });
80
+ }
@@ -0,0 +1,54 @@
1
+ import { UserError } from 'fastmcp';
2
+ import { z } from 'zod';
3
+ import { getFormsClient } from '../../clients.js';
4
+
5
+ export function register(server) {
6
+ server.addTool({
7
+ name: 'create_form',
8
+ description:
9
+ 'Creates a new Google Form with a title and optional description. Returns the form ID, edit URL, and responder URL.',
10
+ parameters: z.object({
11
+ title: z.string().describe('The title of the form (shown to respondents)'),
12
+ description: z.string().optional().describe('A description displayed at the top of the form'),
13
+ documentTitle: z
14
+ .string()
15
+ .optional()
16
+ .describe('The document title (shown in Drive). Defaults to the form title if not provided'),
17
+ }),
18
+ execute: async (args, { log }) => {
19
+ const forms = await getFormsClient();
20
+ log.info(`Creating form: ${args.title}`);
21
+
22
+ const body = {
23
+ info: {
24
+ title: args.title,
25
+ documentTitle: args.documentTitle || args.title,
26
+ },
27
+ };
28
+ if (args.description) {
29
+ body.info.description = args.description;
30
+ }
31
+
32
+ try {
33
+ const response = await forms.forms.create({ requestBody: body });
34
+ const form = response.data;
35
+
36
+ return JSON.stringify(
37
+ {
38
+ formId: form.formId,
39
+ title: form.info?.title,
40
+ editUrl: `https://docs.google.com/forms/d/${form.formId}/edit`,
41
+ responderUrl: form.responderUri || `https://docs.google.com/forms/d/${form.formId}/viewform`,
42
+ },
43
+ null,
44
+ 2,
45
+ );
46
+ } catch (error) {
47
+ log.error(`Error creating form: ${error.message || error}`);
48
+ if (error.code === 401)
49
+ throw new UserError('Authentication failed. Try logging out and re-authenticating.');
50
+ throw new UserError(`Failed to create form: ${error.message || 'Unknown error'}`);
51
+ }
52
+ },
53
+ });
54
+ }
@@ -0,0 +1,118 @@
1
+ import { UserError } from 'fastmcp';
2
+ import { z } from 'zod';
3
+ import { getFormsClient } from '../../clients.js';
4
+
5
+ function extractOptionValues(options) {
6
+ if (!options) return [];
7
+ return options.filter((o) => o.value).map((o) => {
8
+ const opt = { value: o.value };
9
+ if (o.isOther) opt.isOther = true;
10
+ if (o.image) opt.image = o.image;
11
+ if (o.goToAction) opt.goToAction = o.goToAction;
12
+ if (o.goToSectionId) opt.goToSectionId = o.goToSectionId;
13
+ return opt;
14
+ });
15
+ }
16
+
17
+ function getQuestionType(question) {
18
+ if (question.choiceQuestion) return question.choiceQuestion.type || 'RADIO';
19
+ if (question.textQuestion) {
20
+ return question.textQuestion.paragraph ? 'PARAGRAPH' : 'TEXT';
21
+ }
22
+ if (question.scaleQuestion) return 'SCALE';
23
+ if (question.dateQuestion) return 'DATE';
24
+ if (question.timeQuestion) return 'TIME';
25
+ if (question.fileUploadQuestion) return 'FILE_UPLOAD';
26
+ if (question.ratingQuestion) return 'RATING';
27
+ if (question.rowQuestion) return 'GRID_ROW';
28
+ return 'QUESTION';
29
+ }
30
+
31
+ function serializeFormItem(item, index) {
32
+ const result = {
33
+ index,
34
+ itemId: item.itemId,
35
+ title: item.title || '',
36
+ description: item.description || '',
37
+ };
38
+
39
+ if (item.questionItem) {
40
+ const q = item.questionItem.question;
41
+ result.type = getQuestionType(q);
42
+ result.required = q.required || false;
43
+ result.questionId = q.questionId || null;
44
+ if (q.choiceQuestion) {
45
+ result.options = extractOptionValues(q.choiceQuestion.options);
46
+ }
47
+ } else if (item.questionGroupItem) {
48
+ const group = item.questionGroupItem;
49
+ result.type = 'GRID';
50
+ result.grid = {
51
+ columns: group.grid?.columns?.options
52
+ ? extractOptionValues(group.grid.columns.options)
53
+ : [],
54
+ };
55
+ if (group.questions) {
56
+ result.grid.rows = group.questions.map((q) => ({
57
+ questionId: q.questionId,
58
+ title: q.rowQuestion?.title || '',
59
+ required: q.required || false,
60
+ }));
61
+ }
62
+ } else if (item.pageBreakItem !== undefined) {
63
+ result.type = 'PAGE_BREAK';
64
+ } else if (item.textItem !== undefined) {
65
+ result.type = 'TEXT_ITEM';
66
+ } else if (item.imageItem) {
67
+ result.type = 'IMAGE';
68
+ } else if (item.videoItem) {
69
+ result.type = 'VIDEO';
70
+ } else {
71
+ result.type = 'UNKNOWN';
72
+ }
73
+
74
+ return result;
75
+ }
76
+
77
+ export function register(server) {
78
+ server.addTool({
79
+ name: 'get_form',
80
+ description:
81
+ 'Retrieves a Google Form by ID. Returns the form title, description, URLs, and all items (questions, sections, images, etc.) with their types, options, and metadata.',
82
+ parameters: z.object({
83
+ formId: z.string().describe('The ID of the Google Form to retrieve'),
84
+ }),
85
+ execute: async (args, { log }) => {
86
+ const forms = await getFormsClient();
87
+ log.info(`Getting form: ${args.formId}`);
88
+
89
+ try {
90
+ const response = await forms.forms.get({ formId: args.formId });
91
+ const form = response.data;
92
+ const items = (form.items || []).map((item, i) => serializeFormItem(item, i));
93
+
94
+ return JSON.stringify(
95
+ {
96
+ formId: form.formId,
97
+ title: form.info?.title || '',
98
+ description: form.info?.description || '',
99
+ documentTitle: form.info?.documentTitle || '',
100
+ editUrl: `https://docs.google.com/forms/d/${form.formId}/edit`,
101
+ responderUrl:
102
+ form.responderUri || `https://docs.google.com/forms/d/${form.formId}/viewform`,
103
+ itemCount: items.length,
104
+ items,
105
+ },
106
+ null,
107
+ 2,
108
+ );
109
+ } catch (error) {
110
+ log.error(`Error getting form: ${error.message || error}`);
111
+ if (error.code === 401)
112
+ throw new UserError('Authentication failed. Try logging out and re-authenticating.');
113
+ if (error.code === 404) throw new UserError(`Form not found: ${args.formId}`);
114
+ throw new UserError(`Failed to get form: ${error.message || 'Unknown error'}`);
115
+ }
116
+ },
117
+ });
118
+ }
@@ -0,0 +1,45 @@
1
+ import { UserError } from 'fastmcp';
2
+ import { z } from 'zod';
3
+ import { getFormsClient } from '../../clients.js';
4
+
5
+ export function register(server) {
6
+ server.addTool({
7
+ name: 'get_form_response',
8
+ description:
9
+ 'Retrieves a single response from a Google Form by response ID. Returns the response timestamps and all answers keyed by question ID.',
10
+ parameters: z.object({
11
+ formId: z.string().describe('The ID of the Google Form'),
12
+ responseId: z.string().describe('The ID of the specific response to retrieve'),
13
+ }),
14
+ execute: async (args, { log }) => {
15
+ const forms = await getFormsClient();
16
+ log.info(`Getting response ${args.responseId} for form: ${args.formId}`);
17
+
18
+ try {
19
+ const response = await forms.forms.responses.get({
20
+ formId: args.formId,
21
+ responseId: args.responseId,
22
+ });
23
+ const r = response.data;
24
+
25
+ return JSON.stringify(
26
+ {
27
+ responseId: r.responseId,
28
+ createTime: r.createTime,
29
+ lastSubmittedTime: r.lastSubmittedTime,
30
+ answers: r.answers || {},
31
+ },
32
+ null,
33
+ 2,
34
+ );
35
+ } catch (error) {
36
+ log.error(`Error getting form response: ${error.message || error}`);
37
+ if (error.code === 401)
38
+ throw new UserError('Authentication failed. Try logging out and re-authenticating.');
39
+ if (error.code === 404)
40
+ throw new UserError(`Form or response not found: ${args.formId} / ${args.responseId}`);
41
+ throw new UserError(`Failed to get form response: ${error.message || 'Unknown error'}`);
42
+ }
43
+ },
44
+ });
45
+ }
@@ -0,0 +1,15 @@
1
+ import { register as createForm } from './createForm.js';
2
+ import { register as getForm } from './getForm.js';
3
+ import { register as listFormResponses } from './listFormResponses.js';
4
+ import { register as getFormResponse } from './getFormResponse.js';
5
+ import { register as batchUpdateForm } from './batchUpdateForm.js';
6
+ import { register as setPublishSettings } from './setPublishSettings.js';
7
+
8
+ export function registerFormsTools(server) {
9
+ createForm(server);
10
+ getForm(server);
11
+ listFormResponses(server);
12
+ getFormResponse(server);
13
+ batchUpdateForm(server);
14
+ setPublishSettings(server);
15
+ }
@@ -0,0 +1,56 @@
1
+ import { UserError } from 'fastmcp';
2
+ import { z } from 'zod';
3
+ import { getFormsClient } from '../../clients.js';
4
+
5
+ export function register(server) {
6
+ server.addTool({
7
+ name: 'list_form_responses',
8
+ description:
9
+ 'Lists responses submitted to a Google Form. Returns a paginated list of responses with timestamps and answers.',
10
+ parameters: z.object({
11
+ formId: z.string().describe('The ID of the Google Form'),
12
+ pageSize: z
13
+ .number()
14
+ .min(1)
15
+ .max(5000)
16
+ .optional()
17
+ .describe('Number of responses to return per page (default 10, max 5000)'),
18
+ pageToken: z.string().optional().describe('Token for fetching the next page of results'),
19
+ }),
20
+ execute: async (args, { log }) => {
21
+ const forms = await getFormsClient();
22
+ log.info(`Listing responses for form: ${args.formId}`);
23
+
24
+ const params = { formId: args.formId };
25
+ if (args.pageSize) params.pageSize = args.pageSize;
26
+ if (args.pageToken) params.pageToken = args.pageToken;
27
+
28
+ try {
29
+ const response = await forms.forms.responses.list(params);
30
+ const data = response.data;
31
+ const responses = (data.responses || []).map((r) => ({
32
+ responseId: r.responseId,
33
+ createTime: r.createTime,
34
+ lastSubmittedTime: r.lastSubmittedTime,
35
+ answers: r.answers || {},
36
+ }));
37
+
38
+ return JSON.stringify(
39
+ {
40
+ totalResponses: responses.length,
41
+ nextPageToken: data.nextPageToken || null,
42
+ responses,
43
+ },
44
+ null,
45
+ 2,
46
+ );
47
+ } catch (error) {
48
+ log.error(`Error listing form responses: ${error.message || error}`);
49
+ if (error.code === 401)
50
+ throw new UserError('Authentication failed. Try logging out and re-authenticating.');
51
+ if (error.code === 404) throw new UserError(`Form not found: ${args.formId}`);
52
+ throw new UserError(`Failed to list form responses: ${error.message || 'Unknown error'}`);
53
+ }
54
+ },
55
+ });
56
+ }
@@ -0,0 +1,58 @@
1
+ import { UserError } from 'fastmcp';
2
+ import { z } from 'zod';
3
+ import { getFormsClient } from '../../clients.js';
4
+
5
+ export function register(server) {
6
+ server.addTool({
7
+ name: 'set_publish_settings',
8
+ description:
9
+ 'Updates the publish settings of a Google Form. Controls whether the form is published as a template and whether respondents must be authenticated.',
10
+ parameters: z.object({
11
+ formId: z.string().describe('The ID of the Google Form'),
12
+ publishAsTemplate: z
13
+ .boolean()
14
+ .optional()
15
+ .describe('Whether to publish the form as a reusable template'),
16
+ requireAuthentication: z
17
+ .boolean()
18
+ .optional()
19
+ .describe('Whether respondents must sign in with a Google account to submit the form'),
20
+ }),
21
+ execute: async (args, { log }) => {
22
+ const forms = await getFormsClient();
23
+ log.info(`Setting publish settings for form: ${args.formId}`);
24
+
25
+ const body = {};
26
+ if (args.publishAsTemplate !== undefined) {
27
+ body.publishAsTemplate = args.publishAsTemplate;
28
+ }
29
+ if (args.requireAuthentication !== undefined) {
30
+ body.requireAuthentication = args.requireAuthentication;
31
+ }
32
+
33
+ if (Object.keys(body).length === 0) {
34
+ throw new UserError('At least one setting (publishAsTemplate or requireAuthentication) must be provided.');
35
+ }
36
+
37
+ try {
38
+ await forms.forms.setPublishSettings({
39
+ formId: args.formId,
40
+ requestBody: body,
41
+ });
42
+
43
+ return JSON.stringify({
44
+ success: true,
45
+ formId: args.formId,
46
+ message: 'Publish settings updated successfully.',
47
+ appliedSettings: body,
48
+ }, null, 2);
49
+ } catch (error) {
50
+ log.error(`Error setting publish settings: ${error.message || error}`);
51
+ if (error.code === 401)
52
+ throw new UserError('Authentication failed. Try logging out and re-authenticating.');
53
+ if (error.code === 404) throw new UserError(`Form not found: ${args.formId}`);
54
+ throw new UserError(`Failed to set publish settings: ${error.message || 'Unknown error'}`);
55
+ }
56
+ },
57
+ });
58
+ }
@@ -63,6 +63,12 @@ const CATEGORIES = {
63
63
  registerCalendarTools(server);
64
64
  },
65
65
  },
66
+ forms: {
67
+ async loader(server) {
68
+ const { registerFormsTools } = await import('./forms/index.js');
69
+ registerFormsTools(server);
70
+ },
71
+ },
66
72
  };
67
73
 
68
74
  // ---------------------------------------------------------------------------
@@ -6,7 +6,6 @@ import { register as clearSpreadsheetRange } from './clearSpreadsheetRange.js';
6
6
  import { register as getSpreadsheetInfo } from './getSpreadsheetInfo.js';
7
7
  import { register as addSpreadsheetSheet } from './addSpreadsheetSheet.js';
8
8
  import { register as createSpreadsheet } from './createSpreadsheet.js';
9
- import { register as listGoogleSheets } from './listGoogleSheets.js';
10
9
  import { register as deleteSheet } from './deleteSheet.js';
11
10
  import { register as renameSheet } from './renameSheet.js';
12
11
  import { register as duplicateSheet } from './duplicateSheet.js';
@@ -39,7 +38,6 @@ export function registerSheetsTools(server) {
39
38
  getSpreadsheetInfo(server);
40
39
  addSpreadsheetSheet(server);
41
40
  createSpreadsheet(server);
42
- listGoogleSheets(server);
43
41
  deleteSheet(server);
44
42
  renameSheet(server);
45
43
  duplicateSheet(server);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "google-tools-mcp",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Combined Google Workspace MCP server (Drive, Docs, Sheets, Gmail) with lazy-loaded tool categories",
5
5
  "type": "module",
6
6
  "bin": {