Confluence Reader
Read and interact with Confluence Cloud pages by running scripts/confluence.py.
Prerequisites
These environment variables must be set:
- •
CONFLUENCE_TOKEN— Scoped API token - •
CONFLUENCE_EMAIL— Email tied to the Atlassian account - •
CONFLUENCE_CLOUD_IDorCONFLUENCE_BASE_URL— one is required
If any are missing, prompt the user to set them before proceeding.
Commands
All commands are run via:
bash
python scripts/confluence.py <command> [args...]
Fetch a page as markdown
bash
python scripts/confluence.py fetch-page "<confluence-page-url>"
Returns the page content as markdown with child pages listed at the bottom.
List child pages
bash
python scripts/confluence.py list-children "<confluence-page-url>"
Returns titles and IDs of direct child pages without fetching content.
Download an image attachment
bash
python scripts/confluence.py fetch-image "<confluence-page-url>" "<filename>" "<destination-dir>"
Downloads the named attachment and saves it to the destination directory.
Compare local content with a Confluence page
bash
python scripts/confluence.py compare "<confluence-page-url>" "<local-markdown-or-filepath>"
The last argument can be a file path or a raw markdown string. Returns a JSON object with additions, deletions, totalChanges, and the full unified diff.
Supported URL formats
- •
/wiki/spaces/SPACEKEY/pages/123456789/Page+Title - •
/wiki/pages/viewpage.action?pageId=123456789
Workflow: Recursively reading a page tree
- •Run
fetch-pageon the root URL. - •Note the child pages listed at the bottom.
- •Run
fetch-pagefor each child. - •Repeat until all desired pages are fetched.
Workflow: Syncing local docs
- •Read the local markdown file.
- •Run
comparewith the Confluence URL and the local file path. - •If
totalChanges > 0, present the diff to the user.
Edge cases
- •Empty pages return an empty markdown body — normal for container pages.
- •If an attachment filename doesn't match, the script prints available attachments.
- •401/403 errors mean invalid or under-permissioned credentials.