Skip to content
GlxymeshDocs
glxymesh.com
Select theme
Open console
Reading time 3 min

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.

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.

tools/list-open-issues/tool.yml
spec: glxymesh/tool@v1
name: list-open-issues
kind: http
description: Lists open issues in a GitHub repository, newest first.
read_only: true
inputs:
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 ../admin can’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.pick is a JMESPath expression. Keep only what the model needs: every field you return costs tokens.
  • Write most REST endpoints as http tools. Reach for function when one request isn’t enough.

One run function in the project’s language. It receives a ctx and the typed inputs, and returns anything JSON can hold.

tools/summarize-thread/tool.ts
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) }));
}
  • A tool error (ToolError in TypeScript and Python, glxy.Errorf in 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, pass ctx.fetch to SDKs that accept a custom fetch. In Python, make requests with ctx.fetch: requests and httpx open their own connections, which a deployed tool doesn’t have.
  • Every function tool 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.