Skip to content
Back to search

clasp

SkillWorks with Claude CodeOfficial: GoogleGitHub

Develop Apps Script projects locally using clasp

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/google--clasp/badge.svg)](/listings/google--clasp)

HTML

<a href="/listings/google--clasp"><img src="/api/listings/google--clasp/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

First download `clasp`:

npm install -g @google/clasp

Then enable the Google Apps Script API: https://script.google.com/home/usersettings

Installing as a Gemini CLI Extension

You can install clasp as an Gemini CLI extensions using the following command:

gemini extensions install https://github.com/google/clasp

This makes clasp available as an MCP server in Gemini CLI.

Make sure to enable the Google Apps Script API (as explained above) and perform a `clasp login` (with your specific login parameters) before you use the extension.

Installing as a Claude Code CLI Extension

You can use clasp with Claude Code CLI in one of two ways:

1. Install as a Plugin (Recommended)

Run the following command in Claude Code to install clasp as a plugin directly from the repository:

/plugin install @google/clasp

2. Manual Installation

You can manually add clasp as an MCP server using the provided configuration file or by running:

claude mcp add clasp -- npx -y @google/clasp mcp

Or by referencing the configuration file included in the repository:

claude mcp add-json clasp "$(cat claude-mcp.json)"

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

.claude-plugin/plugin.json · Manifest · 11 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. {
  2. "name": "clasp",
  3. "version": "1.0.0",
  4. "description": "Develop Apps Script projects locally using clasp",
  5. "mcpServers": {
  6. "clasp": {
  7. "command": "npx",
  8. "args": ["-y", "@google/clasp", "mcp"]
  9. }
  10. }
  11. }
