Skip to content

[Bug]: confluence_get_page_history / get_page_diff always fail under OAuth (v2 version objects have no "id") #1373

@Code-by-AB

Description

@Code-by-AB

Prerequisites

  • Searched the existing issues; this has not been reported.
  • Checked the README.

Bug Description

confluence_get_page_history and confluence_get_page_diff fail for every page and every version number (including the current one) when the server uses OAuth 2.0 with granular scopes, raising Version {n} not found for page '{id}'.

Under OAuth the call routes to ConfluenceV2Adapter.get_page_by_version() in src/mcp_atlassian/confluence/v2_adapter.py, which maps a version number to a version id:

if ver.get("number") == version:
    version_id = ver.get("id")          # always None
...
raise ValueError(f"Version {version} not found for page '{page_id}'")
url = f"{self.base_url}/api/v2/versions/{version_id}"   # not a real endpoint

But Confluence v2 version objects from GET /api/v2/pages/{id}/versions have no id field. Verified against the live API, the keys are number, message, minorEdit, authorId, createdAt, page. So ver.get("id") is always None and the lookup always raises. get_page_diff calls get_page_history for both versions, so it fails too.

Two deeper issues beyond the id bug:

  1. There is no GET /api/v2/versions/{id} endpoint.
  2. No v2 endpoint returns a historical version's body (the version endpoints are metadata-only), so even with the id lookup fixed, the OAuth/v2 path cannot return historical content.

The v1 fallback GET /rest/api/content/{id}?status=historical&version=N&expand=body.storage returns 401 "scope does not match" under granular OAuth scopes, so it is not available to OAuth apps either.

Steps to Reproduce

  1. Run the server with OAuth 2.0 + granular scopes against a Confluence Cloud site.
  2. Call confluence_get_page_history with a valid page_id and version (e.g. the page's current version number).
  3. See the error. Same for confluence_get_page_diff with any two versions.

Expected Behavior

get_page_history returns the requested version (ideally with body) and get_page_diff returns a diff. At minimum, version metadata should be retrievable under OAuth.

Actual Behavior

Error getting page history: Failed to get page '<id>' version 8: Version 8 not found for page '<id>'

Fails for every version number, including the page's current version.

mcp-atlassian Version: 0.21.1
Installation Method: From PyPI (uvx mcp-atlassian)
Operating System: Windows
Python Version: 3.13.13
Atlassian Instance Type: Confluence Cloud
Client Application: Claude Code (MCP client)

Additional Context / suggested fix

  • For history, match on number and return the version metadata from /pages/{id}/versions (this works under OAuth).
  • Returning a historical body (and therefore the diff) is not possible via v2; it requires the v1 content API, which granular-scope OAuth apps cannot call. Consider documenting that body/diff need API-token auth, and make get_page_diff fail with a clear, actionable message under OAuth instead of Version not found.
  • Buggy line is version_id = ver.get("id") in get_page_by_version (around line 822 on the v0.21.1 tag).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions