Skip to main content
Glama

wikipedia-mcp-server

Get Wikipedia Article Sections

wikipedia_get_sections
Read-only

Fetch the table of contents for a Wikipedia article. Returns section titles, heading levels, section numbering (e.g. "2.1"), and section_index values. The first entry is the lead section, index 0, titled Introduction — the text above the first heading, which Wikipedia's own table of contents omits. Pass a section_index to wikipedia_get_article to retrieve just that section. Useful for enumerating article structure before doing a targeted section read. Redirect pages are followed automatically.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "title": "<title>"
    },
    "name": "wikipedia_get_sections"
  }
}

Input Schema

NameRequiredDescriptionDefault
titleYesArticle title (e.g. "Python (programming language)"). A trailing #fragment is accepted and ignored; the characters < > [ ] { } and | cannot appear in a Wikipedia page name. Special: and Media: titles, and interwiki links such as "wikt:cat", name no page.
languageNoWikipedia language edition code (default "en"). Examples: "fr", "de", "ja".en

Output Schema

NameRequiredDescriptionDefault
errorNoPresent when the call failed. Absent on success.
titleNoArticle title as resolved by Wikipedia.
noticeNoGuidance for a disambiguation page, whose sections group candidate articles.
pageidNoWikipedia page ID. Absent for stub articles.
languageNoLanguage edition queried.
sectionsNoArticle sections in document order with index values for targeted reads, led by the index-0 lead entry.
page_typeNoPresent only on a disambiguation page — one that lists the articles a title can refer to — and then "disambiguation", the value wikipedia_get_summary reports for it.
categoriesNoVisible categories the article belongs to, without the namespace prefix and with spaces for underscores. Pass one to wikipedia_search_articles as incategory:"<name>", writing any double quote in the name as \".
total_sectionsNoNumber of entries returned, counting the index-0 lead section.
redirected_fromNoOriginal alias followed to this article.
redirect_sectionNoTarget fragment of the redirect, normalized to its heading when matched.
redirect_section_indexNoUnique numeric TOC index matching the redirect anchor. Absent when no index is verified.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changed
    • changedInput schema / properties / title / description
      Previous value: -"Article title (e.g. \"Python (programming language)\"). A trailing #fragment is accepted and ignored; the characters < > [ ] { } and | cannot appear in a Wikipedia page name."New value: +"Article title (e.g. \"Python (programming language)\"). A trailing #fragment is accepted and ignored; the characters < > [ ] { } and | cannot appear in a Wikipedia page name. Special: and Media: titles, and interwiki links such as \"wikt:cat\", name no page."
    • changedOutput schema / anyOf
      Previous value: -[
      -  {
      -    "not": {
      -      "required": [
      -        "error"
      -      ]
      -    },
      -    "required": [
      -      "title",
      -      "sections",
      -      "total_sections",
      -      "language"
      -    ]
      -  },
      -  {
      -    "required": [
      -      "error"
      -    ]
      -  }
      -]New value: +[
      +  {
      +    "not": {
      +      "required": [
      +        "error"
      +      ]
      +    },
      +    "required": [
      +      "title",
      +      "sections",
      +      "total_sections",
      +      "categories",
      +      "language"
      +    ]
      +  },
      +  {
      +    "required": [
      +      "error"
      +    ]
      +  }
      +]
    • addedOutput schema / properties / categories
      Added value: +{
      +  "description": "Visible categories the article belongs to, without the namespace prefix and with spaces for underscores. Pass one to wikipedia_search_articles as incategory:\"<name>\", writing any double quote in the name as \\\".",
      +  "items": {
      +    "type": "string"
      +  },
      +  "type": "array"
      +}
    • changedOutput schema / properties / error / properties / data / properties / reason / description
      Previous value: -"Machine-readable failure mode. Declared by this tool: `not_found`: No Wikipedia article exists for the given title. `invalid_title`: The title contains characters MediaWiki cannot name a page with. `no_sections`: Article exists but has no sections (stub or very short article). `invalid_language`: The language is not a valid BCP 47 code, or names a Wikipedia edition that does not exist. Other values are possible when a failure originates below the handler."New value: +"Machine-readable failure mode. Declared by this tool: `not_found`: No Wikipedia article exists for the given title. `invalid_title`: The title can name no page: it contains characters MediaWiki forbids in a page name, is a Special: or Media: title in any edition's spelling, or is an interwiki link such as \"wikt:cat\". `no_sections`: The page exists but has no sections: a stub, a very short article, or a disambiguation page with no headings. `invalid_language`: The language is not a valid BCP 47 code, or names a Wikipedia edition that does not exist. Other values are possible when a failure originates below the handler."
    • addedOutput schema / properties / notice
      Added value: +{
      +  "description": "Guidance for a disambiguation page, whose sections group candidate articles.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / page_type
      Added value: +{
      +  "const": "disambiguation",
      +  "description": "Present only on a disambiguation page — one that lists the articles a title can refer to — and then \"disambiguation\", the value wikipedia_get_summary reports for it.",
      +  "type": "string"
      +}
  2. Changed3 schema fields changed
    • addedOutput schema / properties / redirect_section
      Added value: +{
      +  "description": "Target fragment of the redirect, normalized to its heading when matched.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / redirect_section_index
      Added value: +{
      +  "description": "Unique numeric TOC index matching the redirect anchor. Absent when no index is verified.",
      +  "maximum": 9007199254740991,
      +  "minimum": -9007199254740991,
      +  "type": "integer"
      +}
    • addedOutput schema / properties / redirected_from
      Added value: +{
      +  "description": "Original alias followed to this article.",
      +  "type": "string"
      +}
  3. Changed9 schema fields changed
    • changedInput schema / properties / title / description
      Previous value: -"Article title (e.g. \"Python (programming language)\")."New value: +"Article title (e.g. \"Python (programming language)\"). A trailing #fragment is accepted and ignored; the characters < > [ ] { } and | cannot appear in a Wikipedia page name."
    • changedOutput schema / properties / error / properties / data / properties / reason / description
      Previous value: -"Machine-readable failure mode. Declared by this tool: `not_found`: No Wikipedia article exists for the given title. `no_sections`: Article exists but has no sections (stub or very short article). `invalid_language`: The language is not a valid BCP 47 code, or names a Wikipedia edition that does not exist. Other values are possible when a failure originates below the handler."New value: +"Machine-readable failure mode. Declared by this tool: `not_found`: No Wikipedia article exists for the given title. `invalid_title`: The title contains characters MediaWiki cannot name a page with. `no_sections`: Article exists but has no sections (stub or very short article). `invalid_language`: The language is not a valid BCP 47 code, or names a Wikipedia edition that does not exist. Other values are possible when a failure originates below the handler."
    • changedOutput schema / properties / error / properties / data / properties / reason / examples
      Previous value: -[
      -  "not_found",
      -  "no_sections",
      -  "invalid_language"
      -]New value: +[
      +  "not_found",
      +  "invalid_title",
      +  "no_sections",
      +  "invalid_language"
      +]
    • changedOutput schema / properties / sections / description
      Previous value: -"Ordered list of article sections with index values for targeted reads."New value: +"Article sections in document order with index values for targeted reads, led by the index-0 lead entry."
    • changedOutput schema / properties / sections / items / properties / index / description
      Previous value: -"Section index — pass to wikipedia_get_article as section_index."New value: +"Section index — pass to wikipedia_get_article as section_index. 0 is the lead section."
    • changedOutput schema / properties / sections / items / properties / level / description
      Previous value: -"Heading depth: 2 = ==, 3 = ===, etc."New value: +"Heading depth: 2 = ==, 3 = ===, etc. The lead section reports 1."
    • changedOutput schema / properties / sections / items / properties / number / description
      Previous value: -"Section number (e.g. \"2.1\") for hierarchical navigation."New value: +"Section number (e.g. \"2.1\") for hierarchical navigation; \"0\" for the lead section."
    • changedOutput schema / properties / sections / items / properties / title / description
      Previous value: -"Section heading text."New value: +"Section heading text; \"Introduction\" for the lead, which has no heading."
    • changedOutput schema / properties / total_sections / description
      Previous value: -"Total number of sections in the article."New value: +"Number of entries returned, counting the index-0 lead section."
  4. First observed

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnlyHint and openWorldHint, so the description's job is to add operational context, and it does: redirect pages are followed automatically, and the lead section is surfaced at index 0 even though Wikipedia's own TOC omits it. It does not cover failure modes (missing page, disambiguation pages), which keeps it below a 5.

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

Conciseness4/5

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

Front-loaded with the purpose and four tight sentences, each adding new information about returns, the lead-section quirk, the handoff, and redirects. The enumeration of return fields overlaps with the existing output schema, which is minor redundancy rather than padding.

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

Completeness5/5

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

For a two-parameter read tool with an output schema, annotations, and full schema coverage, the description supplies everything else an agent needs: what comes back, the index-0 convention, redirect behavior, and the downstream call to make. Nothing material is missing.

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?

Schema coverage is 100%, with title and language fully documented including fragment handling and invalid characters, so the schema carries the parameter burden. The description adds no parameter-level detail beyond mentioning section_index as an output/handoff value for another tool; baseline 3 applies.

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?

Opens with a specific verb and resource ("Fetch the table of contents for a Wikipedia article") and immediately scopes it against the sibling read tool by describing the structure-enumeration role. An agent can distinguish this from wikipedia_get_article, get_summary, or get_references without opening any schema.

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

Usage Guidelines4/5

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

Gives a concrete workflow: "Useful for enumerating article structure before doing a targeted section read," and names the follow-up call ("Pass a section_index to wikipedia_get_article"). It lacks an explicit exclusion such as when to prefer wikipedia_get_summary for a quick overview, so it stops just short of full when/when-not guidance.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.