Skip to content

feat(mcp): add GHOST_URL_LOCK env var to lock the OAuth login form#4

Open
titouanmathis wants to merge 1 commit into
mainfrom
feat/ghost-url-lock
Open

feat(mcp): add GHOST_URL_LOCK env var to lock the OAuth login form#4
titouanmathis wants to merge 1 commit into
mainfrom
feat/ghost-url-lock

Conversation

@titouanmathis
Copy link
Copy Markdown
Contributor

Summary

Implements #3.

When GHOST_URL_LOCK is set, the OAuth /authorize login form:

  1. Pre-fills the Ghost site URL field with the locked value.
  2. Renders that field as readonly so the user cannot change it.
  3. Shows a lock notice (🔒) explaining the server is restricted to a specific Ghost instance.

The lock is also enforced server-side on POST /authorize: if GHOST_URL_LOCK is set, the submitted ghostUrl is silently replaced with the env value, preventing bypass via crafted requests.

Example

GHOST_URL_LOCK=https://conversion.ghost.io \
OAUTH_SECRET=$(openssl rand -hex 32) \
npx ghost-mcp-server

Changes

File Change
packages/mcp/src/flags.ts Add parseGhostUrlLock()
packages/mcp/src/oauth.ts Pass lock to renderLoginForm; enforce server-side on POST
packages/mcp/src/server.ts Log the locked URL at startup; add env var to header comment
packages/mcp/src/oauth.test.ts 7 new tests for GET and POST /authorize in locked/unlocked states
packages/mcp/README.md Document GHOST_URL_LOCK in the env table and admin mode section
CHANGELOG.md Add 0.1.3 entry

Test plan

npm test  # 92 tests pass
npm run check  # 0 errors (1 pre-existing warning in auth.test.ts)

🤖 Generated with Claude Code

… a specific Ghost URL

When GHOST_URL_LOCK is set:
- The /authorize form pre-fills the Ghost site URL field with the
  locked value and marks it as readonly, so users only need to supply
  their Staff Access Token.
- A lock notice (🔒) is shown explaining the server is restricted to
  a specific Ghost instance.
- POST /authorize enforces the lock server-side: the submitted
  ghostUrl is silently replaced with the lock value, preventing bypass
  via crafted requests.
- The startup log mentions the locked URL when the server starts in
  admin mode.

Adds parseGhostUrlLock() to flags.ts following the same convention as
the other flag helpers. Tests cover GET and POST /authorize in both
locked and unlocked states.

Closes #3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant