add_lead
Add new leads to your sales pipeline by capturing company details, contact information, industry data, and estimated project value for revenue tracking and management.
Instructions
Add a new lead to the pipeline
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| companyName | Yes | Company name | |
| contactEmail | No | Contact email | |
| contactName | No | Contact person name | |
| contactPhone | No | Contact phone | |
| estimatedValue | No | Estimated project value | |
| industry | No | Industry/sector | |
| notes | No | Additional notes | |
| servicesInterestedIn | No | Services interested in | |
| source | No | Lead source |
Implementation Reference
- index.js:638-640 (handler)Handler for the 'add_lead' MCP tool. Forwards the tool arguments to the shared callAPI helper function, which makes a POST request to the Google Apps Script backend with action='addLead'.case "add_lead": result = await callAPI("addLead", args); break;
- index.js:177-195 (schema)Input schema for the 'add_lead' tool, defining parameters such as companyName (required), contact details, source, estimated value, and notes.inputSchema: { type: "object", properties: { companyName: { type: "string", description: "Company name" }, contactName: { type: "string", description: "Contact person name" }, contactEmail: { type: "string", description: "Contact email" }, contactPhone: { type: "string", description: "Contact phone" }, industry: { type: "string", description: "Industry/sector" }, source: { type: "string", description: "Lead source", enum: ["Upwork", "LinkedIn", "Cold Email", "Referral", "Website", "Other"] }, estimatedValue: { type: "number", description: "Estimated project value" }, servicesInterestedIn: { type: "string", description: "Services interested in" }, notes: { type: "string", description: "Additional notes" }, }, required: ["companyName"], },
- index.js:174-196 (registration)Registration of the 'add_lead' tool in the MCP server's ListTools response, specifying name, description, and input schema.{ name: "add_lead", description: "Add a new lead to the pipeline", inputSchema: { type: "object", properties: { companyName: { type: "string", description: "Company name" }, contactName: { type: "string", description: "Contact person name" }, contactEmail: { type: "string", description: "Contact email" }, contactPhone: { type: "string", description: "Contact phone" }, industry: { type: "string", description: "Industry/sector" }, source: { type: "string", description: "Lead source", enum: ["Upwork", "LinkedIn", "Cold Email", "Referral", "Website", "Other"] }, estimatedValue: { type: "number", description: "Estimated project value" }, servicesInterestedIn: { type: "string", description: "Services interested in" }, notes: { type: "string", description: "Additional notes" }, }, required: ["companyName"], }, },
- index.js:74-131 (helper)Shared helper function used by all API-forwarding tools, including add_lead. Posts form-encoded data to the backend API endpoint.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; } }