cwiki_list_pages
Retrieve a paginated list of pages from the Apache Incubator Confluence space, with an option to force refresh the cache.
Instructions
List pages in the configured Apache Incubator Confluence space.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| start | No | ||
| force_refresh | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/incubator_cwiki_mcp/tools.py:24-46 (handler)The main handler function for the cwiki_list_pages tool. It is decorated with @mcp.tool(), validates limit/start parameters, calls client.confluence_get to fetch the Confluence API listing, and returns pagination metadata plus page summaries.
@mcp.tool() def cwiki_list_pages(limit: int = 25, start: int = 0, force_refresh: bool = False) -> dict[str, Any]: """List pages in the configured Apache Incubator Confluence space.""" validate_range("limit", limit, 1, 100) validate_range("start", start, 0, 1_000_000) pages = client.confluence_get( "/rest/api/content", { "spaceKey": client.SPACE_KEY, "type": "page", "status": "current", "limit": str(limit), "start": str(start), "expand": "version", }, force_refresh=force_refresh, ) return { **client.pagination(pages), "pages": [client.page_summary(page) for page in pages.get("results", [])], } - The confluence_get helper called by cwiki_list_pages; handles caching (read/write) and delegates to confluence_request for the actual HTTP call.
def confluence_get( path: str, query: dict[str, str] | None = None, *, force_refresh: bool = False, ) -> dict[str, Any]: suffix = "" if query: suffix = "?" + urllib.parse.urlencode(query) request_path = f"{path}{suffix}" if not force_refresh: cached = cache.read_cache(request_path, BASE_URL, SPACE_KEY) if cached is not None: return cached response = confluence_request(request_path) cache.write_cache(request_path, response, BASE_URL, SPACE_KEY) return response - The page_summary helper used to transform each Confluence page result into a minimal summary dict (id, title, status, version, updated, updatedBy, url).
def page_summary(page: dict[str, Any]) -> dict[str, Any]: version = page.get("version", {}) history = page.get("history", {}) last_updated = history.get("lastUpdated", {}) links = page.get("_links", {}) return { "id": page.get("id"), "title": page.get("title"), "status": page.get("status"), "version": version.get("number"), "updated": version.get("when") or last_updated.get("when"), "updatedBy": version.get("by", {}).get("displayName") or last_updated.get("by", {}).get("displayName"), "url": f"{BASE_URL}{links['webui']}" if links.get("webui") else None, } - The pagination helper that extracts pagination fields (start, limit, size, hasNext, next) from the Confluence API response.
def pagination(result: dict[str, Any]) -> dict[str, Any]: links = result.get("_links", {}) return { "start": result.get("start", 0), "limit": result.get("limit"), "size": result.get("size", len(result.get("results", []))), "hasNext": bool(links.get("next")), "next": f"{BASE_URL}{links['next']}" if links.get("next") else None, } - The validate_range helper used by cwiki_list_pages to enforce limit (1-100) and start (0-1,000,000) bounds.
def validate_range(name: str, value: int, minimum: int, maximum: int) -> None: if value < minimum or value > maximum: raise ValueError(f"{name} must be between {minimum} and {maximum}")