Skip to content

get_wiki_page: pageName should accept title or auto-convert to sub_url slug #5

Description

@Lcstyle

Problem

get_wiki_page returns 404 for wiki pages when the caller passes the page title (as displayed in list_wiki_pages output) instead of the sub_url slug.

Steps to reproduce

  1. Create a wiki page with title architecture/signal-processing-strategies
  2. Call list_wiki_pages — returns the page with title: "architecture/signal-processing-strategies" and sub_url: "architecture%2Fsignal-processing-strategies.-"
  3. Call get_wiki_page(pageName="architecture/signal-processing-strategies")404
  4. Call get_wiki_page(pageName="architecture%2Fsignal-processing-strategies.-")200 OK

Root cause

In tools/client_wiki.go, MyGetWikiPage constructs the URL as:

endpoint := fmt.Sprintf("/api/v1/repos/%s/%s/wiki/page/%s", owner, repo, pageName)

The pageName is passed through verbatim — no URL encoding, no slug transformation. But the Gitea API expects the sub_url slug at this endpoint, not the display title.

Impact

This makes get_wiki_page effectively unusable in MCP client workflows where the agent:

  1. Lists pages via list_wiki_pages
  2. Sees a title like architecture/foo
  3. Naturally passes that title to get_wiki_page
  4. Gets a 404

The agent has no way to know it needs the sub_url format unless it parses the raw API response (which the MCP tool abstracts away).

Suggested fixes (either would work)

Option A: Accept title, convert to slug internally

  • In get_wiki_page, convert the input pageName to a slug using Gitea's NameToSubURL logic (URL-encode slashes, handle space↔hyphen conversion)
  • This is the most user-friendly approach

Option B: Expose sub_url in list output and document the requirement

  • When list_wiki_pages renders its markdown output, include the sub_url for each page
  • Document that get_wiki_page requires sub_url, not title
  • Less ideal since it requires the caller to always list first

Option C: Try both

  • First try the pageName as-is
  • If 404, URL-encode slashes and retry
  • Graceful fallback

Environment

  • Gitea 1.25.4
  • forgejo-mcp v0.0.7
  • MCP client: Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions