This project provides an intelligent Slack bot with enhanced agent capabilities powered by modular LLM providers (Gemini, OpenAI, Claude) and MCP (Model Control Protocol) tools. The bot uses LangChain's agent framework for better reasoning, problem-solving, and tool usage through an HTTP-based MCP server architecture.
graph TD
User["Slack User"] <-->|Messages| Slack["Slack Platform"]
Slack <-->|Events API / Webhooks| Bot["BNFR Bot (FastAPI)"]
subgraph "BNFR Bot Service"
Bot
LangChainAgent["🤖 Modular LangChain Agent<br/>(Advanced Reasoning + Tool Calling)"]
MCPClient["MCP Client"]
Bot <--> LangChainAgent
LangChainAgent <--> MCPClient
end
LangChainAgent <-->|LangChain Framework| LLMProviders["🔄 LLM Providers (Configurable)<br/>• Google Gemini<br/>• OpenAI<br/>• Anthropic Claude<br/>• Local LLMs (Ollama/Docker)"]
MCPClient <-->|HTTP JSON-RPC| MCPServer["BNFR MCP Server"]
subgraph "BNFR MCP Server Service"
MCPServer
Tools["Tools Registry"]
SearchTool["search_knowledge_base<br/>(vector search)"]
MCPServer --> Tools
Tools --> JokeTools["Joke Tools"]
Tools --> TimeTools["Time Tools"]
Tools --> SearchTool
SearchTool --> VectorDB["ChromaDB Vector Store"]
end
GitHubRepo["GitHub Repositories"] -.->|Indexed Content| VectorDB
-
bnfrmcp/- MCP server with HTTP streaming support- Joke tools (get random programming jokes)
- GitHub ingestion: clone repositories, extract text files (.md, .py, .tf, Dockerfile, etc.) and index them in ChromaDB
- Time zone tools (London, New York)
- Runs on
http://127.0.0.1:8000/bnfr/mcp
-
bnfrbot/- FastAPI-based Slack bot with Modular LangChain Agent- 🤖 Modular LLM Support: Choose between Gemini, OpenAI, or Anthropic by changing one config variable
- LangChain Agent Mode: Advanced reasoning with tool calling capabilities
- Multiple Providers: Gemini 2.5-flash-lite, OpenAI GPT-4o-mini, Claude 3.5 Haiku, or Local LLMs (Ollama/Docker)
- LangChain Integration: Leverages LangChain's agent framework for better tool orchestration
- Smart Tool Usage: Systematically analyzes problems and chooses appropriate tools
- MCP Integration: Automatically discovers and uses MCP tools through LangChain
- Persistent Chat History: Per-user conversation memory with LangChain memory management
- Agent Executor: Built-in retry logic and error handling
- Runs on
http://0.0.0.0:3000
cd bnfrmcp
pip install -r requirements.txt
python server.py --host 127.0.0.1 --port 8000The server will be available at http://127.0.0.1:8000/bnfr/mcp
cd bnfrbot
pip install -r requirements.txt
# Copy and configure environment variables
cp .env.example .env
# Edit .env with your actual valuesEdit bnfrbot/.env with your credentials:
# Slack Configuration
SLACK_SIGNING_SECRET=your_slack_signing_secret
SLACK_BOT_TOKEN=xoxb-your-bot-token
VERIFICATION_TOKEN=your_verification_token
# LLM Provider Configuration (Choose one: gemini | openai | anthropic | local)
LLM_PROVIDER=gemini
# Provider-specific API Keys (configure the one you're using)
GEMINI_API_KEY=your_gemini_api_key # For Gemini
OPENAI_API_KEY=your_openai_api_key # For OpenAI
ANTHROPIC_API_KEY=your_anthropic_api_key # For Claude
# Local LLM Configuration
LOCAL_LLM_BASE_URL=http://localhost:11434/v1
LOCAL_LLM_MODEL=llama3.2:latest
# MCP Server
MCP_SERVER_URL=http://127.0.0.1:8000/bnfr/mcpTo switch LLM providers: Simply change LLM_PROVIDER to gemini, openai, anthropic, or local and ensure the corresponding configuration is set.
Local LLM Examples:
- Ollama:
LOCAL_LLM_BASE_URL=http://localhost:11434/v1with models likellama3.2:latest,mistral:latest - LM Studio:
LOCAL_LLM_BASE_URL=http://localhost:1234/v1with your loaded model - Docker:
LOCAL_LLM_BASE_URL=http://localhost:12434/v1with your container setup
cd bnfrbot
python app.pyThe bot will be available at http://0.0.0.0:3000
For containerized deployment, use Docker Compose:
-
Configure environment:
cp .env.example .env # Edit .env with your actual credentials -
Build and run:
docker-compose up --build
-
Services will be available at:
- MCP Server:
http://localhost:8000/bnfr/mcp - Slack Bot:
http://localhost:3000
- MCP Server:
- Main endpoint:
http://127.0.0.1:8000/bnfr/mcp - Available tools:
Joke Tools|Time Tools|search_knowledge_base
- Slack events:
http://localhost:3000/slack/events - Health check:
http://localhost:3000/health - Refresh tools:
http://localhost:3000/refresh-tools - Interactions:
http://localhost:3000/interactions
The bot now operates in agent mode with enhanced capabilities:
- Direct Messages: Send a direct message to the bot for private conversations
- App Mentions: Mention
@BotNamein channels for public interactions - Tool Queries: Ask about available tools:
"show me the mcp tools you have" - Complex Questions: The agent breaks down complex problems systematically
- Reasoning Display: The bot shows its thinking process for better transparency
"show me the mcp tools you have"- Lists available tools with explanations"what time is it in London?"- Uses time tools intelligently"search for docker configurations"- Searches knowledge base with context"tell me a programming joke"- Uses appropriate tools for entertainment"analyze this project's CI/CD setup"- Combines multiple tools for comprehensive analysis
- 🤖 Agent thinking... - Shows when the agent is processing
- 🤖 Agent Response: - Indicates agent-generated responses with reasoning
- Systematic approach - Breaks down complex queries into steps
- Tool explanation - Explains why specific tools are chosen
- Multiple LLM Providers: Choose between Gemini, OpenAI, or Claude with one config change
- Advanced Reasoning: LangChain-powered agent with systematic problem analysis
- Tool Calling Framework: Automatic tool selection and execution with retry logic
- Conversation Memory: Persistent per-user chat history with LangChain memory management
- Provider Flexibility: Easy switching between different AI models and providers
- Graceful Fallback: Works even if advanced agent features aren't available
- Error Resilience: Built-in error handling and recovery mechanisms
- HTTP Streaming: MCP server uses FastAPI with HTTP streaming transport
- Tool Discovery: Bot automatically discovers MCP tools at startup
- LangChain Integration: Uses LangChain's agent framework for better orchestration
- Health Monitoring: Health check endpoints for both services
- Tool Refresh: Admin endpoint to refresh MCP tools without restart
- Clean Architecture: Simplified codebase with only essential components
The knowledge base indexes GitHub repositories into a single semantic index stored in a local ChromaDB instance. Key points:
- Ingestion:
bnfrmcp/github_ingest.pyclones repositories and extracts text content from supported files. The ingestion pipeline is orchestrated bybnfrmcp/ingest_data.py. - Supported file types:
.md,.txt,.py,.js,.ts,.html,.css,.json,.yaml,.yml,.sh,Dockerfile,.tf,.hcl,.tfvars(add more ingithub_ingest.pyif needed). - Storage & embeddings: Documents are stored in ChromaDB (
chroma_data/). Embeddings useembedding_functions.DefaultEmbeddingFunction()(sentence-transformers) and run locally — this avoids external LLM embedding API usage and helps stay within API quotas. - Search: Use the MCP tool
search_knowledge_baseto query the index. The tool returns matching documents and metadata (repo, filepath, filename, source).
Quick re-index example (rebuild local vector DB):
cd bnfrmcp
# remove prior index
rm -rf chroma_data
# ingest GitHub repos listed in ingest_data.py
python ingest_data.pyTo add a GitHub repository for indexing, edit repo_urls in bnfrmcp/ingest_data.py and re-run the ingestion command above.
# Terminal 1: MCP Server
cd bnfrmcp
python server.py
# Terminal 2: Slack Bot
cd bnfrbot
python app.py
# Terminal 3: ngrok
ngrok http 3000Use the ngrok URL for your Slack app's event subscriptions.
# Start services in detached mode
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down
# Rebuild after code changes
docker-compose up --buildBNFR55-http-new/
├── bnfrmcp/ # MCP Server
│ ├── server.py # FastAPI + FastMCP setup
│ ├── main.py # Server runner
│ ├── requirements.txt # Python dependencies
│ └── tools/ # MCP tools
│
├── bnfrbot/ # Slack Bot with Modular LangChain Agent
│ ├── app.py # Main FastAPI application
│ ├── config.py # Environment configuration (modular LLM providers)
│ ├── mcp_client.py # HTTP MCP client
│ ├── modular_agent.py # 🤖 Modular LangChain Agent (Gemini/OpenAI/Claude)
│ ├── requirements.txt # Python dependencies (LangChain + multiple providers)
│ ├── .env.example # Environment template with LLM provider options
│ └── tools/ # Local tools (minimal)
│
└── README.md # This file
- Host:
127.0.0.1(configurable via--host) - Port:
8000(configurable via--port) - Mount path:
/bnfr/mcp
- Host:
0.0.0.0 - Port:
3000 - Agent Mode: LangChain-powered Modular Agent with advanced reasoning
- LLM Providers:
- Gemini:
gemini-2.5-flash-lite(default) - OpenAI:
gpt-4o-mini - Anthropic:
claude-3-5-haiku-20241022 - Local LLMs: Ollama, LM Studio, Docker containers
- Gemini:
- Framework: LangChain + AgentExecutor
- Modularity: Switch providers by changing
LLM_PROVIDERin config - Tools: MCP tools integrated through LangChain
- Conversation history: 100 users max, 10 messages per user
- MCP tool cache: Refreshed on startup and via admin endpoint
- Agent Thinking: Visible reasoning process (
🤖 Agent thinking...) - Step-by-step Analysis: Breaks down complex problems systematically
- Intelligent Tool Usage: Chooses tools based on context and need
- Better Responses: More structured and informative answers
- Conversation Flow: Maintains context better across interactions
| Feature | Before (Basic) | Now (Agent Mode) |
|---|---|---|
| Thinking Process | Hidden | 🤖 Agent thinking... |
| Responses | Simple | 🤖 Agent Response: with reasoning |
| Tool Usage | Basic | Intelligent selection with explanation |
| Problem Solving | Direct | Step-by-step analysis |
| Context Awareness | Limited | Enhanced conversation memory |
- Modular LangChain Agent: Streamlined architecture with configurable LLM providers
- Default: Google Gemini 2.5-flash-lite
- Alternatives: OpenAI GPT-4o-mini, Anthropic Claude 3.5 Haiku
- Easy Switching: Change
LLM_PROVIDERin config to switch providers - LangChain AgentExecutor for tool orchestration
- ChatMessageHistory for conversation memory
- Graceful fallback if advanced features unavailable
- MCP tool integration through LangChain framework