GitBook MCP Proxy
Enables AI assistants to access and query GitBook documentation through a local MCP proxy. It handles OAuth-style JWT authentication, stores credentials securely, and forwards MCP requests to the configured GitBook MCP endpoint so users can search and interact with their GitBook docs.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
GitBook MCP Proxy
OAuth-style authentication proxy for GitBook MCP with custom JWT authentication and secure credential storage.
A local proxy server that enables AI assistants (Cursor, Claude Desktop, etc.) to access your GitBook documentation via MCP (Model Context Protocol) with custom JWT authentication from your backend.
Features
✨ Dual Transport Support - HTTP server mode or stdio transport for MCP ✨ Auto Port Selection - Automatically finds available port if default is in use ✨ MCP-Compliant Credential Storage - Encrypted at rest using AES-256-GCM ✨ Platform-Specific Application Support - Follows MCP ecosystem standards ✨ OAuth-Style Authentication - Secure browser-based authorization flow ✨ Token Persistence - Survives restarts with encrypted storage ✨ Auto-Open Browser - Automatically opens authorization URL ✨ Automatic Redirect Following - Handles HTTP 3xx redirects ✨ Multi-Method Authentication - Sends JWT as query param and cookie ✨ LaunchDarkly Integration - Forwards feature flags for adaptive content ✨ Detailed Logging - Request tracing, auth context, security info
Related MCP server: AKIMCP
How It Works
┌─────────────────────────────────────────────────────────┐
│ 1. Start proxy → generates session ID │
│ 2. Browser opens → authenticate with your backend │
│ 3. Backend generates JWT → redirects to localhost │
│ 4. Proxy encrypts & stores credentials (MCP compliant) │
│ 5. AI makes MCP request → proxy adds JWT + forwards │
│ 6. GitBook validates JWT → returns documentation │
└─────────────────────────────────────────────────────────┘Prerequisites
Node.js 16+
A backend that can generate GitBook JWT tokens
GitBook space with custom authentication enabled
Installation
npm installConfiguration
Create a .env file (or set environment variables):
# Required: Your authentication backend URL
BACKEND_AUTH_URL=https://your-backend.com
# Required: Your GitBook MCP endpoint
GITBOOK_MCP_URL=https://your-docs.gitbook.io/~gitbook/mcp
# Optional: Proxy port (default: 3333)
MCP_PROXY_PORT=3333See .env.example for a template.
Backend Requirements
Your backend must implement an authorization endpoint that:
Authenticates the user (via session cookie or other method)
Generates a GitBook JWT token with claims like:
{ "iat": 1738478400, "exp": 1739083200, "user_context_id": "user-123", "organization_context_id": "org-456" }Redirects to callback with token and optional LaunchDarkly cookie:
http://localhost:3333/callback?token=JWT&expires=UNIX_TIMESTAMP&ld_cookie={...}
Query parameters received from proxy:
session- Unique session ID for loggingcallback- Localhost callback URL (must validate this is localhost!)
Example authorization endpoint:
public function gitbookMcpAuthorize() {
// 1. Check authentication
if (!authenticated()) {
redirectToLogin();
}
// 2. Validate callback is localhost
$callback = $_GET['callback'];
if (!isLocalhost($callback)) {
halt(400, "Callback must be localhost");
}
// 3. Generate JWT
$jwt = generateGitbookJWT($user, $org);
$expires = time() + 604800; // 1 week
// 4. Get LaunchDarkly flags (optional)
$ldFlags = getLaunchDarklyFlags($user);
// 5. Redirect to callback
redirect($callback . "?token=$jwt&expires=$expires&ld_cookie=" . urlencode($ldFlags));
}Transport Modes
The proxy supports two transport modes. GitBook's MCP server uses HTTP with Server-Sent Events (SSE) transport, which both modes now support.
HTTP Transport (Default)
HTTP transport runs a local HTTP server that MCP clients can connect to.
npm start
# or
node index.jsThe proxy will automatically find an available port starting from 3333. If port 3333 is in use, it will try 3334, 3335, etc.
Configuration for HTTP mode:
{
"mcpServers": {
"your-gitbook": {
"url": "http://localhost:3333"
}
}
}Stdio Transport
Stdio transport uses stdin/stdout for JSON-RPC communication. This is the native MCP protocol.
node index.js --stdioStdio Configuration Options
There are two ways to configure environment variables for stdio mode:
Option 1: Using env field in config (Recommended)
Pass environment variables directly in the MCP configuration:
{
"mcpServers": {
"your-gitbook": {
"command": "node",
"args": ["/path/to/gitbook-mcp-proxy/index.js", "--stdio"],
"env": {
"BACKEND_AUTH_URL": "https://your-backend.com",
"GITBOOK_MCP_URL": "https://your-docs.gitbook.io/~gitbook/mcp",
"MCP_PROXY_PORT": "3333"
}
}
}
}Option 2: Using a shell wrapper script
A wrapper script start-proxy.sh is included:
#!/bin/bash
export BACKEND_AUTH_URL="${BACKEND_AUTH_URL:-https://your-backend.com}"
export GITBOOK_MCP_URL="${GITBOOK_MCP_URL:-https://your-docs.gitbook.io/~gitbook/mcp}"
export MCP_PROXY_PORT="${MCP_PROXY_PORT:-3333}"
exec node "$SCRIPT_DIR/index.js" --stdioEdit the script with your values, then configure:
{
"mcpServers": {
"your-gitbook": {
"command": "/path/to/gitbook-mcp-proxy/start-proxy.sh"
}
}
}Stdio Mode Behavior
In stdio mode, the proxy acts as a JSON-RPC to HTTP/SSE bridge:
Receives JSON-RPC from stdin (MCP protocol)
Forwards to GitBook via HTTP POST with JWT authentication
Parses SSE response from GitBook (extracts JSON from
data:lines)Returns JSON-RPC to stdout
Technical details:
JSON-RPC messages are read from stdin (one per line)
JSON-RPC responses are written to stdout (one per line)
Automatically parses Server-Sent Events (SSE) format from GitBook
All logs and diagnostics go to stderr (keeps stdout clean)
A temporary HTTP server starts only for OAuth callbacks
No port conflicts since there's no permanent HTTP server
Same authentication and credential storage as HTTP mode
Note: Stdio mode works for most MCP operations but may have limitations with streaming operations since it converts persistent SSE connections into discrete request/response cycles.
Usage
1. Start the Proxy
npm startYou'll see output with an authorization URL:
========================================
GitBook MCP Proxy
========================================
✓ Proxy server running
• Local endpoint: http://localhost:3333
• Target: https://your-docs.gitbook.io/~gitbook/mcp
🔐 AUTHORIZATION REQUIRED:
https://your-backend.com/api/gitbook/mcp-authorize?session=abc123...
Opening browser automatically...2. Authorize in Browser
Browser opens automatically (or copy the URL)
Log into your backend if needed
Backend generates JWT and redirects back
Proxy encrypts and saves credentials
You'll see "Authorization Successful"
3. Configure Your AI Assistant
Cursor
Open Cursor settings: ⌘ + Shift + P → "MCP: Configure"
{
"mcpServers": {
"your-gitbook": {
"url": "http://localhost:3333"
}
}
}Claude Desktop
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"your-gitbook": {
"url": "http://localhost:3333"
}
}
}4. Use It!
Ask your AI assistant questions like:
"What does the documentation say about feature flags?"
"Search the docs for authentication examples"
"Show me the API reference"
Credential Storage (MCP Spec)
Following the Model Context Protocol specification for secure credential storage:
Storage Locations (Platform-Specific)
macOS:
~/Library/Application Support/gitbook-mcp-proxy/credentials.jsonLinux:
~/.config/gitbook-mcp-proxy/credentials.jsonWindows:
%APPDATA%/gitbook-mcp-proxy/credentials.json
Encryption
Algorithm: AES-256-GCM (authenticated encryption)
Key Storage: Machine-specific key in
.keyfilePermissions: 0600 (owner read/write only)
Tamper Detection: GCM auth tag ensures integrity
Security Properties
✅ Credentials encrypted at rest
✅ Machine-specific encryption key
✅ Automatic cleanup of expired tokens
✅ Platform-specific Application Support directories
✅ Restrictive file permissions
Security
✅ MCP-compliant credential storage - Follows Model Context Protocol security spec ✅ Encrypted at rest - AES-256-GCM authenticated encryption ✅ No credentials in env vars - OAuth-style browser authorization ✅ Localhost callbacks only - Backend must validate callback URL ✅ Token expiration - Tokens expire automatically ✅ HTTPS only - All GitBook communication over HTTPS ✅ JWT signature verification - GitBook validates token cryptographically ✅ Restrictive file permissions - 0600 on all credential files
API Endpoints
Endpoint | Method | Purpose |
| GET | OAuth callback (receives token from backend) |
| GET | Health check and authentication status |
| * | MCP proxy (forwards all other requests to GitBook) |
Health Check
curl http://localhost:3333/healthResponse:
{
"status": "ok",
"authenticated": true,
"expires": "2026-02-10T12:00:00.000Z"
}Troubleshooting
"BACKEND_AUTH_URL not set"
Set the BACKEND_AUTH_URL environment variable to your authentication backend.
Authorization Timeout
The proxy waits 30 seconds for authorization. Complete the browser flow within that time, or the MCP request will timeout.
Token Expired
Tokens expire based on your backend's configuration (typically 1 week). When expired:
Browser will auto-open to re-authorize
Or manually open the authorization URL shown in console
Port Already in Use
The proxy automatically finds an available port starting from 3333. If port 3333 is in use, it will try 3334, 3335, etc.
You can also:
# Set a specific preferred port
export MCP_PROXY_PORT=3334
npm start
# Or use stdio mode (no permanent HTTP server)
node index.js --stdioCorrupted Credentials
If credentials become corrupted, the proxy will automatically delete them and prompt for re-authorization.
Environment Variables
Variable | Required | Default | Description |
| Yes |
| Your authentication backend URL |
| Yes |
| Your GitBook MCP endpoint |
| No |
| Local proxy port |
Development
# Install dependencies
npm install
# Run in development
npm start
# Run health check
npm run healthArchitecture
The proxy acts as a bridge between AI assistants and GitBook:
Authentication Layer: OAuth-style browser flow with your backend
Credential Storage: MCP-compliant encrypted storage
Request Forwarding: Adds JWT authentication to GitBook requests
Cookie Management: Forwards JWT + LaunchDarkly feature flags
Redirect Handling: Automatically follows HTTP 3xx redirects
Related Resources
License
MIT License - see LICENSE file for details
Contributing
Contributions welcome! Please open an issue or PR.
Author
Created by Forrest Middleton
Support
If you encounter issues:
Check the Troubleshooting section
Review logs in the console
Open an issue on GitHub
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Zero-setup MCP gateway securely connecting AI to your tools with authentication and workflows
Official Fibery MCP server: query and update your workspace from any AI client via OAuth.
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Remote streamable-HTTP MCP server running on a single Cloudflare Worker. Your assistant gets live Airbnb, Amazon, Booking.com, Google Flights, Maps and Reddit data, social search on X, Instagram and TikTok, the Meta Ad Library, and image/video generation without any keys. Connect your own accounts to let it send WhatsApp or Telegram messages, work an IMAP inbox, manage Meta Ads campaigns and publish to X and LinkedIn. OAuth 2.1 with PKCE; stored credentials are AES-256-GCM encrypted.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceGives web-based AI chat clients a governed, OAuth-gated operating surface over a single MCP endpoint, letting them read and edit files, run whitelisted shell commands, search, inspect Git and SQLite, drive browsers and DevTools, manage background jobs, and reach localhost services on your own machine.MIT
- AlicenseNot gradedqualityAmaintenanceExposes a governed suite of 38 tools over a single OAuth-gated MCP endpoint, letting web-based AI chat clients read and edit local files, run whitelisted shell commands, search, use Git, inspect SQLite databases, and drive browser, DevTools, clipboard, and background-task workflows. It requires no system-wide install or admin rights and restricts access to folders and commands approved from a local control panel.MIT
- AlicenseNot gradedqualityAmaintenanceConnects web AI chats and local clients to your own machine through one OAuth-gated MCP endpoint, exposing 38 governed tools for files, shell commands, search, Git, SQLite, browser automation, DevTools, background tasks, localhost services, clipboard, notifications, ports, and Postman control. It lets assistants build and edit projects, inspect databases and local APIs, drive browser workflows, and manage long-running jobs without handing every client unrestricted shell access.MIT
- AlicenseNot gradedqualityAmaintenanceEnables web-based AI chat clients to securely operate a local computer through an OAuth-gated MCP endpoint, exposing governed tools for files, shell, search, Git, SQLite, browser automation, DevTools, background tasks, localhost services, clipboard, notifications, ports, Postman, and AIObox windows.MIT