Skip to main content
Glama
IQAIcom
by IQAIcom

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
NameRequiredDescriptionDefault
queryYesThe query to search for

Implementation Reference

  • 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";
    	}
    },
  • 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);
  • 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;
    	}
    }
  • 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
          }
        }
      }
    `);
Install Server

Other Tools

Related Tools

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/IQAIcom/mcp-iqwiki'

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