feat: Add comprehensive Pages API support with session authentication
Summary
This PR adds complete Pages API support to the Plane MCP server with session-based authentication.
What's New
Pages Tools (18 total)
- Core CRUD: list_pages, get_page, create_page, update_page, delete_page
- Lifecycle Management: archive_page, unarchive_page, lock_page, unlock_page
- Organization: favorite_page, unfavorite_page, duplicate_page, set_page_access, get_pages_summary
- Content Management: get_page_description, update_page_description
- Version History: get_page_versions, get_page_version
Authentication Tools
plane_login: Email/password authentication with session cookiesplane_auth_status: Check current authentication stateplane_logout: Clear session
Technical Implementation
Dual Authentication System
- Session authentication for
/api/endpoints (Pages) - API key authentication for
/api/v1/endpoints (Projects, Issues, etc.)
Session Management
- Form-based authentication with CSRF token handling
- Cookie jar persistence using
tough-cookieandaxios-cookiejar-support - Cookies persist across MCP tool invocations
Path Routing
- Automatic API prefix detection (
/api/vs/api/v1/) - Regex-based endpoint pattern matching for accurate routing
Testing
All functionality tested and verified:
- β Session authentication flow
- β All 18 page operations
- β Backward compatibility with existing API key endpoints
- β Cookie persistence across tool calls
Dependencies Added
axios-cookiejar-support: ^6.0.4tough-cookie: ^5.1.2
Files Changed
src/common/auth.ts- Session authentication implementationsrc/common/request-helper.ts- Dual authentication routingsrc/tools/auth.ts- Authentication MCP toolssrc/tools/pages.ts- Complete Pages API toolspackage.json- Added dependencies
[!NOTE] Adds session (cookie) auth and a full Pages toolset, with request routing between /api (session) and /api/v1 (API key), plus debug logging and new Page schema.
- Pages support (session-auth /api):
- Tools:
list_page(s),get_page,create_page,update_page,delete_page,archive_page,unarchive_page,lock_page,unlock_page,favorite_page,unfavorite_page,duplicate_page,set_page_access,get_pages_summary,get_page_description,update_page_description,get_page_versions,get_page_version.- Registered via
registerPageToolsinsrc/tools/index.ts.- Authentication tools:
plane_login(email/password with CSRF + cookies),plane_auth_status,plane_logoutinsrc/tools/auth.ts.- Request routing:
makePlaneRequestnow auto-selects prefix and auth:/api+ session for Pages,/api/v1+ API key for others; adds sanitized debug logging.- Session auth implementation:
src/common/auth.ts: Axios with cookie jar, CSRF retrieval, session verification, expiry handling, reset.src/common/debug.ts: optional file+stderr debug logging.- Schemas:
- New
Pageschema insrc/schemas.ts.- Dependencies:
- Add
axios-cookiejar-support,tough-cookie(and related transitive entries).Written by Cursor Bugbot for commit 8a396c676015f5511aef3f002edc6055b46e7669. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
-
New Features
- Email/password login, logout, cookie-import, and auth-status tools
- Full suite of page management tools (list/get/create/update/delete, access, archive/unarchive, lock/unlock, favorite/unfavorite, duplicate, description/version operations)
- New Page data shape for richer page metadata
-
Improvements
- Session-aware request routing with CSRF handling and clearer sanitized error reporting
- Optional runtime debug logging to a temp log when enabled
-
Chores
- Added cookie-jar support dependencies for session-based requests
-
Documentation
- Expanded README and new setup guide covering Pages auth and usage
βοΈ Tip: You can customize this high-level summary in your review settings.
[!NOTE]
Other AI code review bot(s) detected
CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.
π Walkthrough
Walkthrough
Adds session-based cookie-jar authentication with CSRF handling, dynamic routing between session (/api/) and API-key (/api/v1/) endpoints, a new Page Zod schema/type, MCP tools for authentication and page management, debug logging, and two runtime cookie dependencies.
Changes
| Cohort / File(s) | Summary |
|---|---|
Dependencies package.json |
Added runtime dependencies axios-cookiejar-support and tough-cookie. |
Authentication core src/common/auth.ts |
New module: cookie-jar-enabled Axios instance, getAxiosInstance(), authenticateWithPassword(email,password,hostUrl): Promise<AuthResult>, isSessionAuthenticated(), resetAuthentication(), importCookies(cookiesJson,hostUrl), CSRF fetch/submission flow, 1-hour session timeout, and debug logging. |
Request helper src/common/request-helper.ts |
New makePlaneRequest<T>(...) routing: pages endpoints β /api/ (session + CSRF), others β /api/v1/ (API key). Enforces session auth for pages endpoints, inspects cookie jar for csrf, sets headers/body, emits detailed debug/sanitized error logs. |
Schema additions src/schemas.ts |
Added exported Zod Page schema and corresponding exported Page TypeScript type. |
Auth tools & wiring src/tools/auth.ts, src/tools/index.ts |
New registerAuthTools(server) registering plane_login, plane_import_cookies, plane_auth_status, plane_logout; registerTools now imports and calls registerAuthTools (and registerPageTools). |
Page tools src/tools/pages.ts |
New registerPageTools(server) registering numerous page-management tools (list/get/create/update/delete, access control, archive/unarchive, lock/unlock, favorite/unfavorite, duplicate, description and versions) using makePlaneRequest; enforces PLANE_WORKSPACE_SLUG. |
Debug logging src/common/debug.ts |
New debugLog(message: string): Promise<void> that appends timestamped messages to a temp log file when PLANE_MCP_DEBUG is enabled and echoes to stderr. |
Docs README.md, SETUP_GUIDE.md |
Added Pages (session auth) documentation and a setup guide describing env vars, auth flows, examples, and troubleshooting. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant MCP as MCP Server
participant Auth as auth.ts
participant Req as request-helper.ts
participant Axios as Axios+CookieJar
participant Plane as Plane API
User->>MCP: plane_login(email,password)
MCP->>Auth: authenticateWithPassword(email,password,host)
Auth->>Axios: getAxiosInstance()
Auth->>Plane: GET /auth/get-csrf-token/
Plane-->>Axios: csrftoken cookie
Auth->>Plane: POST /auth/sign-in/ (form + X-CSRFToken)
Plane-->>Axios: session cookies
Auth-->>MCP: AuthResult (success/error)
User->>MCP: invoke page tool (e.g., list_pages)
MCP->>Req: makePlaneRequest(method, path, body)
Req->>Auth: isSessionAuthenticated()
Auth-->>Req: true
Req->>Axios: request with cookie-jar (+ X-CSRFToken if non-GET)
Axios->>Plane: GET/POST /api/.../pages
Plane-->>Req: response
Req-->>MCP: formatted content block
User->>MCP: plane_logout
MCP->>Auth: resetAuthentication()
Auth-->>MCP: cleared session
Estimated code review effort
π― 4 (Complex) | β±οΈ ~45 minutes
Poem
π I found a jar and kept it warm,
I chased the CSRF through cookie storm,
I logged each hop and hid the keys,
Pages danced across the trees,
Session snug β the server's calm and warm.
π₯ Pre-merge checks | β 3
β Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title accurately summarizes the main objective of the pull request: adding Pages API support with session authentication, which are the core features introduced across multiple new files and modifications. |
| Docstring Coverage | β Passed | Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
β¨ Finishing touches
- [ ] π Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
I tried this and received an error:
No Session cookies received from server.
does it work?
does it work?
It did work for me, however it is a impossible mission to satisfy these two AI reviewer bots. I used it with AI, so i can keep track of work what Claude has done so far.
In any case, i will publish now some updates on this and the newest working version. Please stay tuned i will post some screenshots as proof, if i i manage to make video it will be posted as well. . @mattyx97 @Nicholas-Schaub thank you for asking for this.
I ended up just creating my own fork.
Less than ideal, but it works.
Thanks for working on this.
@Nicholas-Schaub do you have it public?
This can closed now, right? You moved all code to python so this changes won't be ever merged
@mattyx97 It is currently private for a personal project. Not a commercial application.
@jzakirov I think it would still be good to have this built into the MCP. It is very helpful from a documentation/context point of view.
I did not look at the most recent set of updates, but I thought the contributions were still in JS/TS. Last I saw there was no Python integrated.
Why even bother yourself, this repo doesn't accept open source contribution just look at PR's from the past
@koke1997 I ended up writing my own plane-cli that wraps python SDK. In my experience CLI is easier for model to understand and use compared to MCP. But there is still no page update / delete endpoint in API, waiting for Plane team to respond...
@mattyx97 - may be this will help - https://github.com/Drezzler/plane-mcp-server