@withpica/mcp-server
Version:
MCP Server for withPICA — enables AI assistants to interact with your withPICA music catalog
133 lines • 5.95 kB
TypeScript
/**
* The one way an MCP tool links into PICA (ADR-362 §2, founder yes
* 2026-11-21). Every link a tool returns comes from `viewUrl`, so:
*
* - the host is the environment's web origin (`webBaseUrl`), never a
* hardcoded one. The hosted route (app/api/mcp/route.ts) passes the origin
* for links a person opens, via `setWebOrigin(linkOrigin())`, so a preview
* links to its public alias (staging), never production; stdio reads
* PICA_API_URL. Pinned by
* src/__tests__/lib/view-url.test.ts and, for the route,
* app/api/mcp/__tests__/view-url-host.test.ts;
* - a link names only things from a fixed list (below) and UUIDs. Free text
* (titles, names, search words, notes) never goes in a URL (ADR-362 §1);
* a set or a note becomes a saved view (`{ saved_view_id }`, slice 3).
*
* A name or filter not in these tables does not compile; a gap code or id
* that isn't one throws, rather than build a guessed path.
* src/__tests__/lib/view-url.test.ts fails on a hand-built
* `withpica.com/inspect` link in mcp-server/src/tools or the skills.
*
* Pure (no SDK, no I/O). The app holds the lists it shares with this file
* equal through lib/services/__tests__/view-url-parity.test.ts.
*/
/**
* The web origin a person opens links on. The hosted route calls it once per
* request with `linkOrigin()`, which is env-only and so the same value for
* every request in one deployment: module state cannot carry one caller's
* host to another. Without it, a deployment with PICA_API_URL unset linked
* to production (2026-11-23, holdout saved-view-links run 45176451830).
*/
export declare function setWebOrigin(origin: string | null): void;
/**
* The user-facing web origin: the hosted route's origin first, then
* PICA_API_URL without its `/api` (`https://withpica.com/api` →
* `https://withpica.com`), then production.
*/
export declare function webBaseUrl(): string;
/** The record pages, by kind (an audio file opens its work). */
export declare const ENTITY_PATHS: {
readonly work: "works";
readonly person: "people";
readonly recording: "recordings";
readonly release: "releases";
readonly agreement: "agreements";
};
export type EntityKind = keyof typeof ENTITY_PATHS;
/**
* The places on a record page a link may open, by kind: a sub-page, an
* anchor, or both. Each target exists (app/inspect/works/[id]/page.tsx
* #human-made, …/documents, SignOwnLine #sign-sheet; recordings/[id]
* #ownership-splits).
*/
export declare const ENTITY_SECTIONS: {
readonly work: {
readonly "human-made": "#human-made";
readonly documents: "/documents";
readonly "sign-sheet": "/documents#sign-sheet";
};
readonly person: {};
readonly recording: {
readonly "ownership-splits": "#ownership-splits";
};
readonly release: {};
readonly agreement: {};
};
export type EntitySection<K extends EntityKind> = keyof (typeof ENTITY_SECTIONS)[K] & string;
/** The catalogue's tabs (app/inspect/components/CatalogView.tsx CATALOG_TABS). */
export declare const CATALOGUE_TABS: readonly ["works", "recordings", "releases", "projects", "people", "audio", "documents"];
export type CatalogueTab = (typeof CATALOGUE_TABS)[number];
/**
* The 10 gap codes. Mirrors lib/services/integrity-gap-codes.ts
* INTEGRITY_GAP_CODES (mcp <-> lib isolation, duplicated by hand like
* tools/integrity.ts GAP_CODES); lib/services/__tests__/view-url-parity.test.ts
* holds the two equal.
*/
export declare const GAP_CODES: readonly ["WORK_NO_RECORDING", "RECORDING_NO_WORK", "RECORDING_NO_RELEASE", "WORK_NO_WRITER", "RECORDING_NO_OWNER", "COLLABORATOR_NOT_INVITED", "COLLABORATOR_NOT_ATTESTED", "WORK_NO_MASTER", "WORK_SPLITS_ABSENT", "WORK_SPLITS_INVALID"];
export type GapCode = (typeof GAP_CODES)[number];
/** The documents tab's filters (app/inspect/lib/document-kinds.ts). */
export declare const DOCUMENTS_SHOW: readonly ["agreements", "split-sheets"];
export type DocumentsShow = (typeof DOCUMENTS_SHOW)[number];
/** Named views (ADR-362 §1). `compare` and `needs_you` come in slice 2. */
export interface CatalogueFilters {
tab?: CatalogueTab;
gap?: GapCode;
project?: string;
show?: DocumentsShow[];
}
export type ViewRef = {
entity: {
[K in EntityKind]: {
kind: K;
id: string;
section?: EntitySection<K>;
};
}[EntityKind];
} | {
view: {
name: "catalogue";
filters?: CatalogueFilters;
};
} | {
saved_view_id: string;
};
export interface ViewUrlOptions {
/**
* Mark a plain catalogue link as one an AI issued (`from=ai`), counted as
* unverified opens (ADR-362 §5). Ignored on entity and saved-view links.
*/
fromAi?: boolean;
}
export declare class ViewUrlError extends Error {
constructor(message: string);
}
/** The path and query of a view, without the host. */
export declare function viewPath(ref: ViewRef, options?: ViewUrlOptions): string;
/** The full link, on this environment's host. */
export declare function viewUrl(ref: ViewRef, options?: ViewUrlOptions): string;
/** The text answer's line for a link (e1's copy, ADR-362 §2). */
export declare function viewUrlLine(url: string): string;
/** `viewUrl`, or null when the ref names something that isn't a view. */
export declare function safeViewUrl(ref: ViewRef, options?: ViewUrlOptions): string | null;
/**
* The tab each gap code's rows live on. Mirrors lib/services/
* integrity-gap-codes.ts ENTITY_TYPE_FOR_CODE through app/inspect/lib/
* gap-filter.ts tabForEntityType (held equal by view-url-parity.test.ts).
*/
export declare const GAP_TAB: Readonly<Record<GapCode, CatalogueTab>>;
/**
* The catalogue narrowed to one gap, as an AI issues it (`from=ai`), on its
* tab: the same address /inspect's attention row links to.
*/
export declare function gapViewUrl(code: GapCode, project?: string): string;
//# sourceMappingURL=view-url.d.ts.map