Skip to main content
Glama

brain-trust

by bernierllc
README.mdโ€ข12.1 kB
# brain-trust - AI-Powered Q&A and Plan Review MCP Server ๐Ÿง  **Your trusted brain trust for getting AI help with questions and plan reviews.** A simple, powerful FastMCP server with just 3 tools that connect Cursor to OpenAI for intelligent question answering and plan analysis. --- ## ๐ŸŽฏ What is brain-trust? brain-trust is a Model Context Protocol (MCP) server that gives your AI agents direct access to OpenAI for: - **Asking questions** with optional context - **Reviewing planning documents** with multiple analysis depths - **Getting expert answers** tailored to your specific situation Think of it as **phoning a friend** (OpenAI) when you need help! --- ## โœจ The 3 Simple Tools ### 1. ๐Ÿ“ž `phone_a_friend` Ask OpenAI any question, with optional context for better answers. ```python # Simple question phone_a_friend("What is Docker?") # Context-aware question phone_a_friend( question="Should we use microservices?", context="Team of 5 engineers, launching MVP in 3 months" ) ``` ### 2. ๐Ÿ“‹ `review_plan` Get AI-powered feedback on planning documents with structured analysis. **Review Levels:** - `quick` - Basic structure and completeness check - `standard` - Detailed analysis with suggestions - `comprehensive` - Deep analysis with alternatives - `expert` - Professional-level review with best practices ```python review_plan( plan_content="# Q4 2025 Roadmap\n...", review_level="comprehensive", context="Startup with $500K budget, need to launch in 6 months", focus_areas=["timeline", "resources", "risks"] ) ``` **Returns:** - Overall score (0.0-1.0) - Strengths (list) - Weaknesses (list) - Suggestions (list) - Detailed feedback (text) ### 3. โค๏ธ `health_check` Check server status and configuration. ```python health_check() # Returns: {status, timestamp, plan_reviews_count} ``` --- ## ๐Ÿš€ Quick Start ### Prerequisites - Python 3.12+ - OpenAI API key - Docker (optional, but recommended) ### Option 1: Docker (Recommended) ```bash # Clone the repository git clone <repository-url> cd mcp-ask-questions # Start the server (no API key needed) docker-compose up -d # Check logs docker-compose logs -f ``` The server starts immediately without requiring an OpenAI API key. Configure the API key in your MCP client (see below). ### Option 2: Local Python ```bash # Install dependencies pip install -r requirements.txt # Run the server python server.py ``` --- ## ๐Ÿ”ง Configure in Cursor ### Quick Install Button <details> <summary>Click to expand Cursor setup</summary> #### Click the button to install: [<img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Install in Cursor">](https://cursor.com/en/install-mcp?name=brain-trust&config=eyJ1cmwiOiAiaHR0cDovL2xvY2FsaG9zdDo4MDAwL21jcCIsICJ0cmFuc3BvcnQiOiAiaHR0cCIsICJlbnYiOiB7Ik9QRU5BSV9BUElfS0VZIjogInlvdXJfb3BlbmFpX2FwaV9rZXlfaGVyZSJ9fQ==) #### Or install manually: Go to `Cursor Settings` -> `MCP` -> `Add new MCP Server`. Name it "brain-trust", use HTTP transport: - **URL**: `http://localhost:8000/mcp` - **Transport**: `http` - **Environment Variables**: Add `OPENAI_API_KEY` with your OpenAI API key </details> ### Add to `~/.cursor/mcp.json` ```json { "mcpServers": { "brain-trust": { "url": "http://localhost:8000/mcp", "transport": "http", "env": { "OPENAI_API_KEY": "your_openai_api_key_here" } } } } ``` **How it works:** - The `OPENAI_API_KEY` from the MCP client configuration is automatically passed to each tool call - The server receives the API key with each request and uses it to authenticate with OpenAI - Optional: You can override the model and max_tokens per tool call **Important**: Make sure Docker is running and the server is started before using in Cursor! --- ## ๐Ÿ’ก Usage Examples ### Example 1: Quick Question Ask OpenAI directly: ``` Use phone_a_friend to ask: "What are Python best practices?" ``` ### Example 2: Context-Aware Question Get answers specific to your situation: ``` Use phone_a_friend with the question "How should we structure our tests?" and context "We use FastAPI with pytest, SQLAlchemy, and Docker" ``` ### Example 3: Plan Review Get feedback on a planning document: ``` Use review_plan to review the file plans/compare-options-tool.md with review_level "standard" ``` ### Example 4: Comprehensive Plan Analysis Get deep analysis with specific focus: ``` Use review_plan on plans/compare-options-tool.md with review_level "expert", context "Team of 2 engineers, need to build quickly", and focus_areas ["timeline", "implementation", "risks"] ``` --- ## ๐Ÿ—๏ธ Architecture ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ Cursor / AI โ”‚ โ”‚ Agent โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ MCP Protocol (HTTP) โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ brain-trust โ”‚ โ”‚ MCP Server โ”‚ โ”‚ (FastMCP) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ OpenAI API โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ OpenAI โ”‚ โ”‚ (GPT-4) โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` **Flow:** 1. Agent calls MCP tool with API key from MCP client config 2. brain-trust server receives request with API key via HTTP 3. Server creates OpenAI client with provided API key 4. Server formats prompt and calls OpenAI API 5. OpenAI returns AI-generated response 6. Server returns structured response to agent --- ## ๐Ÿณ Docker Setup The server runs in Docker with: - **FastMCP Server**: Python 3.12, running on port 8000 - **Nginx**: Reverse proxy for HTTP requests - **Health Checks**: Every 30 seconds - **Non-root User**: Security best practice ```bash # Start services docker-compose up -d # View logs docker-compose logs -f # Check status curl http://localhost:8000/health # Stop services docker-compose down ``` --- ## ๐Ÿ› ๏ธ Configuration ### Environment Variables The server requires minimal configuration. Create a `.env` file if needed: ```bash # Server Configuration LOG_LEVEL=INFO # Default: INFO PORT=8000 # Default: 8000 ``` **Note:** OpenAI API key is **NOT** required as an environment variable. The API key is passed directly from the MCP client with each tool call. ### MCP Client Configuration (Required) Configure your OpenAI API key in the MCP client settings (e.g., Cursor's `~/.cursor/mcp.json`): ```json { "mcpServers": { "brain-trust": { "url": "http://localhost:8000/mcp", "transport": "http", "env": { "OPENAI_API_KEY": "your_actual_api_key_here" } } } } ``` **How it works:** 1. You configure the API key in your MCP client 2. The MCP client automatically passes the key to tool calls 3. The server uses the key to authenticate with OpenAI per-request 4. No API key storage on the server side **Benefits:** - โœ… No API keys in Docker containers or environment files - โœ… Secure key management via MCP client - โœ… Different clients can use different API keys - โœ… Per-request authentication --- ## ๐Ÿ“Š API Endpoints When running locally: - **MCP Endpoint**: `http://localhost:8000/mcp` - **Health Check**: `http://localhost:8000/health` Test the health endpoint: ```bash curl http://localhost:8000/health # Returns: {"status":"healthy","timestamp":"...","plan_reviews_count":0} ``` --- ## ๐Ÿงช Testing Test that the server is working: ```bash # Check health curl http://localhost:8000/health # In Cursor, try: # "Use phone_a_friend to ask: What is FastMCP?" ``` --- ## ๐Ÿ“ Project Structure ``` mcp-ask-questions/ โ”œโ”€โ”€ server.py # Main MCP server with 3 tools โ”œโ”€โ”€ Dockerfile # Container definition โ”œโ”€โ”€ docker-compose.yml # Multi-container orchestration โ”œโ”€โ”€ nginx.conf # Reverse proxy config โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ pyproject.toml # Project configuration โ”œโ”€โ”€ fastmcp.json # FastMCP deployment config โ”œโ”€โ”€ .env.example # Environment variables template โ”œโ”€โ”€ README.md # This file โ”œโ”€โ”€ FINAL_TOOLS.md # Detailed tool documentation โ”œโ”€โ”€ SIMPLIFIED_TOOLS.md # Simplification notes โ””โ”€โ”€ plans/ # Planning documents โ”œโ”€โ”€ contextual-qa-mcp-server.md โ”œโ”€โ”€ technical-implementation.md โ”œโ”€โ”€ quick-start-guide.md โ””โ”€โ”€ compare-options-tool.md ``` --- ## ๐Ÿ”’ Security - โœ… **No API keys in Docker** - API keys are passed per-request from MCP client - โœ… **No environment file secrets** - No `.env` file with API keys required - โœ… **Per-request authentication** - Each request uses client-provided credentials - โœ… **Non-root Docker user** - Runs as `mcpuser` in container - โœ… **Input validation** - Pydantic models validate all inputs - โœ… **Error handling** - Comprehensive error handling and logging - โœ… **Client-side key management** - Keys managed securely by MCP client --- ## ๐Ÿ› Troubleshooting ### Server won't start ```bash # Check if port 8000 is in use lsof -i:8000 # View Docker logs docker-compose logs -f ``` ### Cursor can't connect 1. Verify server is running: `curl http://localhost:8000/health` 2. Check MCP config in `~/.cursor/mcp.json` 3. Restart Cursor after config changes 4. Ensure `OPENAI_API_KEY` is set in MCP client config ### OpenAI API errors 1. Verify API key is correct and active in `~/.cursor/mcp.json` 2. Check OpenAI account has credits 3. Ensure API key has proper permissions 4. View logs: `docker-compose logs -f` ### "API key required" errors The API key must be configured in your **MCP client** (not in Docker): 1. Open `~/.cursor/mcp.json` 2. Add `OPENAI_API_KEY` to the `env` section 3. Restart Cursor 4. The API key is automatically passed with each tool call ### Tools not showing in Cursor 1. Restart Docker: `docker-compose restart` 2. Restart Cursor completely 3. Check MCP settings are correct --- ## ๐Ÿšฆ Development ### Local Development ```bash # Install dependencies pip install -r requirements.txt # Run server locally (no API key needed for startup) python server.py # Server runs on http://localhost:8000 ``` **Note:** The server starts without requiring an OpenAI API key. The API key is provided by the MCP client when calling tools. ### Making Changes 1. Edit `server.py` for tool changes 2. Rebuild Docker: `docker-compose up -d --build` 3. Restart Cursor to pick up changes ### Adding New Tools See `plans/compare-options-tool.md` for an example of how to propose and plan new tools. --- ## ๐Ÿ“š Documentation - **FINAL_TOOLS.md** - Complete tool documentation with examples - **SIMPLIFIED_TOOLS.md** - Notes on simplification from original design - **PARAMETER_DESCRIPTIONS_ADDED.md** - Parameter documentation details - **plans/** - Detailed planning documents and proposals --- ## ๐ŸŽฏ Why brain-trust? ### Simple - Only 3 tools to learn - Direct, straightforward usage - No complex context management ### Powerful - Full OpenAI GPT-4 capabilities - Context-aware answers - Multiple review levels ### Practical - Solves real problems (questions, plan reviews) - Easy to integrate with Cursor - Production-ready with Docker ### Extensible - Easy to add new tools - Clean, maintainable codebase - Well-documented for contributions --- ## ๐Ÿค Contributing We welcome contributions! To add a new tool: 1. Create a plan in `plans/your-tool-name.md` 2. Implement the tool in `server.py` 3. Add tests and documentation 4. Submit a pull request See `plans/compare-options-tool.md` for an example plan. --- ## ๐Ÿ“„ License MIT License - see LICENSE file for details --- ## ๐Ÿ™ Acknowledgments - Built with [FastMCP](https://github.com/jlowin/fastmcp) - Inspired by the Model Context Protocol specification - Uses OpenAI's GPT-4 for intelligent responses --- **Questions? Issues? Feedback?** Open an issue or reach out! We're here to help. ๐Ÿง โœจ

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bernierllc/brain-trust-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server