Vercel AI SDK tools for NodeRings. With them, a model can search the NodeRings hosting marketplace and run servers for you: compare virtual machine (Compute Instance) plans from independent providers, order a virtual machine, start and stop it, take snapshots, and manage DNS records and SSH keys.
The tools are read-only by default. Tools that change something must be turned on, and with
nodeRingsToolApproval() each one waits for the user's approval.
npm install @noderings/ai-sdk noderings ai zodWorks with generateText, streamText, ToolLoopAgent and useChat (AI SDK 7). The package
runs on Node.js 22+, Vercel (serverless and Edge), Cloudflare Workers, Deno and Bun. It
depends only on the official noderings SDK; ai
and zod are peer dependencies.
Full guide: https://docs.noderings.com/docs/client-guides/vercel-ai-sdk
Create a service account in the NodeRings console (Organization → Access Control → Service accounts), give it only the permissions your agent needs, and set its token on the server:
NODERINGS_TOKEN=... # required
NODERINGS_ORGANIZATION_ID=... # optional: act for another organization you belong toThe tools read NODERINGS_TOKEN on the first tool call, not at import time, so building a
Next.js app needs no token. Never put the token in the browser: no NEXT_PUBLIC_ variable,
no client component. You can also pass token, organizationId and baseURL, or your own
client: new NodeRings({...}).
import { generateText, isStepCount } from "ai";
import { nodeRingsTools } from "@noderings/ai-sdk";
const { text } = await generateText({
model: "openai/gpt-5-mini", // any tool-calling model; AI Gateway model id or a provider instance
tools: nodeRingsTools(), // read-only by default; reads NODERINGS_TOKEN
stopWhen: isStepCount(5),
prompt: "Which of my NodeRings servers are stopped, and what does a 2 vCPU plan in Frankfurt cost?",
});
console.log(text);More: examples/node/generate-text.ts,
examples/node/agent.ts (a read-only ToolLoopAgent) and
examples/next (a chat app with approval buttons).
R = read, W = write (mode: "read-write"), D = destructive (mode: "read-write" and
allowDestructive: true). The names match the NodeRings LangChain tools
(langchain-noderings), so prompts carry over.
In useChat, a tool's message part type is tool-<name>, for example tool-noderings_search_plans.
| Tool | Kind | What it does |
|---|---|---|
noderings_search_plans |
R | Search virtual machine plans with a short query such as "2 vcpu 4 GB in Frankfurt": plan, region, provider, specs, price |
noderings_get_plan |
R | One plan: specs, prices, rating and every region it can be deployed in |
noderings_list_locations |
R | Cities and countries where plans are sold |
noderings_compare_providers |
R | Providers selling one plan code in one city, with prices, ratings, IPv6 and capacity |
noderings_list_distros |
R | Operating systems a new virtual machine can run |
noderings_list_ssh_keys |
R | Saved SSH public keys (id, name, type, fingerprint; never the key body) |
noderings_list_virtual_machines |
R | Virtual machines, optionally by status or tag |
noderings_get_virtual_machine |
R | One virtual machine with addresses, specs, tags and backup status |
noderings_list_snapshots |
R | Snapshots of a virtual machine |
noderings_list_dns_zones |
R | DNS zones with nameservers and delegation status |
noderings_list_dns_records |
R | Records in a zone, optionally by name and type |
noderings_get_account |
R | The organization the token acts for |
noderings_create_ssh_key |
W | Save an SSH public key |
noderings_create_virtual_machine |
W | Order a virtual machine (spends money); optionally wait for its IP addresses |
noderings_power_virtual_machine |
W | Start, stop or restart |
noderings_tag_virtual_machine |
W | Add or remove tags |
noderings_create_snapshot |
W | Snapshot a virtual machine's disk |
noderings_create_dns_zone |
W | Create a DNS zone |
noderings_upsert_dns_record |
W | Create a record (A, AAAA, CNAME, MX, TXT); replaces one only with allowOverwrite |
noderings_reinstall_virtual_machine |
D | Reinstall with a new operating system (erases the disk) |
noderings_delete_virtual_machine |
D | Delete a virtual machine with its snapshots and backups |
noderings_delete_dns_record |
D | Delete records by name and type |
noderings_delete_ssh_key |
D | Remove a saved SSH key |
Tools return compact JSON (lists are capped, with total and truncated). Errors come back as
{ error: "NodeRings error: ..." } so the model can explain or recover; a cancelled generation
(abortSignal) cancels the API call and is not turned into a result.
Each tool also has its own factory (searchPlansTool(), createVirtualMachineTool(), ...) if you
want a single tool or your own names. Calling a factory is the opt-in for that tool: mode,
allowDestructive, include and exclude do not apply, but every check inside the tool does.
noderings_search_plans→planIdandregionId, and the price to tell the user.noderings_list_distros→distro, for exampleDISTRO_UBUNTU_24_04.noderings_list_ssh_keys, ornoderings_create_ssh_keywith the user's public key.noderings_create_virtual_machinewithconfirm: trueonce the user agreed. Withwait: trueit waits up to 15 minutes and returnsipv4/ipv6.- The user connects with their own private key, usually
ssh root@<ipv4>on standard images.
Passwords and private keys are never accepted. Usage-billed (hourly) plans need prepaid credit; if there is not enough, the error states the minimum.
import { nodeRingsTools, nodeRingsToolApproval } from "@noderings/ai-sdk";
const tools = nodeRingsTools({
mode: "read-write", // default "read-only"
allowDestructive: false, // delete and reinstall tools; needs read-write
include: undefined, // only these tool names
exclude: ["noderings_create_dns_zone"],
vmTagScope: "agent-managed", // writes only touch VMs with this tag; new VMs get it
dryRun: false, // writes describe the request instead of sending it
maxListItems: 50, // most items a list tool returns
});
const toolApproval = nodeRingsToolApproval(tools); // every write tool waits for the user| Layer | What it does |
|---|---|
| Read-only by default | Without mode: "read-write" only the 12 read tools exist. |
| Destructive opt-in | Delete and reinstall tools also need allowDestructive: true. |
include / exclude |
Pick tools by name. Unknown names, or an include the mode does not allow, throw when the tools are built. |
confirm |
Every write tool refuses unless the model sends confirm: true; the description tells it to ask the user first. Nothing is sent before this check. |
confirmHostname |
Delete and reinstall read the virtual machine first and refuse unless confirmHostname equals its hostname. |
vmTagScope |
Power, tag, snapshot, reinstall and delete refuse virtual machines without the tag, and the tag cannot be removed. New virtual machines always get it. |
dryRun |
Writes run their checks and reads, then return { dryRun: true, wouldCall, body }. |
| Tool approval | nodeRingsToolApproval(tools) returns a toolApproval map with { type: "user-approval", reason } for every write tool, for generateText, streamText and ToolLoopAgent. |
| No secrets | No password, private key or raw user-data inputs; noderings_create_ssh_key rejects anything that looks like a private key. Outputs never contain the token or public key bodies. |
NODERINGS_WRITE_TOOLS lists every tool that changes something and NODERINGS_DESTRUCTIVE_TOOLS
the subset that deletes or erases.
Give the service account only the permissions the agent needs: the token's permissions are the last line of defence.
examples/next is a complete App Router chat: the route streams with
toolApproval, and the page shows Approve / Deny buttons for every write.
// app/api/chat/route.ts
import { convertToModelMessages, createUIMessageStreamResponse, isStepCount, streamText, toUIMessageStream, type UIMessage } from "ai";
import { nodeRingsTools, nodeRingsToolApproval } from "@noderings/ai-sdk";
export const maxDuration = 60;
const tools = nodeRingsTools({ mode: "read-write", vmTagScope: "agent-managed" });
export async function POST(req: Request) {
const { messages }: { messages: UIMessage[] } = await req.json();
const result = streamText({
model: "openai/gpt-5-mini",
system: "You manage NodeRings servers. Quote prices only from noderings_search_plans. When a tool execution is not approved, do not retry it.",
messages: await convertToModelMessages(messages),
tools,
toolApproval: nodeRingsToolApproval(tools),
stopWhen: isStepCount(8),
});
return createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream }) });
}In the page, useChat from @ai-sdk/react with
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses; render parts with
state === "approval-requested" and call addToolApprovalResponse({ id: part.approval.id, approved }).
Timeouts. Vercel functions may stop before a virtual machine has started (up to 15 minutes).
On serverless, prefer wait: false (the default) and let the model poll with
noderings_get_virtual_machine, or raise maxDuration within your plan's limit.
Rate limits. The SDK retries HTTP 429 (honouring Retry-After) and transient 5xx errors on
safe calls, and virtual machine creates carry an idempotency key. The tools never fan out in
parallel and stop list iteration at maxListItems.
NodeRings also runs a hosted MCP server at https://mcp.noderings.com/mcp. Apps that prefer it
can use the AI SDK MCP client instead of this package:
import { createMCPClient } from "@ai-sdk/mcp";
const mcp = await createMCPClient({
transport: { type: "http", url: "https://mcp.noderings.com/mcp", authProvider: myOAuthProvider },
});
const tools = await mcp.tools();
// … generateText({ tools, … }); then await mcp.close();The difference: the hosted MCP server signs in as a NodeRings user through OAuth (see the MCP guide) and exposes a fixed tool set. This package uses a service-account token on your server, runs on the Edge, and adds the safety options above. See the AI SDK docs on MCP tools.
- Block volumes, load balancers, and resizing or upgrading a running virtual machine (the API only changes tags on an existing VM).
- Custom image upload: the operating system comes from the distro catalogue, a saved cloud-init profile or an Instant App.
- Webhooks or event streams: waiting is polling.
- Snapshots and backups exist per virtual machine; this version lists and creates snapshots only (no restore, no backups).
- NodeRings: https://noderings.com · Docs: https://docs.noderings.com · AI SDK guide: https://docs.noderings.com/docs/client-guides/vercel-ai-sdk · API description: https://api.noderings.com/v1/openapi.json
- JavaScript SDK: https://github.com/noderings/noderings-js
- AI SDK tool calling: https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling
- CHANGELOG · CONTRIBUTING · SECURITY · RELEASING
Apache-2.0 © NodeRings