Tool kinds
The two kinds of Glxymesh tool, http and function, with a complete tool.yml for each and when to use which.
Every tool has a tool.yml with a kind. Start with the simplest kind that does the job.
| Kind | Use it when | You write |
|---|---|---|
http |
The tool is one call to a REST API | A request template |
function |
The tool parses, combines several calls, or has real logic | One run function |
gxmesh new <name> adds a function tool; gxmesh new <name> --kind http adds an http one.
http: no code
Section titled “http: no code”The platform makes the request for you. There’s no function to start, so there’s no cold start, no build, and no compute time on your bill.
spec: glxymesh/tool@v1name: list-open-issueskind: httpdescription: Lists open issues in a GitHub repository, newest first.read_only: trueinputs: owner: {type: string} repo: {type: string} limit: {type: integer, default: 20, max: 100}request: method: GET url: https://api.github.com/repos/{owner}/{repo}/issues query: {state: open, per_page: "{limit}"} headers: {Accept: application/vnd.github+json}response: pick: "[].{number: number, title: title, author: user.login}"output: {format: toon, as: issues}network: {allow: [api.github.com]}tests: - input: {owner: golang, repo: go, limit: 2} expect: {rows: 2}{name}is replaced by the input of that name in the path, the query, headers and the body. Inputs never change the host.- A path value is escaped as one segment, so an argument such as
../admincan’t reach a different endpoint. - A query parameter or body field whose whole template is one input the caller left out is dropped, not sent empty.
response.pickis a JMESPath expression. Keep only what the model needs: every field you return costs tokens.- Write most REST endpoints as
httptools. Reach forfunctionwhen one request isn’t enough.
function: your code
Section titled “function: your code”One run function in the project’s language. It receives a ctx and the typed inputs, and returns
anything JSON can hold.
import { ToolError, type Ctx } from '@glxymesh/sdk';import type { Input } from './tool.gen';
export async function run(ctx: Ctx, input: Input) { const res = await ctx.fetch(`https://api.example.com/threads/${input.thread_id}`); if (res.status === 404) { throw new ToolError(`No thread ${input.thread_id}. Check the id and try again.`); } const { messages } = await res.json(); return messages.map((m: any) => ({ from: m.author, said: m.text.slice(0, 200) }));}package summarizethread
import ( "encoding/json"
"glxymesh.com/sdk/glxy")
func Run(ctx *glxy.Ctx, in Input) (any, error) { res, err := ctx.HTTP().Get("https://api.example.com/threads/" + in.ThreadId) if err != nil { return nil, glxy.Errorf("threads: %v", err) } defer res.Body.Close() if res.StatusCode == 404 { return nil, glxy.Errorf("no thread %s; check the id and try again", in.ThreadId) } var out any return out, json.NewDecoder(res.Body).Decode(&out)}from glxymesh import Ctx, ToolErrorfrom .tool_gen import Input
def run(ctx: Ctx, input: Input) -> list[dict]: res = ctx.fetch(f"https://api.example.com/threads/{input['thread_id']}") if res.status == 404: raise ToolError(f"No thread {input['thread_id']}. Check the id and try again.") messages = res.raise_for_status().json()["messages"] return [{"from": m["author"], "said": m["text"][:200]} for m in messages]- A tool error (
ToolErrorin TypeScript and Python,glxy.Errorfin Go) ends the call with a message the model reads and can act on. Write it as advice. - Any other error is a bug: the model gets a fixed sentence and you get the details in the console.
- In Go,
ctx.HTTP()returns an ordinary*http.Client, so SDKs that accept one, such as go-github or stripe-go, work unchanged. In TypeScript, passctx.fetchto SDKs that accept a customfetch. In Python, make requests withctx.fetch:requestsandhttpxopen their own connections, which a deployed tool doesn’t have. - Every
functiontool in a project runs in the same function, so they share packages, and a cold start wakes them all.
See the SDK reference for everything ctx offers.
© 2026 Glxymesh