Private package containing the CLI source code for MCP Gateway. This package orchestrates the server, API, and TUI components.
Note: This is the private source package. The public wrapper package is
@fiberplane/mcp-gateway
which handles platform-specific binary distribution.
This package contains:
- CLI Entry Point (
src/cli.ts
) - Command-line interface and argument parsing - TUI (
src/tui/
) - Terminal user interface using OpenTUI - Binary Entry (
src/binary-entry.ts
) - Compiled binary entry point - Orchestration - Coordinates server, API, and storage packages
The CLI provides both a terminal UI for interactive server management and serves a web UI for browsing captured logs.
- Bun 1.0+ - Primary runtime and package manager
- Node.js 18+ - For compatibility checks
- Familiarity with Bun workspace commands
If you only need to work on the CLI/TUI and don't need web UI hot reload:
# 1. Build web UI first (one-time or when web changes)
bun run --filter @fiberplane/mcp-gateway-web build
# 2. Run CLI in dev mode
bun run --filter @fiberplane/mcp-gateway-cli dev
This serves the pre-built web UI at http://localhost:3333/ui
.
If you need web UI hot reload during development:
# Terminal 1: Run CLI
bun run --filter @fiberplane/mcp-gateway-cli dev
# Terminal 2: Run web UI dev server
bun run --filter @fiberplane/mcp-gateway-web dev
- CLI runs on port 3333 (API + TUI)
- Vite dev server on port 5173 (Web UI with HMR)
- Access web UI at
http://localhost:5173
- API calls proxied to
http://localhost:3333/api
packages/mcp-gateway/
├── src/
│ ├── cli.ts # CLI entry point and arg parsing
│ ├── binary-entry.ts # Compiled binary entry point
│ ├── tui/ # Terminal UI components
│ │ ├── activity-log.ts
│ │ ├── command-menu.ts
│ │ ├── help-view.ts
│ │ ├── server-management.ts
│ │ └── ...
│ └── events.ts # TUI event system
├── bin/ # Development executable symlink
├── dist/ # Built files (gitignored)
├── public/ # Web UI static files (copied from web package)
├── tests/ # Integration tests
├── package.json
└── tsconfig.json
# Start with custom port
bun run dev -- --port 8080
# Custom storage directory
bun run dev -- --storage-dir /custom/path
# Run in headless mode without TUI
bun run dev -- --no-tui
# Show help
bun run dev -- --help
# Show version
bun run dev -- --version
The --no-tui
flag is useful when:
- Running in Docker containers with TTY allocated but headless mode desired
- Running as a systemd service
- Testing or CI/CD environments
- Running multiple instances where you want to manage via API/Web UI only
/
- Open command menuq
- Quit applicationESC
- Go back / Close modalv
- View Activity Logm
- Manage Serversa
- Add New Serverc
- Clear Activity Logsh
- Help & Setup Guide
The CLI serves the web UI at /ui
endpoint. There are two ways to handle this in development:
The postbuild
script in package.json
:
"postbuild": "bun run --filter @fiberplane/mcp-gateway-web build && cp -r ../web/public ./public"
This:
- Builds the web UI package (
@fiberplane/mcp-gateway-web
) - Copies the output from
packages/web/public/
topackages/cli/public/
- The CLI then serves these files at
/ui
Pre-built Mode (Option 1):
- Run web build once
- Web UI files copied to
packages/cli/public/
- CLI serves static files at
http://localhost:3333/ui
- No hot reload for web changes
Dev Server Mode (Option 2):
- Run Vite dev server separately
- Access at
http://localhost:5173
- Vite proxies
/api
calls to CLI on port 3333 - Full hot module replacement
# From monorepo root
bun run build
# Or explicitly
bun run --filter @fiberplane/mcp-gateway-cli build
This:
- Compiles TypeScript to JavaScript
- Runs
postbuild
script (builds web UI, copies files) - Outputs to
dist/
directory
# Build for current platform only
bun run build:binaries
# Build for all platforms (requires GitHub Actions)
bun run build:binaries --all
This creates platform-specific binaries:
@fiberplane/mcp-gateway-darwin-arm64
@fiberplane/mcp-gateway-darwin-x64
@fiberplane/mcp-gateway-linux-x64
@fiberplane/mcp-gateway-windows-x64
# Build all packages in dependency order
bun run build
# Build binaries
bun run build:binaries
# All tests
bun test
# CLI package only
bun run --filter @fiberplane/mcp-gateway-cli test
Use the test MCP server to validate proxy functionality:
# Terminal 1: Run test MCP server
bun run --filter test-mcp-server dev
# Terminal 2: Run CLI
bun run dev
Then add the test server in the TUI:
- Name:
test-server
- URL:
http://localhost:3000/mcp
cd packages/mcp-gateway
bun add <package-name>
# All packages
bun run typecheck
# CLI only
bun run --filter @fiberplane/mcp-gateway-cli typecheck
# From monorepo root
bun run lint
bun run format
Symptom: Web UI shows 404 at http://localhost:3333/ui
Solution:
# Build web UI
bun run --filter @fiberplane/mcp-gateway-web build
# Copy to CLI package
cp -r packages/web/public packages/cli/public
# Or run postbuild script
cd packages/cli
bun run postbuild
Symptom: Error: "EADDRINUSE: address already in use :::3333"
Solution:
# Find process using port 3333
lsof -i :3333
# Kill the process
kill -9 <PID>
# Or use a different port
bun run dev -- --port 8080
Symptom: Garbled text, overlapping elements
Solution:
- Ensure terminal supports ANSI escape codes
- Try resizing terminal window
- Check terminal emulator compatibility (iTerm2, Alacritty recommended)
Symptom: Web UI doesn't reflect recent changes
Solution:
# Hard refresh in browser (Cmd+Shift+R or Ctrl+Shift+R)
# Or rebuild web UI
bun run --filter @fiberplane/mcp-gateway-web build
cp -r packages/web/public packages/cli/public
Symptom: "Failed to connect to server" errors in TUI
Solution:
- Check server URL is correct
- Verify server is running (
curl <server-url>
) - Check server logs for errors
- Ensure no CORS issues (HTTP MCP servers)
@fiberplane/mcp-gateway-api
- REST API for querying logs@fiberplane/mcp-gateway-core
- Core business logic@fiberplane/mcp-gateway-server
- HTTP server with proxy@fiberplane/mcp-gateway-types
- Type definitions@fiberplane/mcp-gateway-web
- Web UI (dev dependency, bundled in production)@hono/node-server
- Node.js adapter for Honohono
- Web frameworkopen-tui
- Terminal UI frameworkzod
- Schema validation
Managed at monorepo root level.
- CLAUDE.md - Complete monorepo development guide
- packages/web/README.md - Web UI package documentation
- packages/api/README.md - API package documentation
- packages/server/README.md - Server package documentation
- Make changes in
src/
directory - Run in dev mode (choose Option 1 or 2 above)
- Test changes manually or with automated tests
- Type check with
bun run typecheck
- Lint with
bun run lint
- Format with
bun run format
- Commit with conventional commit message
- Create changeset if this is a release-worthy change
# Set log level
DEBUG=* bun run dev
# Or in code
logger.debug("Debug message", { context: "value" });
# View registry
cat ~/.mcp-gateway/mcp.json
# View captures
ls -la ~/.mcp-gateway/captures/
# View logs for specific server
cat ~/.mcp-gateway/captures/my-server/*.jsonl
When contributing to the CLI package:
- Follow monorepo patterns - Use workspace dependencies
- Maintain backwards compatibility - CLI is a public API
- Test with real MCP servers - Not just test servers
- Document new features - Update README and CLAUDE.md
- Add tests - For new CLI options or TUI features
MIT