Sponsored by Deepsite.site

TalkO11yToMe: Learning MCP Servers with Dynatrace Integration

Created By
chiefnamingofficer6 months 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.js โœ… Production 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.js โœ… Production 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.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Playwright McpPlaywright MCP server
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
CursorThe AI Code Editor
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"
Amap Maps้ซ˜ๅพทๅœฐๅ›พๅฎ˜ๆ–น MCP Server
Baidu Map็™พๅบฆๅœฐๅ›พๆ ธๅฟƒAPI็Žฐๅทฒๅ…จ้ขๅ…ผๅฎนMCPๅ่ฎฎ๏ผŒๆ˜ฏๅ›ฝๅ†…้ฆ–ๅฎถๅ…ผๅฎนMCPๅ่ฎฎ็š„ๅœฐๅ›พๆœๅŠกๅ•†ใ€‚
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbotโ„ข
WindsurfThe new purpose-built IDE to harness magic
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
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.
Serper MCP ServerA Serper MCP Server
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.
Tavily Mcp
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.