@theharithsa/dynatrace-mcp-server-dev
v2.1.0
Published
Dynatrace Model Context Protocol (MCP) Server for AI assistants
Downloads
34
Maintainers
Readme
Dynatrace MCP Server
A Model Context Protocol (MCP) server that provides AI assistants with comprehensive access to Dynatrace observability data, automation capabilities, and operational insights. Enhanced with Davis CoPilot AI for intelligent query generation and natural language explanations.
Table of Contents
- Quick Start
- Configuration
- Available Tools
- Davis CoPilot AI Integration
- Environment Variables
- Authentication
- Advanced Usage
- Development
- Dynatrace MCP OpenTelemetry Integration
Quick Start
1. Add to Your MCP Client
Configure your MCP client (Claude Desktop, Cline, etc.) by adding this server to your mcp.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
- Go to your Dynatrace environment → Settings → Platform Management → OAuth clients
- Create a new OAuth client with the required scopes
- Copy the Client ID and Secret
3. Start Using
Your AI assistant can now:
- Query problems and vulnerabilities
- Execute DQL (Dynatrace Query Language) queries
- Get entity details and ownership information
- Create dashboards and workflows
- Send Slack notifications
- Execute custom TypeScript code
Configuration
Basic Configuration
{
"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
# 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"
}
}
}
}Available Tools
🤖 Davis CoPilot AI (NEW!)
generate_dql_from_natural_language- Convert natural language to DQL queries using Davis CoPilot AIexplain_dql_in_natural_language- Get plain English explanations of complex DQL statementschat_with_davis_copilot- AI-powered assistant for Dynatrace questions and troubleshooting
🔍 Monitoring & Observability
get_environment_info- Get Dynatrace environment detailslist_problems- List all active problemsget_problem_details- Get detailed problem informationlist_vulnerabilities- List security vulnerabilitiesget_vulnerabilty_details- Get vulnerability details and affected entities
📊 Data Querying
execute_dql- Execute Dynatrace Query Language statementsverify_dql- Validate DQL syntax before executionget_logs_for_entity- Retrieve logs for specific entitiesget_kubernetes_events- Get Kubernetes cluster events
🏗️ Entity Management
find_entity_by_name- Find monitored entities by nameget_entity_details- Get detailed entity informationget_ownership- Get ownership information for entities
📈 Dashboard & Reporting
create_dashboard- Create dashboards from JSON filesbulk_delete_dashboards- Delete multiple dashboardsshare_document_env- Share documents across environmentsdirect_share_document- Share documents with specific users
🤖 Automation
create_workflow_for_notification- Create notification workflowsmake_workflow_public- Make workflows publicly accessibleexecute_typescript- Execute custom TypeScript code via Function Executor
💬 Communication
send_slack_message- Send messages via Slack integration
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:
"Show me errors in the payment service from the last hour"
↓
fetch logs | filter contains(content, "error") and dt.entity.service == "payment-service" | sort timestamp desc | limit 100DQL Explanation
Understand complex queries in plain English:
fetch spans | filter duration > 5s | summarize avg(duration) by service.name
↓
"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:
- Generate: Use
generate_dql_from_natural_languageto create queries - Verify: Use
verify_dqlto validate syntax - Execute: Use
execute_dqlto run the query - Iterate: Refine based on results and repeat
Required Scopes for Davis CoPilot
Add these scopes to your OAuth client:
davis-copilot:nl2dql:execute
davis-copilot:dql2nl:execute
davis-copilot:conversations:executeUsage Examples
Generate DQL from Natural Language
{
"tool": "generate_dql_from_natural_language",
"arguments": {
"text": "Find all HTTP 500 errors in the last 2 hours for the checkout service"
}
}Explain Complex DQL
{
"tool": "explain_dql_in_natural_language",
"arguments": {
"dql": "fetch logs | filter status_code == 500 | summarize count() by service.name | sort count desc"
}
}Chat with Davis CoPilot
{
"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) |
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:<your-account-urn-guid> |
OpenTelemetry Tracing (Optional)
| Variable | Description | Example |
|----------|-------------|---------|
| OTEL_EXPORTER_OTLP_ENDPOINT | OTLP endpoint for traces | https://abc12345.live.dynatrace.com/api/v2/otlp/v1/traces |
| DYNATRACE_API_TOKEN | API token for trace/log export | dt0c01.ABC123... |
| DYNATRACE_LOG_INGEST_URL | Log ingest endpoint | https://abc12345.live.dynatrace.com/api/v2/logs/ingest |
| OTEL_RESOURCE_ATTRIBUTES | OpenTelemetry resource attributes | service.name=dynatrace-mcp-server,service.version=2.0.0 |
Slack Integration (Optional)
| Variable | Description | Default |
|----------|-------------|---------|
| SLACK_CONNECTION_ID | Slack connection ID from Dynatrace | None |
Document Sharing (Optional)
| Variable | Description | Default |
|----------|-------------|---------|
| DT_SHARE_RECIPIENTS | Comma-separated list of user/group IDs | None |
| DT_SHARE_TYPE | Type of recipients (user/group) | group |
Complete Configuration Example
{
"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",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://abc12345.live.dynatrace.com/api/v2/otlp/v1/traces",
"DYNATRACE_API_TOKEN": "dt0c01.XYZ789...",
"DYNATRACE_LOG_INGEST_URL": "https://abc12345.live.dynatrace.com/api/v2/logs/ingest",
"SLACK_CONNECTION_ID": "your-slack-connection-id",
"DT_SHARE_RECIPIENTS": "group-id-1,group-id-2",
"DT_SHARE_TYPE": "group"
}
}
}
}Authentication
Required Scopes
Your OAuth client needs these scopes:
Core Scopes:
app-engine:apps:runapp-engine:functions:run
Davis CoPilot Scopes (NEW!):
davis-copilot:nl2dql:execute- For natural language to DQL conversiondavis-copilot:dql2nl:execute- For DQL explanation in natural languagedavis-copilot:conversations:execute- For AI-powered conversations
Feature-Specific Scopes:
environment-api:security-problems:read- For vulnerability managementenvironment-api:problems:read- For problem analysisenvironment-api:entities:read- For entity informationstorage:*:read- For DQL queries (logs, metrics, events, etc.)automation:workflows:write- For workflow creationautomation:workflows:read- For workflow managementautomation:workflows:run- For workflow executiondocument:documents:write- For dashboard creationdocument:documents:delete- For dashboard deletiondocument:environment-shares:write- For document sharingdocument:direct-shares:write- For direct document sharingapp-settings:objects:read- For Slack integrationsettings:objects:read- For ownership information
Setting Up OAuth Client
- Navigate to Settings → Platform Management → OAuth clients
- Click Create OAuth client
- Set Client type to
Public - Add all required scopes from the list above
- Save and copy the Client ID and Secret
Advanced Usage
Custom Dashboard Creation
Place JSON dashboard files in a /dashboards folder and use the create_dashboard tool to bulk-create them.
TypeScript Code Execution
Execute custom logic using the Dynatrace Function Executor:
// Example: Query and process data
export default async function({ entityId }) {
// Your custom TypeScript code here
return { processed: true, entityId };
}Slack Integration
Configure Slack notifications by setting up a Slack connection in Dynatrace and providing the SLACK_CONNECTION_ID.
Development
For Code Customization
If you need to modify the server code:
# Install the package for customization
npm install @theharithsa/dynatrace-mcp-server
# Clone and modify the source
git clone https://github.com/theharithsa/dynatrace-mcp-otel.git
cd dynatrace-mcp-otel
npm install
npm run buildLocal Development
{
"mcpServers": {
"dynatrace-local": {
"command": "node",
"args": ["dist/index.js"],
"cwd": "/path/to/dynatrace-mcp-otel",
"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"
}
}
}
}Installation Options
# NPX (recommended for most users)
npx @theharithsa/dynatrace-mcp-server
# Global installation
npm install -g @theharithsa/dynatrace-mcp-server
# Local project installation
npm install @theharithsa/dynatrace-mcp-serverDynatrace MCP OpenTelemetry Integration
Observability Features
Log Correlation
- All logs include
dt.security_contextfield set todynatrace_mcp_otel - Logs are tagged with
logType: build-logsfor filtering - Logs are automatically correlated with traces via standard OpenTelemetry attributes
CI/CD Observability
Our GitHub Actions workflows are instrumented with OpenTelemetry using inception-health/otel-action.
Configuration in GitHub Actions
- name: Setup OpenTelemetry
uses: inception-health/otel-action@v2
with:
dsn: ${{ vars.OTEL_EXPORTER_OTLP_ENDPOINT }}
service_name: 'dynatrace-mcp-server-build'
access_token: ${{ secrets.DYNATRACE_API_TOKEN }}
log_url: ${{ vars.DYNATRACE_LOG_INGEST_URL }}
build_type: ${{ github.ref == 'refs/heads/dev' && 'dev' || 'prod' }}Required Variables/Secrets
OTEL_EXPORTER_OTLP_ENDPOINT: Dynatrace OTLP endpoint URLDYNATRACE_API_TOKEN: API token with ingest permissionDYNATRACE_LOG_INGEST_URL: Dynatrace log ingest URL
Known Issues
- In version 1.0.8, trace ingestion might not work correctly in all environments, but logging functionality works as expected
Version History
- 2.1.0: Added Davis CoPilot AI integration with natural language processing capabilities
- 2.0.0: Updated package structure and naming; enhanced configuration options
- 1.0.8: Switched to standard OpenTelemetry GitHub Action; enhanced logging with security context
- 1.0.7: // ...existing version history...
Support
- Issues: Report issues on GitHub
- Documentation: Dynatrace Platform Documentation
- MCP Protocol: Model Context Protocol
Note: This MCP server is designed for AI assistant integration. For standalone use cases, consider using the Dynatrace CLI or API directly.
