interface Context7Config { apiKey?: string; } /** * A library available in Context7 */ interface Library { /** Context7 library ID (e.g., "/facebook/react") */ id: string; /** Library display name */ name: string; /** Library description */ description: string; /** Number of documentation snippets available */ totalSnippets: number; /** Source reputation score (0-10) */ trustScore: number; /** Quality indicator score (0-100) */ benchmarkScore: number; /** Available versions/tags */ versions?: string[]; } /** * A piece of documentation content */ interface Documentation { /** Title of the documentation snippet */ title: string; /** The documentation content (may include code blocks in markdown format) */ content: string; /** Source URL or identifier for the snippet */ source: string; } interface GetContextOptions { /** * Response format. * - "json": Returns Documentation[] array (default) * - "txt": Returns formatted text string * @default "json" */ type?: "json" | "txt"; } interface SearchLibraryOptions { /** * Response format. * - "json": Returns Library[] array (default) * - "txt": Returns formatted text string * @default "json" */ type?: "json" | "txt"; } type QueryParams = Record; declare class Context7Error extends Error { constructor(message: string); } declare class Context7 { private httpClient; constructor(config?: Context7Config); /** * Search for libraries matching the given query as JSON (array of Library objects) */ searchLibrary(query: string, libraryName: string, options: SearchLibraryOptions & { type: "json"; }): Promise; /** * Search for libraries matching the given query as plain text */ searchLibrary(query: string, libraryName: string, options: SearchLibraryOptions & { type: "txt"; }): Promise; /** * Search for libraries matching the given query (defaults to JSON) */ searchLibrary(query: string, libraryName: string, options?: SearchLibraryOptions): Promise; /** * Get documentation context for a library as JSON (array of documentation snippets) */ getContext(query: string, libraryId: string, options: GetContextOptions & { type: "json"; }): Promise; /** * Get documentation context for a library as plain text */ getContext(query: string, libraryId: string, options: GetContextOptions & { type: "txt"; }): Promise; /** * Get documentation context for a library (defaults to JSON) */ getContext(query: string, libraryId: string, options?: GetContextOptions): Promise; } export { Context7, type Context7Config, Context7Error, type Documentation, type GetContextOptions, type Library, type QueryParams, type SearchLibraryOptions };