NodeRingsDocs

Vercel AI SDK

Give an AI SDK agent NodeRings tools: search the marketplace, order and manage virtual machines, DNS records and SSH keys. Read-only by default, with tool approval for every change.

@noderings/ai-sdk adds NodeRings tools to the Vercel AI SDK (version 7). With them, a model can search the marketplace, compare virtual machine plans from independent providers, order a virtual machine, start and stop it, take snapshots, and manage DNS records and SSH keys. The tools work with generateText, streamText, ToolLoopAgent and useChat, and run on Node.js 22+, Vercel (serverless and Edge), Cloudflare Workers, Deno and Bun.

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 zod

The package is built on the official JavaScript SDK. Source and examples: noderings-ai-sdk on GitHub.


Authentication

Create a service account under Organization → Access Control → Service accounts, give it only the permissions the agent needs, and set its token on the server:

NODERINGS_TOKEN=...                  # required
NODERINGS_ORGANIZATION_ID=...        # optional: act for another organization the token can access

The 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 and no client component. You can also pass token, organizationId and baseURL, or your own client: new NodeRings({ ... }).


Quick start

import { generateText, isStepCount } from "ai";
import { nodeRingsTools } from "@noderings/ai-sdk";

const { text } = await generateText({
  model: "openai/gpt-5-mini", // any tool-calling model: an 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);

Tools

R = read, W = write (mode: "read-write"), D = destructive (mode: "read-write" and allowDestructive: true). In useChat, a tool's message part type is tool-<name>, for example tool-noderings_search_plans.

ToolKindWhat it does
noderings_search_plansRSearch virtual machine plans with a short query such as "2 vcpu 4 GB in Frankfurt": plan, region, provider, specs, price
noderings_get_planROne plan: specs, prices, rating and every region it can be deployed in
noderings_list_locationsRCities and countries where plans are sold
noderings_compare_providersRProviders selling one plan code in one city, with prices, ratings, IPv6 and capacity
noderings_list_distrosROperating systems a new virtual machine can run
noderings_list_ssh_keysRSaved SSH public keys (id, name, type, fingerprint; never the key body)
noderings_list_virtual_machinesRVirtual machines, optionally by status or tag
noderings_get_virtual_machineROne virtual machine with addresses, specs, tags and backup status
noderings_list_snapshotsRSnapshots of a virtual machine
noderings_list_dns_zonesRDNS zones with nameservers and delegation status
noderings_list_dns_recordsRRecords in a zone, optionally by name and type
noderings_get_accountRThe organization the token acts for
noderings_create_ssh_keyWSave an SSH public key
noderings_create_virtual_machineWOrder a virtual machine (spends money); optionally wait for its IP addresses
noderings_power_virtual_machineWStart, stop or restart
noderings_tag_virtual_machineWAdd or remove tags
noderings_create_snapshotWSnapshot a virtual machine's disk
noderings_create_dns_zoneWCreate a DNS zone
noderings_upsert_dns_recordWCreate a record (A, AAAA, CNAME, MX, TXT); replaces one only with allowOverwrite
noderings_reinstall_virtual_machineDReinstall with a new operating system (erases the disk)
noderings_delete_virtual_machineDDelete a virtual machine with its snapshots and backups
noderings_delete_dns_recordDDelete records by name and type
noderings_delete_ssh_keyDRemove a saved SSH key

Tools return compact JSON; lists are capped and report total and truncated. Errors come back as { error: "NodeRings error: ..." }, so the model can explain or recover.

How a model orders a server

noderings_search_plans returns planId, regionId and the listed price to tell the user.

noderings_list_distros returns a distro value, for example DISTRO_UBUNTU_24_04.

noderings_list_ssh_keys returns key ids. Or noderings_create_ssh_key saves the user's public key.

noderings_create_virtual_machine runs with confirm: true once the user agreed. With wait: true it waits up to 15 minutes and returns ipv4 and 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 plans need prepaid credit; if the balance is short, the error states the minimum. Deleting a virtual machine also removes its snapshots and backups and releases its addresses. If it was the last VM on its subscription, the subscription is cancelled and a final usage charge is recorded.


Safety

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
  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,
});

const toolApproval = nodeRingsToolApproval(tools); // every write tool waits for the user
LayerWhat it does
Read-only by defaultWithout mode: "read-write" only the 12 read tools exist.
Destructive opt-inDelete and reinstall tools also need allowDestructive: true.
include / excludePick tools by name. Unknown names throw when the tools are built.
confirmEvery write tool refuses unless the model sends confirm: true. Nothing is sent before this check.
confirmHostnameDelete and reinstall read the virtual machine first and refuse unless confirmHostname equals its hostname.
vmTagScopePower, tag, snapshot, reinstall and delete refuse virtual machines without the tag. New virtual machines always get it.
dryRunWrites run their checks, then return { dryRun: true, wouldCall, body } instead of sending the request.
Tool approvalnodeRingsToolApproval(tools) returns a toolApproval map that asks the user before every write, for generateText, streamText and ToolLoopAgent.
No secretsNo password, private key or raw user-data inputs. Outputs never contain the token or public key bodies.

Give the service account only the permissions the agent needs. The token's permissions are the last line of defence.


Next.js

A route handler streams with toolApproval, and the page shows Approve and Deny buttons for every write. The complete app is in examples/next.

// 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, use useChat from @ai-sdk/react with sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithApprovalResponses. Render parts with state === "approval-requested" and call addToolApprovalResponse({ id: part.approval.id, approved }).

Vercel functions may stop before a new virtual machine has started. On serverless, keep wait: false (the default) and let the model check with noderings_get_virtual_machine, or raise maxDuration within your plan's limit.


MCP instead of code

The hosted MCP server at https://mcp.noderings.com/mcp signs in as a NodeRings user through OAuth and exposes a fixed tool set. An AI SDK app can use it through createMCPClient from @ai-sdk/mcp. This package instead uses a service-account token on your server, runs on the Edge, and adds the safety options above.


Not supported

  • Block volumes, load balancers, and resizing 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.
  • Restoring snapshots and backups. This version lists and creates snapshots only.