@pipeworx/mcp-google_sheets 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +162 -0
- package/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# mcp-google_sheets
|
|
2
|
+
|
|
3
|
+
Google Sheets MCP Pack
|
|
4
|
+
|
|
5
|
+
Part of the [Pipeworx](https://pipeworx.io) open MCP gateway.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `sheets_read` | Read data from a Google Sheets range. Returns rows as arrays. |
|
|
12
|
+
| `sheets_write` | Write data to a Google Sheets range. Overwrites existing data. |
|
|
13
|
+
| `sheets_append` | Append rows to the end of a Google Sheets table. |
|
|
14
|
+
| `sheets_get_spreadsheet` | Get spreadsheet metadata — title, sheets/tabs, and properties. |
|
|
15
|
+
| `sheets_create` | Create a new Google Spreadsheet. |
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
Add to your MCP client config:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"mcpServers": {
|
|
24
|
+
"google_sheets": {
|
|
25
|
+
"url": "https://gateway.pipeworx.io/google_sheets/mcp"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Or use the CLI:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx pipeworx use google_sheets
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-google_sheets",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Google Sheets MCP Pack",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "google_sheets"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-google_sheets"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/google_sheets",
|
|
4
|
+
"title": "google_sheets",
|
|
5
|
+
"description": "Google Sheets MCP Pack",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/google_sheets",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-google_sheets",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/google_sheets/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
interface McpToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: 'object';
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface McpToolExport {
|
|
12
|
+
tools: McpToolDefinition[];
|
|
13
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Google Sheets MCP Pack
|
|
18
|
+
*
|
|
19
|
+
* Requires OAuth connection — gateway injects credentials via _context.google_sheets.
|
|
20
|
+
* Tools: read, write, append, list sheets, create spreadsheet.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
interface GoogleContext {
|
|
25
|
+
google_sheets?: { accessToken: string };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const API = 'https://sheets.googleapis.com/v4/spreadsheets';
|
|
29
|
+
|
|
30
|
+
async function gFetch(ctx: GoogleContext, url: string, options: RequestInit = {}) {
|
|
31
|
+
if (!ctx.google_sheets) {
|
|
32
|
+
return { error: 'connection_required', message: 'Connect your Google account at https://pipeworx.io/account' };
|
|
33
|
+
}
|
|
34
|
+
const res = await fetch(url, {
|
|
35
|
+
...options,
|
|
36
|
+
headers: {
|
|
37
|
+
Authorization: `Bearer ${ctx.google_sheets.accessToken}`,
|
|
38
|
+
'Content-Type': 'application/json',
|
|
39
|
+
...(options.headers ?? {}),
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (!res.ok) {
|
|
43
|
+
const text = await res.text();
|
|
44
|
+
throw new Error(`Google Sheets API error (${res.status}): ${text}`);
|
|
45
|
+
}
|
|
46
|
+
return res.json();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const tools: McpToolExport['tools'] = [
|
|
50
|
+
{
|
|
51
|
+
name: 'sheets_read',
|
|
52
|
+
description: 'Read data from a Google Sheets range. Returns rows as arrays.',
|
|
53
|
+
inputSchema: {
|
|
54
|
+
type: 'object' as const,
|
|
55
|
+
properties: {
|
|
56
|
+
spreadsheet_id: { type: 'string', description: 'Spreadsheet ID (from the URL)' },
|
|
57
|
+
range: { type: 'string', description: 'A1 notation range (e.g., "Sheet1!A1:D10")' },
|
|
58
|
+
},
|
|
59
|
+
required: ['spreadsheet_id', 'range'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'sheets_write',
|
|
64
|
+
description: 'Write data to a Google Sheets range. Overwrites existing data.',
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: 'object' as const,
|
|
67
|
+
properties: {
|
|
68
|
+
spreadsheet_id: { type: 'string', description: 'Spreadsheet ID' },
|
|
69
|
+
range: { type: 'string', description: 'A1 notation range (e.g., "Sheet1!A1")' },
|
|
70
|
+
values: {
|
|
71
|
+
type: 'array',
|
|
72
|
+
description: 'Array of rows, each row is an array of cell values',
|
|
73
|
+
items: { type: 'array', items: { type: 'string' } },
|
|
74
|
+
},
|
|
75
|
+
value_input_option: { type: 'string', enum: ['USER_ENTERED', 'RAW'], description: 'How to interpret input. USER_ENTERED (default) parses formulas/dates/numbers. RAW stores literal strings.' },
|
|
76
|
+
},
|
|
77
|
+
required: ['spreadsheet_id', 'range', 'values'],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'sheets_append',
|
|
82
|
+
description: 'Append rows to the end of a Google Sheets table.',
|
|
83
|
+
inputSchema: {
|
|
84
|
+
type: 'object' as const,
|
|
85
|
+
properties: {
|
|
86
|
+
spreadsheet_id: { type: 'string', description: 'Spreadsheet ID' },
|
|
87
|
+
range: { type: 'string', description: 'A1 notation range to append after (e.g., "Sheet1!A1")' },
|
|
88
|
+
values: {
|
|
89
|
+
type: 'array',
|
|
90
|
+
description: 'Array of rows to append',
|
|
91
|
+
items: { type: 'array', items: { type: 'string' } },
|
|
92
|
+
},
|
|
93
|
+
value_input_option: { type: 'string', enum: ['USER_ENTERED', 'RAW'], description: 'How to interpret input. USER_ENTERED (default) parses formulas/dates/numbers. RAW stores literal strings.' },
|
|
94
|
+
},
|
|
95
|
+
required: ['spreadsheet_id', 'range', 'values'],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'sheets_get_spreadsheet',
|
|
100
|
+
description: 'Get spreadsheet metadata — title, sheets/tabs, and properties.',
|
|
101
|
+
inputSchema: {
|
|
102
|
+
type: 'object' as const,
|
|
103
|
+
properties: {
|
|
104
|
+
spreadsheet_id: { type: 'string', description: 'Spreadsheet ID' },
|
|
105
|
+
},
|
|
106
|
+
required: ['spreadsheet_id'],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: 'sheets_create',
|
|
111
|
+
description: 'Create a new Google Spreadsheet.',
|
|
112
|
+
inputSchema: {
|
|
113
|
+
type: 'object' as const,
|
|
114
|
+
properties: {
|
|
115
|
+
title: { type: 'string', description: 'Title for the new spreadsheet' },
|
|
116
|
+
},
|
|
117
|
+
required: ['title'],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
123
|
+
const context = (args._context ?? {}) as GoogleContext;
|
|
124
|
+
delete args._context;
|
|
125
|
+
|
|
126
|
+
switch (name) {
|
|
127
|
+
case 'sheets_read': {
|
|
128
|
+
const { spreadsheet_id, range } = args as { spreadsheet_id: string; range: string };
|
|
129
|
+
const data = await gFetch(context, `${API}/${spreadsheet_id}/values/${encodeURIComponent(range)}`);
|
|
130
|
+
return data;
|
|
131
|
+
}
|
|
132
|
+
case 'sheets_write': {
|
|
133
|
+
const { spreadsheet_id, range, values, value_input_option = 'USER_ENTERED' } = args as { spreadsheet_id: string; range: string; values: unknown[][]; value_input_option?: string };
|
|
134
|
+
return gFetch(context, `${API}/${spreadsheet_id}/values/${encodeURIComponent(range)}?valueInputOption=${value_input_option}`, {
|
|
135
|
+
method: 'PUT',
|
|
136
|
+
body: JSON.stringify({ values }),
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
case 'sheets_append': {
|
|
140
|
+
const { spreadsheet_id, range, values, value_input_option = 'USER_ENTERED' } = args as { spreadsheet_id: string; range: string; values: unknown[][]; value_input_option?: string };
|
|
141
|
+
return gFetch(context, `${API}/${spreadsheet_id}/values/${encodeURIComponent(range)}:append?valueInputOption=${value_input_option}&insertDataOption=INSERT_ROWS`, {
|
|
142
|
+
method: 'POST',
|
|
143
|
+
body: JSON.stringify({ values }),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
case 'sheets_get_spreadsheet': {
|
|
147
|
+
const { spreadsheet_id } = args as { spreadsheet_id: string };
|
|
148
|
+
return gFetch(context, `${API}/${spreadsheet_id}?fields=spreadsheetId,properties.title,sheets.properties`);
|
|
149
|
+
}
|
|
150
|
+
case 'sheets_create': {
|
|
151
|
+
const { title } = args as { title: string };
|
|
152
|
+
return gFetch(context, API, {
|
|
153
|
+
method: 'POST',
|
|
154
|
+
body: JSON.stringify({ properties: { title } }),
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
default:
|
|
158
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default { tools, callTool, meter: { credits: 10 }, provider: 'google_sheets' } satisfies McpToolExport;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|