View as Markdown

API reference: @salmonui/mcp

SalmonToolsclass

import { SalmonTools } from '@salmonui/mcp';
class SalmonTools {
    #private;
    readonly index: McpIndex;
    readonly map: ExportsMap;
    constructor(index: McpIndex);
    call(name: string, args: Readonly<Record<string, unknown>>): ToolResult;
    url(path: string): string;
    get symbolsByName(): Map<string, IndexSymbol[]>;
    listComponents(filter?: string): ToolResult;
    get docsSearch(): {
        bm25: Bm25;
        refs: {
            doc: IndexDoc;
            section: number;
        }[];
    };
    rankDocs(query: string): {
        doc: IndexDoc;
        score: number;
        sections: {
            index: number;
            score: number;
        }[];
    }[];
    searchDocs(query: string, limit: number): ToolResult;
    docsMentioning(name: string, max?: number): IndexDoc[];
    referenceUrl(specifier: string): string;
    stylesheetLines(specifier: string): string[];
    getComponent(rawName: string): ToolResult;
    suggestNames(name: string, max?: number): string[];
    describeFamily(pkg: IndexPackage, family: IndexFamily): string;
    describeSymbol(symbol: IndexSymbol, { header }?: {
        header?: string;
    }): string;
    propsOf(symbol: IndexSymbol): {
        members: IndexMember[];
        from: string;
        alias?: string;
    } | undefined;
    get demoSearch(): Bm25;
    getExample(id?: string, query?: string): ToolResult;
    checkImports(source: string, stylesheets?: boolean): ToolResult;
}

The tools bound to one index; lookup structures are built lazily, once.

SalmonTools members (21)
NameSignatureDescription
__#1@#private#private;
indexreadonly index: McpIndex;
mapreadonly map: ExportsMap;
callcall(name: string, args: Readonly<Record<string, unknown>>): ToolResult;
urlurl(path: string): string;
symbolsByNameget symbolsByName(): Map<string, IndexSymbol[]>;
listComponentslistComponents(filter?: string): ToolResult;
docsSearchget docsSearch(): { bm25: Bm25; refs: { doc: IndexDoc; section: number; }[]; };
rankDocsrankDocs(query: string): { doc: IndexDoc; score: number; sections: { index: number; score: number; }[]; }[];

Pages for a query: per page, the best section scores, best first.

searchDocssearchDocs(query: string, limit: number): ToolResult;
docsMentioningdocsMentioning(name: string, max?: number): IndexDoc[];

Docs pages that name a symbol in code, most mentions first.

referenceUrlreferenceUrl(specifier: string): string;
stylesheetLinesstylesheetLines(specifier: string): string[];
getComponentgetComponent(rawName: string): ToolResult;
suggestNamessuggestNames(name: string, max?: number): string[];
describeFamilydescribeFamily(pkg: IndexPackage, family: IndexFamily): string;
describeSymboldescribeSymbol(symbol: IndexSymbol, { header }?: { header?: string; }): string;
propsOfpropsOf(symbol: IndexSymbol): { members: IndexMember[]; from: string; alias?: string; } | undefined;

The props of a component (its props parameter type, else <Name>Props), or the members of a type alias. An alias without members of its own (type ButtonProps = ButtonBaseProps & (...), a union of variants) gets the members of the object types it names, merged by name.

demoSearchget demoSearch(): Bm25;
getExamplegetExample(id?: string, query?: string): ToolResult;
checkImportscheckImports(source: string, stylesheets?: boolean): ToolResult;