SEARCH_WIKI
Query IQ.wiki to find specific wikis, enabling AI assistants and applications to retrieve user-created, user-edited content, and detailed wiki activities.
Instructions
Search for a wiki from IQ.wiki by query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The query to search for |
Implementation Reference
- src/tools/search-wiki.ts:14-27 (handler)The execute function of the SEARCH_WIKI tool, which instantiates SearchWikiService, calls it with the query, formats the result, and handles errors.execute: async (params: SearchWikiParams) => { try { const service = new SearchWikiService(); const search = await service.execute(params.query); return service.format(search); } catch (error) { if (error instanceof Error) { console.log(`Error in SEARCH_WIKI tool: ${error.message}`); return `Error searching for wiki: ${error.message}`; } return "An unknown error occurred while searching for wiki data"; } },
- src/tools/search-wiki.ts:4-6 (schema)Zod schema defining the input parameters for the SEARCH_WIKI tool.const searchWikiParams = z.object({ query: z.string().min(1).describe("The query to search for"), });
- src/index.ts:21-21 (registration)Registers the searchWikiTool in the MCP server.server.addTool(searchWikiTool);
- src/services/search-wiki.ts:5-27 (helper)SearchWikiService class containing execute method that performs GraphQL search using SEARCH_WIKIS_QUERY and format method to present results.export class SearchWikiService { async execute(query: string) { const response = await client.request(SEARCH_WIKIS_QUERY, { query }); return response.search; } format(search: Awaited<ReturnType<typeof this.execute>>) { const formattedSearch = dedent` 📜 Search Results - Answer: ${search.answer} - Wiki Suggestions: ${(search.suggestions ?? []) .map( (suggestion: { id: string; title: string; }) => `${suggestion.title} (${suggestion.id})`, ) .join(", ")} `; return formattedSearch; } }
- src/lib/queries.ts:152-162 (helper)GraphQL query definition used by SearchWikiService for searching wikis.export const SEARCH_WIKIS_QUERY = graphql(` query searchWikis($query: String!) { search(query: $query) { answer suggestions { id title } } } `);