A comprehensive Model Context Protocol server for Dynatrace Managed environments
- Features
- Installation
- Configuration
- Available Tools
- OpenTelemetry Integration
- Prompt Guides
- Development
- API Token Permissions
- Troubleshooting
- Authors
- Contributing
- Support
- 39 comprehensive tools covering the complete Dynatrace API
- Enterprise-grade error handling
- Request tracking with UUID
- Automatic retry logic
- Built-in OpenTelemetry tracing
- Parent-child span relationships
- Performance metrics
- Error tracking with stack traces
- Raw JSON responses for LLM interpretation
- No pre-formatting - let AI handle presentation
- Future-proof API field support
- Universal client compatibility
- API token authentication
- Secure credential handling
- Configurable timeouts
- Comprehensive logging
npm install -g @theharithsa/dynatrace-managed-mcp-servergit clone https://github.com/theharithsa/Dynatrace-Managed-MCP.git
cd Dynatrace-Managed-MCP
npm install
npm run build| Variable | Description | Example |
|---|---|---|
DYNATRACE_MANAGED_URL |
Your Dynatrace Managed cluster URL | https://your-cluster.dynatrace.com |
DYNATRACE_ENVIRONMENT_ID |
Environment ID (UUID format) | c08a8ab3-83c9-4efe-8903-73ed21722e70 |
DYNATRACE_API_TOKEN |
API token with required permissions | dt0c01.XXXXX.YYYYY |
| Variable | Default | Description |
|---|---|---|
REQUEST_TIMEOUT |
30000 |
HTTP request timeout (ms) |
MAX_RETRIES |
3 |
Retry attempts for failed requests |
LOG_LEVEL |
info |
Logging level (debug, info, warn, error) |
| Variable | Description |
|---|---|
OTEL_EXPORTER_OTLP_ENDPOINT |
OTLP endpoint URL |
OTEL_EXPORTER_OTLP_HEADERS |
Auth headers for OTLP |
OTEL_RESOURCE_ATTRIBUTES |
Service metadata |
OTEL_TRACES_EXPORTER |
Set to otlp to enable |
OTEL_EXPORTER_OTLP_TRACES_PROTOCOL |
http/protobuf or grpc |
Create .vscode/mcp.json in your workspace:
{
"servers": {
"dynatrace-managed": {
"command": "npx",
"args": ["@theharithsa/dynatrace-managed-mcp-server"],
"env": {
"DYNATRACE_MANAGED_URL": "https://your-cluster.dynatrace.com",
"DYNATRACE_ENVIRONMENT_ID": "your-environment-id",
"DYNATRACE_API_TOKEN": "dt0c01.xxxxx"
}
}
}
}| Platform | Config File Location |
|---|---|
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
{
"mcpServers": {
"dynatrace-managed": {
"command": "npx",
"args": ["@theharithsa/dynatrace-managed-mcp-server"],
"env": {
"DYNATRACE_MANAGED_URL": "https://your-cluster.dynatrace.com",
"DYNATRACE_ENVIRONMENT_ID": "your-environment-id",
"DYNATRACE_API_TOKEN": "dt0c01.xxxxx"
}
}
}
}{
"mcpServers": {
"dynatrace-managed": {
"command": "npx",
"args": ["@theharithsa/dynatrace-managed-mcp-server"],
"env": {
"DYNATRACE_MANAGED_URL": "https://your-cluster.dynatrace.com",
"DYNATRACE_ENVIRONMENT_ID": "your-environment-id",
"DYNATRACE_API_TOKEN": "dt0c01.xxxxx",
"REQUEST_TIMEOUT": "30000",
"MAX_RETRIES": "3",
"LOG_LEVEL": "info",
"OTEL_EXPORTER_OTLP_ENDPOINT": "https://your-tenant.live.dynatrace.com/api/v2/otlp/v1/traces",
"OTEL_EXPORTER_OTLP_HEADERS": "Authorization=Api-Token dt0c01.xxxxx",
"OTEL_RESOURCE_ATTRIBUTES": "service.name=mcp-server,service.version=1.0.0",
"OTEL_TRACES_EXPORTER": "otlp",
"OTEL_EXPORTER_OTLP_TRACES_PROTOCOL": "http/protobuf"
}
}
}
}| Tool | Description |
|---|---|
list_problems |
List problems with filtering, time range, and pagination |
get_problem |
Get detailed problem information including root cause |
close_problem |
Close a problem with an optional message |
add_comment |
Add a comment to a problem |
list_comments |
List all comments on a problem |
get_comment |
Get a specific comment by ID |
update_comment |
Update an existing comment |
delete_comment |
Delete a comment from a problem |
| Tool | Description |
|---|---|
list_metrics |
List available metrics with filtering |
get_metric |
Get metric descriptor and metadata |
query_metrics |
Query metric data points with selectors |
ingest_metrics |
Ingest custom metrics data |
delete_metric |
Delete a custom metric |
list_units |
List available measurement units |
| Tool | Description |
|---|---|
list_entities |
List monitored entities with filtering |
get_entity |
Get detailed entity information |
list_entity_types |
List available entity types |
get_entity_type |
Get entity type schema |
create_custom_device |
Create a custom device entity |
| Tool | Description |
|---|---|
list_events |
List events with filtering |
get_event |
Get event details |
ingest_event |
Send custom events |
list_event_types |
List available event types |
get_event_type |
Get event type schema |
list_event_properties |
List event properties |
get_event_property |
Get event property details |
| Category | Tools |
|---|---|
| Tags | list_tags - add_tags - delete_tags |
| Audit | list_audit_logs - get_audit_log |
| Security | list_vulnerabilities - get_vulnerability_details |
| Discovery | find_monitored_entity_by_name - get_monitored_entity_details - list_monitoring_states |
| Environment | get_unit - get_logs_for_entity - get_events_for_cluster |
This server includes built-in OpenTelemetry instrumentation using @theharithsa/opentelemetry-instrumentation-mcp.
| Feature | Description |
|---|---|
| Automatic Tracing | Every tool call is automatically traced |
| Parent-Child Spans | Full distributed trace context propagation |
| Performance Metrics | Timing and success/failure tracking |
| Error Tracking | Exceptions captured with full stack traces |
| Dynatrace Native | Direct OTLP export to Dynatrace |
| Attribute | Description |
|---|---|
mcp.tool.name |
Tool being executed |
mcp.tool.arguments |
Input parameters |
mcp.tool.result |
Execution result |
dynatrace.environment_id |
Target environment |
Detailed guides for crafting effective prompts are available in the dynatrace-agent-rules/ folder:
| Guide | Description |
|---|---|
| Problems | Problem management prompts |
| Metrics | Metrics query prompts |
| Entities | Entity management prompts |
| Events | Event handling prompts |
| Audit Logs | Audit log prompts |
| Tags | Tag management prompts |
| Vulnerabilities | Security prompts |
- Node.js 18+
- npm 9+
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run tests
npm test- Create a new file in
src/capabilities/ - Follow the existing Zod schema pattern
- Register in
src/index.ts - Add tests in
test/
Create an API token with these scopes:
| Scope | Purpose |
|---|---|
problems.read |
Read problems |
problems.write |
Close problems, add comments |
metrics.read |
Query metrics |
metrics.write |
Ingest metrics |
entities.read |
Read entities |
entities.write |
Create custom devices |
events.read |
Read events |
events.ingest |
Send custom events |
auditLogs.read |
Read audit logs |
securityProblems.read |
Read vulnerabilities |
# Test connectivity
curl -H "Authorization: Api-Token YOUR_TOKEN" \
"https://YOUR_CLUSTER/e/YOUR_ENV/api/v2/problems"# Enable verbose logging
DEBUG=mcp:* npm start| Error | Solution |
|---|---|
401 Unauthorized |
Check API token permissions |
404 Not Found |
Verify environment ID and URL |
ECONNREFUSED |
Check network/firewall settings |
If you encounter 'dynatrace-managed-mcp-server' is not recognized as an internal or external command when running npx @theharithsa/dynatrace-managed-mcp-server, the npm global bin folder may not be in your PATH.
Solution:
-
Add the npm global bin folder to your PATH:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Users\<username>\AppData\Roaming\npm", [EnvironmentVariableTarget]::User)
-
Restart VS Code or your terminal for the PATH change to take effect.
-
Verify the installation:
npx @theharithsa/dynatrace-managed-mcp-server --help
If you've installed the package globally, you can run it directly:
npm install -g @theharithsa/dynatrace-managed-mcp-server
dynatrace-managed-mcp-server --help- Vishruth Harithsa - @theharithsa
- Mithun Gangadharaiah - @mithungangadharaiah
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
- Issues: GitHub Issues
- Discussions: GitHub Discussions
This project is licensed under the MIT License.
Made with ❤️ for the Dynatrace community