@energyatit/mcp-server 0.2.0 → 0.2.2

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.
Files changed (2) hide show
  1. package/dist/index.js +31 -12
  2. 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;
@@ -48,6 +51,18 @@ function resolveDemoPath(path) {
48
51
  }
49
52
  return path;
50
53
  }
54
+ // ─── Region code mapping ──────────────────────────────────────────────────
55
+ const regionCodeMap = {
56
+ "AE-DXB": "UAE", "AE-AUH": "UAE", "AE": "UAE",
57
+ "SA": "Saudi", "SA-RIY": "Saudi",
58
+ "US": "US", "DE": "DE",
59
+ "UAE": "UAE", "Saudi": "Saudi",
60
+ "PJM": "PJM", "ERCOT": "ERCOT", "CAISO": "CAISO",
61
+ "MISO": "MISO", "SPP": "SPP", "NYISO": "NYISO",
62
+ };
63
+ function resolveRegion(input) {
64
+ return regionCodeMap[input] ?? input;
65
+ }
51
66
  // ─── HTTP helpers ──────────────────────────────────────────────────────────
52
67
  async function autoProvisionSandbox() {
53
68
  try {
@@ -138,7 +153,7 @@ function errorResult(err) {
138
153
  // ─── MCP Server ────────────────────────────────────────────────────────────
139
154
  const server = new McpServer({
140
155
  name: "energyatit",
141
- version: "0.2.0",
156
+ version: "0.2.1",
142
157
  });
143
158
  // ── Sites ────────────────────────────────────────────────────────────────
144
159
  server.tool("list_sites", "List all energy sites in your tenant", {}, async () => {
@@ -438,20 +453,20 @@ server.tool("get_site_reliability", "Get reliability score for a site", {
438
453
  }
439
454
  });
440
455
  server.tool("get_grid_capacity", "Get grid capacity for a region", {
441
- region: z.string().describe("Region code (e.g. AE-DXB, PH-LUZ)"),
456
+ region: z.string().describe("Region code (e.g. UAE, Saudi, PJM, ERCOT, CAISO, MISO, SPP, NYISO, DE). Also accepts AE-DXB → UAE, SA → Saudi."),
442
457
  }, async ({ region }) => {
443
458
  try {
444
- return text(await apiGet(`/api/v1/intel/grid/${region}/capacity`));
459
+ return text(await apiGet(`/api/v1/intel/grid/${resolveRegion(region)}/capacity`));
445
460
  }
446
461
  catch (e) {
447
462
  return errorResult(e);
448
463
  }
449
464
  });
450
465
  server.tool("get_grid_trends", "Get grid capacity trends for a region", {
451
- region: z.string().describe("Region code"),
466
+ region: z.string().describe("Region code (e.g. UAE, Saudi, PJM, ERCOT, CAISO). Also accepts AE-DXB → UAE, SA → Saudi."),
452
467
  }, async ({ region }) => {
453
468
  try {
454
- return text(await apiGet(`/api/v1/intel/grid/${region}/trends`));
469
+ return text(await apiGet(`/api/v1/intel/grid/${resolveRegion(region)}/trends`));
455
470
  }
456
471
  catch (e) {
457
472
  return errorResult(e);
@@ -500,10 +515,11 @@ server.tool("get_integration_status", "Get status of all integrations (Modbus, O
500
515
  }
501
516
  });
502
517
  server.tool("get_grid_prices", "Get current grid electricity prices", {
503
- region: z.string().optional().describe("Region code"),
518
+ region: z.string().optional().describe("Region code (e.g. UAE, Saudi, PJM). Also accepts AE-DXB → UAE."),
504
519
  }, async ({ region }) => {
505
520
  try {
506
- const path = region ? `/api/v1/integrations/grid-prices/${region}` : "/api/v1/integrations/grid-prices";
521
+ const resolved = region ? resolveRegion(region) : undefined;
522
+ const path = resolved ? `/api/v1/integrations/grid-prices/${resolved}` : "/api/v1/integrations/grid-prices";
507
523
  return text(await apiGet(path));
508
524
  }
509
525
  catch (e) {
@@ -556,17 +572,20 @@ server.resource("platform-overview", "energyatit://overview", async () => ({
556
572
  " - Integrations: Modbus, OpenADR 2.0b, OCPP 2.0, IEC 61850",
557
573
  "",
558
574
  `Connected to: ${BASE_URL}`,
559
- `Auth: ${TOKEN ? "JWT token" : API_KEY ? "API key" : demoMode ? "demo mode (public endpoints + auto-provision)" : "none"}`,
575
+ `Auth: ${TOKEN ? "JWT token" : API_KEY ? "API key" : JOURNEY_TOKEN ? "journey developer token (read-only)" : demoMode ? "demo mode (public endpoints + auto-provision)" : "none"}`,
560
576
  ].join("\n"),
561
577
  }],
562
578
  }));
563
579
  // ─── Start ─────────────────────────────────────────────────────────────────
564
580
  async function main() {
565
- if (demoMode) {
581
+ if (JOURNEY_TOKEN) {
582
+ console.error(`Authenticating with journey developer token (${JOURNEY_TOKEN.slice(0, 20)}...) — read-only access`);
583
+ }
584
+ else if (demoMode) {
566
585
  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 ENERGYATIT_TOKEN for full access.");
586
+ console.error("Set ENERGYATIT_API_KEY, ENERGYATIT_TOKEN, or ENERGYATIT_JOURNEY_TOKEN for full access.");
568
587
  }
569
- console.error(`EnergyAtIt MCP server v0.2.0 — connecting to ${BASE_URL}`);
588
+ console.error(`EnergyAtIt MCP server v0.2.1 — connecting to ${BASE_URL}`);
570
589
  const transport = new StdioServerTransport();
571
590
  await server.connect(transport);
572
591
  console.error("EnergyAtIt MCP server running on stdio");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@energyatit/mcp-server",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "MCP server for EnergyAtIt — connect Claude, GPT, or any MCP client to energy grid data",
5
5
  "type": "module",
6
6
  "bin": {