Enables AI agents to interact with OpenAI's language models through their API, supporting conversation history, model switching, and extended reasoning capabilities for compatible models.
Polybrain MCP Server
An MCP (Model Context Protocol) server for connecting AI agents to multiple LLM models. Supports conversation history, model switching, and seamless Claude Code integration.
Features
Multi-model support (OpenAI, OpenRouter, custom endpoints)
Conversation history management
Switch models mid-conversation
Extended thinking/reasoning support (configurable by provider)
Pure MCP protocol (silent by default)
Automatic server management
Installation
Quick Setup
1. Configure Models
Option A: YAML (recommended)
Create ~/.polybrain.yaml:
Set env vars:
Option B: Environment variables
2. Add to Claude Code
Open Claude Code settings → MCP Servers, add:
Done! You can now use:
chat- Talk to any configured modellist_models- See available modelsconversation_history- Access past conversations
Configuration Reference
Environment Variables
POLYBRAIN_BASE_URL- LLM API base URLPOLYBRAIN_API_KEY- API keyPOLYBRAIN_MODEL_NAME- Model namePOLYBRAIN_HTTP_PORT- Server port (default: 32701)POLYBRAIN_LOG_LEVEL- Log level (default: info)POLYBRAIN_DEBUG- Enable debug logging to stderrPOLYBRAIN_CONFIG_PATH- Custom config file path
YAML Config Fields
Supported Providers
The provider field enables provider-specific features like extended thinking/reasoning. If not specified, reasoning parameters will not be passed to the API (safe default).
Provider | Reasoning Support | Valid Values |
OpenAI | YES |
|
OpenRouter | VARIES |
|
Examples:
Use
provider: "openai"for OpenAI API models (GPT-4, o-series)Use
provider: "openrouter"for OpenRouter proxy service (supports 400+ models)Omit
providerfield if your endpoint doesn't support reasoning parameters
Example with reasoning:
To use reasoning, set reasoning: true in the chat tool call. If the model and provider support it, you'll receive both the response and reasoning content.
Development
Setup
Build
Lint & Format
Type Check
Development Mode
Project Structure
How It Works
Launcher checks if HTTP server is running
Starts server in background if needed
Connects to Claude Code via stdio MCP
Routes requests to HTTP backend
Maintains conversation history
Responds with MCP protocol messages
Debugging
Enable debug logs to stderr:
Restart Server
After changing configuration in ~/.polybrain.yaml, restart the HTTP backend server:
This kills the background HTTP server. The next time you use polybrain, it will automatically start a fresh server with the updated configuration.
License
MIT
This server cannot be installed