@pepys/api
v0.4.0
Published
The pepys API: typed queries over the store
Readme
The pepys API, for Bun: typed queries over the store that the host writes.
A deployment serves the core queries and each plug-in's queries over oRPC and as MCP tools.
Install
bun add @pepys/apiServe a deployment's queries from an entry file, then call them with a typed client:
// serve-api.ts
import { serveAPI } from '@pepys/api';
import { deployment } from './deployment.ts';
serveAPI({ deployment, environment: process.env, argv: process.argv.slice(2) });PEPYS_STORE_DIR=./store bun serve-api.tsTo compile the entry with bun build --compile, import @pepys/api before any other package that
loads the MCP SDK. Bun's bundler can leave out zod's start-up for the MCP SDK, and @pepys/api runs
it first. With another such package first, the binary exits at start with
undefined is not a constructor (evaluating 'new ZodLazy(...)').
import { createORPCClient } from '@orpc/client';
import { RPCLink } from '@orpc/client/fetch';
import type { DeploymentClient } from '@pepys/api';
import type { deployment } from './deployment.ts';
const api: DeploymentClient<typeof deployment> = createORPCClient(
new RPCLink({ url: '/rpc', origin: 'http://127.0.0.1:8081' }),
);
const pullRequest = await api.get_entity({ id: 'github:pull_request:9001' });Features
serveAPI, which serves a deployment's queries at/rpc, and as MCP tools at/mcpbehind the API's own OAuth server (the API). It also runs the OAuth server's admin commands:passkeys,clientsandgrants.DeploymentClient, the type of a typed client of a deployment's queries.- The store reader over the host's Turso files.
Documentation
The pepys docs hold the design of the API and the store.
