UNPKG

@extenshi/mcp

Version:

Extenshi MCP server — bring the extension catalog (search, security, market research) and pre-publish scanning into your AI tools

149 lines • 5.76 kB
/** * The build map in a chat (plan 2026-11-03-extension-build-map §6.6, phase 4): * MCP Apps (2026-01-26) on the local (stdio) server. * * show_build_map (tools.ts) links to the page `ui://extenshi/build-map`, the * same page `extenshi map` serves (build-map-page.ts, a byte-identical copy of * the CLI's) built with `app`. A client that shows apps draws it in the * conversation; the page then talks to the host, which calls three tools on * this server for it, tools the host keeps from the model (`visibility: app`): * * - build_map_view: the snapshot the page draws. While the author's map server * runs, its snapshot as it is; otherwise one derived from the state file and * what the project files prove (build-map-files.ts, `facts: 'files'`), * without the scan, AI visibility and Dojo readiness records the CLI reads. * - build_map_answer: the author's answers, the same four writes the map * server takes from its page (a mark, a route, a pick or another round), * to the same state file under the same lock, checked the same way. * - build_map_file: a variant's thumbnail as a data: URL, since the page in a * chat may show data: images only (the default MCP Apps CSP). * * The answers are the author's (`via: 'map'`, who `you`), so build_map_answer * refuses unless the client said it shows apps, and index.ts removes all three * tools from a client that did not: a client that ignores `visibility` would * otherwise list them to the model. * * Local only: the hosted connector has no access to the author's files and * registers none of this. */ import type { FastMCP } from 'fastmcp'; import { z } from 'zod'; /** A thumbnail larger than this shows as its number. */ export declare const THUMB_MAX_BYTES: number; /** The bodies the map server's /api/confirm, /api/route and /api/review take (build-map-server.ts). */ declare const ANSWERS: { readonly setting: z.ZodObject<{ setting: z.ZodString; on: z.ZodNullable<z.ZodBoolean>; note: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>; }, "strip", z.ZodTypeAny, { setting: string; on: boolean | null; note?: string | undefined; }, { setting: string; on: boolean | null; note?: string | undefined; }>; readonly confirm: z.ZodObject<{ node: z.ZodString; task: z.ZodNumber; done: z.ZodBoolean; note: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>; }, "strip", z.ZodTypeAny, { done: boolean; task: number; node: string; note?: string | undefined; }, { done: boolean; task: number; node: string; note?: string | undefined; }>; readonly route: z.ZodObject<{ node: z.ZodString; how: z.ZodNullable<z.ZodEnum<["self", "skip"]>>; value: z.ZodOptional<z.ZodString>; since: z.ZodOptional<z.ZodNullable<z.ZodString>>; note: z.ZodEffects<z.ZodOptional<z.ZodString>, string | undefined, string | undefined>; }, "strip", z.ZodTypeAny, { node: string; how: "self" | "skip" | null; value?: string | undefined; note?: string | undefined; since?: string | null | undefined; }, { node: string; how: "self" | "skip" | null; value?: string | undefined; note?: string | undefined; since?: string | null | undefined; }>; readonly review: z.ZodObject<{ node: z.ZodString; round: z.ZodNumber; revision: z.ZodOptional<z.ZodNumber>; choice: z.ZodOptional<z.ZodString>; redo: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { node: string; round: number; redo?: string | undefined; choice?: string | undefined; revision?: number | undefined; }, { node: string; round: number; redo?: string | undefined; choice?: string | undefined; revision?: number | undefined; }>; }; export type BuildMapAnswerKind = keyof typeof ANSWERS; /** Like the map server's answer: ok, or the HTTP status it would send and why. */ export type BuildMapAnswerResult = { ok: true; } | { ok: false; status: number; error: string; message: string; }; export type BuildMapFileRef = { step: string; round: number; variant: string; which: 'image' | 'preview'; }; export type BuildMapApp = { /** The page, built for a chat. */ page(): string; /** The snapshot to draw; `unchanged` when it is the one `since` names. */ view(projectDir?: string, since?: string): Promise<{ etag: string; unchanged: true; } | { etag: string; snapshot: Record<string, unknown>; }>; answer(projectDir: string | undefined, kind: BuildMapAnswerKind, body: unknown): Promise<BuildMapAnswerResult>; /** A variant's image as a data: URL, when it is an image the map may show. */ file(projectDir: string | undefined, ref: BuildMapFileRef): Promise<{ src?: string; }>; }; export declare function buildMapApp(options: { version: string; /** Whether the client shows apps, so the page's answers are the author's. */ writable: () => boolean; cwd?: string; }): BuildMapApp; /** * The page resource and its three app-only tools. Not through registerTools: * they are not the agent's tools (no guide entry, no docs table), and the page * calls build_map_view every few seconds, which must not reach the usage events. */ export declare function registerBuildMapApp(server: FastMCP, app: BuildMapApp): void; export {}; //# sourceMappingURL=build-map-app.d.ts.map