get-mediawiki-syntax
Retrieve up-to-date MediaWiki syntax documentation from official sources, offering complete or summary formats for formatting, links, tables, templates, and more.
Instructions
Retrieve comprehensive MediaWiki syntax documentation by dynamically fetching from official MediaWiki help pages. This provides complete and up-to-date markup syntax for all MediaWiki features including formatting, links, tables, images, templates, categories, magic words, and citations.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| format | No | Format of the documentation - 'complete' for full syntax guide (default), 'summary' for condensed version |
Implementation Reference
- src/server.ts:79-133 (handler)The core handler function for the 'get-mediawiki-syntax' tool. Validates input format, fetches comprehensive syntax documentation using fetchMediaWikiSyntax, optionally creates a summary with createContentSummary, reports progress, logs activity, and returns fallback syntax on failure.execute: async (args, { log, reportProgress }) => { if (!args.format || !["complete", "summary"].includes(args.format)) { throw new UserError( "Invalid format specified. Must be 'complete' or 'summary'.", ); } try { log.info( "Fetching MediaWiki syntax documentation from official help pages...", ); await reportProgress({ progress: 0, total: 100, }); const syntaxDoc = await fetchMediaWikiSyntax(MEDIAWIKI_HELP_PAGES); await reportProgress({ progress: 80, total: 100, }); if (args.format === "summary") { log.info("Creating summary version of documentation..."); const summary = createContentSummary(syntaxDoc); await reportProgress({ progress: 100, total: 100, }); log.info("Successfully created MediaWiki syntax summary"); return summary; } await reportProgress({ progress: 100, total: 100, }); log.info( "Successfully retrieved complete MediaWiki syntax documentation", ); return syntaxDoc; } catch (error) { log.error("Failed to fetch MediaWiki syntax documentation", { error: error instanceof Error ? error.message : "Unknown error", }); // Return fallback basic syntax if fetch fails return getFallbackSyntax(); } },
- src/server.ts:135-142 (schema)Zod schema for tool input parameters. Defines optional 'format' enum: 'complete' (default, full docs) or 'summary' (condensed version).parameters: z.object({ format: z .enum(["complete", "summary"]) .optional() .describe( "Format of the documentation - 'complete' for full syntax guide (default), 'summary' for condensed version", ), }),
- src/server.ts:71-143 (registration)Registration of the 'get-mediawiki-syntax' tool using server.addTool(). Includes annotations, description, inline handler (execute), name, and parameters schema. Note: excerpt abbreviated for handler/schema; full block lines 71-143.server.addTool({ annotations: { openWorldHint: true, // This tool fetches from external MediaWiki sites readOnlyHint: true, // This tool doesn't modify anything title: "Get MediaWiki Syntax", }, description: "Retrieve comprehensive MediaWiki syntax documentation by dynamically fetching from official MediaWiki help pages. This provides complete and up-to-date markup syntax for all MediaWiki features including formatting, links, tables, images, templates, categories, magic words, and citations.", execute: async (args, { log, reportProgress }) => { if (!args.format || !["complete", "summary"].includes(args.format)) { throw new UserError( "Invalid format specified. Must be 'complete' or 'summary'.", ); } try { log.info( "Fetching MediaWiki syntax documentation from official help pages...", ); await reportProgress({ progress: 0, total: 100, }); const syntaxDoc = await fetchMediaWikiSyntax(MEDIAWIKI_HELP_PAGES); await reportProgress({ progress: 80, total: 100, }); if (args.format === "summary") { log.info("Creating summary version of documentation..."); const summary = createContentSummary(syntaxDoc); await reportProgress({ progress: 100, total: 100, }); log.info("Successfully created MediaWiki syntax summary"); return summary; } await reportProgress({ progress: 100, total: 100, }); log.info( "Successfully retrieved complete MediaWiki syntax documentation", ); return syntaxDoc; } catch (error) { log.error("Failed to fetch MediaWiki syntax documentation", { error: error instanceof Error ? error.message : "Unknown error", }); // Return fallback basic syntax if fetch fails return getFallbackSyntax(); } }, name: "get-mediawiki-syntax", parameters: z.object({ format: z .enum(["complete", "summary"]) .optional() .describe( "Format of the documentation - 'complete' for full syntax guide (default), 'summary' for condensed version", ), }), });
- src/syntax-aggregator.ts:26-68 (helper)Key helper function that fetches content from multiple MediaWiki help pages using fetchPageContent, cleans it with cleanMediaWikiContent, and aggregates into a single markdown-formatted syntax reference with sections and error handling per page.export async function fetchMediaWikiSyntax( helpPages: readonly MediaWikiHelpPage[], ): Promise<string> { if (!helpPages || helpPages.length === 0) { throw new Error("No help pages provided"); } const sections: string[] = []; sections.push("# Complete MediaWiki Syntax Reference"); sections.push(""); sections.push( "This comprehensive guide covers all MediaWiki markup syntax, dynamically fetched from official MediaWiki documentation.", ); sections.push(""); for (const page of helpPages) { try { const content = await fetchPageContent(page.url); const cleanContent = cleanMediaWikiContent(content); sections.push(`## ${page.title}`); sections.push(""); sections.push(`*${page.description}*`); sections.push(""); sections.push(cleanContent); sections.push(""); sections.push("---"); sections.push(""); } catch (error) { sections.push(`## ${page.title}`); sections.push(""); sections.push(`*${page.description}*`); sections.push(""); sections.push( `Error fetching content from ${page.url}: ${error instanceof Error ? error.message : "Unknown error"}`, ); sections.push(""); } } return sections.join("\n"); }
- src/content-processor.ts:94-154 (helper)Helper function used by the handler for 'summary' format. Filters full documentation to retain headers, code blocks, tables, and lines containing key MediaWiki syntax patterns for a condensed version.export function createContentSummary(content: string): string { if (!content || typeof content !== "string") { return ""; } const lines = content.split("\n"); const summaryLines: string[] = []; let inCodeBlock = false; let inTable = false; for (const line of lines) { // Include headers if (line.startsWith("#")) { summaryLines.push(line); continue; } // Include code blocks and syntax examples if (line.includes("```") || line.includes("`")) { inCodeBlock = !inCodeBlock; summaryLines.push(line); continue; } if (inCodeBlock) { summaryLines.push(line); continue; } // Include table syntax if ( line.includes("|") && (line.includes("You type") || line.includes("Syntax") || line.includes("Result")) ) { inTable = true; summaryLines.push(line); continue; } if (inTable && line.includes("|")) { summaryLines.push(line); continue; } else if (inTable && !line.includes("|")) { inTable = false; } // Include important syntax patterns const syntaxPatterns = ["[[", "{{", "''", "==", "*", "#", "<", "|"]; const hasSyntaxPattern = syntaxPatterns.some((pattern) => line.includes(pattern), ); if (hasSyntaxPattern) { summaryLines.push(line); } } return summaryLines.join("\n"); }