Pairz
One app, for people and for AI.

People now act through AI assistants and agents, not only through the screens you build. Today that
means building your app for people, then bolting on a bot, an MCP server and a ChatGPT app. Each is
its own codebase, with its own idea of who's asking and what they may touch. With Pairz you write
the app once. People use it, and so do your own agents and everyone else's (ChatGPT, Claude, any MCP
client): the same Actions, the same rules, one record of who did what for whom.
One app, 3 callers
Here is a small booking app, in one file. Its one Action, booking.make, has 3 callers. Ana, a
person, calls it herself. The app's own agent calls it for her. An assistant from outside calls it
over MCP. The agent thinks with an OpenAI model, so the file needs an OPENAI_API_KEY, but the MCP
call needs no model.
import { type Actor, createRuntime, defineAction, definePlugin, peopleOrContacts } from "pairz";
import { memoryStore } from "pairz/stores/memory";
import { models } from "pairz/plugins/models";
import { chat, tool } from "pairz/plugins/agents";
import { access } from "pairz/plugins/access";
import { mcp } from "pairz/plugins/interfaces";
const booking = {
type: "object",
properties: { slot: { type: "string" }, in: { type: "string" }, thread: { type: "string" } },
required: ["slot", "in"],
} as const;
const salon = definePlugin({
name: "salon",
collections: { booking: { schema: booking } },
actions: {
"booking.make": defineAction({
input: booking,
// Asked of every caller, tools included: people, agents working for them, and contacts.
allow: peopleOrContacts,
run: (ctx, input) => ctx.db.collection("booking").insertOne(input),
}),
},
views: {
// Whose bookings? The rules filter the read, for whoever is looking.
bookings: (_, ctx) =>
ctx.db.collection<{ slot: string }>("booking").find().value?.map((b) => b.slot).join(", "),
// What a model reads after it books, the app's own or one over MCP.
"tool:book": (_, ctx) => ctx.show("bookings", {}),
},
resources: {
// The rules: a booking lives in a space, and belongs to the chat it was made in.
shared: { booking: { part: "thread" } },
tools: {
book: tool({
description: "Books a slot, like 'Wed 15:00'.",
input: { type: "object", properties: { slot: { type: "string" } }, required: ["slot"] },
// A tool works where its chat is (ctx.in), for whoever the chat is with.
run: ({ slot }, ctx) => ctx.call("booking.make", { slot, in: ctx.in, thread: ctx.thread }),
}),
},
agents: {
concierge: { instructions: "Book slots.", model: "openai/gpt-5.4-mini", tools: ["book"] },
},
provider: { openai: { apiKey: process.env.OPENAI_API_KEY } },
// An MCP server at /mcp/salon. No sign-in: each conversation is a contact, in its own chat.
mcp: { salon: { in: "desk", tools: { book: {} } } },
spaces: { desk: { name: "Front desk" } },
links: { origin: "http://localhost", secret: "keep-this-in-your-settings-not-in-code" },
},
});
const runtime = await createRuntime({
store: memoryStore(),
plugins: [models, chat, ...access, mcp, salon],
});
// The record: every write names who made it, for whom, and where.
const who = (a: Actor): string => `${a.kind} ${a.id}${a.for ? `, for ${who(a.for as Actor)}` : ""}`;
runtime.subscribe((item) => {
if (item.kind !== "event" || item.event.type !== "booking.created") return;
const { doc } = item.event.data as { doc: { slot: string } };
console.log(`${doc.slot} booked by ${who(item.event.actor!)}, in ${item.event.actor!.in}`);
});
// Ana books a slot herself, then asks the app's agent for another.
const ana: Actor = { kind: "person", id: "ana" };
const { space } = await runtime.call<{ space: string }>("space.personal", {}, { actor: ana });
// She works in her own space, and says so, as the app's page does.
const here = { actor: { ...ana, in: space } };
await runtime.call("booking.make", { slot: "Tue 10:00", in: space }, here);
await runtime.call("chat.send", { text: "Book me Wed 15:00 too.", in: space }, here);
await runtime.idle();