Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/bright-kings-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"ctx7": patch
"@upstash/context7-mcp": patch
---

Display warning when public library access filter is being used to filter libraries.
8 changes: 8 additions & 0 deletions packages/cli/src/commands/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ async function resolveCommand(
}

log.blank();

if (data.searchFilterApplied) {
log.warn(
"Your results only include libraries matching your access settings. To search across all public libraries, update your settings at https://context7.com/dashboard?tab=libraries"
);
log.blank();
}

for (let i = 0; i < results.length; i++) {
log.plain(formatLibraryResult(results[i], i));
log.blank();
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ async function generateCommand(options: GenerateOptions): Promise<void> {
searchSpinner.succeed(pc.green(`Found ${searchResult.results.length} relevant sources`));
log.blank();

if (searchResult.searchFilterApplied) {
log.warn(
"Your results only include libraries matching your access settings. To search across all public libraries, update your settings at https://context7.com/dashboard?tab=libraries"
);
log.blank();
}

let selectedLibraries: LibrarySearchResult[];
try {
const formatProjectId = (id: string) => {
Expand Down
7 changes: 1 addition & 6 deletions packages/cli/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface LibrarySearchResult {

export interface LibrarySearchResponse {
results: LibrarySearchResult[];
searchFilterApplied?: boolean;
error?: string;
message?: string;
}
Expand Down Expand Up @@ -216,12 +217,6 @@ export interface SkillQuotaResponse {
error?: string;
}

export interface LibraryResolveResponse {
results: LibrarySearchResult[];
error?: string;
message?: string;
}

export interface CodeExample {
language: string;
code: string;
Expand Down
5 changes: 2 additions & 3 deletions packages/cli/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
StructuredGenerateInput,
GenerateStreamEvent,
SkillQuotaResponse,
LibraryResolveResponse,
ContextResponse,
} from "../types.js";
import { downloadSkillFromGitHub } from "./github.js";
Expand Down Expand Up @@ -267,7 +266,7 @@ export async function resolveLibrary(
libraryName: string,
query?: string,
accessToken?: string
): Promise<LibraryResolveResponse> {
): Promise<LibrarySearchResponse> {
const params = new URLSearchParams({ libraryName });
if (query) {
params.set("query", query);
Expand All @@ -289,7 +288,7 @@ export async function resolveLibrary(
};
}

return (await response.json()) as LibraryResolveResponse;
return (await response.json()) as LibrarySearchResponse;
}

export interface GetContextOptions {
Expand Down
1 change: 1 addition & 0 deletions packages/mcp/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface SearchResult {
export interface SearchResponse {
error?: string;
results: SearchResult[];
searchFilterApplied?: boolean;
}

// Version state is still needed for validating search results
Expand Down
12 changes: 11 additions & 1 deletion packages/mcp/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,18 @@ export function formatSearchResults(searchResponse: SearchResponse): string {
return "No documentation libraries found matching your query.";
}

const parts: string[] = [];

if (searchResponse.searchFilterApplied) {
parts.push(
"**Note:** Your results only include libraries matching your access settings. To search across all public libraries, update your settings at https://context7.com/dashboard?tab=libraries"
);
}

const formattedResults = searchResponse.results.map(formatSearchResult);
return formattedResults.join("\n----------\n");
parts.push(formattedResults.join("\n----------\n"));

return parts.join("\n\n");
}

/**
Expand Down