plane-mcp-server icon indicating copy to clipboard operation
plane-mcp-server copied to clipboard

feat: Add comprehensive Pages API support with session authentication

Open koke1997 opened this issue 1 year ago β€’ 11 comments

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 cookies
  • plane_auth_status: Check current authentication state
  • plane_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-cookie and axios-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.4
  • tough-cookie: ^5.1.2

Files Changed

  • src/common/auth.ts - Session authentication implementation
  • src/common/request-helper.ts - Dual authentication routing
  • src/tools/auth.ts - Authentication MCP tools
  • src/tools/pages.ts - Complete Pages API tools
  • package.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 registerPageTools in src/tools/index.ts.
  • Authentication tools:
    • plane_login (email/password with CSRF + cookies), plane_auth_status, plane_logout in src/tools/auth.ts.
  • Request routing:
    • makePlaneRequest now 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 Page schema in src/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.

koke1997 avatar Nov 15 '25 16:11 koke1997

[!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.

❀️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Nov 15 '25 16:11 coderabbitai[bot]

I tried this and received an error: No Session cookies received from server.

Nicholas-Schaub avatar Dec 01 '25 16:12 Nicholas-Schaub

does it work?

mattyx97 avatar Jan 23 '26 13:01 mattyx97

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.

ghost avatar Jan 23 '26 13:01 ghost

I ended up just creating my own fork.

Less than ideal, but it works.

Thanks for working on this.

Nicholas-Schaub avatar Jan 23 '26 13:01 Nicholas-Schaub

@Nicholas-Schaub do you have it public?

mattyx97 avatar Jan 23 '26 13:01 mattyx97

This can closed now, right? You moved all code to python so this changes won't be ever merged

jzakirov avatar Feb 20 '26 20:02 jzakirov

@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.

Nicholas-Schaub avatar Feb 20 '26 21:02 Nicholas-Schaub

Why even bother yourself, this repo doesn't accept open source contribution just look at PR's from the past

ghost avatar Feb 22 '26 15:02 ghost

@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...

jzakirov avatar Feb 23 '26 21:02 jzakirov

@mattyx97 - may be this will help - https://github.com/Drezzler/plane-mcp-server

Drezzler avatar May 23 '26 19:05 Drezzler