MCPcopy Create free account
hub / github.com/cursor/community-plugins / searchCompanies

Function searchCompanies

apps/cursor/src/data/client-queries.ts:32–60  ·  view source on GitHub ↗
(
  term: string,
  limit?: number,
)

Source from the content-addressed store, hash-verified

30// Searches the entire companies table by name (case-insensitive), rather than
31// filtering an already-loaded page of results.
32export async function searchCompanies(
33 term: string,
34 limit?: number,
35): Promise<CompanySearchResult[]> {
36 const trimmed = term.trim();
37
38 if (!trimmed) {
39 return [];
40 }
41
42 const supabase = createClient();
43 const baseQuery = () =>
44 supabase
45 .from("companies")
46 .select("id, name, slug, image, location")
47 .ilike("name", `%${trimmed}%`)
48 .order("name", { ascending: true });
49
50 if (limit !== undefined) {
51 const { data } = await baseQuery().limit(limit);
52 return ((data ?? []) as CompanyRow[]).map(toSearchResult);
53 }
54
55 const { data } = await fetchAllPages<CompanyRow>((from, to) =>
56 baseQuery().range(from, to),
57 );
58
59 return (data ?? []).map(toSearchResult);
60}
61
62export async function getMCPsClient({
63 page = 1,

Callers 1

CompanyFormFunction · 0.90

Calls 2

createClientFunction · 0.90
baseQueryFunction · 0.70

Tested by

no test coverage detected