google-apps-script-mcp

nikolai-cardinal/google-apps-script-mcp

3.2

If you are the rightful owner of google-apps-script-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Google Apps Script MCP Server is a Model Context Protocol server designed to automate the development and deployment of Google Apps Script projects using AI agents.

Tools
5
Resources
0
Prompts
0

Google Apps Script MCP Server

A Model Context Protocol (MCP) server that enables AI agents (like Claude) to programmatically create, read, update, and deploy Google Apps Script projects.

Project Goal

Enable AI-powered automation of Google Apps Script development - allowing Claude Code and other MCP-compatible AI agents to:

  1. Create new Apps Script projects (standalone or bound to Sheets/Docs/Forms)
  2. Read and update script content programmatically
  3. Deploy scripts as web apps, add-ons, or API executables
  4. Execute Apps Script functions remotely
  5. Manage versions and deployments

This eliminates the copy/paste workflow and allows true end-to-end automation of Google Workspace scripting.


Why This Matters

Current WorkflowWith This MCP Server
User describes needUser describes need
AI writes codeAI writes code
User manually copies to Apps Script editorAI deploys directly
User tests and reports errorsAI tests and debugs
Repeat...Done!

Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│                        Claude Code / AI Agent                    │
└─────────────────────────────────────────────────────────────────┘
                                │
                                │ MCP Protocol (stdio/SSE)
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                   Google Apps Script MCP Server                  │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                    MCP Tool Handlers                     │    │
│  │  • create_project    • get_project    • update_content  │    │
│  │  • get_content       • create_version • deploy          │    │
│  │  • list_deployments  • run_function   • get_logs        │    │
│  └─────────────────────────────────────────────────────────┘    │
│                              │                                   │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                  OAuth2 Authentication                   │    │
│  │         (Google Cloud Platform Credentials)              │    │
│  └─────────────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────────────┘
                                │
                                │ HTTPS REST API
                                ▼
┌─────────────────────────────────────────────────────────────────┐
│                    Google Apps Script API                        │
│                   (script.googleapis.com/v1)                     │
└─────────────────────────────────────────────────────────────────┘

Core MCP Tools (Planned)

Project Management

ToolDescription
create_projectCreate a new Apps Script project (standalone or bound)
get_projectGet project metadata (title, script ID, creator, etc.)
list_projectsList all Apps Script projects accessible to the user
delete_projectDelete an Apps Script project

Content Management

ToolDescription
get_contentRetrieve all files from a project (code, HTML, manifest)
update_contentUpdate/replace project files
add_fileAdd a new file to a project
delete_fileRemove a file from a project

Version & Deployment

ToolDescription
create_versionCreate a new immutable version
list_versionsList all versions of a project
create_deploymentDeploy a version (web app, add-on, API executable)
update_deploymentUpdate an existing deployment to a new version
list_deploymentsList all deployments
delete_deploymentArchive/delete a deployment

Execution & Debugging

ToolDescription
run_functionExecute a function in the Apps Script project
get_logsRetrieve execution logs
get_metricsGet project metrics (executions, errors, users)

Prerequisites

Before building this MCP server, you'll need:

1. Google Cloud Platform Project

  • Create a GCP project at console.cloud.google.com
  • Enable the Apps Script API
  • Enable the Google Drive API (for bound scripts)

2. OAuth 2.0 Credentials

  • Create OAuth 2.0 Client ID (Desktop Application type)
  • Download the credentials JSON file
  • Required scopes:
    • https://www.googleapis.com/auth/script.projects
    • https://www.googleapis.com/auth/script.deployments
    • https://www.googleapis.com/auth/script.metrics
    • https://www.googleapis.com/auth/drive.file (for bound scripts)

3. Development Environment

  • Node.js 18+ (LTS recommended)
  • npm or pnpm
  • TypeScript knowledge (optional but recommended)

Tech Stack

ComponentTechnologyReason
RuntimeNode.js 18+MCP SDK support, async/await
LanguageTypeScriptType safety, better DX
MCP SDK@modelcontextprotocol/sdkOfficial MCP implementation
Google Authgoogle-auth-libraryOfficial Google OAuth
Google APIsgoogleapisOfficial Google API client
HTTP ServerBuilt-in (stdio)MCP standard transport

Project Structure (Planned)

google-apps-script-mcp/
├── README.md                 # This file
├── package.json              # Node.js dependencies
├── tsconfig.json             # TypeScript configuration
├── .env.example              # Environment variables template
├── .gitignore                # Git ignore rules
│
├── src/
│   ├── index.ts              # MCP server entry point
│   ├── server.ts             # MCP server setup
│   │
│   ├── auth/
│   │   ├── oauth.ts          # OAuth2 flow implementation
│   │   └── credentials.ts    # Credential management
│   │
│   ├── tools/
│   │   ├── projects.ts       # Project management tools
│   │   ├── content.ts        # Content management tools
│   │   ├── deployments.ts    # Deployment tools
│   │   └── execution.ts      # Function execution tools
│   │
│   ├── api/
│   │   └── apps-script.ts    # Google Apps Script API wrapper
│   │
│   └── types/
│       └── index.ts          # TypeScript type definitions
│
├── credentials/              # OAuth credentials (gitignored)
│   └── .gitkeep
│
└── docs/
    ├── SETUP.md              # Detailed setup instructions
    ├── AUTHENTICATION.md     # OAuth flow documentation
    └── TOOLS.md              # Tool reference documentation

Implementation Phases

Phase 1: Foundation (Current)

  • Create project structure
  • Document goals and architecture
  • Set up Node.js project with TypeScript
  • Configure Google Cloud Platform
  • Implement OAuth2 authentication flow

Phase 2: Core Tools

  • Implement create_project
  • Implement get_project and get_content
  • Implement update_content
  • Basic error handling and validation

Phase 3: Deployment Tools

  • Implement create_version
  • Implement create_deployment
  • Implement list_deployments
  • Implement update_deployment

Phase 4: Advanced Features

  • Implement run_function
  • Implement get_logs
  • Add support for bound scripts (Sheets, Docs, Forms)
  • Comprehensive error handling

Phase 5: Polish & Release

  • Add comprehensive documentation
  • Write tests
  • Create example workflows
  • Publish to npm (optional)

API Reference

Google Apps Script API Endpoints

OperationMethodEndpoint
Create ProjectPOST/v1/projects
Get ProjectGET/v1/projects/{scriptId}
Get ContentGET/v1/projects/{scriptId}/content
Update ContentPUT/v1/projects/{scriptId}/content
Create VersionPOST/v1/projects/{scriptId}/versions
List VersionsGET/v1/projects/{scriptId}/versions
Create DeploymentPOST/v1/projects/{scriptId}/deployments
List DeploymentsGET/v1/projects/{scriptId}/deployments
Update DeploymentPUT/v1/projects/{scriptId}/deployments/{deploymentId}
Delete DeploymentDELETE/v1/projects/{scriptId}/deployments/{deploymentId}
Run FunctionPOST/v1/scripts/{scriptId}:run
Get MetricsGET/v1/projects/{scriptId}/metrics

Base URL: https://script.googleapis.com


Key Limitations & Considerations

API Limitations

  1. No Service Account Support: The Apps Script API does not work with service accounts - must use OAuth2 with user consent
  2. Full File Replacement: updateContent replaces ALL files - must fetch existing content first, modify, then update
  3. Versioned Deployments: Cannot delete versioned deployments, only archive them
  4. Rate Limits: Subject to Google API quotas

MCP Considerations

  1. Authentication State: Must persist OAuth tokens between sessions
  2. Token Refresh: Handle automatic token refresh
  3. Error Handling: Map Google API errors to meaningful MCP responses

Resources

Official Documentation

Related Tools

Community


Getting Started

Next Step: Continue to Phase 1 Setup - We'll configure the Google Cloud Platform and implement OAuth2 authentication.


License

MIT License - See LICENSE file for details.


Contributing

This is a personal project, but suggestions and feedback are welcome!