@meterbox/ops
v0.1.0
Published
Thin HTTP client for the Meterbox /v1 API plus OpenAPI-driven operation discovery, shared by the Meterbox CLI and MCP server.
Maintainers
Readme
@meterbox/ops
Tiny HTTP client for the Meterbox /v1 API, plus the OpenAPI-driven operation
discovery that @meterbox/cli
and @meterbox/mcp are built
on. You probably don't need to install this directly; use one of those
packages instead.
npm install @meterbox/opsconst { Ops } = require("@meterbox/ops");
const ops = new Ops({
baseUrl: "https://your-meterbox-host",
apiKey: process.env.METERBOX_API_KEY, // mb_live_... from Settings > API keys
});
const plans = await ops.request({ method: "GET", path: "/v1/plans" });
const plan = await ops.request({
method: "POST",
path: "/v1/plans/{id}/publish",
pathParams: { id: "pro" },
});Authentication
apiKey: a tenant API key (mb_live_...). Sent asAuthorization: Bearer <key>.adminKey: a self-hosted deployment's operatorADMIN_API_KEY, sent asX-Admin-Key. A tenant key passed here (anything starting withmb_) is still sent as a Bearer token.operatorId(optional): sent asX-Operator-Idso audit rows can tell operators sharing one key apart.
Surface
Ops#request({ method, path, pathParams, query, body })MeterboxApiError: carriesstatus,body, and the responseX-Trace-Id. Its message includes the server's error text.fetchSpec(baseUrl),buildOperationsFromSpec(spec),partitionArgs(op, args),dispatchOperation(ops, op, args): turn a deployment's/openapi.jsoninto a list of operations whoseinputSchemais valid JSON Schema 2020-12, and call them.toJsonSchema(schema): convert an OpenAPI 3.0 schema object to JSON Schema 2020-12.
Requires Node.js 18 or later.
