Skip to main content
Glama

Create function

create_function

Create a sandboxed user function in the caller's active workspace. Provide a 'name' (slug [a-z][a-z0-9_]*), an optional 'description', the 'code' (Deno TS/JS — it must define a top-level function main(input) that returns the JSON output; Phase 1 is PURE COMPUTE: no network, no filesystem, no env, no callbacks), an 'input_schema' and 'output_schema' (JSON Schema), and 'expose_as_tool' (default false — when true the function appears as the custom tool fn_ on YOUR workspace's MCP surface only). Enforces the plan's functions_count limit. CONFIRMATION: this tool is PROPOSED, never performed directly. You get status='confirmation_required' with an action_id and a plan_token, and the write happens only after confirm_action.

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": "create_function"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYes
nameYes
descriptionNo
input_schemaNo
output_schemaNo
expose_as_toolNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Goes well past the annotations by disclosing the two-phase confirmation protocol (status='confirmation_required' with action_id and plan_token, write only after confirm_action) and that the plan's functions_count limit is enforced. It also discloses the runtime sandbox: Phase 1 is pure compute with no network, filesystem, env access or callbacks, and that expose_as_tool publishes fn_<name> only on the caller's own workspace MCP surface.

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

Conciseness4/5

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

Front-loaded with the action and scope, and every sentence carries information, including the labeled CONFIRMATION clause that highlights the most surprising behavior. The single dense paragraph with stacked parentheticals is harder to scan than a short bulleted layout would be.

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

Completeness5/5

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

Six parameters, nested schema objects and no output schema, yet the description covers creation semantics, sandbox constraints, plan limits, tool exposure, and even the shape of the confirmation response. Nothing an agent needs in order to invoke this correctly is missing.

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

Parameters5/5

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

Schema description coverage is 0%, so the description carries the full burden and does so: it explains the name slug pattern, that description is optional, what code must contain, that input_schema/output_schema are JSON Schema, and that expose_as_tool defaults to false with a specific publication effect. Only the relationship between input_schema and the argument passed to main(input) is left implicit.

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

Purpose5/5

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

States a specific verb and resource with scope: 'Create a sandboxed user function in the caller's active workspace.' The verb alone separates it from the sibling verbs update_function, run_function, get_function and delete_function, so an agent can pick it without opening another schema.

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

Usage Guidelines4/5

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

Gives concrete preconditions and workflow guidance: name must be a slug matching [a-z][a-z0-9_]*, code must define `function main(input)`, and the call must be followed through confirm_action before the write lands. It does not explicitly say when to prefer this over update_function (altering an existing function) or when to set expose_as_tool, so a small inference remains.

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