Skip to main content
Glama
mohalmah

Google Apps Script MCP Server

by mohalmah

list_script_processes

Retrieve execution details for Google Apps Script processes to monitor performance, filter by criteria like function name or time range, and analyze script behavior.

Instructions

List information about a script's executed processes.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptIdYesThe ID of the script to list processes for.
pageSizeNoThe number of processes to return per page.
functionNameNoFilter by function name.
pageTokenNoToken for pagination.
startTimeNoFilter by start time.
endTimeNoFilter by end time.
deploymentIdNoFilter by deployment ID.
typesNoFilter by process types.
statusesNoFilter by process statuses.
userAccessLevelsNoFilter by user access levels.

Implementation Reference

  • Main handler function that executes the logic to list script processes using the Google Apps Script Processes API. Constructs URL with filters, makes authenticated GET request, handles response and errors.
    const executeFunction = async ({ scriptId, pageSize = 100, functionName, pageToken, startTime, endTime, deploymentId, types, statuses, userAccessLevels }) => {
      const baseUrl = 'https://script.googleapis.com';
      const accessToken = ''; // will be provided by the user
      const startTimeMs = Date.now();
      
      try {
        logger.info('SCRIPT_PROCESSES_LIST', 'Starting script processes list request', { scriptId, pageSize, functionName });
    
        // Construct the URL with query parameters
        const url = new URL(`${baseUrl}/v1/processes:listScriptProcesses`);
        url.searchParams.append('scriptId', scriptId);
        url.searchParams.append('pageSize', pageSize.toString());
        if (functionName) url.searchParams.append('scriptProcessFilter.functionName', functionName);
        if (pageToken) url.searchParams.append('pageToken', pageToken);
        if (startTime) url.searchParams.append('scriptProcessFilter.startTime', startTime);
        if (endTime) url.searchParams.append('scriptProcessFilter.endTime', endTime);
        if (deploymentId) url.searchParams.append('scriptProcessFilter.deploymentId', deploymentId);
        if (types) url.searchParams.append('scriptProcessFilter.types', types);
        if (statuses) url.searchParams.append('scriptProcessFilter.statuses', statuses);
        if (userAccessLevels) url.searchParams.append('scriptProcessFilter.userAccessLevels', userAccessLevels);
        url.searchParams.append('alt', 'json');
        url.searchParams.append('prettyPrint', 'true');
    
        logger.debug('SCRIPT_PROCESSES_LIST', 'Constructed API URL', {
          url: url.toString(),
          pathSegments: url.pathname.split('/'),
          queryParams: Object.fromEntries(url.searchParams)
        });
    
        // Set up headers for the request
        const headers = {
          'Authorization': `Bearer ${accessToken}`,
          'Accept': 'application/json'
        };
    
        logger.logAPICall('GET', url.toString(), headers);
    
        // Perform the fetch request
        const fetchStartTime = Date.now();
        const response = await fetch(url.toString(), {
          method: 'GET',
          headers
        });
        
        const fetchDuration = Date.now() - fetchStartTime;
        const responseSize = response.headers.get('content-length') || 'unknown';
        
        logger.logAPIResponse('GET', url.toString(), 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: url.toString(),
            errorResponse: errorData,
            duration: Date.now() - startTimeMs,
            scriptId,
            timestamp: new Date().toISOString()
          };
    
          logger.error('SCRIPT_PROCESSES_LIST', '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('SCRIPT_PROCESSES_LIST', 'Successfully retrieved script processes', {
          scriptId,
          processesCount: data.processes?.length || 0,
          duration: Date.now() - startTimeMs
        });
        
        console.log('✅ Successfully retrieved script processes');
        return data;
      } catch (error) {
        const errorDetails = {
          message: error.message,
          stack: error.stack,
          scriptId,
          duration: Date.now() - startTimeMs,
          timestamp: new Date().toISOString(),
          errorType: error.name || 'Unknown'
        };
    
        logger.error('SCRIPT_PROCESSES_LIST', 'Error listing script processes', errorDetails);
        
        console.error('❌ Error listing script processes:', errorDetails);
        
        // Return detailed error information for debugging
        return { 
          error: true,
          message: error.message,
          details: errorDetails,
          rawError: {
            name: error.name,
            stack: error.stack
          }
        };
      }
    };
  • Input schema defining the parameters for the list_script_processes tool, including required scriptId and optional filters.
    parameters: {
      type: 'object',
      properties: {
        scriptId: {
          type: 'string',
          description: 'The ID of the script to list processes for.'
        },
        pageSize: {
          type: 'integer',
          description: 'The number of processes to return per page.'
        },
        functionName: {
          type: 'string',
          description: 'Filter by function name.'
        },
        pageToken: {
          type: 'string',
          description: 'Token for pagination.'
        },
        startTime: {
          type: 'string',
          description: 'Filter by start time.'
        },
        endTime: {
          type: 'string',
          description: 'Filter by end time.'
        },
        deploymentId: {
          type: 'string',
          description: 'Filter by deployment ID.'
        },
        types: {
          type: 'string',
          description: 'Filter by process types.'
        },
        statuses: {
          type: 'string',
          description: 'Filter by process statuses.'
        },
        userAccessLevels: {
          type: 'string',
          description: 'Filter by user access levels.'
        }
      },
      required: ['scriptId']
    }
  • Tool registration object apiTool that binds the handler function to the tool name 'list_script_processes' and its schema definition.
    const apiTool = {
      function: executeFunction,
      definition: {
        type: 'function',
        function: {
          name: 'list_script_processes',
          description: 'List information about a script\'s executed processes.',
          parameters: {
            type: 'object',
            properties: {
              scriptId: {
                type: 'string',
                description: 'The ID of the script to list processes for.'
              },
              pageSize: {
                type: 'integer',
                description: 'The number of processes to return per page.'
              },
              functionName: {
                type: 'string',
                description: 'Filter by function name.'
              },
              pageToken: {
                type: 'string',
                description: 'Token for pagination.'
              },
              startTime: {
                type: 'string',
                description: 'Filter by start time.'
              },
              endTime: {
                type: 'string',
                description: 'Filter by end time.'
              },
              deploymentId: {
                type: 'string',
                description: 'Filter by deployment ID.'
              },
              types: {
                type: 'string',
                description: 'Filter by process types.'
              },
              statuses: {
                type: 'string',
                description: 'Filter by process statuses.'
              },
              userAccessLevels: {
                type: 'string',
                description: 'Filter by user access levels.'
              }
            },
            required: ['scriptId']
          }
        }
      }
    };
    
    export { apiTool };
  • tools/paths.js:12-12 (registration)
    The path to this tool's implementation file is registered in the toolPaths array, likely for dynamic tool loading.
    'google-app-script-api/apps-script-api/script-processes-list-script-processes.js',
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions listing information but fails to describe key traits like whether this is a read-only operation, if it supports pagination (implied by 'pageToken' in schema but not explained), rate limits, authentication needs, or what the output format looks like. This leaves significant gaps for an agent to understand how to interact with the tool effectively.

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 front-loads the core action ('List information about a script's executed processes'). There is no wasted verbiage, making it easy for an agent to parse quickly and understand the basic intent without unnecessary details.

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 the complexity of 10 parameters, no annotations, and no output schema, the description is incomplete. It doesn't address behavioral aspects like pagination, filtering logic, or response structure, which are critical for an agent to use this tool correctly. The schema covers parameters well, but the overall context lacks sufficient guidance for safe and effective invocation.

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?

The schema description coverage is 100%, with all 10 parameters well-documented in the schema. The description adds no additional meaning beyond what the schema provides, such as explaining filter interactions or parameter constraints. Since the schema does the heavy lifting, a baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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 ('List') and resource ('script's executed processes'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'script_processes_list' or 'get_script_metrics', which appear to have overlapping functionality, leaving some ambiguity about when to choose this specific tool.

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 like 'script_processes_list' or 'get_script_metrics'. It lacks context about prerequisites, such as needing a valid script ID, or exclusions, leaving the agent to infer usage from the schema alone.

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