Skip to main content
Glama
search.ts1.07 kB
import { BASE_URL } from "./index.js"; // section item in search results interface SearchSection { url: string; title: string; content: string; } // response from the search API interface SearchDocsResponse { sections: SearchSection[]; truncated?: boolean; } export async function searchDocs( query: string, docforkIdentifier?: string, tokens?: string ): Promise<SearchDocsResponse> { const url = new URL(`${BASE_URL}/search`); url.searchParams.set("query", query); if (docforkIdentifier) { url.searchParams.set("libraryId", docforkIdentifier); } if (tokens) { url.searchParams.set("tokens", tokens); } const response = await fetch(url.toString(), { method: "GET", headers: { "Content-Type": "application/json", "User-Agent": "docfork-mcp", }, }); if (!response.ok) { const text = await response.text(); throw new Error( `${response.status} ${response.statusText}: ${text.slice(0, 500)}` ); } const result = await response.json(); return result as SearchDocsResponse; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/docfork/docfork-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server