Skip to main content
Glama

updateFunctionCode

Destructive

Update the source code of a function. The code can export either: 1) A 'main' function directly, OR 2) Any named function (auto-wrapped). Examples: Bitcoin price fetcher: 'export async function main() { const res = await fetch("https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"); return { price_usd: (await res.json()).bitcoin.usd }; }'. With KV counter: 'import kv from "@microfn/kv"; export async function main() { const count = (await kv.get("visits")) || 0; await kv.set("visits", count + 1); return { visits: count + 1 }; }'. IMPORTANT: Always use default imports for @microfn/* modules. Requires functionName (format: 'username/functionName') and code parameters.

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": {
      "functionName": "<functionName>",
      "code": "<code>"
    },
    "name": "updateFunctionCode"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe new TypeScript code. Can export: 1) 'export async function main() {...}' directly, OR 2) Any named exported function (gets auto-wrapped). Examples: Weather API: 'export async function getWeather() { const res = await fetch("https://wttr.in/Tokyo?format=3"); return res.text(); }'. Timer with KV: 'import kv from "@microfn/kv"; export async function main() { const val = (await kv.get<number>("timer")) || 0; await kv.set("timer", val + 1); return val + 1; }'. ALWAYS use default imports for @microfn/* modules.
functionNameYesThe function identifier in format 'username/functionName' (e.g., 'david/func1')

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

C2.9/5.0
Behavior3/5

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

Annotations already declare destructiveHint=true and readOnlyHint=false, so the safety profile is partly covered. The description adds code-handling behavior, including direct 'main' exports, auto-wrapped named exports, and default imports for @microfn modules, but it does not state that the existing code is overwritten, whether the change is reversible, or whether deployment follows.

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

Conciseness2/5

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

The purpose is front-loaded, but the description is bloated with long code examples that duplicate the schema's code parameter descriptions. The final sentence also redundantly restates the two required parameter names.

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 covers code format and import rules, and annotations flag destructiveness. However, for a destructive update tool it omits important lifecycle context such as overwriting existing source, validation failures, permissions, and deployment effects.

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 coverage is 100%, so the baseline is 3 even without parameter guidance in the description. The description largely repeats the schema, including the functionName format and code examples, rather than adding meaning beyond it.

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 first sentence gives a specific verb and resource: 'Update the source code of a function.' This distinguishes it from settings-oriented siblings like updateFunctionSettings, though it does not explicitly name alternatives such as createFunction or generateFunction.

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

Usage Guidelines2/5

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

The description does not explain when to use this tool versus createFunction, generateFunction, checkCode, or getFunctionCode, nor does it state prerequisites such as whether the function must already exist. Usage is only implied by the word 'update'.

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