Skip to content

ibarkowski/mcp-dynatrace-managed

Repository files navigation

Dynatrace Managed MCP Server

An MCP (Model Context Protocol) server that integrates Claude with Dynatrace Managed for environment monitoring, problem analysis, and infrastructure diagnostics.

Features

  • Problem monitoring — retrieve and analyze active problems with severity filtering
  • Entity search & details — search hosts, services, and applications by name, tag, or health state
  • Metric analysis — time series data, trend analysis, and AI-powered metric recommendations
  • Event tracking — monitor system events and deployments
  • SLO monitoring — check Service Level Objectives status and compliance
  • Host inventory — list all monitored hosts with CPU, memory, OS, and network zone info
  • Analysis guidelines — built-in rules for interpreting severity, detecting false positives, and investigation order
  • MCP Resources — analysis guidelines exposed as dynatrace://guidelines/analysis
  • Tool annotations — all tools declare readOnlyHint=true for MCP-compliant safety metadata

Requirements

  • Python 3.10+
  • Access to a Dynatrace Managed instance
  • API token with required permissions

Installation

1. Clone the repository

git clone https://github.com/YOUR_USERNAME/DynatraceManagedMCPServer.git
cd DynatraceManagedMCPServer

2. Create a virtual environment

python -m venv .venv
source .venv/bin/activate    # Linux/Mac
# or
.venv\Scripts\activate       # Windows

3. Install dependencies

Option A: pip install (editable)

pip install -e .

Option B: requirements.txt

pip install -r requirements.txt

4. Generate a Dynatrace API Token

In your Dynatrace Managed instance:

  1. Go to Settings > Integration > Dynatrace API
  2. Click Generate token
  3. Name the token (e.g., "MCP Server")
  4. Select the following permissions:
    • problems.read
    • entities.read
    • metrics.read
    • events.read
    • networkZones.read
    • settings.read
  5. Copy the generated token

5. Configure environment variables

Copy the example file and fill in your credentials:

cp .env.example .env

Edit .env with your values:

DYNATRACE_URL=https://your-dynatrace-managed-instance.com
DYNATRACE_ENVIRONMENT_ID=your-environment-id
DYNATRACE_TOKEN=dt0c01.XXXXXXXX.YYYYYYYY

6. Test the server

# Using the package module (recommended — run from src/)
cd src && python -m dynatrace_mcp_server

# Or using the compatibility shim (from repo root)
python dynatrace_mcp_server.py

# Or on Windows
run_server.bat

If configured correctly, the server will start without errors and wait for MCP connections.

Claude Desktop / Claude Code Configuration

Config file location

OS Path
Windows %APPDATA%\Claude\claude_desktop_config.json
Mac ~/Library/Application Support/Claude/claude_desktop_config.json
Linux ~/.config/Claude/claude_desktop_config.json

Option A: Using -m module invocation (recommended)

{
  "mcpServers": {
    "dynatrace": {
      "command": "python",
      "args": ["-m", "dynatrace_mcp_server"],
      "cwd": "/path/to/DynatraceManagedMCPServer/src",
      "env": {
        "DYNATRACE_URL": "https://your-instance.com",
        "DYNATRACE_ENVIRONMENT_ID": "your-environment-id",
        "DYNATRACE_TOKEN": "dt0c01.XXXXXXXX.YYYYYYYY"
      }
    }
  }
}

Option B: Using the startup script

This approach uses a .env file for credentials and a startup script:

Windows:

{
  "mcpServers": {
    "dynatrace": {
      "command": "C:\\path\\to\\DynatraceManagedMCPServer\\run_server.bat",
      "args": [],
      "env": {}
    }
  }
}

Mac/Linux:

{
  "mcpServers": {
    "dynatrace": {
      "command": "/path/to/DynatraceManagedMCPServer/run_server.sh",
      "args": [],
      "env": {}
    }
  }
}

Option C: Using the compatibility shim