README.md · README · 808 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Clasp
  2. Note: This is not an officially supported Google product.
  3. ![build status](https://github.com/google/clasp/actions/workflows/ci.yaml/badge.svg)
  4. <a href="https://coveralls.io/github/google/clasp?branch=master"><img src="https://coveralls.io/repos/github/google/clasp/badge.svg?branch=master" alt="Coverage Status"></a>
  5. <a href="https://www.npmjs.com/package/@google/clasp"><img src="https://img.shields.io/npm/v/@google/clasp.svg" alt="npm Version"></a>
  6. <a href="https://npmcharts.com/compare/@google/clasp?minimal=true"><img src="https://img.shields.io/npm/dw/@google/clasp.svg" alt="npm Downloads"></a>
  7. <a href="https://github.com/google/gts" title="Code Style: Google"><img src="https://img.shields.io/badge/code%20style-google-blueviolet.svg"/></a>
  8. > Develop [Apps Script](https://developers.google.com/apps-script/) projects locally using clasp (**C**ommand **L**ine **A**pps **S**cript **P**rojects).
  9. <!-- GIF bash prompt: PS1='\[\033[38;5;9m\]❤ \[$(tput sgr0)\]' -->
  10. <!-- Width: 888px -->
  11. <!-- Commands:
  12. clasp create "Hello"
  13. ls
  14. echo 'function hello() {
  15. Logger.log("Hello, Apps Script!");
  16. }' >> hello.js
  17. clasp push
  18. clasp deploy
  19. rm .clasp.json appsscript.json hello.js
  20. clear
  21. -->
  22. ![clasp](https://user-images.githubusercontent.com/744973/42856573-a5d96d7c-89fa-11e8-9d69-8d2c66f00d8d.gif)
  23. **To get started, try out the [codelab](https://g.co/codelabs/clasp)!**
  24. You can also try clasp in Gitpod, a one-click online IDE for GitHub:
  25. [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/google/clasp/blob/master/docs/Gitpod/)
  26. ## Features
  27. **🗺️ Develop Locally:** `clasp` allows you to develop your Apps Script projects locally. That means you can check-in your code into source control, collaborate with other developers, and use your favorite tools to develop Apps Script.
  28. **🔢 Manage Deployment Versions:** Create, update, and view your multiple deployments of your project.
  29. **📁 Structure Code:** `clasp` automatically converts your flat project on [script.google.com](https://script.google.com) into **folders**. For example:
  30. - _On script.google.com_:
  31. - `tests/slides.gs`
  32. - `tests/sheets.gs`
  33. - _locally_:
  34. - `tests/`
  35. - `slides.js`
  36. - `sheets.js`
  37. **➡️ Run Apps Script:** Execute your Apps Script from the command line. Features:
  38. - _Instant_ deployment.
  39. - Suggested functions Autocomplete (Fuzzy)
  40. - Easily add custom Google OAuth scopes
  41. - [And more…](docs/run.md)
  42. ## Install
  43. First download `clasp`:
  44. ```sh
  45. npm install -g @google/clasp
  46. ```
  47. Then enable the Google Apps Script API: https://script.google.com/home/usersettings
  48. ![Enable Apps Script API](https://user-images.githubusercontent.com/744973/54870967-a9135780-4d6a-11e9-991c-9f57a508bdf0.gif)
  49. ### Installing as a Gemini CLI Extension
  50. You can install clasp as an Gemini CLI extensions using the following command:
  51. ```sh
  52. gemini extensions install https://github.com/google/clasp
  53. ```
  54. This makes clasp available as an MCP server in Gemini CLI.
  55. Make sure to enable the Google Apps Script API (as explained above) and perform a `clasp login` (with your specific login parameters) before you use the extension.
  56. ### Installing as a Claude Code CLI Extension
  57. You can use clasp with Claude Code CLI in one of two ways:
  58. #### 1. Install as a Plugin (Recommended)
  59. Run the following command in Claude Code to install clasp as a plugin directly from the repository:
  60. ```sh
  61. /plugin install @google/clasp
  62. ```
  63. #### 2. Manual Installation
  64. You can manually add clasp as an MCP server using the provided configuration file or by running:
  65. ```sh
  66. claude mcp add clasp -- npx -y @google/clasp mcp
  67. ```
  68. Or by referencing the configuration file included in the repository:
  69. ```sh
  70. claude mcp add-json clasp "$(cat claude-mcp.json)"
  71. ```
  72. ## Commands
  73. The following command provide basic Apps Script project management.
  74. > Note: Most of them require you to `clasp login` and `clasp create/clone` before using the rest of the commands.
  75. ```sh
  76. clasp
  77. ```
  78. - [`clasp login [--no-localhost] [--creds <file>] [--use-project-scopes] [--include-clasp-scopes] [--extra-scopes <scopes>] [--redirect-port]`](#login)
  79. - [`clasp logout`](#logout)
  80. - [`clasp show-authorized-user [--json]`](#show-authorized-user)
  81. - [`clasp create-script [--title <title>] [--type <type>] [--rootDir <dir>] [--parentId <id>]`](#create)
  82. - [`clasp clone-script <scriptId | scriptURL> [versionNumber] [--rootDir <dir>]`](#clone)
  83. - [`clasp delete-script [--force]`](#delete)
  84. - [`clasp pull [--versionNumber]`](#pull)
  85. - [`clasp push [--watch] [--force]`](#push)
  86. - [`clasp show-file-status [--json]`](#status)
  87. - [`clasp open-script`](#open)
  88. - [`clasp list-deployments`](#deployments)
  89. - [`clasp create-deployment [--versionNumber <version>] [--description <description>] [--deploymentId <id>]`](#deploy)
  90. - [`clasp delete-deployment [deploymentId] [--all]`](#undeploy)
  91. - [`clasp create-version [description]`](#version)
  92. - [`clasp list-versions`](#versions)
  93. - [`clasp list-scripts`](#list)
  94. ### Advanced Commands
  95. > **NOTE**: These commands require you to add your [Project ID](#projectid-optional).
  96. - [`clasp tail-logs [--json] [--watch] [--simplified]`](#logs)
  97. - [`clasp setup-logs [--json]`](#setup-logs)
  98. - [`clasp list-apis`](#apis)
  99. - [`clasp enable-api<api>`](#apis)
  100. - [`clasp disable-api <api>`](#apis)
  101. - [`clasp run-function [function]`](#clasp-run)
  102. ## Guides
  103. ### Migrating from 2.x to 3.x
  104. #### Drop typescript support
  105. Clasp no longer transpiles typescript code. For typescript projects, use typescript with a bundler like [Rollup](https://rollupjs.org/) to transform code prior to pushing with clasp. This has the advantage of offering more
  106. robust support for Typescript features along with ESM module and NPM package support.
  107. There are several template projects on GitHub that show how to transform Typescript code into Apps Script that are all excellent choices.
  108. * https://github.com/WildH0g/apps-script-engine-template
  109. * https://github.com/tomoyanakano/clasp-typescript-template
  110. * https://github.com/google/aside
  111. * https://github.com/sqrrrl/apps-script-typescript-rollup-starter
  112. #### Command renames
  113. Clasp 3.x introduces some breaking changes from 2.x. For common use cases these changes should not impact usage, but some lesser used commands have been restructured and renamed to improve consistency.
  114. | 2.x | 3.x |
  115. |----------------------------|----------------------------------------|
  116. |`open` | `open-script` |
  117. |`open --web` | `open-web-app` |
  118. |`open --addon` | `open-container` |
  119. |`open --creds` | `open-credentials-setup` |
  120. |`login --creds <file>` | `login -u <name> --creds <file>` |
  121. |`logs --open` | `open-logs` |
  122. |`logs --setup` | N/A |
  123. |`apis --open` | `open-api-console` |
  124. |`apis enable <api>` | `enable-api <api>` |
  125. |`apis disable <api>` | `disable-api <api>` |
  126. |`deploy -i <id>` | `update-deployment <id>` |
  127. |`settings` | N/A |
  128. Other commands have also been renamed but retain aliases for compatibility.
  129. ### Authorization
  130. Most command require user authorization. Run `clasp login` to authorize access to manage your scripts.
  131. #### Multiple user support
  132. Use the global `--user` option to switch between accounts. This supports both running clasp as different users as well as when invoking the `clasp run-function` command.
  133. Examples:
  134. ```sh
  135. clasp login # Saves as default credentials
  136. clasp clone # User not specified, runs using default credentials
  137. clasp login --user testaccount # Authorized new named credentials
  138. clasp run-function --user testaccount myFunction # Runs function as test account
  139. ```
  140. ### Bring your own project/credentials
  141. While clasp includes a default OAuth client, using your own project is recommend and can improve security and compliance in environments that limit which third party applications users may authorize. To set up your own project:
  142. 1. [Create a new project](https://cloud.google.com/resource-manager/docs/creating-managing-projects) in the Google Cloud Developer Console.
  143. 1. [Create an OAuth client](https://support.google.com/cloud/answer/15549257?hl=en#:~:text=To%20create%20an%20OAuth%202.0,are%20yet%20to%20do%20so.). The client type must be `Desktop Application`. Download and save the generated client secrets file. This is required when authorizing using the`clasp login --creds <filename>` command.
  144. 1. [Enable services](https://cloud.google.com/endpoints/docs/openapi/enable-api). For full functionality, clasp requires the following:
  145. * Apps Script API - `script.googleapis.com` (required)
  146. * Service Usage API - `serviceusage.googleapis.com` (required to list/enable/disable APIs)
  147. * Google Drive API - `drive.googleapis.com` (required to list scripts, create container-bound scripts)
  148. - Cloud Logging API - `logging.googleapis.com` (required to read logs)
  149. Note: If configuring the project for external use where OAuth scopes must be registered, include the following:
  150. ```
  151. https://www.googleapis.com/auth/script.deployments
  152. https://www.googleapis.com/auth/script.projects
  153. https://www.googleapis.com/auth/script.webapp.deploy
  154. https://www.googleapis.com/auth/drive.metadata.readonly
  155. https://www.googleapis.com/auth/drive.file
  156. https://www.googleapis.com/auth/service.management
  157. https://www.googleapis.com/auth/logging.read
  158. https://www.googleapis.com/auth/userinfo.email
  159. https://www.googleapis.com/auth/userinfo.profile
  160. https://www.googleapis.com/auth/cloud-platform
  161. ```
  162. ### Allow-list clasp
  163. If your organization restricts authorization for third-party apps, you may either:
  164. * Request your admin allow-list clasp's client id `1072944905499-vm2v2i5dvn0a0d2o4ca36i1vge8cvbn0.apps.googleusercontent.com`
  165. * Set up an internal-only GCP project for clasp as described in the previous section.
  166. ### Service accounts (EXPERIMENTAL/NOT WORKING)
  167. Use the `--adc` option on any command to read credentials from the environment using Google Cloud's [application default credentials](https://cloud.google.com/docs/authentication/application-default-credentials) mechanism.
  168. Note that if using a service account, service accounts can not own scripts. To use a service account to push or pull files from Apps Script, the scripts must be shared with the service account with the appropriate role (e.g. `Editor` in able to push.)
  169. ### Ignore File (`.claspignore`)
  170. Like `.gitignore`, `.claspignore` allows you to ignore files that you do not wish to upload on `clasp push`. Steps:
  171. 1. Create a file called `.claspignore` in your project's root directory.
  172. 1. Add patterns to be excluded from `clasp push`. _Note_: The `.claspignore` patterns are applied by [multimatch](https://github.com/sindresorhus/multimatch), which is different from `.gitignore`, especially for directories. To ignore a directory, use syntax like `**/node_modules/**`.
  173. A sample `.claspignore` ignoring everything except the manifest and `build/main.js`:
  174. ```text
  175. **/**
  176. !build/main.js
  177. !appsscript.json
  178. ```
  179. _Note_: The `.claspignore` patterns are applied relative from the `rootDir`.
  180. If no `.claspignore` is specified, a default set of patterns is applied. This default set will only consider the `appsscript.json` manifest and any JavaScript, TypeScript and `.html` source files within the `rootDir` folder. Child folders other than `.git` and `node_modules` are processed.
  181. ```text
  182. # ignore all files…
  183. **/**
  184. # except the extensions…
  185. !appsscript.json
  186. !**/*.gs
  187. !**/*.js
  188. !**/*.ts
  189. !**/*.html
  190. # ignore even valid files if in…
  191. .git/**
  192. node_modules/**
  193. ```
  194. ## Project Settings File (`.clasp.json`)
  195. When running `clone` or `create`, a file named `.clasp.json` is created in the current directory to describe `clasp`'s configuration for the current project. Example `.clasp.json`:
  196. ```json
  197. {
  198. "scriptId": "",
  199. "rootDir": "build/",
  200. "projectId": "project-id-xxxxxxxxxxxxxxxxxxx",
  201. "fileExtension": "ts",
  202. "filePushOrder": ["file1.ts", "file2.ts"]
  203. }
  204. ```
  205. The following configuration values can be used:
  206. ### `scriptId` (required)
  207. Specifies the id of the Google Script project that clasp will target.
  208. 1. Open script url.
  209. 1. File > Project properties > Script ID
  210. ### `rootDir` (optional)
  211. Specifies the **local** directory in which clasp will store your project files. If not specified, clasp will default to the current directory.
  212. ### `projectId` (optional)
  213. Specifies the id of the Google Cloud Platform project that clasp will target.
  214. You must [associate Google Script project with Google Cloud Platform](https://github.com/google/clasp/blob/master/docs/run.md#setup-instructions) beforehand.
  215. 1. Run `clasp open`.
  216. 1. Click `Resources > Cloud Platform project...`.
  217. 1. Specify the project ID `project-id-xxxxxxxxxxxxxxxxxxx`.
  218. Even if you do not set this manually, clasp will ask this via a prompt to you at the required time.
  219. ### `fileExtension` (deprecated, optional)
  220. Specifies the file extension for **local** script files in your Apps Script project.
  221. ### `scriptExtensions` (optional)
  222. Specifies the file extensions for **local** script files in your Apps Script project. May be a string or array of strings. Files matching the extension will be considered scripts files.
  223. When pulling files, the first extension listed is used to write files.
  224. Defaults to `[".js", ".gs"]`
  225. ### `htmlExtensions` (optional)
  226. Specifies the file extensions for **local** HTML files in your Apps Script project. May be a string or array of strings. Files matching the extension will be considered HTML files.
  227. When pulling files, the first extension listed is used to write files.
  228. Defaults to `[".html"]`
  229. ### `filePushOrder` (optional)
  230. Specifies the files that should be pushed first, useful for scripts that rely on order of execution. All other files are pushed after this list of files, sorted by name.
  231. Note that file paths are relative to directory containing .clasp.json. If `rootDir` is also set, any files listed should include that path as well.
  232. ### `skipSubdirectories` (optional)
  233. For backwards compatibility with previous behavior where subdirectories
  234. are ignored if a `.claspignore` file is not present. Clasp provides default
  235. ignore rules, making the previous warning and behavior confusing. If you
  236. need to force clasp to ignore subdirectories and do not want to construct
  237. a `.claspignore` file, set this option to true.
  238. ## Reference
  239. ### Global options
  240. - `--user <name>`: Uses credentials stored under the named key. When omitted, the `default` user is used.
  241. - `--adc`: Uses application default credentials from the environment. Intended to support service accounts in CI workflows.
  242. - `--project <file>`: Reads project settings from a file other than `.clasp.json`. Intended to support multiple deployment targets.
  243. - `--auth <file>`: (**DEPRECATED**) Reads credentials from a file other than `.clasprc.json`. Use the `--user` option to maintain multiple authorized accounts.
  244. - `--ignore <file>`: Reads ignore patterns from a file other than `.claspignore`.
  245. - `--json`: Show output in JSON format.
  246. ### Login
  247. Logs the user in. Saves the client credentials to a `.clasprc.json` file in the user's home directory
  248. #### Options
  249. - `--no-localhost`: Do not run a local server, manually enter code instead.
  250. - `--creds <file>`: Use custom credentials used for `clasp run`. Saves a `.clasprc.json` file to current working directory. This file should be private!
  251. - `--use-project-scopes`: Use scopes from `appsscript.json` instead of default clasp scopes. Useful for `clasp run` when your script requires runtime scopes.
  252. - `--include-clasp-scopes`: Include default clasp scopes in addition to project scopes from `appsscript.json`. Can only be used with `--use-project-scopes`.
  253. - `--extra-scopes <scopes>`: Include additional OAuth scopes as a comma-separated list (for example, `scopeA,scopeB`). Empty entries are rejected.
  254. - `--redirect-port <port>`: Specify a custom port for the local redirect server during the login process. Useful for environments where a specific port is required.
  255. #### Examples
  256. - `clasp login`
  257. - `clasp login --no-localhost`
  258. - `clasp login --user test-user --creds client_secret.json`
  259. - `clasp login --user test-user --use-project-scopes --creds client_secret.json`
  260. - `clasp login --user test-user --use-project-scopes --include-clasp-scopes --creds client_secret.json`
  261. - `clasp login --user test-user --extra-scopes https://www.googleapis.com/auth/spreadsheets.readonly,https://www.googleapis.com/auth/drive.readonly --creds client_secret.json`
  262. - `clasp login --redirect-port 37473`
  263. ### Logout
  264. Logs out the user by deleting client credentials.
  265. #### Examples
  266. - `clasp logout`
  267. ### Show Authorized User
  268. Shows the current authorization status. When logged in, the output includes
  269. the OAuth client ID and whether the client is `google-provided` (clasp default)
  270. or `user-provided` (custom credentials).
  271. #### Options
  272. - `--json`: Output authorization details as JSON, including `clientId` and `clientType`.
  273. #### Examples
  274. - `clasp show-authorized-user`
  275. - `clasp show-authorized-user --json`
  276. ### Create
  277. Creates a new script project. Prompts the user for the script type if not specified.
  278. #### Options
  279. - `--type [docs/sheets/slides/forms]`: If specified, creates a new add-on attached to a Document, Spreadsheet, Presentation, or Form. If `--parentId` is specified, this value is ignored.
  280. - `--title <title>`: A project title.
  281. - `--rootDir <dir>`: Local directory in which clasp will store your project files. If not specified, clasp will default to the current directory.
  282. - `--parentId <id>`: A project parent Id.
  283. - The Drive ID of a parent file that the created script project is bound to. This is usually the ID of a Google Doc, Google Sheet, Google Form, or Google Slides file. If not set, a standalone script project is created.
  284. - i.e. `https://docs.google.com/presentation/d/{id}/edit`
  285. #### Examples
  286. - `clasp create-script`
  287. - `clasp create-script --type standalone` (default)
  288. - `clasp create-script --type docs`
  289. - `clasp create-script --type sheets`
  290. - `clasp create-script --type slides`
  291. - `clasp create-script --type forms`
  292. - `clasp create-script --type webapp`
  293. - `clasp create-script --type api`
  294. - `clasp create-script --title "My Script"`
  295. - `clasp create-script --rootDir ./dist`
  296. - `clasp create-script --parentId "1D_Gxyv*****************************NXO7o"`
  297. These options can be combined like so:
  298. - `clasp create-script --title "My Script" --parentId "1D_Gxyv*****************************NXO7o" --rootDir ./dist`
  299. ### Clone
  300. Clones the script project from script.google.com.
  301. #### Options
  302. - `scriptId | scriptURL`: The script ID _or_ script URL to clone.
  303. - `--versionNumber <number>`: The version of the script to clone.
  304. - `--rootDir <dir>`: Local directory in which clasp will store your project files. If not specified, clasp will default to the current directory.
  305. #### Examples
  306. - `clasp clone-script "15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC"`
  307. - `clasp clone-script "https://script.google.com/d/15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC/edit"`
  308. - `clasp clone-script "15ImUCpyi1Jsd8yF8Z6wey_7cw793CymWTLxOqwMka3P1CzE5hQun6qiC" --rootDir ./src`
  309. ### Delete
  310. Interactively deletes a script or a project and the `.clasp.json` file. Prompt the user for confirmation if the --force option is not specified.
  311. #### Options
  312. - `-f` `--force`: Bypass any confirmation messages. It’s not a good idea to do this unless you want to run clasp from a script.
  313. #### Examples
  314. - `clasp delete-script`
  315. - `clasp delete-script -f`
  316. ### Pull
  317. Fetches a project from either a provided or saved script ID.
  318. Updates local files with Apps Script project.
  319. #### Options
  320. - `--versionNumber <number>`: The version number of the project to retrieve.
  321. - `--deleteUnusedFiles`: Deletes local files that would have been pushed that were not returned by the server. Prompts for confirmation
  322. - `--force`: Used with `--deleteUnusedFiles` to automatically confirm. Use with caution.
  323. #### Examples
  324. - `clasp pull`
  325. - `clasp pull --versionNumber 23`
  326. ### Push
  327. Force writes all local files to script.google.com.
  328. > Warning: Google `scripts` APIs do not currently support atomic nor per file operations. Thus the `push` command always **replaces** the whole content of the online project with the files being pushed.
  329. Ignores files:
  330. - That start with a `.`
  331. - That don't have an accepted file extension
  332. - That are ignored (filename matches a glob pattern in the `.claspignore` file)
  333. #### Options
  334. - `-f` `--force`: Forcibly overwrites the remote manifest.
  335. - `-w` `--watch`: Watches local file changes. Pushes files every few seconds.
  336. #### Examples
  337. - `clasp push`
  338. - `clasp push -f`
  339. - `clasp push --watch`
  340. ### Status
  341. Lists files that will be written to the server on `push`.
  342. Ignores files:
  343. - That start with a `.`
  344. - That don't have an accepted file extension
  345. - That are ignored (filename matches a glob pattern in the ignore file)
  346. #### Options
  347. - `--json`: Show status in JSON form.
  348. #### Examples
  349. - `clasp show-file-status`
  350. - `clasp show-file-status --json`
  351. ### Open
  352. Clasp offers several commands to opens the current directory's `clasp` project and related resources.
  353. #### Examples
  354. - `clasp open-script`
  355. - `clasp open-web-app`
  356. - `clasp open-container`
  357. - `clasp open-credentials-setup`
  358. ### Deployments
  359. List deployments of a script.
  360. #### Examples
  361. - `clasp list-deployments`: List all deployments for the current project
  362. - `clasp list-deployments [scriptId]`: List all deployments for a script ID
  363. ### Deploy
  364. Creates a version and deploys a script.
  365. The response gives the deployment ID and the version of the deployment.
  366. For web apps, each deployment has a unique URL.
  367. To update/redeploy an existing deployment, provide the deployment ID.
  368. #### Options
  369. - `-V <version>` `--versionNumber <version>`: The project version to deploy at.
  370. - `-d <description>` `--description <description>`: The deployment description.
  371. - `-i <id>` `--deploymentId <id>`: The deployment ID to redeploy.
  372. #### Examples
  373. - `clasp create-deployment` (create new deployment and new version)
  374. - `clasp create-deployment --versionNumber 4` (create new deployment)
  375. - `clasp create-deployment --description "Updates sidebar logo."` (deploy with description)
  376. - `clasp create-deployment --deploymentId abcd1234` (redeploy and create new version)
  377. - `clasp create-deployment -V 7 -d "Updates sidebar logo." -i abdc1234`
  378. ### Redeploy
  379. Updates an existing deployment. Same as `create-deployment -i id`.
  380. #### Options
  381. - `-V <version>` `--versionNumber <version>`: The project version to deploy at.
  382. - `-d <description>` `--description <description>`: The deployment description.
  383. #### Examples
  384. - `clasp update-deployment abcd1234` (redeploy and create new version)
  385. ### Undeploy
  386. Undeploys a deployment of a script.
  387. #### Options
  388. - `[deploymentId]`: An optional deployment ID.
  389. - `-a` `--all`: Undeploy all deployments.
  390. #### Examples
  391. - `clasp delete-deployment` (prompts for deployment or deletes if only one)
  392. - `clasp delete-deployment "123"`
  393. - `clasp delete-deployment --all`
  394. ### Version
  395. Creates an immutable version of the script.
  396. #### Options
  397. - `description`: description The description of the script version.
  398. #### Examples
  399. - `clasp create-version`
  400. - `clasp create-version "Bump the version."`
  401. ### Versions
  402. List versions of a script.
  403. #### Options
  404. #### Examples
  405. - `clasp list-versions`: List all versions for the current project
  406. - `clasp list-versions [scriptId]`: List all versions for a script ID
  407. ### List
  408. Lists your most recent Apps Script projects.
  409. #### Examples
  410. - `clasp list-scripts`: Prints `helloworld1 – xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...`
  411. ### MCP (EXPERIMENTAL)
  412. Runs clasp in MCP (model context protocol) mode for use with coding agents. Configure clasp as a local tool using STDIO transport. While running in MCP mode clasp uses the same credentials as
  413. normal when used as a CLI. Run `clasp login` ahead of time to authorize.
  414. When used in MCP mode clasp does not need to be started from the project directory. The project directoy is specified in the tool calls. Switching projects does not require a restart of the MCP server, while switching credentials does.
  415. This feature is experimental and currently offers a limited subset of tools for agents. Feedback is welcome.
  416. #### Options
  417. N/A
  418. #### Examples
  419. - `clasp mcp`
  420. ## Advanced Commands
  421. > **NOTE**: These commands require Project ID/credentials setup ([see below](#projectid-optional)).
  422. ### Setup Logs
  423. Ensures your script is configured with a GCP project ID, which is required to view logs in Cloud Logging with `clasp logs`.
  424. #### Options
  425. - `--json`: Output result in json format.
  426. #### Examples
  427. - `clasp setup-logs`
  428. - `clasp setup-logs --json`
  429. ### Logs
  430. Prints out most recent the _Cloud Logging logs_. These are logs from `console.log`, not `Logger.log`.
  431. #### Options
  432. - `--json`: Output logs in json format.
  433. - `--watch`: Retrieves the newest logs every 5 seconds.
  434. - `--simplified`: Removes timestamps from the logs.
  435. #### Examples
  436. ```text
  437. clasp logs
  438. ERROR Sat Apr 07 2019 10:58:31 GMT-0700 (PDT) myFunction my log error
  439. INFO Sat Apr 07 2019 10:58:31 GMT-0700 (PDT) myFunction info message
  440. ```
  441. - `clasp logs --json`
  442. - `clasp logs --watch`
  443. - `clasp logs --simplified`
  444. ### Run
  445. Remotely executes an Apps Script function.
  446. The complete step-by-step information on how to use `clasp run` is available here: [Run](/docs/run.md)
  447. Below is a short summary:
  448. 1. Log in with your credentials (`clasp login --creds creds.json`), see: [Run - Prerequisites](/docs/run.md#prerequisites)
  449. 1. Deploy the Script as an API executable (Easiest done via GUI at the moment).
  450. 1. Enable any APIs that are used by the script, see: [Run - Function with Scopes](/docs/run.md#run-a-function-that-requires-scopes)
  451. 1. Have the following in your `appsscript.json`. Be sure it's pushed:
  452. ```json
  453. "executionApi": {
  454. "access": "ANYONE"
  455. }
  456. ```
  457. #### Options
  458. - `<functionName>`: The name of the function in the script that you want to run.
  459. - `--nondev`: If true, runs the function in non-devMode.
  460. - `-p <paramString>` `--params <paramString>`: A JSON string array of parameters to pass to the function
  461. #### Examples
  462. - `clasp run-function 'sendEmail'`
  463. - `clasp run-function 'addOptions' -p '["string", 123, {"test": "for"}, true]'`
  464. ### List/Enable/Disable Google APIs
  465. List available APIs. Enables and disables Google APIs.
  466. #### List APIs
  467. Lists Google APIs that can be enabled as [Advanced Services](https://developers.google.com/apps-script/guides/services/advanced).
  468. - `clasp list-apis`
  469. - `clasp list-apis`
  470. #### Enable/Disable APIs
  471. Enables or disables APIs with the Google Cloud project. These APIs are used via services like GmailApp and Advanced Services like BigQuery.
  472. The API name can be found using `clasp apis list`.
  473. - `clasp enable-api drive`
  474. - `clasp disable-api drive`
  475. #### Open APIs Console
  476. Open the Google Cloud Console where you can view and manage API access.
  477. - `clasp open-api-console`
  478. ### Help
  479. Displays the help function.
  480. #### Examples
  481. - `clasp`
  482. - `clasp help`
  483. #### Clasp Run
  484. > **NOTE**: This command requires you to [bring your own Google API credentials](/docs/run.md).
  485. - [`clasp run-function [functionName] [--nondev] [--params <StringArray>]`](#run)
  486. ## Troubleshooting
  487. ### NodeJS Version
  488. The library requires **NodeJS version >= 22.0.0**.
  489. You can check your version of NodeJS with this command.
  490. ```sh
  491. node -v
  492. ```
  493. You can use these commands to upgrade NodeJS if necessary (**not on Windows**):
  494. ```sh
  495. npm install -g npm # Update npm and npx
  496. npx n latest # use the n package to update node
  497. ```
  498. ### Debugging & filing issues
  499. Clasp uses the [debug](https://www.npmjs.com/package/debug) library for internal logging. If you encounter an issue and want to file a bug report, please include a log with debugging enabled. Enable debugging by setting the envionment variable `DEBUG=clasp:*`
  500. Example:
  501. ```sh
  502. DEBUG=clasp:* clasp pull # Runs clasp with verbose debug output
  503. ```
  504. ### Using a Proxy
  505. Clasp supports proxies via the Google APIs Node Module.
  506. See ["Using a Proxy"](https://github.com/googleapis/google-api-nodejs-client#using-a-proxy) and [this discussion](https://github.com/google/clasp/issues/8#issuecomment-427560737) for details on how to use the proxy.
  507. This requires using the environment variables `HTTP_PROXY` / `HTTPS_PROXY`.
  508. ## README Badge
  509. Using clasp for your project? Add a README badge to show it off: [![clasp](https://img.shields.io/badge/built%20with-clasp-4285f4.svg)](https://github.com/google/clasp)
  510. ```md
  511. [![clasp](https://img.shields.io/badge/built%20with-clasp-4285f4.svg)](https://github.com/google/clasp)
  512. ```
  513. ## Develop clasp
  514. See [the develop guide](docs/develop.md) for instructions on how to build `clasp`. It's not that hard!
  515. ## Contributing
  516. The main purpose of this tool is to enable local Apps Script development.
  517. If you have a core feature or use-case you'd like to see, find a GitHub issue or
  518. create a detailed proposal of the use-case.
  519. PRs are very welcome! See the [issues](https://github.com/google/clasp/issues) (especially **good first issue** and **help wanted**).
  520. ⚡ Powered by the [Apps Script API](https://developers.google.com/apps-script/api/).

Version history

  • v1.0.010/19/2026

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.