Skip to content

HTTP / REST tools

{placeholder} in the URL is filled from the args; ${ENV} in a header expands from the environment at call time and is never logged. Non-2xx becomes an HTTP <status>: <body> error result.

import { httpTool } from "toolnexus"
tk.register(httpTool({
name: "get_post", description: "Fetch a placeholder blog post by id.",
method: "GET", url: "https://jsonplaceholder.typicode.com/posts/{id}",
inputSchema: {
type: "object",
properties: { id: { type: "number" } },
required: ["id"],
},
}))

An authenticated endpoint uses ${ENV} in a header — e.g. a POST with "Authorization": "Bearer ${API_TOKEN}". See HTTP / REST tools.

Next: Bring your own HTTP client.