OpenSearch Agent Server for OpenSearch Dashboards — multi-agent orchestrator with page-context routing
Project description
OpenSearch Agent Server
A multi-agent orchestration server for OpenSearch Dashboards with context-aware routing and Model Context Protocol (MCP) integration.
Overview
OpenSearch Agent Server enables intelligent agent-based interactions within OpenSearch Dashboards by:
- Multi-Agent Orchestration — Routes requests to specialized agents based on context
- OpenSearch Integration — Connects to OpenSearch via MCP for real-time data access
- AG-UI Protocol — Implements OpenSearch Dashboard's agent UI protocol with SSE streaming
- Flexible LLM Support — Works with AWS Bedrock, Ollama, or other LLM providers
- Production Ready — Includes authentication, rate limiting, error recovery, and observability
Architecture
OpenSearch Dashboards (AG-UI)
↓
OpenSearch Agent Server
├── Router (context-based)
├── Agent Registry
│ ├── ART Agent (strands-agents)
│ └── Fallback Agent
└── OpenSearch MCP Server
↓
OpenSearch Cluster
Features
- Context-Aware Routing — Automatically selects the appropriate agent based on request context
- Streaming Responses — Real-time SSE streaming for interactive user experiences
- Tool Execution — Agents can execute tools and visualize results in the dashboard
- Authentication & Authorization — JWT-based auth with configurable policies
- Rate Limiting — Protects backend services from overload
- Error Recovery — Automatic retry with exponential backoff
- Observability — Structured logging with request tracking
Prerequisites
- Python 3.10+
- OpenSearch 2.x (local or remote cluster)
- LLM Provider (choose one):
- AWS Bedrock (requires AWS credentials)
- Ollama (local installation)
Installation
-
Clone the repository
git clone https://github.com/mingshl/opensearch-agent-server.git cd opensearch-agent-server
-
Create virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
pip install -e .
-
Configure environment
cp .env.example .env # Edit .env with your configuration
Configuration
Create a .env file with the following settings:
# OpenSearch Connection
OPENSEARCH_URL=https://localhost:9200
OPENSEARCH_USERNAME=admin
OPENSEARCH_PASSWORD=admin
# Authentication (set to false for local development)
AG_UI_AUTH_ENABLED=false
# CORS (allow OpenSearch Dashboards origin)
AG_UI_CORS_ORIGINS=http://localhost:5601
# LLM Provider — Option 1: AWS Bedrock
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
BEDROCK_INFERENCE_PROFILE_ARN=arn:aws:bedrock:...
# LLM Provider — Option 2: Ollama (local)
OLLAMA_MODEL=llama3
# Logging
AG_UI_LOG_FORMAT=human
AG_UI_LOG_LEVEL=INFO
Quick Start
Complete Setup (3-Component Stack)
To run the full demo with OpenSearch, Agent Server, and Dashboards:
Terminal 1 - OpenSearch
# Start OpenSearch on port 9200
docker run -d -p 9200:9200 -p 9600:9600 \
-e "discovery.type=single-node" \
-e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=Admin1234!" \
opensearchproject/opensearch:latest
# Verify
curl http://localhost:9200 -u admin:Admin1234!
Terminal 2 - Agent Server
# Configure and start opensearch agent server
cd opensearch-agent-server
cp .env.example .env
# Edit .env with your settings
source .venv/bin/activate
python run_server.py
# Server starts on http://localhost:8001
Terminal 3 - OpenSearch Dashboards
# Start dashboard (requires Node.js 22+)
cd OpenSearch-Dashboards
# Ensure config/opensearch_dashboards.yml has chat.agUiUrl configured
yarn start --no-base-path
# Dashboard opens on http://localhost:5601
Access the Chat
- Open http://localhost:5601
- Click the chat icon (💬) in the top-right header
- Start asking questions about your data!
Usage
Start the Server
python run_server.py
Or using uvicorn directly:
uvicorn server.ag_ui_app:app --host 0.0.0.0 --port 8001
The server will start on http://localhost:8001
Verify Installation
# Check server health
curl http://localhost:8001/health
# List available agents
curl http://localhost:8001/agents
# Test agent interaction (requires OpenSearch running)
curl -X POST http://localhost:8001/runs \
-H "Content-Type: application/json" \
-d '{
"input": "Show me recent logs",
"context": [{"appId": "discover"}]
}'
Integration with OpenSearch Dashboards
-
Start OpenSearch (port 9200)
# Using Docker docker run -d -p 9200:9200 -p 9600:9600 \ -e "discovery.type=single-node" \ -e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=Admin1234!" \ opensearchproject/opensearch:latest # Or use your local OpenSearch installation
-
Start OpenSearch Agent Server (port 8001)
cd opensearch-agent-server source .venv/bin/activate python run_server.py
-
Configure OpenSearch Dashboards
Edit
config/opensearch_dashboards.yml:# OpenSearch connection opensearch.hosts: ["http://localhost:9200"] opensearch.ssl.verificationMode: none # Enable new UI header (required for chat button) uiSettings: overrides: "home:useNewHomePage": true # Enable context provider (sends page context to agent) contextProvider: enabled: true # Enable chat with opensearch agent server chat: enabled: true agUiUrl: "http://localhost:8001/runs"
-
Start OpenSearch Dashboards (port 5601)
cd OpenSearch-Dashboards yarn start --no-base-path
-
Access the Chat Interface
- Open http://localhost:5601 in your browser
- Look for the chat icon in the top-right header
- Click to open the assistant panel
- Start chatting with your data!
Development
Install Development Dependencies
pip install -e ".[dev]"
Run Tests
pytest
Code Formatting
ruff format .
ruff check .
Project Structure
opensearch-agent-server/
├── src/
│ ├── agents/ # Agent implementations
│ │ ├── art_agent.py # Main agent using strands-agents
│ │ └── fallback_agent.py # Fallback for errors
│ ├── orchestrator/ # Routing and registry
│ │ ├── router.py # Context-based routing
│ │ └── registry.py # Agent registry
│ ├── server/ # FastAPI application
│ │ ├── ag_ui_app.py # Main FastAPI app
│ │ ├── run_routes.py # AG-UI protocol endpoints
│ │ ├── config.py # Configuration management
│ │ └── ... # Middleware, auth, etc.
│ └── utils/ # Utilities
│ └── mcp_connection.py # OpenSearch MCP client
├── tests/ # Test suite
├── run_server.py # Entry point
├── pyproject.toml # Project metadata
└── .env.example # Environment template
API Endpoints
Health Check
GET /health
Returns server health status.
List Agents
GET /agents
Returns available agents and their capabilities.
Create Run (AG-UI Protocol)
POST /runs
Creates a new agent run with streaming responses via SSE.
Get Run Status
GET /runs/{run_id}
Returns the status of a specific run.
Troubleshooting
OpenSearch Connection Issues
- Verify OpenSearch is running:
curl http://localhost:9200 - Check credentials in
.env - Disable SSL verification for local development
LLM Provider Issues
- AWS Bedrock: Ensure AWS credentials are configured
- Ollama: Verify Ollama is running:
ollama list
Port Conflicts
If port 8001 is in use, modify the startup command:
uvicorn server.ag_ui_app:app --host 0.0.0.0 --port 8002
Contributing
Contributions are welcome! Please:
- 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
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Acknowledgments
- Built with strands-agents for multi-agent orchestration
- Implements AG-UI Protocol for OpenSearch Dashboards
- Uses Model Context Protocol (MCP) for OpenSearch integration
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opensearch_agent_server-0.1.0.tar.gz.
File metadata
- Download URL: opensearch_agent_server-0.1.0.tar.gz
- Upload date:
- Size: 308.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
947f588ce9ec0e728aef73a1fbe91eacfc5ab29f519080dc9ea843dada88f668
|
|
| MD5 |
3e4cade5059860e7aa2bc32abaca54eb
|
|
| BLAKE2b-256 |
48a9148e7fee8a518a0a32ab128c0a2c8efc388579e8f556c32eb19df7526031
|
File details
Details for the file opensearch_agent_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: opensearch_agent_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fbd95fdbb14e0a9e02a8d7d8f8c50cc12e69666104dbb6a78d02f77c1755ecc
|
|
| MD5 |
6e6fa2d0b5a0978d4a1d4bf7e4fd7322
|
|
| BLAKE2b-256 |
d4beee8f0a52419530a327491c8664b1793574cd77082253ef5700fe84d1d2f3
|