@energyatit/mcp-server 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +12 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,8 +8,9 @@ const BASE_URL = (process.env.ENERGYATIT_BASE_URL ??
|
|
|
8
8
|
"https://energyatit.com").replace(/\/$/, "");
|
|
9
9
|
const API_KEY = process.env.ENERGYATIT_API_KEY ?? "";
|
|
10
10
|
const TOKEN = process.env.ENERGYATIT_TOKEN ?? "";
|
|
11
|
+
const JOURNEY_TOKEN = process.env.ENERGYATIT_JOURNEY_TOKEN ?? "";
|
|
11
12
|
// ─── Demo Mode ──────────────────────────────────────────────────────────────
|
|
12
|
-
const demoMode = !API_KEY && !TOKEN;
|
|
13
|
+
const demoMode = !API_KEY && !TOKEN && !JOURNEY_TOKEN;
|
|
13
14
|
let sessionApiKey = "";
|
|
14
15
|
function authHeaders() {
|
|
15
16
|
const h = { "Content-Type": "application/json" };
|
|
@@ -17,6 +18,8 @@ function authHeaders() {
|
|
|
17
18
|
h["Authorization"] = `Bearer ${TOKEN}`;
|
|
18
19
|
else if (API_KEY)
|
|
19
20
|
h["X-API-Key"] = API_KEY;
|
|
21
|
+
else if (JOURNEY_TOKEN)
|
|
22
|
+
h["X-Journey-Token"] = JOURNEY_TOKEN;
|
|
20
23
|
else if (sessionApiKey)
|
|
21
24
|
h["X-API-Key"] = sessionApiKey;
|
|
22
25
|
return h;
|
|
@@ -138,7 +141,7 @@ function errorResult(err) {
|
|
|
138
141
|
// ─── MCP Server ────────────────────────────────────────────────────────────
|
|
139
142
|
const server = new McpServer({
|
|
140
143
|
name: "energyatit",
|
|
141
|
-
version: "0.2.
|
|
144
|
+
version: "0.2.1",
|
|
142
145
|
});
|
|
143
146
|
// ── Sites ────────────────────────────────────────────────────────────────
|
|
144
147
|
server.tool("list_sites", "List all energy sites in your tenant", {}, async () => {
|
|
@@ -556,17 +559,20 @@ server.resource("platform-overview", "energyatit://overview", async () => ({
|
|
|
556
559
|
" - Integrations: Modbus, OpenADR 2.0b, OCPP 2.0, IEC 61850",
|
|
557
560
|
"",
|
|
558
561
|
`Connected to: ${BASE_URL}`,
|
|
559
|
-
`Auth: ${TOKEN ? "JWT token" : API_KEY ? "API key" : demoMode ? "demo mode (public endpoints + auto-provision)" : "none"}`,
|
|
562
|
+
`Auth: ${TOKEN ? "JWT token" : API_KEY ? "API key" : JOURNEY_TOKEN ? "journey developer token (read-only)" : demoMode ? "demo mode (public endpoints + auto-provision)" : "none"}`,
|
|
560
563
|
].join("\n"),
|
|
561
564
|
}],
|
|
562
565
|
}));
|
|
563
566
|
// ─── Start ─────────────────────────────────────────────────────────────────
|
|
564
567
|
async function main() {
|
|
565
|
-
if (
|
|
568
|
+
if (JOURNEY_TOKEN) {
|
|
569
|
+
console.error(`Authenticating with journey developer token (${JOURNEY_TOKEN.slice(0, 20)}...) — read-only access`);
|
|
570
|
+
}
|
|
571
|
+
else if (demoMode) {
|
|
566
572
|
console.error("Running in demo mode — read-only tools use public endpoints, write tools auto-provision sandbox");
|
|
567
|
-
console.error("Set ENERGYATIT_API_KEY or
|
|
573
|
+
console.error("Set ENERGYATIT_API_KEY, ENERGYATIT_TOKEN, or ENERGYATIT_JOURNEY_TOKEN for full access.");
|
|
568
574
|
}
|
|
569
|
-
console.error(`EnergyAtIt MCP server v0.2.
|
|
575
|
+
console.error(`EnergyAtIt MCP server v0.2.1 — connecting to ${BASE_URL}`);
|
|
570
576
|
const transport = new StdioServerTransport();
|
|
571
577
|
await server.connect(transport);
|
|
572
578
|
console.error("EnergyAtIt MCP server running on stdio");
|