Skip to content

TypeScript SDK

Call Qosm agents from TypeScript with @qosm/mcp-client.


The TypeScript SDK (@qosm/mcp-client) lets you call published Qosm agents from TypeScript/JavaScript applications.

Install

npm install @qosm/mcp-client

Credentials

Credentials are resolved in order:

  1. Explicit constructor options
  2. Environment variables (QOSM_BASE_URL, QOSM_TOKEN)
  3. .env file

Quick start

import { AsyncQosmClient } from "@qosm/mcp-client";

const client = new AsyncQosmClient();

// List projects
const projects = await client.getProjects();

// Typecheck code
const check = await client.qosmCheck("let x = 1;", "@alice/my-project");

// Run an agent
const run = await client.qosmRun("@alice/my-agent");

Bound project API

Get a project-scoped client with typed function access:

const q = await client.project("@alice/my-project");
const result = await q.add(1, 2);

Typed code generation

Generate a TypeScript interface for a project:

npx qosm-tsgen @alice/my-project > my_project.ts

Then import the typed client:

import { createClient } from "./my_project";

const q = createClient({ token: "..." });
const result = await q.classify("Hello world");
// result is typed based on the Qosm function signature

Direct function calls

const fns = await client.getProjectFunctions("@alice/my-project");
const result = await client.callProjectFunction(
  "@alice/my-project",
  "add",
  ["1", "2"]
);

Available methods

| Method | Description | |--------|-------------| | getProjects() | List all projects | | getProjectContext(address) | Get project code and capabilities | | qosmCheck(code, address) | Typecheck code | | qosmRun(address) | Execute a published agent | | getProjectFunctions(address) | List functions | | callProjectFunction(address, name, args) | Call a function |