Skip to Content
MCP IntegrationAuthentication

Authentication

SharkBlock MCP uses OAuth 2.1 with PKCE to securely authenticate AI agents. This is the same standard used by major platforms like GitHub and Google.


How It Works

AI Agent SharkBlock API SharkBlock App (Privy) │ │ │ │ 1. GET /oauth/authorize │ │ │ ──────────────────────► │ │ │ │ 2. Redirect to login │ │ ◄────────────────────── │ ──────────────────────► │ │ │ │ │ 3. User signs in with Privy │ │ │ ◄────────────────────── │ │ │ 4. Auth code issued │ │ ◄────────────────────── │ │ │ 5. Redirect with code │ │ │ │ │ │ 6. POST /oauth/token │ │ │ ──────────────────────► │ │ │ │ 7. Verify PKCE │ │ ◄────────────────────── │ 8. Return JWT tokens │ │ Access + Refresh tokens │ │ │ │ │ │ 9. POST /mcp (Bearer token) │ │ │ ──────────────────────► │ │ │ ◄────────────────────── │ │ │ Tool results │ │

OAuth 2.1 Endpoints

EndpointMethodPurpose
/.well-known/oauth-protected-resourceGETDiscover authorization server
/oauth/.well-known/openid-configurationGETOpenID Connect discovery
/oauth/authorizeGETStart authorization flow
/oauth/tokenPOSTExchange code for tokens / refresh tokens
/oauth/callbackPOSTInternal — Privy token exchange

Discovery

MCP clients automatically discover auth configuration via the Protected Resource Metadata endpoint:

curl https://api.alpha.sharkblock.io/.well-known/oauth-protected-resource
{ "resource": "https://api.alpha.sharkblock.io", "authorization_servers": ["https://api.alpha.sharkblock.io"], "scopes_supported": [ "profile:read", "trade:execute", "wallet:delegate", "blockchain-data:read" ], "bearer_methods_supported": ["header"] }

Scopes

Scopes control what your AI agent can access:

ScopeAccess
profile:readView profile, notifications, preferences, affiliations
trade:executeCreate/manage strategies, open/close positions, manage wallets
wallet:delegateEnable/disable wallet delegation for automated trading
blockchain-data:readToken prices, charts, market data, wallet analysis

Your SharkBlock account’s existing permissions determine which scopes are available.


Token Lifecycle

Access Token

  • Type: JWT (Bearer)
  • Included in: Authorization: Bearer <token> header on MCP requests
  • Contains: User ID, session ID, scopes

Refresh Token

  • Purpose: Obtain new access tokens without re-authenticating
  • Usage: POST /oauth/token with grant_type=refresh_token
curl -X POST https://api.alpha.sharkblock.io/oauth/token \ -H "Content-Type: application/json" \ -d '{ "grant_type": "refresh_token", "refresh_token": "your_refresh_token" }'

Security Measures

PKCE (Proof Key for Code Exchange)

Every authorization request requires PKCE with the S256 method. This prevents authorization code interception attacks — even if someone captures the code, they can’t exchange it without the original code verifier.

Rate Limiting

All MCP requests are rate-limited per user:

ScopeLimitWindow
trade:execute30 requests1 minute
blockchain-data:read60 requests1 minute
profile:read120 requests1 minute
Global200 requests1 minute

Exceeding limits returns HTTP 429 with a resetAt timestamp.

What MCP Cannot Do

  • Access your private keys (managed by Privy)
  • Withdraw funds from your wallet
  • Change your login credentials
  • Bypass your strategy settings
  • Execute trades without delegation enabled

Revoking Access

To disconnect an AI agent:

  1. The agent’s tokens will expire naturally
  2. Do not re-authenticate when prompted
  3. For immediate revocation, log out of your SharkBlock session

Future: A dedicated token management page will allow granular control over connected agents.

Last updated on