{
  "mcpServers": {
    "dynatrace": {
      "command": "python",
      "args": ["/path/to/dynatrace_mcp_server.py"],
      "env": {
        "DYNATRACE_URL": "https://your-instance.com",
        "DYNATRACE_ENVIRONMENT_ID": "your-environment-id",
        "DYNATRACE_TOKEN": "dt0c01.XXXXXXXX.YYYYYYYY"
      }
    }
  }
}

Restart Claude Desktop after changing the configuration.

Available Tools

All tools declare readOnlyHint=true — they only read data from Dynatrace, never modify it.

Tool Description
get_problems Get problems with filtering by status (open/closed/all) and severity level
get_problem_details Detailed problem analysis including evidence, root cause, and affected entities
search_entities Search entities by name/pattern with filters for type, tag, health state, management zone
get_entity_details Detailed entity info including properties, relationships, tags, and management zones
list_entity_types List all available entity types in the environment
get_events Get events filtered by type and entity selector
get_slos Get SLO status, target values, and actual values
test_connection Verify Dynatrace API connectivity
suggest_optimal_metrics AI-powered metric recommendations for performance, capacity, or reliability analysis
analyze_metric_trends Automated trend analysis with anomaly detection
get_time_series_data Raw time series data for custom analysis
get_monitored_hosts List all monitored hosts with CPU, memory, OS, and network zone details
get_analysis_guidelines Built-in rules for severity interpretation and false positive detection

MCP Resources

URI Description
dynatrace://guidelines/analysis Analysis guidelines markdown — accessible via MCP resources/read

Usage Examples

After configuring the server, you can ask Claude questions like:

  • "What are the currently active problems in Dynatrace?"
  • "Analyze problem P-2602848 in detail"
  • "Check the health of host XYZ"
  • "Show CPU metrics for application servers over the last 12 hours"
  • "Are there any SLO violations?"
  • "List all monitored hosts and their memory usage"
  • "What events occurred in the last 6 hours?"
  • "Suggest the best metrics to analyze for this service's performance"

Project Structure

DynatraceManagedMCPServer/
├── dynatrace_mcp_server.py        # Compatibility shim
├── pyproject.toml                  # Package metadata & build config
├── requirements.txt               # Pinned dependencies
├── run_server.bat                  # Windows launcher
├── run_server.sh                   # Linux/Mac launcher
├── analysis_guidelines.md          # Severity rules & investigation order
├── DYNATRACE_METRICS.md            # Metric reference
└── src/
    └── dynatrace_mcp_server/
        ├── __init__.py             # Version string
        ├── __main__.py             # Entry point (python -m)
        ├── server.py               # MCP server core + resource exposure
        ├── config.py               # Env vars & named constants
        ├── client.py               # Dynatrace API client
        ├── utils.py                # Shared helpers
        └── tools/
            ├── __init__.py         # Tool registry aggregation
            ├── problems.py         # get_problems, get_problem_details
            ├── entities.py         # search_entities, get_entity_details, list_entity_types
            ├── metrics.py          # suggest_optimal_metrics, analyze_metric_trends, get_time_series_data
            ├── events.py           # get_events
            ├── slos.py             # get_slos
            ├── hosts.py            # get_monitored_hosts
            └── diagnostics.py      # test_connection, get_analysis_guidelines

Troubleshooting

Authorization error

  • Verify the API token is valid and has the required permissions
  • Make sure the Dynatrace URL is correct (no trailing /)

Connection error

  • Check that the Dynatrace instance is reachable from your network
  • Verify your firewall allows outbound HTTPS connections

Server does not start

  • Ensure all dependencies are installed: pip install -e . or pip install -r requirements.txt
  • Verify Python version is 3.10+
  • Check error logs in the console

Claude does not see MCP tools

  • Verify the PYTHONPATH includes the src directory
  • Check that environment variables are set
  • Restart Claude Desktop after configuration changes

Security Best Practices

  • Never commit API tokens to a repository
  • Use environment variables or .env files for credentials
  • Rotate API tokens regularly
  • Limit token permissions to the minimum required
  • Add .env to .gitignore (already included)

License

MIT License

About

MCP Server for Dynatrace Managed

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages