Bỏ qua để đến nội dung

Claude Code

Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.

Claude Code talks to remote MCP servers natively over Streamable HTTP — so unlike Claude Desktop, you don’t need the mcp-remote bridge or Node.js. One claude mcp add command and you’re wired.

The worker accepts both auth styles on /mcp. Use OAuth unless you need a static token for a CI/headless runner.

MethodSetupAuthToken rotation
OAuth (recommended)claude mcp add/mcp → AuthenticatePer-user OAuth (PKCE)Auto, refreshed silently
Bearer token (--header)claude mcp add with --headerStatic sn_prod_*Manual revoke + recreate

The endpoint is the same as Claude Desktop’s:

https://seo-navigator-mcp.autumn-recipe-cac7.workers.dev/mcp

claude mcp add writes the server to one of three scopes — decide where it should live before running it:

ScopeFlagStored inUse it for
User--scope user~/.claude.json (global)Your own machine — available in every project. Best default for personal use.
Project--scope project.mcp.json in the repo rootA team repo — commit it so teammates get the server (each still authenticates as themselves).
Local--scope local (default)~/.claude.json, this project onlyA quick, project-private setup you don’t want to share.

Examples below use --scope user. Swap in --scope project for a shared repo.

OAuth uses Dynamic Client Registration

  • PKCE: Claude Code registers itself with the worker, walks you through an “approve this app” browser flow, and receives a short-lived token it refreshes automatically.
  1. Add the server (no credentials yet):

    Terminal window
    claude mcp add --transport http --scope user seo-navigator https://seo-navigator-mcp.autumn-recipe-cac7.workers.dev/mcp
  2. Authenticate. Either start a session and use the menu:

    Terminal window
    claude

    then inside the TUI:

    /mcp

    Select seo-navigator (it shows ! Needs authentication), press Enter, and choose Authenticate.

    Or, on Claude Code v2.1.186+, do it straight from the shell:

    Terminal window
    claude mcp login seo-navigator
  3. Your browser opens the worker’s authorize page. Sign in with a real user account — the master token won’t work here; OAuth requires a user identity. Create one at /admin/users if needed.

  4. Review the scope (mcp:full) and click Approve.

  5. Back in Claude Code the status flips to ✓ Connected.

Token lifetime: access token ~1 hour (refreshed silently), refresh token 30 days. If it sits unused past 30 days, re-run the /mcp → Authenticate flow (10 seconds).

  • In a session: /mcp → seo-navigator → Clear authentication.
  • From the shell (v2.1.186+): claude mcp logout seo-navigator.
  • Worker side: filter /admin/audit by tool=oauth_revoke.

Use this for CI/headless runners, or when you’d rather pin a static scoped token than do a browser flow.

  • A bearer token from /admin/tokens (format sn_prod_<32 hex>). See Tokens & scoping for minting and scope.
Terminal window
claude mcp add --transport http --scope user seo-navigator \
https://seo-navigator-mcp.autumn-recipe-cac7.workers.dev/mcp \
--header "Authorization: Bearer sn_prod_PASTE_TOKEN_HERE"

The whole header is one quoted argument"Authorization: Bearer <token>".

Or edit .mcp.json directly (project scope)

Section titled “Or edit .mcp.json directly (project scope)”

To check the server into a team repo, add it to .mcp.json at the repo root:

{
"mcpServers": {
"seo-navigator": {
"type": "http",
"url": "https://seo-navigator-mcp.autumn-recipe-cac7.workers.dev/mcp",
"headers": {
"Authorization": "Bearer ${SN_TOKEN}"
}
}
}
}

${SN_TOKEN} expands from the environment at connect time — so you commit the config without committing the secret. The first time Claude Code sees a project-scoped server it asks you to approve it (a security check); approve in the prompt or via /mcp.

Terminal window
claude mcp list

seo-navigator should show ✓ Connected. Then in a session ask:

List my sites.

Claude calls list_sites and prints the registry. You’re set — at least 31 tools are now available.

CommandDoes
claude mcp listAll servers + connection status
claude mcp get seo-navigatorConfig + status + errors for one server
claude mcp remove seo-navigatorRemove it (add --scope <scope> if defined in several)
/mcp (in a session)Authenticate, re-authenticate, or inspect tools
claude mcp reset-project-choicesRe-prompt approval for .mcp.json servers you previously rejected
SymptomLikely causeFix
claude mcp list shows ! Needs authenticationOAuth not completedRun /mcp → Authenticate (or claude mcp login seo-navigator)
✗ Failed to connectURL wrong or worker offlineOpen the /mcp URL in a browser to confirm the worker responds
! Connected · tools fetch failedConnected but tool list erroredclaude mcp get seo-navigator for details; re-authenticate
OAuth stuck on login screenNo user accounts on the workerMaster-admin creates one at /admin/users; OAuth won’t accept the master token
Browser opens then errors outWorker OAuth endpoints unreachableCheck …workers.dev/.well-known/oauth-protected-resource returns JSON
Bearer: tool fails with E_AUTHToken expired/revokedRecreate at /admin/tokens, re-run claude mcp add
Tool fails with E_SCOPE_DENIEDToken/user scope excludes the site or toolWiden scope in /admin/tokens or re-approve OAuth
Project server never loads.mcp.json server not approvedApprove via /mcp, or claude mcp reset-project-choices