OpenSearch MCP Server
Allows retrieving error stack traces by transaction ID from OpenSearch logs, with filtering by index pattern and application name.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OpenSearch MCP Serverget stack trace for tid e1020584c0a74074a930c4e90e953912.139.17702793574644017"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OpenSearch MCP Server
A Model Context Protocol (MCP) server built with FastMCP for retrieving error stack traces by transaction ID (TID) from OpenSearch logs.
Features
Error stack trace retrieval: Get complete error stack traces by transaction ID (TID)
Docker-based setup: Easy local development with Docker Compose
Environment variable configuration: Flexible connection settings via environment variables
Related MCP server: OpenSearch Logs MCP Server
Prerequisites
Python 3.10 or higher
Docker and Docker Compose (for running the MCP server in a container)
An accessible OpenSearch instance (you provide your own)
pip or uv for package management
Installation
Clone the repository:
git clone <repository-url>
cd opensearch-mcpInstall dependencies:
pip install -r requirements.txtOr using uv:
uv pip install -r requirements.txtSet up environment variables (optional):
cp .env.example .env
# Edit .env with your OpenSearch connection settingsQuick Start
Prerequisites: You need your own OpenSearch instance running and accessible. Configure the connection details in the .env file.
Option 1: Using Docker Compose (Recommended)
Copy the environment file and configure your OpenSearch connection:
cp .env.example .env
# Edit .env and set OPENSEARCH_HOST and OPENSEARCH_PORT to your OpenSearch instanceStart the MCP server:
docker-compose upThis will start:
MCP server on port 48081 (HTTP endpoint:
http://localhost:48081/mcp)
The MCP server will connect to your OpenSearch instance using the configuration from .env.
To run in detached mode:
docker-compose up -dOption 2: Run MCP Server directly with Python
Set up environment variables:
cp .env.example .env
# Edit .env and configure OPENSEARCH_HOST and OPENSEARCH_PORT to your OpenSearch instanceRun the MCP server:
python server.pyThe server will start on http://localhost:48081/mcp.
Option 3: Run MCP Server with Docker (standalone)
Build the Docker image:
docker build -t opensearch-mcp .Run the container with your OpenSearch connection details:
docker run --rm -p 48081:48081 \
-e OPENSEARCH_HOST=your-opensearch-host \
-e OPENSEARCH_PORT=9200 \
opensearch-mcpOr use an env file:
docker run --rm -p 48081:48081 --env-file .env opensearch-mcpThe MCP server will be available at http://localhost:48081/mcp.
Note:
Replace
your-opensearch-hostwith your actual OpenSearch hostname or IPUse
host.docker.internal(macOS/Windows) or your host IP (Linux) if OpenSearch is running on the host machineFor remote instances, use the actual hostname or IP address
Configuration
The MCP server reads connection settings from environment variables:
Variable | Default | Description |
|
| OpenSearch host |
|
| OpenSearch port |
|
| Enable SSL/TLS |
|
| Verify SSL certificates |
| - | Username for authentication (optional) |
| - | Password for authentication (optional) |
When using Docker Compose, these variables are automatically available from the container environment.
MCP Tools
stack_trace_tid
Retrieve full error stack trace by transaction ID (TID).
Parameters:
tid(string, required): Transaction ID to search forindex_pattern(string, optional): Index pattern to search (default:servicelogs-*)repo_name(string, optional): Filter by repository/application name (maps toapplication_namefield)
Example:
{
"tid": "e1020584c0a74074a930c4e90e953912.139.17702793574644017",
"repo_name": "xxx"
}Returns: Formatted text with one log entry per line. Each line follows the format:
timestamp - level - message - application_name - projectIf a separate stack_trace field exists in the log document, the format is:
timestamp - level - message - stack_trace - application_name - projectNote: Log entries are sorted chronologically by @timestamp in ascending order. Newlines in messages and stack traces are normalized to | (pipe characters) for single-line format.
Example Output:
2026-02-05T08:15:57.566Z - INFO - channel GOPAY got phone A0:1ec614bbcb328b7c66436a318d7b77e0 from token - xxx - xxx
2026-02-05T08:15:57.570Z - INFO - register user for A0:44b351780fec875b97ad01d9bb946f3e , system : SYSTEM_TYPE_ATOME, channel: GOPAY - user-service-provider - pintar-user
2026-02-05T08:15:58.263Z - ERROR - POST http://:8080/user/info -d [{"module":"RESIDENTIAL_INFO","module":"RESIDENTIAL_INFO",...}] ***RESPONSE*** 400 {"timestamp":1770279358262,"status":400,"error":"Bad Request","path":"/user/info"} - xxx - xxx
2026-02-05T08:15:58.264Z - ERROR - [Gopay Linking] Failed to save user info for userId : [400 ] during [POST] to [http://:8080/user/info] [PintarUserInfoFeignClient#saveUserInfo(List)]: [{"timestamp":1770279358262,"status":400,"error":"Bad Request","path":"/user/info"}] - feign.FeignException$BadRequest: [400 ] during [POST] to [http://:8080/user/info] [PintarUserInfoFeignClient#saveUserInfo(List)]: [{"timestamp":1770279358262,"status":400,"error":"Bad Request","path":"/user/info"}] | at feign.FeignException.clientErrorStatus(FeignException.java:243) | at feign.FeignException.errorStatus(FeignException.java:223) | at feign.FeignException.errorStatus(FeignException.java:213) | ... - xxx - xxx
2026-02-05T08:15:58.267Z - INFO - [GopayServiceImpl] linking account failed for userId: , error: INVALID_KYC - xxx - xxxNote: Log entries are sorted by timestamp in ascending order. Stack traces (when present) are included as part of the message field, with stack frames separated by | (pipe characters).
Usage with MCP Clients
The MCP server uses streamableHttp transport on port 48081. This enables HTTP-based communication instead of stdio, making it easier to deploy and scale.
Starting the Server
Important: Ensure your OpenSearch instance is running and accessible before starting the MCP server.
Option 1: Using Docker Compose (Recommended)
Configure your OpenSearch connection in
.env:
cp .env.example .env
# Edit .env with your OpenSearch host and portStart the MCP server:
docker-compose upThe MCP server will be available at http://localhost:48081/mcp.
Option 2: Running Locally
Set up environment variables:
cp .env.example .env
# Edit .env with your OpenSearch host and portRun the MCP server:
python server.pyThe server will start on http://localhost:48081/mcp.
Option 3: Using Docker Run
Build the image:
docker build -t opensearch-mcp .Run the container with your OpenSearch connection:
docker run --rm -p 48081:48081 \
-e OPENSEARCH_HOST=your-opensearch-host \
-e OPENSEARCH_PORT=9200 \
opensearch-mcpOr use an env file:
docker run --rm -p 48081:48081 --env-file .env opensearch-mcpConfiguring MCP Clients
Cursor IDE
Add to your Cursor MCP settings (mcp.json):
{
"mcpServers": {
"opensearch": {
"url": "http://localhost:48081/mcp"
}
}
}Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"opensearch": {
"url": "http://localhost:48081/mcp"
}
}
}Remote Access
If the MCP server is running on a remote machine, use the remote URL:
{
"mcpServers": {
"opensearch": {
"url": "http://your-server-ip:48081/mcp"
}
}
}Configuration
The MCP server port and host can be configured via environment variables:
MCP_PORT: Port for the HTTP server (default: 48081)MCP_HOST: Host to bind to (default: 0.0.0.0)
Example:
MCP_PORT=8080 MCP_HOST=127.0.0.1 python server.pyDocker Networking Notes
Local development: Use
http://localhost:48081/mcpVPN Access: The docker-compose.yml uses
network_mode: hostto allow the container to access VPN resources through your host's networkDocker Compose: When using host network mode, the container shares your host's network stack, including VPN connections
Remote access: Ensure port 48081 is accessible from your MCP client
Note: With network_mode: host, the container uses your host's network directly, so:
VPN resources are accessible from the container
No port mapping is needed (ports are directly accessible on the host)
The container can access resources that require VPN connection
Development
Project Structure
opensearch-mcp/
├── src/
│ └── opensearch_mcp/
│ ├── __init__.py
│ ├── server.py # FastMCP server with tool definitions
│ └── opensearch_client.py # OpenSearch client wrapper
├── docker-compose.yml # Docker Compose setup (OpenSearch + MCP server)
├── Dockerfile # MCP server Docker image
├── .dockerignore # Docker ignore file
├── .env.example # Example environment variables
├── mcp.json.example # Example MCP client configuration
├── requirements.txt # Python dependencies
├── pyproject.toml # Python project configuration
└── README.md # This fileRunning Tests
# Ensure your OpenSearch instance is running and accessible
# Start MCP server with Docker Compose
docker-compose up
# Or run MCP server locally
python server.pyDocker Compose Services
The docker-compose.yml includes only the MCP server service:
opensearch-mcp: MCP server (uses
.envfile for configuration)
The MCP server service:
Builds from the local Dockerfile
Loads environment variables from
.envfileConnects to your OpenSearch instance using the configuration from
.envExposes HTTP endpoint on port 48081 at
/mcppathUses streamableHttp transport for MCP communication
Note: You need to provide your own OpenSearch instance. Configure the connection details in the .env file.
Log Data Format
The MCP server expects log documents with the following structure:
{
"@timestamp": "2024-01-01T10:00:00Z",
"level": "ERROR",
"msg": "Error occurred...",
"application_name": "xxx",
"project": "xxx",
"stack_trace": "feign.FeignException$BadRequest: [...] | at ...",
"TID": "e1020584c0a74074a930c4e90e953912.139.17702793574644017"
}Key fields:
@timestamp: Log timestamp (ISO 8601 format)level: Log level (INFO, WARN, ERROR, etc.)msg: Log message contentapplication_name: Application/service name (used for filtering viarepo_nameparameter)project: Project/repository namestack_trace: Stack trace content (optional, formatted as pipe-separated lines)TID: Transaction ID field (searched using phrase matching across all fields)
Troubleshooting
Connection Errors
If you see connection errors:
Ensure your OpenSearch instance is running and accessible
Check OpenSearch health:
curl http://your-opensearch-host:9200/_cluster/healthVerify environment variables in
.envare set correctly (OPENSEARCH_HOST and OPENSEARCH_PORT)If running in Docker, ensure the container can reach your OpenSearch instance (network configuration)
No Results Found
Check that your index pattern matches existing indices (default:
servicelogs-*)Verify that the TID exists in your log documents (searched using phrase matching across all fields)
If using
repo_namefilter, verify thatapplication_namefield exists and matches the filter valueEnsure the TID format matches what's stored in your logs
SSL/TLS Issues
If using SSL:
Set
OPENSEARCH_USE_SSL=trueConfigure
OPENSEARCH_VERIFY_CERTSappropriatelyProvide CA certificates if needed
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/hpower2/opensearch-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server