# Dynatrace Mcp Otel

> Dynatrace MCP Server is an AI‑assistant back‑end that lets clients query Dynatrace data, execute DQL and manage dashboards and workflows, exporting logs and traces via OpenTelemetry.

- **Type:** MCP server
- **Install:** `agentstack add mcp-theharithsa-dynatrace-mcp-otel`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [theharithsa](https://agentstack.voostack.com/s/theharithsa)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [theharithsa](https://github.com/theharithsa)
- **Source:** https://github.com/theharithsa/dynatrace-mcp-otel

## Install

```sh
agentstack add mcp-theharithsa-dynatrace-mcp-otel
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Dynatrace MCP

[](https://www.npmjs.com/package/@theharithsa/dynatrace-mcp-server)
[](https://www.npmjs.com/package/@theharithsa/dynatrace-mcp-server)
[](https://github.com/theharithsa/dynatrace-mcp-otel/blob/main/LICENSE)
[](https://github.com/theharithsa/dynatrace-mcp-otel/actions)
[](https://nodejs.org/)
[](https://www.typescriptlang.org/)
[](https://opentelemetry.io/)
[](https://docs.dynatrace.com/docs/platform-modules/davis-copilot)
[](https://modelcontextprotocol.io/)
[](https://docs.dynatrace.com/)

A powerful Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to Dynatrace's observability platform. Features dual authentication architecture, Davis CoPilot AI integration, and **24 specialized tools** for monitoring, automation, and operational intelligence.

## 🚀 What's New in v2.6.0

- **📊 Grail Budget Tracking**: Advanced budget monitoring system with real-time usage tracking, warnings, and limits
- **🏷️ Entity Tagging**: Add custom tags to monitored entities for better organization and filtering
- **📈 HTTP Server Mode**: Run as a standalone HTTP server for broader integration possibilities
- **🔧 Enhanced DQL Execution**: Improved metadata extraction, error handling, and budget integration
- **📧 Enhanced Email System**: Professional email capabilities with HTML/text support and multiple recipients
- **🧪 Comprehensive Testing**: 38 test cases covering all major functionality with 83% success rate
- **📚 Extended Documentation**: Updated guides, examples, and troubleshooting resources

## Costs

**Important:** While this local MCP server is provided for free, using it to access data in Dynatrace Grail may incur additional costs based on your Dynatrace consumption model. This affects `execute_dql` tool and other capabilities that **query** Dynatrace Grail storage, and costs depend on the volume (GB scanned/billed).

**Before using this MCP server extensively, please:**

1. Review your current Dynatrace consumption model and pricing
2. Understand the cost implications of the specific data you plan to query (logs, events, metrics) - see [Dynatrace Pricing and Rate Card](https://www.dynatrace.com/pricing/)
3. Start with smaller timeframes (e.g., 12h-24h) and make use of [buckets](https://docs.dynatrace.com/docs/discover-dynatrace/platform/grail/data-model#built-in-grail-buckets) to reduce the cost impact

**Note**: We will be providing a way to monitor Query Usage of the dynatrace-mcp-server in the future.

## Table of Contents

- [Quick Start](#quick-start)
- [Configuration](#configuration)
- [Available Tools](#available-tools-24-total)
- [Davis CoPilot AI Integration](#davis-copilot-ai-integration)
- [Environment Variables](#environment-variables)
- [Authentication](#authentication)
- [Advanced Usage](#advanced-usage)
- [Development](#development)
- [Dynatrace MCP OpenTelemetry Integration](#dynatrace-mcp-opentelemetry-integration)

## 🏆 Production Ready & Tested

**v2.6.0 has been extensively tested with real Dynatrace environments:**

- ✅ **20/24 tools working perfectly** (83% success rate)
- ✅ **All core monitoring functions** operational (DQL, entities, dashboards)
- ✅ **AI integration** fully functional (Davis CoPilot, natural language processing)
- ✅ **Budget tracking** prevents cost overruns with real-time monitoring
- ✅ **Communication tools** validated (Slack, Email with professional formatting)
- ✅ **Automation workflows** tested and operational

**Minor OAuth scope adjustments needed for 4 tools** - mainly permission-related issues that are easily configurable.

## Quick Start

### 1. Add to Your MCP Client

Configure your MCP client (Claude Desktop, Cline, etc.) by adding this server to your `mcp.json`:

```json
{
  "mcpServers": {
    "dynatrace": {
      "command": "npx",
      "args": ["@theharithsa/dynatrace-mcp-server"],
      "env": {
        "OAUTH_CLIENT_ID": "dt0s02.ABC123...",
        "OAUTH_CLIENT_SECRET": "dt0s02.ABC123.DEF456...",
        "DT_ENVIRONMENT": "https://abc12345.apps.dynatrace.com"
      }
    }
  }
}
```

### 2. Get Your Dynatrace Credentials

1. Go to your Dynatrace environment → **Settings** → **Platform Management** → **OAuth clients**
2. Create a new OAuth client with the [required OAuth scopes](#required-oauth-scopes)
3. Copy the Client ID and Secret

### 3. Start Using

Your AI assistant can now:

- **🤖 AI-Powered Queries**: Convert natural language to DQL using Davis CoPilot
- **📊 Monitor & Analyze**: Query problems, vulnerabilities, and execute DQL statements
- **🏗️ Entity Management**: Find, tag, and manage monitored entities with ownership info
- **📈 Dashboard Operations**: Create, delete, and share dashboards with access control
- **🤖 Automation**: Create workflows and execute custom TypeScript functions
- **💬 Communication**: Send Slack messages and professional emails
- **📊 Budget Control**: Track and manage Grail query usage with budget limits

> ℹ️ On startup the server now verifies your Dynatrace connection with up to three exponential-backoff retries. Invalid URLs, credentials, or missing scopes will fail fast with detailed guidance so you can correct the configuration before using any tools.

## Configuration

### Basic Configuration

```json
{
  "mcpServers": {
    "dynatrace": {
      "command": "npx",
      "args": ["@theharithsa/dynatrace-mcp-server"],
      "env": {
        "OAUTH_CLIENT_ID": "dt0s02.your-client-id",
        "OAUTH_CLIENT_SECRET": "dt0s02.your-client-id.your-client-secret",
        "DT_ENVIRONMENT": "https://your-tenant.apps.dynatrace.com"
      }
    }
  }
}
```

### Alternative: Global Installation

```bash
# Install globally
npm install -g @theharithsa/dynatrace-mcp-server

# Then use in mcp.json
{
  "mcpServers": {
    "dynatrace": {
      "command": "dynatrace-mcp-server",
      "env": {
        "OAUTH_CLIENT_ID": "dt0s02.your-client-id",
        "OAUTH_CLIENT_SECRET": "dt0s02.your-client-id.your-client-secret",
        "DT_ENVIRONMENT": "https://your-tenant.apps.dynatrace.com"
      }
    }
  }
}
```

### HTTP Server Mode (NEW!)

Run as a standalone HTTP server for broader integration possibilities:

```bash
# Install globally first
npm install -g @theharithsa/dynatrace-mcp-server

# Run as HTTP server (requires all environment variables set)
dynatrace-mcp-server --http-port 3000

# Server will be available at http://localhost:3000
# Endpoints:
# GET  /health      - Health check
# POST /tools/list  - List available tools  
# POST /tools/call  - Execute tool calls
```

**Environment Variables for HTTP Mode:**

```bash
export OAUTH_CLIENT_ID="dt0s02.your-client-id"
export OAUTH_CLIENT_SECRET="dt0s02.your-client-id.your-client-secret"
export DT_ENVIRONMENT="https://your-tenant.apps.dynatrace.com"
export DT_GRAIL_QUERY_BUDGET_GB="100"  # Optional: Set Grail budget limit
export LOG_LEVEL="info"                # Optional: debug, info, warn, error
```

**Docker Support:**

```dockerfile
FROM node:18-alpine
WORKDIR /app
RUN npm install -g @theharithsa/dynatrace-mcp-server
EXPOSE 3000
CMD ["dynatrace-mcp-server", "--http-port", "3000"]
```

## Available Tools (24 Total)

### 🤖 Davis CoPilot AI Integration (3 tools)

- **`generate_dql_from_natural_language`** - Convert natural language to DQL queries using Davis CoPilot AI
- **`explain_dql_in_natural_language`** - Get plain English explanations of complex DQL statements  
- **`chat_with_davis_copilot`** - AI-powered assistant for Dynatrace questions and troubleshooting

### 🔍 Monitoring & Observability (4 tools)

- **`get_environment_info`** - Get Dynatrace environment details and configuration
- **`list_problems`** - List all active problems in your environment
- **`list_vulnerabilities`** - List security vulnerabilities detected by Dynatrace
- **`get_kubernetes_events`** - Get Kubernetes cluster events and status

### 📊 Data Querying & Analysis (2 tools)

- **`execute_dql`** - Execute Dynatrace Query Language statements with budget tracking
- **`verify_dql`** - Validate DQL syntax and structure before execution

### 🏗️ Entity Management & Tagging (4 tools)

- **`find_entity_by_name`** - Find monitored entities by name across all entity types
- **`get_entity_details`** - Get detailed information about specific monitored entities
- **`add_entity_tags`** - Add custom tags to Dynatrace monitored entities
- **`get_ownership`** - Get ownership information and team assignments for entities

### 📈 Dashboard & Document Management (4 tools)

- **`create_dashboard`** - Create dashboards from JSON files in bulk
- **`bulk_delete_dashboards`** - Delete multiple dashboards by document IDs
- **`share_document_env`** - Share documents across environments with access control
- **`direct_share_document`** - Share documents directly with specific recipients

### 🤖 Automation & Workflows (3 tools)

- **`create_workflow_for_notification`** - Create notification workflows for problem alerts
- **`make_workflow_public`** - Make private workflows publicly accessible
- **`execute_typescript`** - Execute custom TypeScript code via Dynatrace Function Executor

### 💬 Communication (2 tools)

- **`send_slack_message`** - Send messages via Dynatrace Slack integration
- **`send_email`** - Send professional emails with HTML/text support via Dynatrace Email API

### 📊 Budget & Usage Management (2 tools)

- **`get_grail_budget_status`** - Monitor current Grail query budget usage and limits
- **`reset_grail_budget`** - Reset the budget tracker when limits are exceeded

## Davis CoPilot AI Integration

### Overview

Davis CoPilot AI integration brings intelligent query generation and natural language processing to your Dynatrace MCP workflows. This feature is perfect for:

- Converting natural language requests into powerful DQL queries
- Understanding complex DQL statements in plain English
- Getting AI-powered assistance for Dynatrace-related questions

### Key Features

#### Natural Language to DQL

Transform plain English into powerful queries:

```text
Input: "Show me CPU usage for all hosts in the last hour"
↓ Davis CoPilot AI ↓
Generated: timeseries from:now()-1h, by:{dt.entity.host}, cpuUsage = avg(dt.host.cpu.usage)
```

#### DQL Explanation

Understand complex queries in plain English:

```text
Input: fetch spans | filter duration > 5s | summarize avg(duration) by service.name
↓ Davis CoPilot AI ↓
"This query retrieves all spans with duration longer than 5 seconds, then calculates the average duration grouped by service name"
```

#### AI Assistant

Get contextual help for any Dynatrace topic, from troubleshooting to best practices.

### Workflow Integration

The recommended AI workflow is:

1. **Generate**: Use `generate_dql_from_natural_language` to create queries from natural language
2. **Verify**: Use `verify_dql` to validate DQL syntax and structure
3. **Execute**: Use `execute_dql` to run queries with automatic budget tracking
4. **Monitor**: Use `get_grail_budget_status` to check query costs and usage
5. **Reset**: Use `reset_grail_budget` if budget limits are exceeded
6. **Iterate**: Refine based on results, costs, and repeat

### Required Scopes for Davis CoPilot

Add these scopes to your OAuth client:

```text
davis-copilot:nl2dql:execute
davis-copilot:dql2nl:execute
davis-copilot:conversations:execute
```

### Usage Examples

#### Generate DQL from Natural Language

```json
{
  "tool": "generate_dql_from_natural_language",
  "arguments": {
    "text": "Show me CPU usage for all hosts in the last hour"
  }
}
```

**Result:** Generated DQL ready for execution with verification token.

#### Explain Complex DQL

```json
{
  "tool": "explain_dql_in_natural_language", 
  "arguments": {
    "dql": "timeseries from:now()-1h, by:{dt.entity.host}, cpuUsage = avg(dt.host.cpu.usage)"
  }
}
```

**Result:** Plain English explanation of query logic and data sources.

#### Chat with Davis CoPilot

```json
{
  "tool": "chat_with_davis_copilot",
  "arguments": {
    "text": "How do I optimize database query performance in my Java application?",
    "context": "We're seeing high response times in our e-commerce application"
  }
}
```

## Environment Variables

### Core Required Variables

| Variable              | Description                              | Example                               | Required               |
| --------------------- | ---------------------------------------- | ------------------------------------- | ---------------------- |
| `OAUTH_CLIENT_ID`     | Dynatrace OAuth Client ID                | `dt0s02.ABC123...`                    | ✅                     |
| `OAUTH_CLIENT_SECRET` | Dynatrace OAuth Client Secret            | `dt0s02.ABC123.DEF456...`             | ✅                     |
| `DT_ENVIRONMENT`      | Dynatrace environment URL (Platform API) | `https://abc12345.apps.dynatrace.com` | ✅                     |
| `DT_PLATFORM_TOKEN`   | Platform API token for Davis CoPilot     | `dt0c01.XYZ789...`                    | ✅ (for Davis CoPilot) |

### Budget & Logging Configuration (NEW!)

| Variable                      | Description                          | Example | Default |
| ----------------------------- | ------------------------------------ | ------- | ------- |
| `DT_GRAIL_QUERY_BUDGET_GB`    | Grail query budget limit in GB       | `100`   | `10`    |
| `LOG_LEVEL`                   | Logging level (debug/info/warn/error)| `info`  | `info`  |
| `HTTP_PORT`                   | Port for HTTP server mode            | `3000`  | None    |

### OAuth Configuration (Optional)

| Variable          | Description          | Default                                      |
| ----------------- | -------------------- | -------------------------------------------- |
| `OAUTH_TOKEN_URL` | OAuth token endpoint | `https://sso.dynatrace.com/sso/oauth2/token` |
| `OAUTH_URN`       | OAuth resource URN   | `urn:dtaccount:`      |

### OpenTelemetry Tracing (Optional)

The MCP server now includes automatic OpenTelemetry instrumentation using [@theharithsa/opentelemetry-instrumentation-mcp](https://www.npmjs.com/package/@theharithsa/opentelemetry-instrumentation-mcp). This provides comprehensive distributed tracing of all MCP tool calls with zero configuration required.

**Features:**

- 🔄 Automatic instrumentation of MCP tool calls
- 📊 Parent-child span relationships for complete traces
- 🚀 Drop-in solution with auto-registration
- 📈 OTLP export with Dynatrace support
- 🔍 Error tracking and exception recording

| Variable                        | Description                       | Example                                                      | Required |
| ------------------------------- | --------------------------------- | ------------------------------------------------------------ | -------- |
| `OTEL_EXPORTER_OTLP_ENDPOINT`   | OTLP endpoint for traces          | `https://abc12345.live.dynatrace.com/api/v2/otlp/v1/traces`  | ✅       |
| `OTEL_EXPORTER_OTLP_HEADERS`    | OTLP headers (comma-separated)    | `Authorization=Api-Token dt0c01.ABC123...`                   | ✅       |

**Example Configuration:**

```bash
# Single header
OTEL_EXPORTER_OTLP_ENDPOINT=https://abc12345.live.dynatrace.com/api/v2/otlp/v1/traces
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Api-Token dt0c01.ABC123...

# Multiple headers (comma-separated)
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Api-Token dt0c01.ABC123...,Custom-Header=value
```

**Trace Structure:**

Each tool call creates a hierarchical span structure:

```text
Tool.{toolName} (Parent Span)
  ├── mcp.tool:{toolName} (Child Span - auto-instrumented)
  │   ├── Duration, status, attributes
  │   └── Error tracking and exceptions
  └── Additional child spans from operations
```

### Slack Integration (Optional)

| Variable              | Description                        | Default |
| --------------------- | ---------------------------------- | ------- |
| `SLACK_CONNECTION_ID` | Slack connection ID from Dynatrace | None    |

### Document Sharing (Optional)

| Variable

…

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [theharithsa](https://github.com/theharithsa)
- **Source:** [theharithsa/dynatrace-mcp-otel](https://github.com/theharithsa/dynatrace-mcp-otel)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-theharithsa-dynatrace-mcp-otel
- Seller: https://agentstack.voostack.com/s/theharithsa
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
