Skip to main content
Glama
mohalmah

Google Apps Script MCP Server

by mohalmah

script_processes_list

List and filter execution processes for Google Apps Script projects to monitor performance and debug issues.

Instructions

List processes for a Google Apps Script project.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
scriptIdYesThe ID of the script to filter processes.
startTimeNoThe start time for filtering processes.
functionNameNoThe name of the function to filter processes.
deploymentIdNoThe deployment ID to filter processes.
projectNameNoThe project name to filter processes.
statusesNoThe statuses to filter processes.
pageTokenNoToken for pagination.
typesNoThe types of processes to filter.
userAccessLevelsNoUser access levels to filter.
pageSizeNoThe number of processes to return per page.
endTimeNoThe end time for filtering processes.
fieldsNoSelector specifying which fields to include in a partial response.
prettyPrintNoReturns response with indentations and line breaks.

Implementation Reference

  • The handler function for the 'script_processes_list' tool. It validates inputs, constructs the API URL with userProcessFilter parameters, fetches using OAuth headers from getAuthHeaders(), logs extensively, and returns the processes list or error.
    const executeFunction = async ({
      scriptId,
      startTime,
      functionName,
      deploymentId,
      projectName,
      statuses,
      pageToken,
      types,
      userAccessLevels,
      pageSize = 100,
      endTime,
      fields,
      prettyPrint = true
    }) => {
      const baseUrl = 'https://script.googleapis.com';
      const startTime_exec = Date.now();
    
      logger.info('API_CALL', 'Starting script processes list request', {
        scriptId,
        pageSize,
        startTime,
        endTime,
        functionName,
        deploymentId,
        baseUrl
      });
    
      try {
        // Validate required parameters
        if (!scriptId) {
          logger.error('API_CALL', 'Missing required parameter: scriptId');
          throw new Error('scriptId is required');
        }
    
        // Construct the URL with query parameters
        const url = new URL(`${baseUrl}/v1/processes`);
        const params = new URLSearchParams();
        params.append('userProcessFilter.scriptId', scriptId);
        if (startTime) params.append('userProcessFilter.startTime', startTime);
        if (functionName) params.append('userProcessFilter.functionName', functionName);
        if (deploymentId) params.append('userProcessFilter.deploymentId', deploymentId);
        if (projectName) params.append('userProcessFilter.projectName', projectName);
        if (statuses) params.append('userProcessFilter.statuses', statuses.join(','));
        if (pageToken) params.append('pageToken', pageToken);
        if (types) params.append('userProcessFilter.types', types.join(','));
        if (userAccessLevels) params.append('userProcessFilter.userAccessLevels', userAccessLevels.join(','));
        if (endTime) params.append('userProcessFilter.endTime', endTime);
        if (fields) params.append('fields', fields);
        params.append('pageSize', pageSize);
        params.append('prettyPrint', prettyPrint);
        
        url.search = params.toString();
    
        logger.debug('API_CALL', 'Constructed API URL', {
          url: url.toString(),
          queryParams: Object.fromEntries(params)
        });
    
        // Get OAuth headers
        logger.debug('API_CALL', 'Getting OAuth headers');
        const headers = await getAuthHeaders();
    
        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 };
          }
    
          logger.error('API_CALL', 'API request failed', {
            status: response.status,
            statusText: response.statusText,
            url: url.toString(),
            errorResponse: errorData,
            scriptId
          });
          
          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();
        const totalDuration = Date.now() - startTime_exec;
        
        logger.info('API_CALL', 'Script processes list request completed successfully', {
          scriptId,
          processCount: data.processes ? data.processes.length : 0,
          hasNextPageToken: !!data.nextPageToken,
          totalDuration: `${totalDuration}ms`,
          responseSize: JSON.stringify(data).length
        });
        
        return data;
      } catch (error) {
        logger.error('API_CALL', 'Script processes list request failed', {
          scriptId,
          error: {
            message: error.message,
            stack: error.stack
          }
        });
        
        console.error('Error listing processes:', error);
        return { 
          error: true,
          message: error.message,
          details: {
            scriptId,
            timestamp: new Date().toISOString(),
            errorType: error.name || 'Unknown'
          }
        };
      }
    };
  • The tool definition object containing the schema for inputs (parameters with scriptId required, optional filters like pageSize, statuses, etc.) and references the handler function. Exported for registration.
    const apiTool = {
      function: executeFunction,
      definition: {
        type: 'function',
        function: {
          name: 'script_processes_list',
          description: 'List processes for a Google Apps Script project.',
          parameters: {
            type: 'object',
            properties: {
              scriptId: {
                type: 'string',
                description: 'The ID of the script to filter processes.'
              },
              startTime: {
                type: 'string',
                description: 'The start time for filtering processes.'
              },
              functionName: {
                type: 'string',
                description: 'The name of the function to filter processes.'
              },
              deploymentId: {
                type: 'string',
                description: 'The deployment ID to filter processes.'
              },
              projectName: {
                type: 'string',
                description: 'The project name to filter processes.'
              },
              statuses: {
                type: 'array',
                items: {
                  type: 'string'
                },
                description: 'The statuses to filter processes.'
              },
              pageToken: {
                type: 'string',
                description: 'Token for pagination.'
              },
              types: {
                type: 'array',
                items: {
                  type: 'string'
                },
                description: 'The types of processes to filter.'
              },
              userAccessLevels: {
                type: 'array',
                items: {
                  type: 'string'
                },
                description: 'User access levels to filter.'
              },
              pageSize: {
                type: 'integer',
                description: 'The number of processes to return per page.'
              },
              endTime: {
                type: 'string',
                description: 'The end time for filtering processes.'
              },
              fields: {
                type: 'string',
                description: 'Selector specifying which fields to include in a partial response.'
              },
              prettyPrint: {
                type: 'boolean',
                description: 'Returns response with indentations and line breaks.'
              }
            },
            required: ['scriptId']
          }
        }
      }
    };
  • Exports the apiTool object which is imported and registered in the MCP tools list.
    export { apiTool };
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a list operation but doesn't mention whether it's paginated (though 'pageToken' and 'pageSize' parameters suggest it is), what authentication is required, rate limits, or what the output format looks like. For a tool with 13 parameters and no output schema, this is insufficient.

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, clear sentence that states exactly what the tool does without any unnecessary words. It's appropriately sized and front-loaded with the essential information.

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?

For a tool with 13 parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain the relationship between parameters, how filtering works, what the output contains, or provide any context about the processes being listed. The agent would need to infer too much from parameter names alone.

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 13 parameters thoroughly. The description doesn't add any parameter-specific information beyond what's in the schema descriptions, so it meets the baseline expectation without adding extra value.

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 action ('List') and resource ('processes for a Google Apps Script project'), making the purpose immediately understandable. However, it doesn't differentiate this tool from the sibling 'list_script_processes' which appears to serve a similar function, preventing a perfect score.

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 'list_script_processes' or 'get_script_metrics'. There's no mention of prerequisites, typical use cases, or when other tools might be more appropriate.

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