Skip to content

Commit 913f767

Browse files
fix: Fixed an issue with MCP communication failing due to dotenv.
1 parent ea9fbb1 commit 913f767

File tree

7 files changed

+32
-8
lines changed

7 files changed

+32
-8
lines changed

.dt-mcp/token.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"access_token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjEifQ.eyJzdWIiOiJiMzJiY2Y0Ni03NWU2LTRkMGQtYTg0MS02MWMyN2NmNmQ1YTYiLCJfY2xhaW1fbmFtZXMiOnsiZ3JvdXBzIjoiMCJ9LCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJjaHJpc3RpYW4ua3JldXpiZXJnZXJAZHluYXRyYWNlLmNvbSIsImd0IjoiYWMiLCJpbnQiOnRydWUsImNzIjoiSDRzSUFBQUFBQUFBLzBzc0tOQk56VXZQekV1MVNpdk5TeTdKek04cnRpb3F6Vk5JUkVnQW1XQXhBTXlQWWVVc0FBQUEiLCJhdWQiOiJkdDBzMDguZHQtYXBwLWxvY2FsIiwic2NvcGUiOiIiLCJfY2xhaW1fc291cmNlcyI6eyIwIjp7ImVuZHBvaW50IjpudWxsfX0sImV4cCI6MTc1ODcxODgzMywiaWF0IjoxNzU4NzE4NTMzLCJqdGkiOiIxMTkyY2U2Yi0xYWYzLTRjODYtYjkzMi01MjFjZWQ0NDQwYjEiLCJlbWFpbCI6ImNocmlzdGlhbi5rcmV1emJlcmdlckBkeW5hdHJhY2UuY29tIn0.vP0bbMyW2i7KsUEnZltdxHhu2_EN2D0gLBTleSyVmeATI1Gn_wsRnnlk1avmFDev-JE5f1MXV_jlETwe3T0upg",
3+
"refresh_token": "dt0s06.9e0479f5-6321-4066-8088-be1a6d43884f",
4+
"expires_at": 1758718834936,
5+
"scopes": ["app-engine:apps:run", "app-engine:functions:run"]
6+
}

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# @dynatrace-oss/dynatrace-mcp-server
22

3-
## Unreleased Changes
3+
## 0.6.1
4+
5+
- Fixed an issue with MCP communication failing with `SyntaxError: Unexpected token 'd'` due to `dotenv`
6+
- Added Support for Google Gemini CLI
47

58
## 0.6.0
69

gemini-extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dynatrace-mcp-server",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"mcpServers": {
55
"dynatrace": {
66
"command": "npx",

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dynatrace-oss/dynatrace-mcp-server",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"mcpName": "io.github.dynatrace-oss/Dynatrace-mcp",
55
"description": "Model Context Protocol (MCP) server for Dynatrace",
66
"keywords": [

server.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
"url": "https://github.com/dynatrace-oss/Dynatrace-mcp",
88
"source": "github"
99
},
10-
"version": "0.6.0",
10+
"version": "0.6.1",
1111
"packages": [
1212
{
1313
"registry_type": "npm",
1414
"registry_base_url": "https://registry.npmjs.org",
1515
"identifier": "@dynatrace-oss/dynatrace-mcp-server",
16-
"version": "0.6.0",
16+
"version": "0.6.1",
1717
"runtime_hint": "npx",
1818
"transport": {
1919
"type": "stdio"

src/index.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,22 @@ import { Http2ServerRequest } from 'node:http2';
4949
import { resetGrailBudgetTracker, getGrailBudgetTracker } from './utils/grail-budget-tracker';
5050
import { read } from 'node:fs';
5151

52-
config();
52+
// Load environment variables from .env file if available, and suppress warnings/logging to stdio
53+
// as it breaks MCP communication when using stdio transport
54+
const dotEnvOutput = config({ quiet: true });
55+
56+
if (dotEnvOutput.error) {
57+
// Only log error if it's not about missing .env file
58+
if ((dotEnvOutput.error as NodeJS.ErrnoException).code !== 'ENOENT') {
59+
console.error('Error loading .env file:', dotEnvOutput.error);
60+
process.exit(1);
61+
}
62+
} else {
63+
// Successfully loaded .env file
64+
console.error(
65+
`.env file loaded successfully - loaded ${dotEnvOutput.parsed ? Object.keys(dotEnvOutput.parsed).length : 0} environment variables: ${Object.keys(dotEnvOutput.parsed || {}).join(', ')}`,
66+
);
67+
}
5368

5469
let scopesBase = [
5570
'app-engine:apps:run', // needed for environmentInformationClient

0 commit comments

Comments
 (0)