Try it free

Dynatrace MCP server

  • Latest Dynatrace
  • Overview
  • 5-min read

This page provides an overview of the Dynatrace Model Context Protocol (MCP) server and how you can use it to maximize your efficiency and quickly complete a variety of tasks, such as generating, executing or explaining a DQL query, with the help of an MCP client (external agent).

Currently, the MCP server supports the following use cases:

  • Generating a DQL query with generative AI
  • Explaining a DQL query with generative AI
  • Using generative AI to quickly answer product-related questions
  • Running a generated DQL query
  • Investigating problems and vulnerabilities
  • Analyzing Kubernetes events
  • Forecasting and analyzing timeseries data
  • Finding documents and troubleshooting guides
  • Resolving entity names and IDs

What is MCP?

The Dynatrace MCP server is a server that hosts tools that can be used to fulfill specific use cases. An external agent, such as GitHub CoPilot VS Code integration or Claude desktop, can then make use of the MCP server and its tools to execute a series of calls when fulfilling a user request.

To learn more about MCP servers, see What is the Model Context Protocol (MCP)?.

Server and server tools

Dynatrace provides a dynatrace-mcp server that hosts a collection of tools designed for external connections. It currently hosts the following tools:

Connect to the MCP server

You can connect to an MCP server via a URL by using the following address:

https://{environment-name}.apps.dynatrace.com/platform-reserved/mcp-gateway/v0.1/servers/dynatrace-mcp/mcp

You can setup connections by using VS Code and its chat integration, or by using any other tool of your choice.

Prepare authentication

Every request to the MCP server needs a bearer token in the authorization header. You can authenticate in one of the following ways:

  • Provide a bearer token directly—obtain a token from a Platform token or an OAuth client and add it to the authorization header in your configuration. We recommend Platform tokens, because a token generated from an OAuth client is short-lived.
  • Authenticate via an OAuth client—create a confidential OAuth client with the Authorization Code grant type, configure it with the required scopes, and provide only the server URL in your MCP client configuration. An MCP client like VS Code handles the OAuth 2.0 Authorization Code flow and obtains the bearer token for you. For more information, see Authorization code flow. While generating a token from an OAuth client means that you have to manually refresh tokens each time they expire, creating and using an OAuth client with a client secret allows you to automate token refreshing.

The MCP server doesn't support CIMD, public OAuth clients, or dynamic client registration yet. To authenticate via an OAuth client, you must use a confidential OAuth client and provide both its client ID and client secret to your MCP client. The client secret is required so that your MCP client can refresh the access token automatically—without it, the token expires and the connection breaks. For more information, see Authorization code flow.

Regardless of the authentication method, the bearer token works only within the scope of your user permissions. To use the Dynatrace MCP server, you need to have all of the necessary permissions. For more information, see Platform tokens or OAuth clients, depending on the type of authentication you use.

Get MCP-related permissions

In addition to the tool permissions mentioned in Server and server tools, both the user and the token must have the following permissions to access and invoke server tools:

  • mcp-gateway:servers:invoke
  • mcp-gateway:servers:read

Permissions for OAuth client authentication

If you're using an OAuth client to authenticate, the effective token permissions consist of the intersection of the permissions configured on the OAuth client and the permissions of the user who created the client. To ensure access to all MCP tools, configure the OAuth client with the following permissions:

  • ai:operator:execute
  • mcp-gateway:servers:invoke
  • mcp-gateway:servers:read
  • davis-copilot:conversations:execute
  • davis-copilot:nl2dql:execute
  • davis-copilot:document-search:execute
  • davis-copilot:dql2nl:execute
  • davis:analyzers:read
  • davis:analyzers:execute
  • document:documents:read
  • storage:bizevents:read
  • storage:buckets:read
  • storage:system:read
  • storage:spans:read
  • storage:entities:read
  • storage:user.events:read
  • storage:user.sessions:read
  • storage:user.replays:read
  • storage:smartscape:read
  • storage:events:read
  • storage:metrics:read
  • storage:logs:read
  • storage:files:read
  • storage:security.events:read

For more information, see OAuth clients.

Use the Dynatrace MCP server in Visual Studio Code

You can connect the Dynatrace MCP server to VS Code by using the MCP client support available through GitHub Copilot Chat or any MCP‑enabled extension. Additionally, you need to set up authentication, configure VS Code, and validate the setup.

To set up a proper configuration and connect the Dynatrace MCP server to the VS Code, follow the steps below:

1. Configure VS Code to use the Dynatrace MCP server

To configure VS Code for using Dynatrace MCP server:

  1. Open your workspace in VS Code.

  2. In the .vscode folder, create or open mcp.json file in your project. The resulting path should look like this: .vscode/mcp.json.

  3. Add an MCP server configuration. The configuration depends on how you want to authenticate.

    When you authenticate with a bearer token, VS Code doesn't automatically refresh it. After the token expires, you need to generate a new one and update your configuration accordingly. When you authenticate via an OAuth client and provide both the client ID and client secret, VS Code refreshes the access token automatically.

    Add a configuration similar to the one below, providing the bearer token in the authorization header:

    {
    "servers": {
    "dynatrace-mcp": {
    "url": "https://{environment-name}.apps.dynatrace.com/platform-reserved/mcp-gateway/v0.1/servers/dynatrace-mcp/mcp",
    "headers": {
    "Authorization": "Bearer YOUR_BEARER_TOKEN_HERE"
    }
    }
    }
    }

    Replace:

    • {environment-name} with your Dynatrace environment identifier.
    • YOUR_BEARER_TOKEN_HERE with the token you generated, either via Platform token or an OAuth client.

    Add a configuration with only the server URL—don't add an authorization header:

    {
    "servers": {
    "dynatrace-mcp": {
    "url": "https://{environment-name}.apps.dynatrace.com/platform-reserved/mcp-gateway/v0.1/servers/dynatrace-mcp/mcp"
    }
    }
    }

    Replace {environment-name} with your Dynatrace environment identifier.

    When you start the server, VS Code prompts you to enter your OAuth client ID and client secret into the command palette. VS Code requires the client secret to refresh the access token automatically, so you need to provide both values. If you don't provide the client secret, the connection breaks after the token expires, and you have to refresh the token manually.

    We recommend using a confidential OAuth client created with the Authorization Code grant type and ensuring that it includes all required MCP scopes. To learn more about the Authorization Code grant type, see Authorization code flow.

  4. Save your file changes.

  5. Select Start above the server name. If you configured an OAuth client, enter your client ID and client secret when VS Code prompts you.

For a more detailed guide on how to set up a VS Code configuration, see the official Visual Studio Code guide.

2. Verify the setup

To confirm the connection works:

  1. Open Copilot Chat in VS Code.
  2. Use ctrl+# to open the list of contexts.
  3. Select Tools.
  4. Find and select dynatrace-mcp (All tools).
  5. Enter the following prompt: Show me last 10 logs.

    Ensure that both the user and the token have the storage:logs:read permission. Otherwise, you won't be able to see any logs.

  6. Run the prompt.

If your configuration is correct, you will receive a response from the Dynatrace MCP server.

Related topics

  • Dynatrace Intelligence agentic and generative AI overview
  • Dynatrace Assist
Related tags
Dynatrace Platform