Skip to main content
Glama

createFunction

Create a new MicroFn workspace/function with TypeScript code. The code must export either: 1) A 'main' function as the entry point, OR 2) Any named function (which will be auto-wrapped with a main function). Examples: 'export async function main() { return "hello" }', 'export async function sayHello(name) { return "hello " + name }' (auto-wrapped), 'export async function main() { const btc = await fetch("..."); return btc.json() }'. IMPORTANT: Import @microfn/* modules as defaults: 'import kv from "@microfn/kv"' NOT 'import { kv } from "@microfn/kv"'. Common patterns: use @microfn/secret for env vars, @microfn/kv for persistent storage (e.g., counters, cache), and fetch() for HTTP requests. Input: 'name' (string) - the function name, 'code' (string) - the TypeScript code. Output: the created workspace object with its name and metadata.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "name": "<name>",
      "code": "<code>"
    },
    "name": "createFunction"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesTypeScript code with exported function(s). Can be: 1) 'export async function main() {...}' for direct entry point, 2) 'export async function anyName() {...}' which auto-wraps with main(), 3) Multiple functions where main() calls others. Examples: Simple API call: 'export async function main() { const res = await fetch("https://api.example.com"); return res.json(); }'. With KV storage: 'import kv from "@microfn/kv"; export async function main() { const count = (await kv.get("count")) || 0; await kv.set("count", count + 1); return count + 1; }'. ALWAYS use default imports for @microfn/* modules.
nameYesThe name for the new function/workspace

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=false, destructiveHint=false and openWorldHint=false, so the write-and-isolated profile is covered by structured data. The description adds that the return value is the created workspace object with name and metadata, which is useful, but omits key behavior: what happens on a name collision, whether creation triggers a deployment (a waitForFunctionDeployment sibling exists), and whether the name must be unique.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The purpose and input/output summary are front-loaded, which is good, but the middle is a dense run-on of inline code samples that largely duplicate the schema's 'code' description (same default-import warning, same KV example). It reads as padded rather than tightly scoped.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description does state the return value, which matters given there is no output schema, and covers code-format expectations well. For a creation mutation it still leaves gaps around name-uniqueness errors and post-creation deployment state, which are the questions an agent is most likely to hit next.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so both 'name' and 'code' are fully documented in the schema, which already contains the import and example guidance. The description's restatement of code shapes and import syntax adds marginal meaning rather than new semantics, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a specific verb and resource ('Create a new MicroFn workspace/function') and narrows it to TypeScript code, so the agent knows exactly what gets produced. It does not, however, distinguish this from siblings like generateFunction or updateFunctionCode, leaving ambiguity about when creation vs. generation is appropriate.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Substantial guidance is given on how to supply code (entry-point shapes, default vs. named imports, common @microfn/* patterns), which is genuinely useful. But there is no statement of when to use this tool instead of generateFunction or updateFunctionCode, and no prerequisites or exclusions are mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources