Sponsored by Deepsite.site

TalkO11yToMe: Learning MCP Servers with Dynatrace Integration

Created By
chiefnamingofficera year ago
Learning what it means to use MCP by trying to interact with Dynatrace MCP server.
Content

TalkO11yToMe: Learning MCP Servers with Dynatrace Integration

Welcome to your MCP (Model Context Protocol) learning journey! This project will help you understand MCP servers, their use cases, and specifically how to integrate with Dynatrace tenants for powerful observability-driven AI workflows.

🎉 PROJECT STATUS: FULLY OPERATIONAL

All 6 Dynatrace tools are now production-ready with:

  • Standardized Configuration: Shared dotenv-based config eliminates 200+ lines of duplicate code
  • DQL Query Polling: Proper handling of async query execution (202 → poll → results)
  • OAuth Authentication: Working across all tools with 5-minute bearer tokens
  • Real Data Retrieval: Successfully finding production problems, logs, and metrics
  • Clean Architecture: lib/ vs tools/ separation for maintainability

📊 Code Quality Improvements:

  • Before: 40+ lines of environment parsing per tool × 6 tools = 240+ lines
  • After: 6 lines using shared config × 6 tools = 36 lines
  • Eliminated: 204+ lines of duplicate code with enhanced validation

🚨 IMPORTANT: Grail vs Classic Environment Support

Your Dynatrace environment type determines which tools and configuration you need:

  • URL Pattern: https://xxx.apps.dynatrace.com
  • Authentication: OAuth Bearer tokens required
  • API Endpoints: /platform/classic/environment-api/v2/
  • Primary Tool: grail-log-query.jsProduction Ready
  • MCP Server: ✅ Ready to Build - Complete Design Available

🏛️ Classic Environment (Legacy Platform)

  • URL Pattern: https://xxx.live.dynatrace.com
  • Authentication: API tokens OR OAuth
  • API Endpoints: /api/v2/
  • Primary Tool: classic-log-query.jsProduction Ready
  • MCP Server: ✅ Ready to Build - Complete Design Available

📖 See Environment Detection Guide below for setup details.


📁 Project Structure

TalkO11yToMe/
├── lib/                    # 🔧 Shared Infrastructure
│   ├── config.js          #    → Standardized dotenv configuration
│   └── demo-dotenv.js     #    → Configuration demonstration
├── tools/                  # 🚀 Production Tools (6 tools)
│   ├── grail-log-query.js        #    → Primary tool for Grail environments
│   ├── grail-business-analytics.js #  → DQL and business events (Grail)
│   ├── classic-log-query.js      #    → Primary tool for Classic environments
│   ├── classic-api-client.js     #    → Comprehensive API client (both)
│   ├── dynatrace-oauth-tool.js   #    → Authentication testing
│   └── dynatrace-monitor.js      #    → Visual monitoring dashboard
├── tests/                  # 🧪 Comprehensive Test Suite
│   ├── test-suite.js      #    → Main test runner with 8 validation tests
│   ├── test-config.js     #    → Test configuration and scenarios
│   ├── test-history.js    #    → Test history tracking and analysis
│   ├── results/           #    → Organized timestamped test results
│   └── README.md          #    → Complete testing documentation
├── docs/                   # 📚 Documentation
│   ├── FIXES_SUMMARY.md          #    → Complete technical solution summary
│   ├── TOOLS_GUIDE.md            #    → Detailed tool usage and examples
│   ├── DYNATRACE_LOGS_SOLUTION.md #  → Environment setup guide
│   └── [additional guides...]
└── env/                    # 🔐 Environment Configuration
    └── .env.dev                  #    → Your Dynatrace credentials

📚 Documentation

Quick Reference

Key Sections

  1. What is MCP?
  2. Understanding MCP Architecture
  3. Dynatrace MCP Server
  4. Setup Instructions
  5. Environment Detection
  6. Quick Start Demo
  7. Real-World Use Cases
  8. Resources
  9. Project Roadmap

🤖 What is MCP?

The Model Context Protocol (MCP) is an open standard that enables AI systems (like Claude, Cursor, VS Code Copilot) to securely connect to the tools and data your business already uses. Think of it as a "universal adapter" for AI.

Key Benefits:

  • Standardized Integration: No more custom integrations for each AI tool
  • Secure Data Access: Controlled access to your systems
  • Real-time Context: AI gets up-to-date information from your production systems
  • Extensible: Easy to add new capabilities and data sources

🏗️ Understanding MCP Architecture

MCP consists of three main components:

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│    Host     │◄───┤   Client    │◄───┤   Server    │
│ (AI Agent)  │    │(Translator) │    │ (Data/Tool) │
└─────────────┘    └─────────────┘    └─────────────┘
  • Host: Your AI application (Claude Desktop, VS Code, etc.)
  • Client: Handles communication and translates requests
  • Server: Provides specific functionality (Dynatrace data, file access, APIs, etc.)

MCP Features:

  1. Tools: Functions that AI can call (query metrics, create alerts, etc.)
  2. Resources: Data sources AI can read (logs, dashboards, configurations)
  3. Prompts: Templates for common AI interactions

🔍 Dynatrace MCP Server

The official Dynatrace MCP server enables AI assistants to interact with your Dynatrace environment for real-time observability insights.

Capabilities:

  • Problem Management: List and analyze production problems
  • Security Issues: Access vulnerability and security problem details
  • DQL Queries: Execute Dynatrace Query Language for logs and events
  • Slack Integration: Send alerts via Slack connectors
  • Workflow Automation: Set up notification workflows
  • Entity Ownership: Get ownership information for services

Use Cases:

  • Real-time Debugging: Get production context while coding
  • Incident Response: AI-assisted troubleshooting with live data
  • Security Analysis: Correlate code vulnerabilities with production issues
  • Performance Optimization: Query metrics and logs in natural language

🚀 Setup Instructions

Prerequisites

  • Node.js 18+ (we use v20.19.2 LTS)
  • Access to Dynatrace tenant(s)
  • Dynatrace API token OR OAuth client credentials
  • AI client (Cursor IDE recommended)

Environment Configuration

  1. Copy the environment template:
cp env/env.template env/.env.dev
  1. Edit env/.env.dev with your credentials:
# Dynatrace Environment
DT_ENVIRONMENT=https://your-environment-id.live.dynatrace.com

# API Token (simpler setup)
API_TOKEN=dt0c01.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY

# OAuth (optional - for official MCP server)
OAUTH_CLIENT_ID=dt0s02.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
OAUTH_CLIENT_SECRET=dt0s02.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.YYYYYYYYYYYYYYYYYYYYYYYYYYYY
OAUTH_RESOURCE_URN=urn:dynatrace:environment:your-environment-id
  1. Test your configuration:
# Test shared configuration
node lib/demo-dotenv.js

# Verify tools work
node tools/dynatrace-monitor.js

# Run comprehensive test suite
node tests/test-suite.js

🔍 Environment Detection

Check your Dynatrace URL to determine your environment type:

Grail Environment Detection

https://xxx.apps.dynatrace.com  ← Contains ".apps."

→ Use: grail-log-query.js (OAuth required)

Classic Environment Detection

https://xxx.live.dynatrace.com  ← Contains ".live."

→ Use: classic-log-query.js (API token supported)

🎯 Quick Start Demo

For Grail Environments:

# Run primary tool for modern Dynatrace platforms
node tools/grail-log-query.js "error" now-2h

# Business analytics with DQL polling
node tools/grail-business-analytics.js query "fetch logs | limit 5"

# Visual monitoring dashboard
node tools/dynatrace-monitor.js

For Classic Environments:

# Run primary tool for legacy Dynatrace platforms
node tools/classic-log-query.js search "error" now-2h

# Comprehensive API client with auto-detection
node tools/classic-api-client.js problems 10

# Visual monitoring dashboard
node tools/dynatrace-monitor.js

🎯 Recent Testing Results:

  • 5 log records retrieved with rich metadata (scanned 418,085 records in 16ms)
  • 17 Lambda problems detected including high error rates and timeouts
  • OAuth tokens working with 5-minute bearer token lifecycle
  • DQL polling functional - proper 202 → poll → results workflow

📖 For detailed tool usage, see Tools Guide.

🎯 Real-World Use Cases

1. AI-Powered Incident Response

Use the AI Integration Demo to:

  • Analyze Lambda function errors automatically
  • Generate incident response priorities
  • Create security assessments
  • Design monitoring dashboards

2. Production Debugging Context

# Get context for coding session
node tools/dynatrace-monitor.js

# Search for specific errors with polling
node tools/grail-log-query.js "timeout" now-1h

3. Daily Health Monitoring

# Morning standup dashboard
node tools/dynatrace-monitor.js

# Lambda function health check
node tools/classic-api-client.js lambda-problems now-24h

📊 Architecture Improvements

Shared Configuration (lib/config.js)

Before: Each tool had 40+ lines of duplicate environment parsing After: Single shared config with dotenv standardization

// All tools now use this simple pattern:
const config = require('../lib/config');
const dt = await config.getDynatraceConfig();
// 6 lines replace 40+ lines of custom parsing

Benefits Achieved:

  • 204+ lines eliminated - Massive code reduction
  • Standardized error handling - Consistent across all tools
  • Environment validation - Automatic Grail vs Classic detection
  • Enhanced security - Proper credential masking in logs
  • Better maintainability - Single source of configuration truth

📚 Resources

Official MCP Resources:

Dynatrace MCP Integration:

Project Documentation:


🎉 Ready to get started? Check out the Tools Guide for comprehensive usage examples and best practices!

🧪 Test Suite

We've included a comprehensive test suite to validate all tools and infrastructure:

Quick Test Run

# Run all tests (takes ~8 seconds)
node tests/test-suite.js

What Gets Tested

  • File Structure: All 9 expected files present
  • Shared Configuration: Dotenv integration working
  • Authentication: OAuth token generation (5-minute lifecycle)
  • All 6 Tools: Grail, Classic, and Universal tools
  • Real Data Access: Production problems and logs
  • DQL Polling: Async query execution (202 → poll → results)

Expected Results

📊 TEST RESULTS SUMMARY
Total Tests: 8
✅ Passed: 8
❌ Failed: 0
📈 Success Rate: 100.0%

📋 See Test Suite Documentation for detailed usage and troubleshooting.


🚀 Project Roadmap

🎯 Current Status: Production Ready

All tools operational with comprehensive testing and organized structure. Ready for next phase enhancements.

📋 Upcoming Priorities

  1. 🌐 HTTP Improvements: Migrate from fetch to axios for better error handling and request interceptors
  2. 🤖 MCP Server Development: Build custom MCP server exposing tools as AI-accessible capabilities
  3. ⚡ Performance Optimization: Parallel testing, performance benchmarking, load testing

📚 Planning Documents

💡 Ideas & Contributions

The roadmap includes advanced features like:

  • Natural language querying ("Show me Lambda errors from the last hour")
  • Multi-environment support and comparison
  • Predictive analytics and anomaly detection
  • Integration with other observability platforms

📝 Contributing: Review the TODO.md for ways to contribute to future development

🎯 Focus Areas: HTTP improvements and MCP server development are immediate priorities**

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Serper MCP ServerA Serper MCP Server
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
DeepChatYour AI Partner on Desktop
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
ChatWiseThe second fastest AI chatbot™
CursorThe AI Code Editor
Amap Maps高德地图官方 MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
WindsurfThe new purpose-built IDE to harness magic
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Tavily Mcp
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。