Guides
TypeScript SDK
The @portlesslabs/sdk package: status and planned API.
In development
@portlesslabs/sdk isn't published yet. The API below is the planned design and may change before the first release. Until then, use the REST API directly: it's what the SDK wraps.What it will be
- A small, typed client for the gateway's REST API, with no runtime dependencies.
- Works in Node.js 18+, Bun, Deno and edge runtimes (Vercel, Cloudflare Workers).
- Typed errors, timeouts, cancellation, and safe retries for read requests.
Planned usage
Install
npm install @portlesslabs/sdkTypeScript
import { Portless } from "@portlesslabs/sdk";
// Reads PORTLESS_API_KEY from the environment by default.
const portless = new Portless({ agent: "Release bot" });
const tools = await portless.tools.list({ enabled: true });
const call = await portless.tools.call("github.search_repos", { query: "mcp" });
if (call.isError) console.error("Tool failed:", call.text);
else console.log(call.text);
// Or throw on tool failures:
const issue = await portless.tools.run("github.create_issue", { repo: "acme/app", title: "Bug" });Planned API
| Method | Calls |
|---|---|
portless.me() | GET /api/v1/me |
portless.servers.list() | GET /api/v1/servers |
portless.servers.sync(id) | POST /api/v1/servers/:id/sync |
portless.tools.list({ enabled }) | GET /api/v1/tools |
portless.tools.call(tool, args, opts) | POST /api/v1/tools/call |
portless.tools.run(tool, args, opts) | Same, but throws when the tool reports an error |
portless.mcp.config() | Builds an MCP client config for the gateway (contains your key) |
Planned errors
Each gateway error maps to a class: AuthenticationError (401), PermissionError (403), NotFoundError (404), ValidationError (400, 422), UpstreamError (501, 502), ServerError, plus ConnectionError and TimeoutError for network problems. All extend PortlessError with status and code.
Tool calls won't be retried automatically, because a tool may have side effects (opening an issue twice is worse than failing once). Read requests will be.