search_growthbook_docs
Search the GrowthBook documentation to find detailed instructions and guidance on using specific features effectively.
Instructions
Search the GrowthBook docs on how to use a feature
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The search query to look up in the GrowthBook docs. |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"query": {
"description": "The search query to look up in the GrowthBook docs.",
"type": "string"
}
},
"required": [
"query"
],
"type": "object"
}
Implementation Reference
- src/tools/search.ts:20-53 (handler)Handler function that executes the search_growthbook_docs tool logic: fetches search results from GrowthBook docs via the helper function and formats them into structured text responses.async ({ query }) => { const hits = await searchGrowthBookDocs(query); return { content: hits.slice(0, 5).map((hit: any) => { // Algolia typically returns content in various fields const content = hit.content || hit.text || hit._snippetResult?.content?.value || hit._highlightResult?.content?.value; const snippet = hit._snippetResult?.content?.value || hit._highlightResult?.content?.value; const title = hit.title || hit.hierarchy?.lvl0 || hit.hierarchy?.lvl1; const url = hit.url || hit.anchor; let text = ""; if (title) { text += `**${title}**\n`; } if (url) { text += `URL: ${url}\n`; } if (snippet || content) { text += `\n${snippet || content}`; } return { type: "text", text: text || JSON.stringify(hit), }; }), }; }
- src/tools/search.ts:12-16 (schema)Input schema definition using Zod for the tool's 'query' parameter.{ query: z .string() .describe("The search query to look up in the GrowthBook docs."), },
- src/tools/search.ts:8-55 (registration)Tool registration via server.tool() in the registerSearchTools export function, including name, description, schema, and handler.export function registerSearchTools({ server }: { server: McpServer }) { server.tool( "search_growthbook_docs", "Search the GrowthBook docs on how to use a feature", { query: z .string() .describe("The search query to look up in the GrowthBook docs."), }, { readOnlyHint: true, }, async ({ query }) => { const hits = await searchGrowthBookDocs(query); return { content: hits.slice(0, 5).map((hit: any) => { // Algolia typically returns content in various fields const content = hit.content || hit.text || hit._snippetResult?.content?.value || hit._highlightResult?.content?.value; const snippet = hit._snippetResult?.content?.value || hit._highlightResult?.content?.value; const title = hit.title || hit.hierarchy?.lvl0 || hit.hierarchy?.lvl1; const url = hit.url || hit.anchor; let text = ""; if (title) { text += `**${title}**\n`; } if (url) { text += `URL: ${url}\n`; } if (snippet || content) { text += `\n${snippet || content}`; } return { type: "text", text: text || JSON.stringify(hit), }; }), }; } ); }
- src/utils.ts:169-199 (helper)Supporting helper function that performs the actual Algolia search query against the GrowthBook documentation index and returns raw hits.export async function searchGrowthBookDocs(query: string) { const APPLICATION_ID = "MN7ZMY63CG"; const API_KEY = "e17ebcbd97bce29ad0bdec269770e9df"; const INDEX_NAME = "growthbook"; const url = `https://${APPLICATION_ID}-dsn.algolia.net/1/indexes/${INDEX_NAME}/query`; try { const response = await fetch(url, { method: "POST", headers: { "X-Algolia-API-Key": API_KEY, "X-Algolia-Application-Id": APPLICATION_ID, "Content-Type": "application/json", }, body: JSON.stringify({ query, attributesToSnippet: ["content:20", "text:20"], snippetEllipsisText: "...", hitsPerPage: 5, }), }); await handleResNotOk(response); const data = await response.json(); const hits = data.hits || []; return hits; } catch (error) { return []; } }