Skip to main content
Glama

MinecraftWiki_getPageSection

Retrieve a specific section from a Minecraft Wiki page by providing the page title and section index number to access detailed information.

Instructions

Get a specific section from a Minecraft Wiki page. Should be used as step 3 after searching for the page and getting its summary. The section index corresponds to the order of sections on the page, starting with 0 for the main content, 1 for the first section, 2 for the second section, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the Minecraft Wiki page
sectionIndexYesIndex of the section to retrieve (0 = main, 1 = first section, 2 = second section, etc.)

Implementation Reference

  • The main handler function that implements the tool logic by calling the MediaWiki parse API to retrieve a specific section of a page, sanitizes the content, and returns formatted JSON.
    async getPageSection(title: string, sectionIndex: number): Promise<string> {
      const response = await apiService.get<WikiResponse, Record<string, unknown>>("", {
        action: "parse",
        page: title,
        section: sectionIndex,
      });
    
      if (!response.parse?.text?.["*"]) {
        throw new Error(`No content found for section ${sectionIndex} of "${title}"`);
      }
    
      const content = sanitizeWikiContent(response.parse.text["*"]);
      return JSON.stringify({
        title: formatMCPText(title),
        sectionIndex: sectionIndex,
        content: content,
      });
    }
  • The Tool object defining the schema, name, description, and input schema (title: string, sectionIndex: number) for the MinecraftWiki_getPageSection tool.
    export const GET_PAGE_SECTION_MINECRAFTWIKI_TOOL: Tool = {
      name: "MinecraftWiki_getPageSection",
      description:
        "Get a specific section from a Minecraft Wiki page. Should be used as step 3 after searching for the page and getting its summary. The section index corresponds to the order of sections on the page, starting with 0 for the main content, 1 for the first section, 2 for the second section, etc.",
      inputSchema: {
        type: "object",
        properties: {
          title: {
            type: "string",
            description: "Title of the Minecraft Wiki page",
          },
          sectionIndex: {
            type: "number",
            description:
              "Index of the section to retrieve (0 = main, 1 = first section, 2 = second section, etc.)",
          },
        },
        required: ["title", "sectionIndex"],
      },
    };
  • src/server.ts:82-88 (registration)
    Registration of the tool handler in the MCP server's CallToolRequestSchema switch statement, which validates arguments using the guard and calls the wikiService handler.
    case GET_PAGE_SECTION_MINECRAFTWIKI_TOOL.name: {
      if (!isGetPageSectionArgs(args)) {
        throw new Error("Invalid arguments for getPageSection");
      }
      const section = await wikiService.getPageSection(args.title, args.sectionIndex);
      return { content: [{ type: "text", text: section }] };
    }
  • src/server.ts:49-60 (registration)
    Registration of the tool in the ListToolsRequestSchema handler, making it discoverable by clients.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        SEARCH_WIKI_MINECRAFTWIKI_TOOL,
        GET_PAGE_SUMMARY_MINECRAFTWIKI_TOOL,
        GET_SECTIONS_IN_PAGE_MINECRAFTWIKI_TOOL,
        GET_PAGE_SECTION_MINECRAFTWIKI_TOOL,
        GET_PAGE_CONTENT_MINECRAFTWIKI_TOOL,
        RESOLVE_REDIRECT_MINECRAFTWIKI_TOOL,
        LIST_CATEGORY_MEMBERS_MINECRAFTWIKI_TOOL,
        LIST_ALL_CATEGORIES_MINECRAFTWIKI_TOOL,
        GET_CATEGORIES_FOR_PAGE_MINECRAFTWIKI_TOOL,
      ],
  • Type guard function for validating input arguments matching the tool schema (title: string, sectionIndex: number).
    export function isGetPageSectionArgs(
      args: unknown
    ): args is { title: string; sectionIndex: number } {
      return (
        typeof args === "object" &&
        args !== null &&
        "title" in args &&
        typeof (args as { title: string }).title === "string" &&
        "sectionIndex" in args &&
        typeof (args as { sectionIndex: number }).sectionIndex === "number"
      );
    }
  • Helper function to sanitize wiki HTML content by removing tags, decoding escapes, and formatting for MCP compatibility, used in the handler.
    export function sanitizeWikiContent(text: string): string {
      return formatMCPText(
        // First decode any Unicode escapes
        decodeUnicodeEscapes(
          // Remove HTML tags
          text.replace(/<[^>]*>/g, " ")
        )
      );
    }

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/L3-N0X/Minecraft-Wiki-MCP'

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