mcp-gsheets 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mcp-gsheets contributors
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,273 @@
1
+ # MCP Google Sheets Server
2
+
3
+ <a href="https://glama.ai/mcp/servers/@freema/mcp-gsheets">
4
+ <img width="380" height="200" src="https://glama.ai/mcp/servers/@freema/mcp-gsheets/badge" />
5
+ </a>
6
+
7
+ ![CI](https://github.com/freema/mcp-gsheets/workflows/CI/badge.svg)
8
+ ![Coverage](https://codecov.io/gh/freema/mcp-gsheets/branch/main/graph/badge.svg)
9
+ ![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
10
+ ![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-007ACC?logo=typescript&logoColor=white)
11
+ ![Node](https://img.shields.io/badge/Node.js-18%2B-339933?logo=node.js&logoColor=white)
12
+ ![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?logo=prettier&logoColor=white)
13
+
14
+ A Model Context Protocol (MCP) server for Google Sheets API integration. Enables reading, writing, and managing Google Sheets documents directly from your MCP client (e.g., Claude Desktop).
15
+
16
+ ## 🚀 Quick Start
17
+
18
+ ### 1. Prerequisites
19
+
20
+ - Node.js v18 or higher
21
+ - Google Cloud Project with Sheets API enabled
22
+ - Service Account with JSON key file
23
+
24
+ ### 2. Installation
25
+
26
+ ```bash
27
+ # Clone the repository
28
+ git clone https://github.com/freema/mcp-gsheets.git
29
+ # Or using SSH
30
+ # git clone git@github.com:freema/mcp-gsheets.git
31
+ cd mcp-gsheets
32
+
33
+ # Install dependencies
34
+ npm install
35
+
36
+ # Build the project
37
+ npm run build
38
+ ```
39
+
40
+ ### 3. Google Cloud Setup
41
+
42
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com)
43
+ 2. Create a new project or select existing
44
+ 3. Enable Google Sheets API:
45
+ - Navigate to "APIs & Services" → "Library"
46
+ - Search for "Google Sheets API" and click "Enable"
47
+ 4. Create Service Account:
48
+ - Go to "APIs & Services" → "Credentials"
49
+ - Click "Create Credentials" → "Service Account"
50
+ - Download the JSON key file
51
+ 5. Share your spreadsheets:
52
+ - Open your Google Sheet
53
+ - Click Share and add the service account email (from JSON file)
54
+ - Grant "Editor" permissions
55
+
56
+ ### 4. Configure MCP Client
57
+
58
+ #### Easy Setup (Recommended)
59
+
60
+ Run the interactive setup script:
61
+
62
+ ```bash
63
+ npm run setup
64
+ ```
65
+
66
+ This will:
67
+ - Guide you through the configuration
68
+ - Automatically detect your Node.js installation (including nvm)
69
+ - Find your Claude Desktop config
70
+ - Create the proper JSON configuration
71
+ - Optionally create a .env file for development
72
+
73
+ #### Manual Setup
74
+
75
+ If you prefer manual configuration, add to your Claude Desktop config:
76
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
77
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
78
+ - Linux: `~/.config/claude/claude_desktop_config.json`
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "mcp-gsheets": {
84
+ "command": "node",
85
+ "args": ["/absolute/path/to/mcp-gsheets/dist/index.js"],
86
+ "env": {
87
+ "GOOGLE_PROJECT_ID": "your-project-id",
88
+ "GOOGLE_APPLICATION_CREDENTIALS": "/absolute/path/to/service-account-key.json"
89
+ }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ Restart Claude Desktop after adding the configuration.
96
+
97
+ ## 📦 Build & Development
98
+
99
+ ### Development Commands
100
+
101
+ ```bash
102
+ # Development mode with hot reload
103
+ npm run dev
104
+
105
+ # Build for production
106
+ npm run build
107
+
108
+ # Type checking
109
+ npm run typecheck
110
+
111
+ # Clean build artifacts
112
+ npm run clean
113
+
114
+ # Run MCP inspector for debugging
115
+ npm run inspector
116
+
117
+ # Run MCP inspector in development mode
118
+ npm run inspector:dev
119
+ ```
120
+
121
+ ### Task Runner (Alternative)
122
+
123
+ If you have [Task](https://taskfile.dev) installed:
124
+
125
+ ```bash
126
+ # Install dependencies
127
+ task install
128
+
129
+ # Build the project
130
+ task build
131
+
132
+ # Run in development mode
133
+ task dev
134
+
135
+ # Run linter
136
+ task lint
137
+
138
+ # Format code
139
+ task fmt
140
+
141
+ # Run all checks
142
+ task check
143
+ ```
144
+
145
+ ### Development Setup
146
+
147
+ 1. Create `.env` file for testing:
148
+ ```bash
149
+ cp .env.example .env
150
+ # Edit .env with your credentials:
151
+ # GOOGLE_PROJECT_ID=your-project-id
152
+ # GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
153
+ # TEST_SPREADSHEET_ID=your-test-spreadsheet-id
154
+ ```
155
+
156
+ 2. Run in development mode:
157
+ ```bash
158
+ npm run dev # Watch mode with auto-reload
159
+ ```
160
+
161
+ ## 📋 Available Tools
162
+
163
+ ### Reading Data
164
+ - `sheets_get_values` - Read from a range
165
+ - `sheets_batch_get_values` - Read from multiple ranges
166
+ - `sheets_get_metadata` - Get spreadsheet info
167
+ - `sheets_check_access` - Check access permissions
168
+
169
+ ### Writing Data
170
+ - `sheets_update_values` - Write to a range
171
+ - `sheets_batch_update_values` - Write to multiple ranges
172
+ - `sheets_append_values` - Append rows to a table
173
+ - `sheets_clear_values` - Clear cell contents
174
+
175
+ ### Sheet Management
176
+ - `sheets_insert_sheet` - Add new sheet
177
+ - `sheets_delete_sheet` - Remove sheet
178
+ - `sheets_duplicate_sheet` - Copy sheet
179
+ - `sheets_copy_to` - Copy to another spreadsheet
180
+ - `sheets_update_sheet_properties` - Update sheet settings
181
+
182
+ ### Cell Formatting
183
+ - `sheets_format_cells` - Format cells (colors, fonts, alignment, number formats)
184
+ - `sheets_update_borders` - Add or modify cell borders
185
+ - `sheets_merge_cells` - Merge cells together
186
+ - `sheets_unmerge_cells` - Unmerge previously merged cells
187
+ - `sheets_add_conditional_formatting` - Add conditional formatting rules
188
+
189
+ ## 🔧 Code Quality
190
+
191
+ ### Linting
192
+
193
+ ```bash
194
+ # Run ESLint
195
+ npm run lint
196
+
197
+ # Fix auto-fixable issues
198
+ npm run lint:fix
199
+ ```
200
+
201
+ ### Formatting
202
+
203
+ ```bash
204
+ # Check formatting with Prettier
205
+ npm run format:check
206
+
207
+ # Format code
208
+ npm run format
209
+ ```
210
+
211
+ ### Type Checking
212
+
213
+ ```bash
214
+ # Run TypeScript type checking
215
+ npm run typecheck
216
+ ```
217
+
218
+ ## ❗ Troubleshooting
219
+
220
+ ### Common Issues
221
+
222
+ **"Authentication failed"**
223
+ - Verify JSON key path is absolute and correct
224
+ - Check GOOGLE_PROJECT_ID matches your project
225
+ - Ensure Sheets API is enabled
226
+
227
+ **"Permission denied"**
228
+ - Share spreadsheet with service account email
229
+ - Service account needs "Editor" role
230
+ - Check email in JSON file (client_email field)
231
+
232
+ **"Spreadsheet not found"**
233
+ - Verify spreadsheet ID from URL
234
+ - Format: `https://docs.google.com/spreadsheets/d/[SPREADSHEET_ID]/edit`
235
+
236
+ **MCP Connection Issues**
237
+ - Ensure you're using the built version (`dist/index.js`)
238
+ - Check that Node.js path is correct in Claude Desktop config
239
+ - Look for errors in Claude Desktop logs
240
+ - Use `npm run inspector` to debug
241
+
242
+ ## 🔍 Finding IDs
243
+
244
+ ### Spreadsheet ID
245
+ From the URL:
246
+ ```
247
+ https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit
248
+ ↑ This is the spreadsheet ID
249
+ ```
250
+
251
+ ### Sheet ID
252
+ Use `sheets_get_metadata` to list all sheets with their IDs.
253
+
254
+ ## 📝 Tips
255
+
256
+ 1. Always test with a copy of your data
257
+ 2. Use batch operations for better performance
258
+ 3. Set appropriate permissions (read-only vs edit)
259
+ 4. Check rate limits for large operations
260
+ 5. Use `sheets_check_access` to verify permissions before operations
261
+
262
+ ## 🤝 Contributing
263
+
264
+ 1. Fork the repository
265
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
266
+ 3. Run tests and linting (`npm run check`)
267
+ 4. Commit your changes (`git commit -m 'Add some amazing feature'`)
268
+ 5. Push to the branch (`git push origin feature/amazing-feature`)
269
+ 6. Open a Pull Request
270
+
271
+ ## 📄 License
272
+
273
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.