Skip to content

[DO NOT MERGE] Multienvironment update#3

Open
aledsage wants to merge 20 commits into
mainfrom
multienvironment-update
Open

[DO NOT MERGE] Multienvironment update#3
aledsage wants to merge 20 commits into
mainfrom
multienvironment-update

Conversation

@aledsage

@aledsage aledsage commented Jan 23, 2026

Copy link
Copy Markdown
Member

// This is for review only; do not merge here. When we are ready, we will create PR against the true upstream repo (github.com/dynatrace-oss/dynatrace-managed-mcp).

Note/tip: when comparing the files changed, add ?w=1 at the end of the URL. That tells it to ignore white space. This is very useful for reviewing the code changes, especially for things like formatList methods where we have an additional loop around the code, so indents have changed without actually changing the original code. (Let's include that tip when we open the PR against the real dynatrace-oss repo)

Pedro [C] Perez and others added 11 commits January 16, 2026 11:56
- Added ManagedAuthClientManager, used as a wrapper to handle several environments.
- environment.ts updated to use new JSON array data structure.
- Updated all APIs to use ManagedAuthClientManager wrapper functions.
- formatResponse functions updated to handle several data sources
- Minimal updates to instructions for LLM. More to do here
…ynatrace envs.

- Refactored all related functions that would make use of it
- Added checks in environment.ts to validate environments configuration before checking connections.
- Added tool for LLM so it can query environment setting diagnostics.
- `environment_alias` is now a required field. LLM will have to pass always one value to this tool param.
- Reworked environment.test.ts to touch more cases with the new multienvironment approach.
- Fixed 2 out of 4 integrations test files (working on those other 2)
- Fixed getEntityRelationships to return expected response structure
- Fixed ManagedAuthClient to instance proxy data on creation
- Removed 'dynatraceUrl' from required configuration fields.
- Updated .env.template
- Auto formatting of some files
- Added "dotenv/config" to jest configuration to read from .env file during integration tests
- Replaced usage of arrays in favor of Map<string, TypeInterface> for handling responses
- Updated unit and integration tests to work with the new approach
- Removed unused symbols
…own.

- Added flushLogger() call on shutdownHandler to avoid potentially missing log information on process.exit()
Updating README for multi-env, plus spelling/grammar/syntax/formatting
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
@aledsage

Copy link
Copy Markdown
Member Author

Can we add a few lines to the readme about reload/refresh, for when the environment config has been changed (e.g. someone edits the mcp.json file). Ivan asked in dynatrace-oss#16 for:

-- Hot reload/restart behavior is documented (e.g., edits require restart vs dynamic reload).

@aledsage

Copy link
Copy Markdown
Member Author

For Ivan's github issue, can you check what behaviour he wanted if we could not connect to any of the environments?
I interpret it as we should fail to start the MCP if we cannot connect to any of the environments.
However, if one env has a valid-looking config, but we get a connection failure, then we still start up.
For example, try changing your apiEndpointUrl to this: "apiEndpointUrl": "https://WRONGexample.dynatrace-managed.com:1234",
dynatrace-oss#16

@aledsage

Copy link
Copy Markdown
Member Author

This branch says it has conflicts with main. Will it have conflicts with https://github.com/dynatrace-oss/dynatrace-mcp/ main branch? Will we need to rebase this?

@aledsage

Copy link
Copy Markdown
Member Author

The examples in docs/DEVELOPMENT.md still use DT_MANAGED_ENVIRONMENT. Can you update those as well please?

@aledsage

Copy link
Copy Markdown
Member Author

server.json still talks about DT_MANAGED_ENVIRONMENT - I think that's one of the files you mentioned on the call; can you update that as well please.

(Also worth grep'ing the entire repo for DT_MANAGED_ENVIRONMENT)

@aledsage

aledsage commented Jan 23, 2026

Copy link
Copy Markdown
Member Author

A couple of tests mention DT_MANAGED_ENVIRONMENTS. Can you update those as well.

@aledsage

Copy link
Copy Markdown
Member Author
grep -R -E "DT_API_ENDPOINT_URL|DT_DYNATRACE_URL|DT_MANAGED_API_TOKEN|DT_MANAGED_ENVIRONMENT" *

Gives:

dist/authentication/managed-auth-client.js:            logger_1.logger.error('1. DT_MANAGED_ENVIRONMENTS is correct');
docs/DEVELOPMENT.md:        "DT_MANAGED_ENVIRONMENT": "01234567-89ab-cdef-abcd-ef0123456789",
docs/DEVELOPMENT.md:        "DT_API_ENDPOINT_URL": "https://abc123.dynatrace-managed.example.com:9999",
docs/DEVELOPMENT.md:        "DT_DYNATRACE_URL": "https://dmz123.dynatrace-managed.example.com",
docs/DEVELOPMENT.md:        "DT_MANAGED_API_TOKEN": "dt0s16.SAMPLE.abcd1234",
docs/DEVELOPMENT.md:        "DT_MANAGED_ENVIRONMENT",
docs/DEVELOPMENT.md:        "DT_API_ENDPOINT_URL",
docs/DEVELOPMENT.md:        "DT_DYNATRACE_URL",
docs/DEVELOPMENT.md:        "DT_MANAGED_API_TOKEN",
docs/DEVELOPMENT.md:        "DT_MANAGED_ENVIRONMENT": "01234567-89ab-cdef-abcd-ef0123456789",
docs/DEVELOPMENT.md:        "DT_API_ENDPOINT_URL": "https://abc123.dynatrace-managed.example.com:9999",
docs/DEVELOPMENT.md:        "DT_DYNATRACE_URL": "https://dmz123.dynatrace-managed.example.com",
docs/DEVELOPMENT.md:        "DT_MANAGED_API_TOKEN": "dt0s16.SAMPLE.abcd1234"
README.md:  If not specified, will default to use the same value as `DT_API_ENDPOINT_URL`.
README.md:  If not specified, will default to use the same value as `DT_API_ENDPOINT_URL`.
server.json:          "name": "DT_MANAGED_ENVIRONMENT",
server.json:          "name": "DT_API_ENDPOINT_URL",
server.json:          "name": "DT_DYNATRACE_URL",
server.json:          "name": "DT_MANAGED_API_TOKEN",
src/utils/__tests__/environment.test.ts:  it('should throw error when DT_MANAGED_ENVIRONMENTS is missing', () => {
src/authentication/managed-auth-client.ts:      logger.error('1. DT_MANAGED_ENVIRONMENTS is correct');

Comment thread src/capabilities/entities-api.ts Outdated
Comment thread src/capabilities/entities-api.ts
Comment thread src/index.ts Outdated
Comment thread src/index.ts Outdated
Comment thread src/index.ts
logger.error(`2. DT_MANAGED_API_TOKEN has required scopes: ${MANAGED_API_SCOPES.join(', ')}`);
logger.error('3. Network connectivity to the Managed cluster');

process.exit(2);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous behaviour was that if we could not connect then we would quit / fail-fast. So I think it makes sense to keep that behaviour (if we can't connect to any of the environment then we quit). I'll ask Ivan for confirmation though.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting on input for make any changes related to this (if necessary)

Comment thread src/index.ts Outdated
Pedro [C] Perez and others added 2 commits January 23, 2026 12:15
…make clear where the data is coming from.

- MINIMUM_VERSION added to ManagedAuthClientManager. Added to instructions.
- Removed old references to non-existing env vars.
- Small changes to LLM instructions.
- README.md and DEVELOPMENT.md changes for easier reading.
@pedroperezcs

Copy link
Copy Markdown

This branch says it has conflicts with main. Will it have conflicts with https://github.com/dynatrace-oss/dynatrace-mcp/ main branch? Will we need to rebase this?

It was a one-liner conflict in the README.md file. Solved.

Pedro [C] Perez and others added 6 commits January 23, 2026 14:46
- Rephrased instructions so LLMs don't skip call to get_environments_info.
- Added instructions for the LLM to return URLs from responses to the user
- Added auxiliary method to ManagedAuthClientManager
- Updated tests
- Avoid confusion of calling SaaS a "Dynatrace enviornment" etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants