Skip to main content
Glama

get-mediawiki-syntax

Read-only

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
NameRequiredDescriptionDefault
formatNoFormat of the documentation - 'complete' for full syntax guide (default), 'summary' for condensed version

Implementation Reference

  • 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();
      }
    },
  • 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",
          ),
      }),
    });
  • 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");
    }
  • 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");
    }
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate readOnlyHint=true and openWorldHint=true, which the description does not contradict. The description adds valuable behavioral context beyond annotations by specifying that it 'dynamically fetches' from external sources, ensuring 'complete and up-to-date' information, which helps the agent understand real-time data retrieval and reliability aspects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by specifics in a second sentence. Every sentence adds essential information (e.g., dynamic fetching, scope of features) without redundancy, making it highly efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (external data fetching), rich annotations (readOnlyHint, openWorldHint), and no output schema, the description is largely complete. It covers purpose, behavior, and scope adequately, though it could slightly enhance completeness by mentioning potential limitations like network dependencies or response formats.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, clearly documenting the 'format' parameter with its enum values and default. The description does not add any parameter-specific details beyond what the schema provides, so it meets the baseline score of 3 for high schema coverage without extra semantic value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Retrieve comprehensive MediaWiki syntax documentation') and resources ('from official MediaWiki help pages'), and it enumerates the scope of content covered ('formatting, links, tables, images, templates, categories, magic words, and citations'). With no sibling tools, this level of detail is excellent.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for obtaining up-to-date MediaWiki syntax, but it does not provide explicit guidance on when to use this tool versus alternatives (e.g., other documentation sources) or any prerequisites. Since there are no sibling tools, the lack of comparative guidance is less critical, but no explicit when/when-not instructions are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/kongyo2/MediaWiki-Syntax-MCP'

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