Skip to content

Commit 8af0f3c

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

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

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)