updateFunctionCode
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
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The 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. | |
| functionName | Yes | The function identifier in format 'username/functionName' (e.g., 'david/func1') |