get_eve_wiki_related_topics
Retrieve related topics for an EVE University Wiki article using its categories. Specify the article title and limit results to explore relevant content efficiently.
Instructions
Get topics related to an EVE University Wiki article based on categories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of related topics to return | |
| title | Yes | Title of the EVE University Wiki article |
Implementation Reference
- src/server.ts:177-214 (registration)Registration of the 'get_eve_wiki_related_topics' MCP tool, including annotations, description, input schema, output formatting, and handler function that delegates to EveWikiClient.getRelatedTopics.// Get related topics from EVE University Wiki server.addTool({ annotations: { openWorldHint: true, readOnlyHint: true, title: "Get Related EVE University Wiki Topics", }, description: "Get topics related to an EVE University Wiki article based on categories", execute: async (args) => { try { const relatedTopics = await eveWikiClient.getRelatedTopics( args.title, args.limit, ); return JSON.stringify( { related_topics: relatedTopics, title: args.title, }, null, 2, ); } catch (error) { return `Error getting related topics: ${error}`; } }, name: "get_eve_wiki_related_topics", parameters: z.object({ limit: z .number() .min(1) .max(20) .default(10) .describe("Maximum number of related topics to return"), title: z.string().describe("Title of the EVE University Wiki article"), }), });
- src/eve-wiki-client.ts:262-328 (handler)Main handler logic for fetching related topics: retrieves categories of the given wiki article title, then fetches up to 5 member pages from each of the first 3 categories (excluding the original title), collecting up to the specified limit.async getRelatedTopics(title: string, limit: number = 10): Promise<string[]> { return this.retryableRequest(async () => { try { // First get categories for the article const categoriesResponse = await this.client.get("", { params: { action: "query", cllimit: 10, format: "json", prop: "categories", titles: title, }, }); const pages = categoriesResponse.data?.query?.pages; if (!pages) { return []; } const pageId = Object.keys(pages)[0]; const page = pages[pageId]; if (page.missing || !page.categories) { return []; } // Get articles from the same categories const categories = page.categories.slice(0, 3); // Limit to first 3 categories const relatedArticles: Set<string> = new Set(); for (const category of categories) { try { const categoryResponse = await this.client.get("", { params: { action: "query", cmlimit: 5, cmtitle: category.title, cmtype: "page", format: "json", list: "categorymembers", }, }); if (categoryResponse.data?.query?.categorymembers) { categoryResponse.data.query.categorymembers.forEach( (member: { title: string }) => { if (member.title !== title && relatedArticles.size < limit) { relatedArticles.add(member.title); } }, ); } } catch (error) { console.warn( `Error getting category members for ${category.title}:`, error, ); } } return Array.from(relatedArticles); } catch (error) { console.error("Error getting related topics:", error); throw new Error(`Failed to get related topics for "${title}": ${error}`); } }); }
- src/server.ts:205-213 (schema)Input schema validation using Zod: requires 'title' string and optional 'limit' number (1-20, default 10).parameters: z.object({ limit: z .number() .min(1) .max(20) .default(10) .describe("Maximum number of related topics to return"), title: z.string().describe("Title of the EVE University Wiki article"), }),