Skip to main content
Glama

update_lead

Modify lead details like status, value, notes, and next actions in the revenue pipeline to maintain accurate sales tracking and follow-up scheduling.

Instructions

Update an existing lead

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
leadIdYesLead ID to update
statusNo
estimatedValueNo
notesNo
nextActionNo
nextActionDateNoYYYY-MM-DD

Implementation Reference

  • Handler for the 'update_lead' tool that delegates the execution to the external Google Apps Script API via callAPI('updateLead', args).
    case "update_lead":
      result = await callAPI("updateLead", args);
      break;
  • Input schema defining the parameters for the 'update_lead' tool, including leadId (required), status, estimatedValue, notes, nextAction, and nextActionDate.
    inputSchema: {
      type: "object",
      properties: {
        leadId: { type: "number", description: "Lead ID to update" },
        status: {
          type: "string",
          enum: ["New", "Contacted", "Call Booked", "Proposal Sent", "Closed", "Lost"]
        },
        estimatedValue: { type: "number" },
        notes: { type: "string" },
        nextAction: { type: "string" },
        nextActionDate: { type: "string", description: "YYYY-MM-DD" },
      },
      required: ["leadId"],
    },
  • index.js:197-215 (registration)
    Registration of the 'update_lead' tool in the MCP server's listTools response, specifying name, description, and input schema.
    {
      name: "update_lead",
      description: "Update an existing lead",
      inputSchema: {
        type: "object",
        properties: {
          leadId: { type: "number", description: "Lead ID to update" },
          status: {
            type: "string",
            enum: ["New", "Contacted", "Call Booked", "Proposal Sent", "Closed", "Lost"]
          },
          estimatedValue: { type: "number" },
          notes: { type: "string" },
          nextAction: { type: "string" },
          nextActionDate: { type: "string", description: "YYYY-MM-DD" },
        },
        required: ["leadId"],
      },
    },
  • Shared helper function callAPI that all tools use to POST requests to the Google Apps Script backend at the specified API_URL, handling form data, logging, and JSON parsing.
    async function callAPI(action, data = {}) {
      debugLog('=== API CALL START ===');
      debugLog(`Action: ${action}`);
      debugLog(`Data: ${JSON.stringify(data)}`);
    
      try {
        // Build form-encoded body for POST
        const formData = new URLSearchParams();
        formData.append('action', action);
    
        // Add all data fields to form
        for (const [key, value] of Object.entries(data)) {
          if (value !== undefined && value !== null) {
            formData.append(key, value.toString());
          }
        }
    
        const formString = formData.toString();
        debugLog(`FormData: ${formString}`);
        debugLog(`API_URL: ${API_URL}`);
    
        // Use POST with proper content type
        const response = await fetch(API_URL, {
          method: 'POST',
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded',
          },
          body: formString
        });
    
        debugLog(`Response status: ${response.status}`);
        debugLog(`Response ok: ${response.ok}`);
    
        if (!response.ok) {
          debugLog(`Response not OK: ${response.status} ${response.statusText}`);
          throw new Error(`API request failed: ${response.status} ${response.statusText}`);
        }
    
        const text = await response.text();
        debugLog(`Response text length: ${text.length}`);
        debugLog(`Response text: ${text}`);
    
        if (!text) {
          debugLog('ERROR: Empty response from API');
          throw new Error('Empty response from API');
        }
    
        const parsed = JSON.parse(text);
        debugLog(`Parsed successfully: ${JSON.stringify(parsed)}`);
        debugLog('=== API CALL END ===');
        return parsed;
    
      } catch (error) {
        debugLog(`ERROR in callAPI: ${error.message}`);
        debugLog(`ERROR stack: ${error.stack}`);
        throw error;
      }
    }

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/PromptishOperations/mcpSpec'

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