A modern web application for chatting with AI providers while leveraging Model Context Protocol (MCP) servers to extend AI capabilities with external tools and data sources.
MCPConsole is a Next.js 15 + React 19 TypeScript application that provides:
- Multi-Provider AI Chat: Connect to various AI providers (Google Gemini, OpenAI, Anthropic Claude, etc.) and chat with their models
- MCP Server Integration: Add and manage MCP servers to extend AI capabilities with external tools, APIs, and data sources
- OAuth2 Authentication: Secure OAuth2 flows for MCP servers requiring authentication, with automatic token refresh
- Persistent Configuration: All settings, chat history, and OAuth tokens persist in localStorage and sync across browser tabs
- Modern UI: Clean, responsive interface built with Tailwind CSS, Radix UI, and shadcn-style components
- Add multiple AI providers with custom API keys and endpoints
- Support for various API types: OpenAI-compatible, Google, Anthropic, Ollama
- Configure multiple models per provider
- Easy switching between providers and models during chat
- Add HTTP, SSE, and HTTP-direct MCP servers
- OAuth2 authentication with PKCE flow
- Automatic token refresh and persistence
- Connection status monitoring
- Server-side connection management with fallback strategies
- Real-time streaming responses
- Markdown rendering with syntax highlighting
- Tool call execution from connected MCP servers
- Chat history persistence
- Settings and configurations sync across browser tabs in real-time
- OAuth tokens persist and restore automatically on page reload
- Consistent state management across multiple windows
- Framework: Next.js 15 (App Router)
- UI: React 19, TypeScript
- Styling: Tailwind CSS, Radix UI, lucide-react icons
- Forms: react-hook-form, zod validation
- MCP SDK: @modelcontextprotocol/sdk
- State: React Context with localStorage persistence
- Deployment: Firebase App Hosting (configurable)
- Node.js 20+ (or Bun)
- npm, pnpm, or bun package manager
- Clone the repository:
git clone <repository-url>
cd mcpconsole- Install dependencies:
npm install
# or
pnpm install
# or
bun install- Set up environment variables (optional):
Create a .env.local file in the root directory:
# Application URL (used for OAuth callbacks)
NEXT_PUBLIC_APP_URL=http://localhost:9002
# Optional: Firebase configuration
FIREBASE_API_KEY=your_api_key
FIREBASE_AUTH_DOMAIN=your_auth_domain
FIREBASE_PROJECT_ID=your_project_idnpm run dev
# or
pnpm dev
# or
bun devOpen http://localhost:9002 in your browser.
npm run build
npm start- Navigate to Settings > Providers
- Click Add Provider
- Fill in:
- Name (e.g., "My OpenAI")
- API Key
- API Type (OpenAI Compatible, Google, Anthropic, etc.)
- Base URL (optional, for custom endpoints)
- Models (comma-separated list of model IDs)
-
Navigate to Settings > MCP Servers
-
Click Add Server
-
Fill in:
- Name (e.g., "GitHub MCP")
- Type (HTTP, SSE, or HTTP-direct)
- URL (MCP server endpoint)
- OAuth2 Configuration (if required):
- Client ID
- Client Secret (optional)
- Authorization URL
- Token URL
- Scope
-
If OAuth is required, click Authorize to complete the OAuth flow in a popup window
MCPConsole implements a secure OAuth2 PKCE (Proof Key for Code Exchange) flow:
- Authorization Request: User clicks "Authorize" on an MCP server
- Popup Window: Authorization URL opens in a new popup window
- User Authentication: User logs in and grants permissions on the provider's site
- Callback: Provider redirects to the callback URL with an authorization code
- Token Exchange: Code is exchanged for access and refresh tokens
- Token Storage: Tokens are stored in:
- localStorage (for persistence across reloads)
- Auto-Close: Popup window posts message to main window and closes automatically
- Connection: Server automatically connects using the access token
- Access tokens are automatically refreshed when expired
- Refresh tokens are persisted in localStorage
- Tokens sync across browser tabs via storage events
Standard HTTP transport for stateless MCP servers. Each request is independent.
Bidirectional streaming transport for real-time MCP servers. Falls back to HTTP if SSE fails.
Direct HTTP transport without the MCP coordinator, for servers that implement their own stateless protocol.
- TypeScript strict mode enabled
- Feature-based organization with barrel exports
- Component co-location (components, hooks, services, types per feature)
- Tailwind CSS for styling with shadcn-style components
- AppContext (
src/shared/context/app-context.tsx): Global state management for providers, servers, chat history, and OAuth tokens - MCPCoordinator (
src/features/mcp-servers/services/coordinator.ts): Server-side MCP connection coordination - useLocalStorage (
src/shared/hooks/use-local-storage.ts): Persistent state with cross-tab sync
npm run dev # Start development server (port 9002)
npm run build # Build for production
npm start # Start production server
npm run lint # Run ESLint
npm run typecheck # Run TypeScript type checking- Check Environment: Ensure
NEXT_PUBLIC_APP_URLmatches your actual URL - Popup Blocked: Some browsers block popups; allow popups for this site
- Redirect URI: Ensure the redirect URI in your OAuth app matches:
${APP_URL}/api/mcp/oauth-callback - CORS: MCP server must allow your origin for OAuth flows
- Check URL: Verify the MCP server URL is correct and accessible
- OAuth Required: If server returns 401, configure OAuth2 settings
- Network: Check browser console for network errors
- Type: Try different transport types (HTTP/SSE/HTTP-direct)
- localStorage: Ensure browser allows localStorage
- Private Mode: Tokens won't persist in incognito/private mode
- Clear Storage: Check if localStorage is being cleared by extensions
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Built with Next.js
- UI components based on shadcn/ui
- MCP integration via @modelcontextprotocol/sdk
- Icons from Lucide
Developed by Heygeeks.in