search_eve_wiki
Find articles on EVE University Wiki with an integrated Wayback Machine fallback to ensure reliable access to EVE Online knowledge.
Instructions
Search for articles on EVE University Wiki (with Wayback Machine fallback)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results to return | |
| query | Yes | Search query for EVE University Wiki |
Implementation Reference
- src/server.ts:15-50 (registration)Registration of the 'search_eve_wiki' tool using FastMCP server.addTool, including annotations, description, inline execute handler that delegates to EveWikiClient.search, name, and Zod parameters schema.server.addTool({ annotations: { openWorldHint: true, // This tool interacts with external systems readOnlyHint: true, // This tool doesn't modify anything title: "Search EVE University Wiki", }, description: "Search for articles on EVE University Wiki (with Wayback Machine fallback)", execute: async (args) => { try { const results = await eveWikiClient.search(args.query, args.limit); const hasArchivedResults = results.some(r => r.pageid === -1); return JSON.stringify( { query: args.query, results: results, note: hasArchivedResults ? "Some results are from Internet Archive Wayback Machine" : undefined, }, null, 2, ); } catch (error) { return `Error searching EVE Wiki: ${error}`; } }, name: "search_eve_wiki", parameters: z.object({ limit: z .number() .min(1) .max(50) .default(10) .describe("Maximum number of results to return"), query: z.string().describe("Search query for EVE University Wiki"), }), });
- src/eve-wiki-client.ts:419-500 (handler)Core implementation of the search functionality in EveWikiClient class. Performs MediaWiki API search with retryable requests, fallback to hardcoded common pages via Wayback Machine availability check if API fails.async search(query: string, limit: number = 10): Promise<SearchResult[]> { return this.retryableRequest(async () => { try { const response = await this.client.get("", { params: { action: "query", format: "json", list: "search", srlimit: limit, srprop: "snippet|titlesnippet|size|wordcount|timestamp", srsearch: query, }, }); if (response.data?.query?.search) { return response.data.query.search.map( (item: { pageid: number; snippet?: string; timestamp?: string; title: string; wordcount?: number; }) => ({ pageid: item.pageid, snippet: this.cleanSnippet(item.snippet || ""), timestamp: item.timestamp || "", title: item.title, wordcount: item.wordcount || 0, }), ); } return []; } catch (error) { console.error("Primary EVE Wiki search failed, trying Wayback Machine fallback:", error); // Try Wayback Machine fallback with common EVE-related pages try { const commonEvePages = [ "Fitting", "Ships", "Mining", "Trading", "PvP", "Missions", "Corporations", "Alliances", "Industry", "Exploration" ]; const matchingPages = commonEvePages.filter(page => page.toLowerCase().includes(query.toLowerCase()) || query.toLowerCase().includes(page.toLowerCase()) ); if (matchingPages.length === 0) { // If no matches, try to get a few common pages matchingPages.push(...commonEvePages.slice(0, Math.min(limit, 3))); } const results: SearchResult[] = []; for (const page of matchingPages.slice(0, limit)) { try { const articleUrl = `https://wiki.eveuniversity.org/wiki/${encodeURIComponent(page.replace(/ /g, '_'))}`; const snapshot = await this.checkWaybackAvailability(articleUrl); if (snapshot) { results.push({ pageid: -1, // Indicate this is from Wayback Machine snippet: `Archived content related to ${page} (from Wayback Machine)`, timestamp: snapshot.timestamp, title: `${page} (Archived)`, wordcount: 0, }); } } catch (pageError) { console.warn(`Failed to check Wayback availability for ${page}:`, pageError); } } return results; } catch (waybackError) { console.error("Wayback Machine fallback also failed:", waybackError); throw new Error(`Failed to search EVE Wiki from both primary source and Wayback Machine`); } } }); }
- src/server.ts:41-49 (schema)Zod input schema defining parameters for the tool: required 'query' string and optional 'limit' number (1-50, default 10).parameters: z.object({ limit: z .number() .min(1) .max(50) .default(10) .describe("Maximum number of results to return"), query: z.string().describe("Search query for EVE University Wiki"), }),
- src/eve-wiki-client.ts:12-18 (schema)TypeScript interface defining the structure of search results returned by the search method.export interface SearchResult { pageid: number; snippet: string; timestamp: string; title: string; wordcount: number; }
- src/eve-wiki-client.ts:505-509 (helper)Helper method to clean HTML snippets from search results by removing tags using cheerio.private cleanSnippet(snippet: string): string { // Remove HTML tags and decode entities const $ = cheerio.load(snippet); return $.root().text().trim(); }