GET_WIKI
Retrieve detailed information about a specific wiki from IQ.wiki by its unique ID using the MCP server for AI assistants and applications.
Instructions
Get details about a specific wiki from IQ.wiki by ID
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The ID of the wiki to retrieve |
Implementation Reference
- src/tools/get-wiki.ts:14-27 (handler)The main handler function for the GET_WIKI tool. It instantiates GetWikiService, calls its execute method with the provided wiki ID, formats the result, and handles any errors gracefully.execute: async (params: GetWikiParams) => { try { const service = new GetWikiService(); const wiki = await service.execute(params.id); return service.format(wiki); } catch (error) { if (error instanceof Error) { console.log(`Error in GET_WIKI tool: ${error.message}`); return `Error retrieving wiki: ${error.message}`; } return "An unknown error occurred while fetching wiki data"; } },
- src/tools/get-wiki.ts:4-6 (schema)Zod schema defining the required input parameter 'id' (string, non-empty) for the GET_WIKI tool.const getWikiParams = z.object({ id: z.string().min(1).describe("The ID of the wiki to retrieve"), });
- src/index.ts:17-17 (registration)Registers the GET_WIKI tool (imported as getWikiTool) with the FastMCP server instance.server.addTool(getWikiTool);
- src/index.ts:6-6 (registration)Imports the GET_WIKI tool definition from src/tools/get-wiki.js for registration.import { getWikiTool } from "./tools/get-wiki.js";
- src/services/get-wiki.ts:6-33 (helper)Supporting service class for GET_WIKI that executes a GraphQL query using WIKI_QUERY to fetch wiki details by ID and formats the output into a readable string.export class GetWikiService { async execute(id: string) { try { const response = await client.request(WIKI_QUERY, { id, }); if (!response.wiki) { throw new Error("Wiki Not found"); } return response.wiki; } catch (error: any) { throw new Error(error.message); } } format(wiki: any) { const formattedWiki = dedent` 📜 Wiki Details - Title: ${wiki.title} - Summary: ${wiki.summary} 🔗 Source: ${IQ_BASE_URL}/${wiki.id} 🔗 Transaction: https://polygonscan.com/tx/${wiki.transactionHash} `; return formattedWiki; } }