UNPKG

@withpica/mcp-server

Version:

MCP Server for withPICA — enables AI assistants to interact with your withPICA music catalog

102 lines • 3.57 kB
/** * ADR-352 D4 — `search` and `fetch`, in the exact shapes ChatGPT's deep * research and company knowledge call (developers.openai.com/api/docs/mcp). * * Served only on an OpenAI host's curated surface: ToolRegistry registers * them only when the caller context carries `curatedHost: "openai"`, so * Claude, stdio and the flat listing never see them (Claude has * pica_search_all, and a second search would be noise there). * * - `search {query}` → the chain search pica_search_all uses → * `{results: [{id, title, url}]}`. `id` is `<type>:<uuid>`; `url` is the * entity's absolute /inspect page, so ChatGPT can cite it. * - `fetch {id}` → splits the type and reads that one entity with its thin * getter → `{id, title, text, url, metadata}`, `text` a readable summary. * * `fetch` maps a FIXED set of five types to five reads. It is not a generic * executor: the model names an entity, never an operation (OpenAI's * guideline against dispatchers). Every read goes through the caller's own * credential, so the API's organisation scoping and scopes apply as for any * tool; an entity the caller can't read answers not-found. * * Both put the result in `structuredContent` and in `content`, as OpenAI * requires. */ import { PicaClient } from "@withpica/mcp-sdk"; import type { ToolDefinition, ToolExecutor } from "./index.js"; /** The five entity types `fetch` reads, and where each one's page is. */ export declare const FETCH_TYPES: { readonly work: "works"; readonly person: "people"; readonly recording: "recordings"; readonly release: "releases"; readonly agreement: "agreements"; }; export type FetchType = keyof typeof FETCH_TYPES; /** Parse `<type>:<uuid>`; null for anything else. */ export declare function parseFetchId(id: unknown): { type: FetchType; uuid: string; } | null; type ChainLike = { match_type?: string; work?: { id?: string; title?: string; primary_artist?: string; }; person?: { id?: string; name?: string; }; recording?: { id?: string; recording_title?: string; artist_name?: string; }; release?: { id?: string; title?: string; }; standalone_agreement?: { id?: string; title?: string; }; agreement?: { id?: string; title?: string; }; }; /** The entity a chain match is about, when it is one `fetch` can read. */ export declare function searchHit(r: ChainLike): { type: FetchType; id: string; title: string; } | null; /** A plain-English summary of one entity, built from its known fields. */ export declare function summarise(type: FetchType, entity: Record<string, unknown>): { title: string; text: string; metadata: Record<string, string>; }; /** * The entity's own row from its read: the SDK already unwraps the * `{success, data}` envelope the works, people, recordings and releases * routes answer; the agreements route answers `{success, agreement, …}`. */ export declare function unwrap(type: FetchType, entity: Record<string, unknown>): Record<string, unknown> | null; export declare class OpenAiSearchFetchTools { private readonly pica; private readonly origin; constructor(pica: PicaClient, apiUrl: string | undefined); private url; getTools(): Array<{ definition: ToolDefinition; executor: ToolExecutor; }>; private search; private fetch; private read; } export {}; //# sourceMappingURL=openai-search-fetch.d.ts.map