Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
This val was added by the MCP tool to provide utility functions for working with Twilio in Val Town.
generateSmsResponse(message)
: Creates a formatted TwiML response for SMS.parseTwilioRequest(request)
: Parses Twilio webhook form data from a request.validateTwilioRequest(request, authToken)
: Validates that a request is coming from Twilio.createTwimlResponse(twimlContent)
: Creates a Response with proper TwiML headers.addedByMCP()
: Returns true to indicate this val was added by the MCP tool.
Each function includes an indicator that it was added by the MCP tool, either through:
- The
_addedByMCP: "true"
property in returned objects - The
X-Created-By: "MCP-Tool"
header in responses - The dedicated
addedByMCP()
function
import { mcpTwilioHelper } from "https://esm.town/v/prashamtrivedi/mcpTwilioHelper";
export default async function(request: Request): Promise<Response> {
const twilioData = await mcpTwilioHelper.parseTwilioRequest(request);
// Handle the SMS message
const responseMessage = `Hello ${twilioData.From}! You said: ${twilioData.Body}`;
// Generate and return a TwiML response
const twiml = mcpTwilioHelper.generateSmsResponse(responseMessage);
return mcpTwilioHelper.createTwimlResponse(twiml);
}