Skip to main content

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

Demo

https://github.com/user-attachments/assets/d465d805-40c9-4158-8e4b-0805c675df45

Architecture

OpenSearch Dashboards (AG-UI)
            ↓
    OpenSearch Agent Server
    ├── Router (context-based)
    ├── Agent Registry
    │   ├── ART Agent (strands-agents)
    │   └── Default 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.12+
  • OpenSearch 2.x (local or remote cluster)
  • LLM Provider (choose one):
    • AWS Bedrock (requires AWS credentials)
    • Ollama (local installation)

Installation

  1. Clone the repository

    git clone https://github.com/opensearch-project/opensearch-agent-server.git
    cd opensearch-agent-server
    
  2. Create virtual environment

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  3. Install dependencies

    pip install -e .
    
  4. 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

./scripts/quickstart.sh

This clones, builds, and starts everything in one command:

  1. Clones search-relevance and OpenSearch Dashboards (with the dashboards-search-relevance plugin)
  2. Bootstraps OSD and starts OpenSearch via ./gradlew run
  3. Starts MCP Server (port 3001), OSD (port 5601), and Agent Server (port 8001)
  4. Creates a workspace with a local data source and loads demo data
  5. Runs a smoke test against all services

Prerequisites: Java 21+, Node.js 20+, Python 3.12+, uv, yarn, jq, curl

Access the Chat: Open http://localhost:5601 and click the chat icon in the header.

PyPI Installation

If you already have an OpenSearch cluster running and don't need the full quickstart setup, you can install and run the agent server directly from PyPI:

pip install opensearch-agent-server

Configure your environment:

export OPENSEARCH_URL=https://localhost:9200
export OPENSEARCH_USERNAME=admin
export OPENSEARCH_PASSWORD=admin
export AG_UI_AUTH_ENABLED=false

Start the agent server and MCP server together:

opensearch-agent-server --with-mcp

This starts both the OpenSearch MCP Server (port 3001) and the Agent Server (port 8001) in a single process. Both stop together on Ctrl+C.

# Verify
curl http://localhost:8001/health    # {"status": "ok"}
curl http://localhost:8001/agents    # list registered agents

You can also customize the MCP server port and config:

opensearch-agent-server --with-mcp --mcp-port 3002 --mcp-config ./custom_mcp.yml

Manual Setup

To run each component separately:

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

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

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

  1. 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
    
  2. Start OpenSearch Agent Server (port 8001)

    cd opensearch-agent-server
    source .venv/bin/activate
    python run_server.py
    
  3. 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"
    
  4. Start OpenSearch Dashboards (port 5601)

    cd OpenSearch-Dashboards
    yarn start --no-base-path
    
  5. 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/                   # ART (Search Relevance Testing) agent
│   │   │   ├── art_agent.py       # ART orchestrator agent
│   │   │   └── specialized_agents.py  # Hypothesis, evaluation, UBI sub-agents
│   │   ├── base.py                # Agent protocol / base types
│   │   └── default_agent.py       # General OpenSearch assistant
│   ├── orchestrator/              # Routing and registry
│   │   ├── router.py              # Context-based routing
│   │   └── registry.py            # Agent registry
│   ├── server/                    # FastAPI application
│   │   ├── ag_ui_app.py           # Main FastAPI app and lifespan
│   │   ├── cli.py                 # CLI entry point (opensearch-agent-server command)
│   │   ├── agent_orchestrator.py  # Orchestrator: routes requests to agents
│   │   ├── run_routes.py          # AG-UI protocol endpoints
│   │   ├── config.py              # Configuration management
│   │   └── ...                    # Middleware, auth, rate limiting, etc.
│   ├── tools/                     # Agent tools (local computation)
│   │   └── art/                   # ART-specific tools
│   │       └── experiment_tools.py  # Experiment results aggregation
│   └── utils/                     # Shared utilities
│       ├── mcp_connection.py      # OpenSearch MCP client
│       ├── logging_helpers.py     # Structured logging
│       ├── monitored_tool.py      # Tool instrumentation wrapper
│       └── ...                    # Persistence, activity monitor, etc.
├── tests/
│   ├── helpers/                   # Shared test helpers
│   ├── integration/               # Integration tests
│   └── unit/                      # Unit tests
├── run_server.py                  # Entry point
├── pyproject.toml                 # Project metadata and dependencies
└── .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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opensearch_agent_server-0.2.1.tar.gz (103.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opensearch_agent_server-0.2.1-py3-none-any.whl (126.1 kB view details)

Uploaded Python 3

File details

Details for the file opensearch_agent_server-0.2.1.tar.gz.

File metadata

  • Download URL: opensearch_agent_server-0.2.1.tar.gz
  • Upload date:
  • Size: 103.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for opensearch_agent_server-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6aaa50b382dfe6b52163855d1e86fe00d091a7c9b9c233e70989613c7aa65634
MD5 de94e70e4bfc11c0fa14777c7f94238f
BLAKE2b-256 7bef9a78f100fda02a070eec9d2d30c393ea6d6b2691bbb0a89dee028343cd55

See more details on using hashes here.

Provenance

The following attestation bundles were made for opensearch_agent_server-0.2.1.tar.gz:

Publisher: release-drafter.yml on opensearch-project/opensearch-agent-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file opensearch_agent_server-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for opensearch_agent_server-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e5bc5d4a31ea3ebbce88d579ead12350b79fbafb23a19ebff3c64cc016621f3
MD5 b294cb14624e397a40bbf219d2ac4114
BLAKE2b-256 10571b47fb028153cd944b428ef4ca2c705f7c26ffa6e45e4b0ddd3a16b093e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for opensearch_agent_server-0.2.1-py3-none-any.whl:

Publisher: release-drafter.yml on opensearch-project/opensearch-agent-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page