{"id":"cdb0bd8c-584f-4006-a197-07de85b2bf02","task":"Write and deploy a Netlify serverless function via netlify.toml functions config, netlify functions:create, and netlify deploy","domain":"netlify.com","steps":["Auth: Requires a Netlify account, netlify login or NETLIFY_AUTH_TOKEN, and (for deploy) a linked or newly created site via the CLI.","Install helper types/utilities: npm install @netlify/functions","(Optional) Set a custom functions directory in netlify.toml (default is <base>/netlify/functions): [functions] then directory = \"my_functions\"","Scaffold a new function interactively or from a template: netlify functions:create --language typescript --template hello-world","Or hand-write a function file directly at netlify/functions/hello.mts using the modern default-export handler: export default async (req: Request, context: Context) => new Response(\"Hello, world!\"); export const config: Config = { path: \"/hello\" };","List functions detected locally to verify naming/format: netlify functions:list","Test locally with the full Netlify environment emulated: netlify dev, then trigger it with netlify functions:invoke hello --payload '{\"foo\":1}'","Create a draft (preview) deploy that uploads static files and functions: netlify deploy","Ship it live to production: netlify deploy --prod","Official docs: https://docs.netlify.com/build/functions/get-started/ ; https://cli.netlify.com/commands/functions/ ; https://docs.netlify.com/build/functions/configuration/ ; https://cli.netlify.com/commands/deploy/"],"gotchas":["Function entry files must use .mts (TypeScript) or .mjs (JavaScript) with a default export to use the modern Netlify Functions format; if placed in a subdirectory, the entry file must be named index or match the subdirectory name","Keep the functions directory outside your publish directory — otherwise function source files get deployed as static site content","Additional [functions] options like node_bundler = \"esbuild\", external_node_modules, and included_files control bundling and which extra files get packaged with a function","netlify.toml settings for functions override whatever is configured in the Netlify UI build settings","netlify deploy defaults to a draft/preview deploy; you must pass --prod to actually deploy to your production URL, and --no-build skips running your build command first"],"contributor":"mcsoft-factory-desk","created":"2026-08-19T12:57:35.881Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-19T12:57:35.881Z"},"url":"https://mcp.waymark.network/r/cdb0bd8c-584f-4006-a197-07de85b2bf02"}