Skip to main content
Glama
mohalmah

Google Apps Script MCP Server

by mohalmah

script_projects_deployments_create

Deploy Google Apps Script projects by creating new deployments with specified versions and descriptions.

Instructions

Creates a deployment of an Apps Script project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptIdYesThe ID of the script to deploy.
manifestFileNameYesThe name of the manifest file.
versionNumberYesThe version number of the script.
descriptionYesA description for the deployment.

Implementation Reference

  • The main handler function `executeFunction` that executes the tool logic: constructs the API URL, prepares the request body, fetches with OAuth headers from `getAuthHeaders`, handles responses, errors, logging, and returns the deployment data or error details.
    const executeFunction = async ({ scriptId, manifestFileName, versionNumber, description }) => {
      const baseUrl = 'https://script.googleapis.com';
      const url = `${baseUrl}/v1/projects/${scriptId}/deployments`;
      const startTime = Date.now();
    
      const body = {
        manifestFileName,
        versionNumber,
        description
      };
    
      try {
        logger.info('DEPLOYMENT_CREATE', 'Starting deployment creation', { scriptId, versionNumber, description });
    
        // Get OAuth headers
        const headers = await getAuthHeaders();
        headers['Content-Type'] = 'application/json';
    
        logger.logAPICall('POST', url, headers, body);
    
        // Perform the fetch request
        const fetchStartTime = Date.now();
        const response = await fetch(url, {
          method: 'POST',
          headers,
          body: JSON.stringify(body)
        });
        
        const fetchDuration = Date.now() - fetchStartTime;
        const responseSize = response.headers.get('content-length') || 'unknown';
        
        logger.logAPIResponse('POST', url, response.status, fetchDuration, responseSize);
    
        // Check if the response was successful
        if (!response.ok) {
          const errorText = await response.text();
          let errorData;
          
          try {
            errorData = JSON.parse(errorText);
          } catch (parseError) {
            errorData = { message: errorText };
          }
    
          const detailedError = {
            status: response.status,
            statusText: response.statusText,
            url,
            errorResponse: errorData,
            duration: Date.now() - startTime,
            scriptId,
            versionNumber,
            timestamp: new Date().toISOString()
          };
    
          logger.error('DEPLOYMENT_CREATE', 'API request failed', detailedError);
          
          console.error('❌ API Error Details:', JSON.stringify(detailedError, null, 2));
          
          throw new Error(`API Error (${response.status}): ${errorData.error?.message || errorData.message || 'Unknown error'}`);
        }
    
        // Parse and return the response data
        const data = await response.json();
        
        logger.info('DEPLOYMENT_CREATE', 'Successfully created deployment', {
          scriptId,
          deploymentId: data.deploymentId,
          versionNumber,
          duration: Date.now() - startTime
        });
        
        console.log('✅ Successfully created deployment');
        return data;
      } catch (error) {
        const errorDetails = {
          message: error.message,
          stack: error.stack,
          scriptId,
          versionNumber,
          duration: Date.now() - startTime,
          timestamp: new Date().toISOString(),
          errorType: error.name || 'Unknown'
        };
    
        logger.error('DEPLOYMENT_CREATE', 'Error creating deployment', errorDetails);
        
        console.error('❌ Error creating deployment:', errorDetails);
        
        // Return detailed error information for debugging
        return { 
          error: true,
          message: error.message,
          details: errorDetails,
          rawError: {
            name: error.name,
            stack: error.stack
          }
        };
      }
    };
  • The `apiTool` configuration object that registers the tool with MCP-compatible schema: includes reference to the handler function, tool name 'script_projects_deployments_create', description, input parameters schema with types and required fields.
    const apiTool = {
      function: executeFunction,
      definition: {
        type: 'function',
        function: {
          name: 'script_projects_deployments_create',
          description: 'Creates a deployment of an Apps Script project.',
          parameters: {
            type: 'object',
            properties: {
              scriptId: {
                type: 'string',
                description: 'The ID of the script to deploy.'
              },
              manifestFileName: {
                type: 'string',
                description: 'The name of the manifest file.'
              },
              versionNumber: {
                type: 'number',
                description: 'The version number of the script.'
              },
              description: {
                type: 'string',
                description: 'A description for the deployment.'
              }
            },
            required: ['scriptId', 'manifestFileName', 'versionNumber', 'description']
          }
        }
      }
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. While 'creates' implies a write operation, it doesn't disclose behavioral traits like whether this requires specific permissions, what happens if deployment fails, whether it's idempotent, or what the typical response looks like. For a mutation tool with zero annotation coverage, this is a significant gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, with every word earning its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations, no output schema, and siblings that suggest complex workflows (e.g., versions, updates, deletions), the description is incomplete. It doesn't address what happens after creation, error conditions, or how this fits into the broader deployment lifecycle, leaving significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all four parameters with basic descriptions. The description adds no additional meaning about parameters beyond what's in the schema, such as explaining relationships between them (e.g., manifestFileName must match an existing file) or providing examples. Baseline 3 is appropriate when schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('creates') and resource ('deployment of an Apps Script project'), making the purpose immediately understandable. However, it doesn't distinguish this tool from its sibling 'script_projects_versions_create' which also creates something related to Apps Script projects, nor does it specify what type of deployment this creates (e.g., web app, API executable).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'script_projects_deployments_update' and 'script_projects_versions_create', there's no indication of prerequisites (e.g., needing an existing script project), sequencing (e.g., create version first), or when to choose this over other deployment-related tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mohalmah/google-appscript-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server