GUIDE

Deploy your first JavaScript function

Updated September 09, 2026 By microfn 2 min read
javascript getting-started

A Microfn function is a small JavaScript or TypeScript module with an exported main function. Saving it deploys an HTTP endpoint you can call from the dashboard, an agent, or another application.

Create the function

Open Microfn, create a function named greet, and replace the editor contents with:

type Input = { name?: string };

export async function main(input: Input) {
  const name = input.name?.trim() || "there";
  return { message: `Hello, ${name}!` };
}

Save the function and wait for the deployment to finish.

Run it

Open the runner, enter this JSON, and run the function:

{"name":"Ada"}

The result should be:

{"message":"Hello, Ada!"}

Every run appears under Executions, with its input, output, logs, and status. If you change the code, save again before testing the new version.

Ask an agent to build it

After you connect Microfn through MCP, an agent can create and test the same function for you.

Example agent conversation
You

Create a Microfn function named greet. It should accept an optional name and return a greeting. Deploy it and test it with Ada.

Agent

I’ll create the function, deploy it, and run one test.

create_function

Created and deployed greet.

execute_function

{"message":"Hello, Ada!"}

Agent

The greet function is deployed and the test returned Hello, Ada!

Review generated code before giving it credentials or connecting it to an external system. Next, call an external API or turn the function into an MCP tool.

Related guides

All guides