dynatrace-mcp
Provides read-only access to Dynatrace logs, problems, events, entities, metrics, security problems, and SLOs, plus root-cause analysis and service-debugging tools for Dynatrace Managed and SaaS environments.
Click on "Deploy 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., "@dynatrace-mcp investigate the latest production problem and summarize the root cause"
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.
dynatrace-mcp
An MCP server that gives Cursor's agent read-only access to Dynatrace: logs, problems, events, entities, metrics, security problems and SLOs, plus two composite tools for root-cause analysis (investigate_problem) and service debugging (debug_service).
It targets the classic Environment API v2 with an API token (Authorization: Api-Token ...), so it works on self-hosted Dynatrace Managed (https://<host>/e/<env-id>) as well as SaaS (https://<env>.live.dynatrace.com). Grail/DQL is an optional extra for SaaS environments that have it.
Cursor agent ──stdio──► dynatrace-mcp ──HTTPS + Api-Token──► Dynatrace Managed / SaaS /api/v2/...
│ read-only by default, secrets redacted, output size-bounded
└─ optional: Grail DQL (platform token), write tools (opt-in flag)Why this and not the official server
dynatrace-oss/dynatrace-mcp is built on the Dynatrace platform (Grail, DQL, OAuth clients and platform tokens). Those APIs do not exist on Dynatrace Managed, and many companies only hand out classic API tokens. This server uses only API v2 endpoints that Managed supports, and borrows the official server's ideas where they fit (problem-centric workflow, entity lookup by name, DQL when available).
Why Python: the mcp Python SDK (FastMCP) builds tool schemas from type hints, and it already ships httpx and pydantic, which cover custom CA bundles, proxies and TLS options. So the server has one runtime dependency (mcp) and the tests mock HTTP with httpx.MockTransport without extra libraries. uv handles the Python version, so the machine's system Python does not matter.
Related MCP server: Dynatrace SaaS MCP Server
Tools
Read-only (always on):
Area | Tool | API |
Setup |
| Shows the active config (no secrets) and probes which token scopes work |
Logs |
|
|
|
| |
| Log lines enriched with a trace id (classic API has no PurePath endpoint) | |
Problems |
|
|
|
| |
| Full evidence list, root-cause items first | |
| Root cause, affected and impacted entities, impact analysis | |
|
| |
Events |
|
|
Entities |
|
|
Metrics |
|
|
|
| |
Security |
|
|
SLOs |
|
|
RCA |
| Problem + root-cause entity and its process groups/hosts, change events (deployments, config, restarts) before the start, error logs in the window grouped by signature, key metrics before vs during. Returns |
Service |
| Service by id or name: failure rate, requests and response time (baseline vs recent), failure logs of its process groups, recent deployments/config changes, problems in the window, callers and callees |
Opt-in:
Tool | Enabled by | API |
|
|
|
|
|
|
|
| Grail |
Tools that are off are not registered at all, so the agent cannot see or call them.
Setup
1. Create an API token
Dynatrace -> Access tokens -> Generate new token (on Managed: inside the environment, not the Cluster Management Console). Pick these API v2 scopes:
Scope | UI name | Needed for |
| Read logs |
|
| Read problems | problem tools, RCA |
| Read events | events, deployments in RCA / |
| Read entities | entity tools, relationships in RCA, name lookup |
| Read metrics | metric tools, key metrics in RCA |
| Read security problems | security tools (needs Application Security) |
| Read SLO | SLO tools |
| Write problems | only with |
DataExport (API v1 "Access problem and event feed, metrics, and topology") is not needed; this server never calls API v1. Add it only if your admins issue one token for several tools that use v1. Missing scopes only disable the tools that need them: check_connection lists them.
2. Get the code
Requires uv (it installs Python 3.10+ if needed).
git clone <this-repo> ~/github/dynatrace-mcpcd ~/github/dynatrace-mcp && uv sync && uv run dynatrace-mcp --versionBehind a corporate proxy or TLS-inspecting firewall, uv sync itself may need HTTPS_PROXY and SSL_CERT_FILE (or UV_NATIVE_TLS=true) to reach PyPI or your internal mirror (UV_INDEX_URL).
3. Put the token in the environment
The server reads the token only from DT_API_TOKEN. It never logs it, never returns it and never writes it to disk. Pick one:
Shell profile (Cursor picks up your login shell's environment; restart Cursor fully after changing it):
export DT_BASE_URL="https://dynatrace.corp.example.com/e/<environment-id>" export DT_API_TOKEN="dt0c01.XXXX..." # better: read it from a secret store, see belowmacOS Keychain (nothing in plain-text files):
security add-generic-password -a "$USER" -s dynatrace-api-token -wThen use
examples/mcp.keychain.json, which reads the token at launch.
4. Register the server in Cursor
Add to ~/.cursor/mcp.json (all projects) or <project>/.cursor/mcp.json, with the absolute path of this repo:
Dynatrace Managed (examples/mcp.managed.json):
{
"mcpServers": {
"dynatrace": {
"command": "uv",
"args": ["run", "--quiet", "--directory", "/absolute/path/to/dynatrace-mcp", "dynatrace-mcp"],
"env": {
"DT_BASE_URL": "https://dynatrace.corp.example.com/e/<environment-id>",
"DT_API_TOKEN": "${env:DT_API_TOKEN}",
"DT_CA_BUNDLE": "/absolute/path/to/corp-root-ca.pem"
}
}
}
}SaaS (examples/mcp.saas.json): same, with "DT_BASE_URL": "https://<env-id>.live.dynatrace.com" and no CA bundle. A *.apps.dynatrace.com URL is rewritten to *.live.dynatrace.com, where the classic API lives.
This repo's own .cursor/mcp.json uses ${workspaceFolder}, so opening the repo in Cursor launches the server directly (handy for development).
If Cursor cannot find uv, use its absolute path (which uv, e.g. /opt/homebrew/bin/uv) as command.
5. Check it
Cursor Settings -> MCP: dynatrace shows a green dot and 23 tools. Then ask the agent:
Run check_connection for Dynatrace and tell me which scopes are missing.Configuration
Variable | Default | Meaning |
| (required) | Managed: |
| (required) | API token, bare value (no |
| PEM file with your company's root/intermediate CAs (Managed with internal certificates) | |
|
| Skip TLS verification. Last resort; prefer |
| Proxy URL for Dynatrace calls, e.g. | |
|
| Request timeout in seconds |
|
| Retries for GET on 429/502/503/504 (honors |
|
| Register |
| Comma-separated tool names to hide (e.g. to stay under Cursor's tool limit) | |
|
| Mask secrets in tool output (passwords, tokens, keys, JWTs, credentials in URLs). The configured tokens are masked even when |
|
| Output budget per tool call; the largest lists are trimmed and |
|
| Max characters kept per log line |
|
| Allow a plain |
| Optional Grail DQL on SaaS: | |
|
| Server log level; logs go to stderr (Cursor: Output -> MCP Logs) |
If DT_BASE_URL or DT_API_TOKEN is missing, the server still starts and lists its tools, and every call returns the configuration error, so the problem shows up in chat instead of as a silent red dot.
Use
Investigate Dynatrace problem P-24101 and write an RCA.checkout-service has been throwing 500s since 10:20 UTC. Debug it with Dynatrace.List open Dynatrace problems in the last 6 hours that touch services tagged team:payments.Search Dynatrace logs for status="ERROR" AND content="SQLTimeoutException" in the last 30 minutes, grouped by log.source.Companion skill and rule
.cursor/skills/dynatrace-rca/SKILL.md: RCA workflow (frame,investigate_problem, verify with drill-down tools, report template with Confirmed / Likely / Unknown, write-back only on confirmation) and a selector/query cheat sheet. Invoke with/dynatrace-rcaor let the agent pick it up..cursor/rules/dynatrace-guardrails.mdc: agent-requested rule (evidence first, narrow queries, never handle the token, confirm writes).
Copy them into the project where you investigate incidents, or install the skill for all projects:
mkdir -p ~/.cursor/skills && cp -R .cursor/skills/dynatrace-rca ~/.cursor/skills/mkdir -p /path/to/project/.cursor/rules && cp .cursor/rules/dynatrace-guardrails.mdc /path/to/project/.cursor/rules/How the RCA tool correlates
investigate_problem(problem_id, lookback_minutes=60):
Loads the problem with evidence, impact analysis and comments (
P-12345is resolved to the internal id).Takes the root-cause entity (or the first affected entity) and its relationships. Services are mapped to the process groups, instances and hosts they run on, because classic logs and deployment events are attached to those, not to the service.
In parallel, for
[start - lookback, end + 5 min]:events on those entities; deployments, config changes, restarts and annotations before the start become
changesBeforeProblemwith minutes-before;error logs (
status="ERROR"by default) scoped bydt.entity.process_group(or instance/host), grouped by a normalized signature (numbers, ids, timestamps removed);key metrics for the entity type (service: failure rate, failed requests, requests, response time avg/p90 in ms; host: CPU, memory, fullest disk; process: CPU, memory) with baseline vs during averages and
changePct.
Builds
findings, a MarkdownsummaryandnextSteps. A missing scope or failed sub-query is recorded inerrorsand the rest of the report still comes back.
The findings are hypotheses ranked by evidence; the skill tells the agent to verify them before calling something the root cause.
Security model
Read-only by default. Write tools are not registered unless
DT_ENABLE_WRITE=true, carry MCPdestructiveHint/readOnlyHintannotations, and are onlyPOSTs to problem comments/close. GETs are the only requests retried.Token handling. Read from the environment only; sent only to
DT_BASE_URL; redirects are not followed (so the token is never replayed to an SSO page or another host); masked in errors, logs and tool output;check_connectionshows"api_token": "set", never the value. Plainhttp://is refused.Output hygiene. Secret-looking values in log lines, event properties and errors are masked; long lines and huge result sets are cut to a budget so a single call cannot flood the agent's context.
TLS. Verification is on by default;
DT_CA_BUNDLEadds internal CAs;DT_INSECURE_TLSlogs a warning at startup.Least privilege. Grant only the read scopes you need.
check_connectionshows what works.
Troubleshooting
Symptom | Fix |
| Wrong token or token from another environment. On Managed, the token must be created inside the environment you point |
| Add the scope named in the hint; |
|
|
"TLS verification failed" | Export your corporate root CA as PEM and set |
"unexpected redirect" / "not JSON" | A proxy or SSO page is in the way; set |
Logs empty in RCA | Log Monitoring not enabled for those process groups, or logs carry other entity attributes; run |
Security tools 404/403 | Application Security not licensed/enabled in that environment |
Server red in Cursor | Cursor -> Output -> "MCP Logs"; run |
Development
uv sync && uv run pytest -vsrc/dynatrace_mcp/
config.py env -> Settings (URL normalization, TLS, proxy, flags)
client.py async httpx client: Api-Token auth, retries, errors with scope hints
redact.py secret masking and output budget
api.py one function per API v2 operation, compact output
rca.py investigate_problem and debug_service
server.py FastMCP tool registration (stdio)
tests/ HTTP mocked with httpx.MockTransport; includes a real stdio launch that lists the toolsTests never touch the network; tests/test_server.py::test_stdio_end_to_end starts the server the way Cursor does and checks the tool list.
License
MIT, see LICENSE.
Available Tools
23 toolsaggregate_logsARead-only
Count log records over time and by attribute (GET /api/v2/logs/aggregate). Needs logs.read.
Inputs: query, to_time, group_by, from_time, +2 more.
check_connectionARead-only
Show the active configuration (no secrets) and probe which token scopes work.
Inputs: no named parameters.
debug_serviceARead-only
Debug a service: failure rate, request volume and response time (baseline vs recent), failure logs of its process groups grouped by signature, recent deployments/config changes, problems in the window, and callers/callees.
Inputs: service (required), to_time, from_time, log_limit, +2 more.
find_entity_by_nameBRead-only
Find entities by display name (exact first, then contains).
Inputs: name (required), entity_type.
get_entityCRead-only
Entity details: properties, tags, management zones and relationships (calls, runsOn, ...).
Inputs: entity_id (required), to_time, from_time, include_relationships.
get_eventBRead-only
One event with all properties (GET /api/v2/events/{id}).
Inputs: event_id (required).
get_metric_descriptorBRead-only
Full descriptor of one metric: unit, dimensions, aggregations, transformations.
Inputs: metric_key (required).
get_problemBRead-only
Problem details: status, root-cause entity, root-cause evidence, impacts, recent comments.
Inputs: problem_id (required).
get_problem_evidenceCRead-only
Evidence Dynatrace collected for a problem (events, metric change points, transactions).
Inputs: problem_id (required), limit, root_cause_only.
get_problem_impactCRead-only
Root cause, affected and impacted entities, and impact analysis (users, services, apps).
Inputs: problem_id (required).
get_security_problemBRead-only
One vulnerability with risk assessment, affected entities and remediation.
Inputs: security_problem_id (required).
get_sloCRead-only
One SLO with evaluated percentage, error budget and burn rate.
Inputs: slo_id (required), to_time, from_time.
get_trace_logsBRead-only
Log lines for one distributed trace / PurePath. Classic API v2 has no trace endpoint.
Inputs: trace_id (required), to_time, attribute, from_time.
investigate_problemARead-only
One-shot RCA: correlates the problem's root-cause entity and evidence, change events (deployments, config, restarts) before the start, error logs in the problem window grouped by signature, and key metrics before vs during. Returns findings, a Markdown summary and next steps.
Inputs: problem_id (required), log_limit, log_filter, lookback_minutes.
list_eventsBRead-only
List events (deployments, config changes, restarts, anomalies). Needs events.read.
Inputs: to_time, from_time, page_size, next_page_key, +2 more.
list_metricsBRead-only
Find metric keys and their units and dimensions (GET /api/v2/metrics).
Inputs: text, page_size, next_page_key, metric_selector.
list_problem_commentsCRead-only
Comments on a problem (GET /api/v2/problems/{id}/comments).
Inputs: problem_id (required), page_size, next_page_key.
list_problemsBRead-only
List problems (GET /api/v2/problems). Needs problems.read.
Inputs: sort, to_time, from_time, page_size, +3 more.
list_security_problemsBRead-only
List vulnerabilities (GET /api/v2/securityProblems). Needs securityProblems.read.
Inputs: sort, to_time, selector, from_time, +2 more.
list_slosBRead-only
List SLOs with status and error budget (GET /api/v2/slo). Needs slo.read.
Inputs: to_time, evaluate, from_time, page_size, +2 more.
query_metricsARead-only
Query metric data (GET /api/v2/metrics/query) with per-series min/max/avg/last. Needs metrics.read.
Inputs: metric_selector (required), to_time, from_time, resolution, +3 more.
search_entitiesBRead-only
Search monitored entities by selector (GET /api/v2/entities). Needs entities.read.
Inputs: entity_selector (required), fields, to_time, from_time, +2 more.
search_logsBRead-only
Search log records (GET /api/v2/logs/search). Needs scope logs.read.
Inputs: sort, limit, query, to_time, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 23 tools
Most tools target a clearly distinct resource+action (logs vs events vs metrics vs entities vs SLOs vs security problems), and pairs like list_metrics/get_metric_descriptor and search_entities/find_entity_by_name are separable from their descriptions. The main fuzziness is within the problem cluster: get_problem already claims to return root-cause evidence and impacts, which overlaps with get_problem_evidence and get_problem_impact, and investigate_problem/debug_service are both RCA-style aggregators that an agent could pick between imprecisely.
Every tool is snake_case verb_noun (list_problems, get_problem_impact, query_metrics, check_connection), including the more elaborate ones like find_entity_by_name and investigate_problem. No camelCase or bare-noun outliers, so the pattern is fully predictable.
23 tools is on the heavy side of the 3-15 sweet spot, but Dynatrace is a broad platform (logs, events, problems, metrics, entities, SLOs, security) and each resource gets a small, coherent list/get pair plus a few aggregate helpers, so nothing looks like pure filler. It is slightly over-scoped rather than bloated.
Read-side coverage is strong and consistent: list/get pairs for problems, events, entities, SLOs, security problems, metrics, plus log search/aggregate and RCA helpers like investigate_problem and debug_service. Gaps are minor but real: there is list_problem_comments with no create-comment/mute/close operation, and no trace listing or trace metadata lookup beyond get_trace_logs, which blocks a few lifecycle workflows.
Related MCP Connectors
Lets AI agents analyze API metrics, request logs, and traces, and manage apps and alerts.
Open-source agent that observes and fixes your application. Query logs, traces, metrics, incidents.
Query your AI agent traces, root-cause verdicts and issues, and run investigations, from your agent.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Related MCP Servers
- AlicenseAqualityBmaintenanceEnables AI assistants to interact with self-hosted Dynatrace Managed environments to retrieve observability data, security insights, and performance metrics. It allows users to query problems, logs, events, and SLOs through natural language interfaces in both local and remote modes.18571 npm35Apache 2.0
- AlicenseBqualityCmaintenanceEnables LLM agents to query Dynatrace SaaS for observability data (logs, metrics, traces, entities, problems, vulnerabilities) and manage configurations (dashboards, notebooks, SLOs, synthetic monitors, settings).100MIT
- AlicenseNot gradedqualityNot gradedmaintenanceQuery Grafana logs, metrics, and dashboards from Cursor. Enables the AI to call your Grafana instance via tools without leaving the editor.4Apache 2.0
- FlicenseNot gradedqualityDmaintenanceEnables interaction with Dynatrace Grail and API endpoints by executing DQL queries, retrieving logs, reporting active problems, and querying metrics.-