google-apps-script-mcp-improved

redmorestudio/google-apps-script-mcp-improved

3.2

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

The Google Apps Script MCP Server - Improved Version is an enhanced server implementation for managing and executing Google Apps Script projects with improved JSON handling, error management, and OAuth scope support.

Tools
  1. script_projects_get

    Get project metadata

  2. script_projects_create

    Create new project

  3. script_projects_get_content

    Retrieve project files

  4. update_script_content

    Update project files

  5. script_projects_deployments_create

    Create deployment

  6. script_projects_deployments_update

    Update deployment

  7. script_projects_deployments_list

    List deployments

  8. script_projects_deployments_get

    Get deployment details

  9. script_projects_deployments_delete

    Delete deployment

  10. script_projects_versions_create

    Create new version

  11. script_projects_versions_list

    List versions

  12. script_projects_versions_get

    Get version details

  13. script_run

    Execute deployed scripts

  14. list_script_processes

    List running processes

  15. get_script_metrics

    Get execution metrics

Google Apps Script MCP Server - Improved Version

An improved version of the Google Apps Script MCP (Model Context Protocol) server with fixes for JSON parsing errors and better error handling.

🎯 Improvements Over Original

1. Fixed JSON Parsing Errors

  • Removed all emoji console.logs that were corrupting JSON responses
  • Clean JSON output for all API responses
  • Proper error handling without breaking JSON structure

2. Added Missing OAuth Scopes

  • Added https://www.googleapis.com/auth/script.run for script execution
  • Complete scope list for full functionality

3. Better Error Handling

  • Graceful handling of API errors
  • Clear error messages
  • No JSON corruption on errors

4. Environment Configuration

  • Support for LOG_LEVEL environment variable
  • Configurable logging without JSON interference

📦 Installation

Option 1: NPM Install (Recommended)

npm install -g @redmorestudio/google-apps-script-mcp-improved

Option 2: Clone and Link

git clone https://github.com/redmorestudio/google-apps-script-mcp-improved
cd google-apps-script-mcp-improved
npm install
npm link

🔧 Configuration

Claude Desktop Configuration

Add to ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "google-apps-script": {
      "command": "node",
      "args": ["/path/to/google-apps-script-mcp-improved/dist/index.js"],
      "env": {
        "LOG_LEVEL": "error"
      }
    }
  }
}

Environment Variables

  • LOG_LEVEL: Set to "error" to prevent console output from corrupting JSON

🚀 First Time Setup

1. Authenticate

cd /path/to/google-apps-script-mcp-improved
npm run auth

2. Follow OAuth Flow

  • Browser will open for Google authentication
  • Approve all requested scopes
  • Token will be saved to ~/Library/Application Support/google-apps-script-mcp/tokens.json

3. Restart Claude Desktop

After configuration, restart Claude Desktop for changes to take effect.

📋 Available Tools

Project Management

  • script_projects_get - Get project metadata
  • script_projects_create - Create new project
  • script_projects_get_content - Retrieve project files
  • update_script_content - Update project files

Deployment Management

  • script_projects_deployments_create - Create deployment
  • script_projects_deployments_update - Update deployment
  • script_projects_deployments_list - List deployments
  • script_projects_deployments_get - Get deployment details
  • script_projects_deployments_delete - Delete deployment

Version Management

  • script_projects_versions_create - Create new version
  • script_projects_versions_list - List versions
  • script_projects_versions_get - Get version details

Script Execution

  • script_run - Execute deployed scripts (requires proper deployment)

Process Monitoring

  • list_script_processes - List running processes
  • get_script_metrics - Get execution metrics

🐛 Fixed Issues

1. JSON Parsing Errors

Problem: Original server had console.logs with emojis that corrupted JSON Solution: Removed all decorative console output

2. Script Execution 404 Errors

Problem: Missing OAuth scope for script.run Solution: Added required scope to oauth-helper.js

3. Environment Pollution

Problem: Debug logs interfering with tool responses Solution: LOG_LEVEL environment variable support

💡 Usage Tips

Testing Connection

After setup, test with:

await script_projects_get({
  scriptId: "your-script-id"
});

Creating Web App Deployment

// 1. Create a version
await script_projects_versions_create({
  scriptId: "your-script-id",
  description: "Version for web app"
});

// 2. Create deployment
await script_projects_deployments_create({
  scriptId: "your-script-id",
  manifestFileName: "appsscript",
  versionNumber: 1,
  description: "Web app deployment"
});

Handling Script Execution

For scripts that need to be executed via API:

  1. Deploy as Web App first
  2. Use the Web App URL for execution
  3. Handle authentication appropriately

🔒 Security Notes

  • Tokens are stored locally in your application support directory
  • Never commit tokens to version control
  • Use environment variables for sensitive configuration
  • Regularly rotate OAuth tokens

🤝 Contributing

Found an issue or want to add features?

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

📝 License

MIT License - See LICENSE file for details

🙏 Acknowledgments

  • Original MCP server by @mohalmah
  • Claude Desktop team for MCP protocol
  • Google Apps Script team for the API

📞 Support


Note: This is an improved version addressing specific issues found during production use. For the original server, see https://github.com/mohalmah/google-apps-script-mcp