UNPKG

@ekwo-ai/mcp

Version:

MCP server for Ekwo OS: let an AI agent work on the books, under the user's own row level security.

42 lines • 1.99 kB
/** * What a tool does to the books, said once, in its own definition. * * Every tool of this server is one of three: it **reads** (nothing changes), * it **adds** (a draft, a contact, a note, a setting — something a person can * look at, change back or leave unused), or it is **destructive** (it posts, * cancels, replaces, removes, or reaches outside the books — a key, a public * link, a file sent). The protocol carries that as two hints, `readOnlyHint` * and `destructiveHint`, and a client that reads them asks before the third * kind; one that ignores them works as before. * * The rule is held twice, and neither is a list kept beside the tools. The * type below makes a registration without its hints a compile error — see * `register` in `server.ts` — and `tests/mcp/surface.test.ts` reads what a * client is actually offered. `packages/mcp/TOOL_DESIGN.md` says how to choose. */ /** The three effects a tool can have, in increasing order of care. */ export const TOOL_EFFECTS = ['read', 'additive', 'destructive']; /** The protocol's hints for an effect. */ export function annotationsFor(effect, details = {}) { const openWorldHint = details.openWorld === true; if (effect === 'read') return { readOnlyHint: true, openWorldHint }; return { readOnlyHint: false, destructiveHint: effect === 'destructive', ...(details.idempotent === undefined ? {} : { idempotentHint: details.idempotent }), openWorldHint, }; } /** * The effect the hints of a tool say, or `undefined` when they say none — * which a tool of this server never does, and a test makes sure of. */ export function effectOf(annotations) { if (annotations?.readOnlyHint === true) return 'read'; if (annotations?.readOnlyHint !== false || typeof annotations.destructiveHint !== 'boolean') return undefined; return annotations.destructiveHint ? 'destructive' : 'additive'; } //# sourceMappingURL=effect.js.map