Bonsai Search MCP Server
March 11, 2025 ยท View on GitHub
A Model Context Protocol (MCP) server that provides search capabilities through Bonsai's Search cluster. This server enables Large Language Models (LLMs) like Claude to perform search queries on your indexed data.
Features
search: Execute search queries against your Bonsai elasticsearch cluster
Prerequisites
- Python 3.10 or higher
- MCP SDK 1.2.0 or higher
- Bonsai cluster credentials
- Pre-existing indexed data. (Example indexer)
Installation
-
Clone repository
-
Install dependencies
pip install -r requirements.txt
- Configure environment variables:
Create a
.envfile in your project root with the following:
INDEX_NAME=your_index_name
BONSAI_URL=your_bonsai_cluster_url
Usage
Running the Server
python server.py
Integrating with Claude for Desktop
-
Install the latest version of Claude for Desktop
-
Create or edit the Claude Desktop configuration file:
- MacOS/Linux:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- MacOS/Linux:
-
Add the server configuration:
{
"mcpServers": {
"bonsai-mcp": {
"env": {
"BONSAI_URL": "https://user:pass@your-cluster.bonsai.io",
"INDEX_NAME": "index_name"
},
"command": "python", // use absolute path to the executable
"args": [
"/absolute/path/to/server.py"
]
}
}
}
- Restart Claude for Desktop
Available Tool
- Search
- Function:
search(query: str) - Parameter: Search query string
- Returns: Formatted JSON response from Bonsai elasticsearch cluster containing search results
- Function:
Testing the server
You can test the server functionality without running the full MCP server using the included test script:
python test_server.py "your search query here"
Troubleshooting
Logs Location
- Claude Desktop MCP logs:
~/Library/Logs/Claude/mcp.log - Server-specific logs:
~/Library/Logs/Claude/mcp-server-server.log
Common Issues
-
Server not showing up in Claude:
- Verify
claude_desktop_config.jsonsyntax - Ensure paths are absolute
- Restart Claude for Desktop
- Verify
-
Search API Issues:
- Verify environment variables are properly set
- Check Bonsai cluster status
- Verify index name exists
- Check network connectivity to Bonsai cluster
Environment Variables
| Variable | Description |
|---|---|
| INDEX_NAME | The name of your Bonsai elasticsearch index |
| BONSAI_URL | The URL of your Bonsai elasticsearch cluster |