@randomknights/aieds-mcp 0.0.0-stage → 2.5.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.
@@ -0,0 +1,78 @@
1
+ // Modeled water for the MCP estimate (methodology 2.5.0, section 2.6).
2
+ //
3
+ // waterL = energyKWh x (siteWUE + gridWaterIntensity)
4
+ //
5
+ // The coefficients are read from the published table through ./factors.js.
6
+ // This is the same arithmetic and the same words as lib/src/water.ts (the
7
+ // server carries no dependency on the reference library); both are pinned to
8
+ // the same test vectors, so they cannot drift without a test failing.
9
+ //
10
+ // Consumption basis, inference only, always a low to high range, confidence
11
+ // `low` by rule, US average for any region without its own figure (none yet).
12
+ import { FACTORS } from "./factors.js";
13
+ const W = FACTORS.water;
14
+ function amount(v) {
15
+ if (v >= 100)
16
+ return String(Math.round(v));
17
+ if (v >= 0.095)
18
+ return v.toFixed(1);
19
+ const two = v.toFixed(2);
20
+ return two === "0.00" ? "<0.01" : two;
21
+ }
22
+ function teaspoonPhrase(tsp) {
23
+ if (tsp < 0.0625)
24
+ return "a small fraction of a teaspoon";
25
+ if (tsp < 0.19)
26
+ return "about an eighth of a teaspoon";
27
+ if (tsp < 0.29)
28
+ return "about a quarter of a teaspoon";
29
+ if (tsp < 0.42)
30
+ return "about a third of a teaspoon";
31
+ if (tsp < 0.62)
32
+ return "about half a teaspoon";
33
+ if (tsp < 0.88)
34
+ return "about three quarters of a teaspoon";
35
+ if (tsp < 1.5)
36
+ return "about a teaspoon";
37
+ if (tsp < 10)
38
+ return `about ${tsp.toFixed(1)} teaspoons`;
39
+ return `about ${Math.round(tsp)} teaspoons`;
40
+ }
41
+ /** Water for an energy in kWh, or null when there is no usable energy. */
42
+ export function waterFromEnergyKWh(energyKWh) {
43
+ if (!Number.isFinite(energyKWh) || energyKWh < 0)
44
+ return null;
45
+ const ml = (site, grid) => energyKWh * (site + grid) * 1000;
46
+ const waterMl = {
47
+ low: ml(W.siteWue.low, W.gridWaterIntensity.low),
48
+ default: ml(W.siteWue.value, W.gridWaterIntensity.value),
49
+ high: ml(W.siteWue.high, W.gridWaterIntensity.high),
50
+ };
51
+ const tsp = (v) => v / W.comparison.milliliters;
52
+ const teaspoons = {
53
+ low: tsp(waterMl.low),
54
+ default: tsp(waterMl.default),
55
+ high: tsp(waterMl.high),
56
+ };
57
+ let line;
58
+ if (teaspoons.default > W.comparison.showLitersAboveTeaspoons) {
59
+ const l = (v) => amount(v / 1000);
60
+ line =
61
+ `Water: about ${l(waterMl.default)} L (${l(waterMl.low)} to ${l(waterMl.high)} L). ` +
62
+ `Modeled estimate.`;
63
+ }
64
+ else {
65
+ line =
66
+ `Water: about ${amount(waterMl.default)} mL ` +
67
+ `(${amount(waterMl.low)} to ${amount(waterMl.high)} mL), ` +
68
+ `${teaspoonPhrase(teaspoons.default)}. Modeled estimate.`;
69
+ }
70
+ return {
71
+ waterMl,
72
+ teaspoons,
73
+ basis: W.gridBasisDefaultLabel,
74
+ confidence: "low",
75
+ line,
76
+ requiredCopy: W.requiredCopy,
77
+ };
78
+ }
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@randomknights/aieds-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.5.1",
4
+ "mcpName": "io.github.random-knights/aieds",
5
+ "description": "AiEDs (AI Energy Disclosure Standard) 2.5.1 MCP server: energy, carbon and modeled water estimates from compute metrics, the published factor tables, and a check of a disclosure record against the AiEDs JSON Schema. Runs over stdio, needs no key and makes no network call.",
6
+ "type": "module",
7
+ "bin": {
8
+ "aieds-mcp": "mcp/dist/index.js"
9
+ },
10
+ "files": [
11
+ "mcp/dist/*.js",
12
+ "spec/aieds.schema.json",
13
+ "spec/v2/aieds-factors.json",
14
+ "LICENSE",
15
+ "LICENSE-DOCS",
16
+ "NOTICE"
17
+ ],
18
+ "scripts": {
19
+ "prepack": "node ../../scripts/stage-npm-package.mjs aieds-mcp"
20
+ },
21
+ "dependencies": {
22
+ "@modelcontextprotocol/sdk": "^1.32.0",
23
+ "ajv": "^8.17.1",
24
+ "ajv-formats": "^3.0.1"
25
+ },
26
+ "keywords": [
27
+ "aieds",
28
+ "mcp",
29
+ "mcp-server",
30
+ "ai",
31
+ "energy",
32
+ "carbon",
33
+ "disclosure",
34
+ "json-schema"
35
+ ],
36
+ "license": "Apache-2.0 AND CC-BY-4.0",
37
+ "author": "Random Knights, LLC",
38
+ "homepage": "https://standard.rand0m.ai",
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/random-knights/standard.git",
42
+ "directory": "packages/aieds-mcp"
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/random-knights/standard/issues"
46
+ },
47
+ "engines": {
48
+ "node": ">=20"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ }
53
+ }
@@ -0,0 +1,290 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://standard.rand0m.ai/aieds/v2/aieds.schema.json",
4
+ "title": "AiEDs Disclosure Record",
5
+ "description": "AI Energy Disclosure Standard 2.0.0 - a single disclosure record for an AI subject's modeled energy consumption and carbon footprint. AiEDs scope is device, usage, inference, or training. It is a per-subject disclosure and is NOT a planetary or Earth-system health score, which is a different kind of claim with different inputs.",
6
+ "type": "object",
7
+ "required": [
8
+ "id",
9
+ "subject",
10
+ "scope",
11
+ "window",
12
+ "energyKWh",
13
+ "gCO2e",
14
+ "gridIntensity",
15
+ "confidence",
16
+ "methodologyVersion",
17
+ "source",
18
+ "generatedAt"
19
+ ],
20
+ "additionalProperties": false,
21
+ "properties": {
22
+ "$schema": {
23
+ "type": "string",
24
+ "description": "Optional JSON Schema URI - may be included for editor tooling."
25
+ },
26
+ "id": {
27
+ "type": "string",
28
+ "description": "Stable unique identifier for this disclosure record. UUID or URI recommended (e.g. 'aieds:my-model:inference:2026-06-29:001')."
29
+ },
30
+ "subject": {
31
+ "type": "object",
32
+ "description": "The AI subject this disclosure covers.",
33
+ "required": [
34
+ "kind",
35
+ "name"
36
+ ],
37
+ "additionalProperties": false,
38
+ "properties": {
39
+ "kind": {
40
+ "type": "string",
41
+ "enum": [
42
+ "model",
43
+ "agent",
44
+ "app"
45
+ ],
46
+ "description": "model = a foundation/fine-tuned model; agent = an orchestrated AI agent; app = an AI-powered application."
47
+ },
48
+ "name": {
49
+ "type": "string",
50
+ "description": "Human-readable name of the subject."
51
+ },
52
+ "version": {
53
+ "type": "string",
54
+ "description": "Optional semver or other version string."
55
+ }
56
+ }
57
+ },
58
+ "scope": {
59
+ "type": "string",
60
+ "enum": [
61
+ "device",
62
+ "usage",
63
+ "inference",
64
+ "training"
65
+ ],
66
+ "description": "Measurement boundary. 'device' = client device energy (CPU/GPU/display) running an AI app; 'usage' = device + server-side inference combined; 'inference' = server-side inference only; 'training' = model training run. AiEDs v1 is optimized for device/usage/inference (agent-native). Training disclosures are supported but factor tables are inference-focused."
67
+ },
68
+ "window": {
69
+ "type": "string",
70
+ "pattern": "^P(?:\\d+Y)?(?:\\d+M)?(?:\\d+W)?(?:\\d+D)?(?:T(?:\\d+H)?(?:\\d+M)?(?:\\d+S)?)?$",
71
+ "description": "ISO 8601 duration this disclosure covers (e.g. 'P30D' = 30 days, 'PT15M' = 15 minutes, 'PT1H' = 1 hour)."
72
+ },
73
+ "compute": {
74
+ "type": "object",
75
+ "description": "Optional compute metrics used to derive energyKWh. Provide at least one of tokens, gpuSeconds, or flops for provenance; omit if energy was measured directly.",
76
+ "additionalProperties": false,
77
+ "properties": {
78
+ "tokens": {
79
+ "type": "number",
80
+ "minimum": 0,
81
+ "description": "Total tokens processed (input + output)."
82
+ },
83
+ "gpuSeconds": {
84
+ "type": "number",
85
+ "minimum": 0,
86
+ "description": "Wall-clock GPU-seconds consumed across all accelerators."
87
+ },
88
+ "flops": {
89
+ "type": "number",
90
+ "minimum": 0,
91
+ "description": "Total floating-point operations (FP16/BF16 equivalent)."
92
+ },
93
+ "hardware": {
94
+ "type": "string",
95
+ "description": "Accelerator identifier (e.g. 'NVIDIA H100 SXM', 'Google TPU v4'). Used with gpuSeconds to derive energy."
96
+ }
97
+ }
98
+ },
99
+ "energyKWh": {
100
+ "type": "number",
101
+ "minimum": 0,
102
+ "description": "Total energy consumed in kilowatt-hours for the declared scope and window."
103
+ },
104
+ "gCO2e": {
105
+ "type": "number",
106
+ "minimum": 0,
107
+ "description": "Total greenhouse gas emissions in grams of CO2-equivalent. Must be derived as energyKWh x gridIntensity.gCO2ePerKWh (within rounding tolerance)."
108
+ },
109
+ "gridIntensity": {
110
+ "type": "object",
111
+ "description": "Grid carbon intensity applied to convert energy to CO2e.",
112
+ "required": [
113
+ "gCO2ePerKWh"
114
+ ],
115
+ "additionalProperties": false,
116
+ "properties": {
117
+ "gCO2ePerKWh": {
118
+ "type": "number",
119
+ "minimum": 0,
120
+ "description": "Carbon intensity in grams of CO2-equivalent per kilowatt-hour."
121
+ },
122
+ "region": {
123
+ "type": "string",
124
+ "description": "Grid region or country code used (e.g. 'US', 'EU27', 'France', 'global_average')."
125
+ }
126
+ }
127
+ },
128
+ "confidence": {
129
+ "description": "Confidence in the energyKWh figure. String enum or fractional 0 to 1. 'high' = direct hardware power measurement; 'med' = GPU-seconds x TDP factor; 'low' = token or FLOP proxy.",
130
+ "oneOf": [
131
+ {
132
+ "type": "string",
133
+ "enum": [
134
+ "low",
135
+ "med",
136
+ "high"
137
+ ]
138
+ },
139
+ {
140
+ "type": "number",
141
+ "minimum": 0,
142
+ "maximum": 1
143
+ }
144
+ ]
145
+ },
146
+ "provenance": {
147
+ "type": "string",
148
+ "enum": [
149
+ "measured",
150
+ "vendor-published",
151
+ "class-estimated",
152
+ "unknown"
153
+ ],
154
+ "description": "Optional. Where the emission or energy factor came from, on the section 5.1 ladder: measured, vendor-published, class-estimated, or unknown. This is a DIFFERENT ladder from `confidence`, which grades how the energy figure itself was arrived at. A record may carry both; neither implies the other. Never upgrade either because an estimate looks plausible."
155
+ },
156
+ "water": {
157
+ "type": "object",
158
+ "description": "Optional. Modeled water consumed (methodology 2.6, added in 2.5.0), inference only. A record without this block makes no water claim. A value that cannot be sourced is null, never zero. Water is a modeled estimate: confidence is 'low' by rule and the range is always present when waterL is.",
159
+ "required": [
160
+ "waterL",
161
+ "siteL",
162
+ "gridL",
163
+ "rangeL",
164
+ "basis",
165
+ "siteWueLPerKWh",
166
+ "gridWaterLPerKWh",
167
+ "gridBasis",
168
+ "confidence",
169
+ "comparison",
170
+ "factorsVersion"
171
+ ],
172
+ "additionalProperties": false,
173
+ "properties": {
174
+ "waterL": {
175
+ "type": ["number", "null"],
176
+ "minimum": 0,
177
+ "description": "Liters consumed: siteL + gridL (rule W2, within rounding). Null when either term is unsourced."
178
+ },
179
+ "siteL": {
180
+ "type": ["number", "null"],
181
+ "minimum": 0,
182
+ "description": "Liters consumed on site for cooling: energyKWh x siteWueLPerKWh. Kept apart from gridL."
183
+ },
184
+ "gridL": {
185
+ "type": ["number", "null"],
186
+ "minimum": 0,
187
+ "description": "Liters consumed to make the grid electricity: energyKWh x gridWaterLPerKWh. Kept apart from siteL."
188
+ },
189
+ "rangeL": {
190
+ "description": "Low and high liters from the Table 5 range ends. Null only when waterL is null (rule W4).",
191
+ "oneOf": [
192
+ { "type": "null" },
193
+ {
194
+ "type": "object",
195
+ "required": ["low", "high"],
196
+ "additionalProperties": false,
197
+ "properties": {
198
+ "low": { "type": "number", "minimum": 0 },
199
+ "high": { "type": "number", "minimum": 0 }
200
+ }
201
+ }
202
+ ]
203
+ },
204
+ "basis": {
205
+ "const": "consumption",
206
+ "description": "Consumption (water that leaves the local source), never withdrawal (rule W5)."
207
+ },
208
+ "siteWueLPerKWh": {
209
+ "type": ["number", "null"],
210
+ "minimum": 0,
211
+ "description": "Site water coefficient applied, liters per kWh."
212
+ },
213
+ "gridWaterLPerKWh": {
214
+ "type": ["number", "null"],
215
+ "minimum": 0,
216
+ "description": "Grid water coefficient applied, liters per kWh."
217
+ },
218
+ "gridBasis": {
219
+ "type": "string",
220
+ "enum": ["default", "region"],
221
+ "description": "'default' is the US average and must be labeled 'US avg' when shown (rule W10). 'region' requires gridRegion."
222
+ },
223
+ "gridRegion": {
224
+ "type": "string",
225
+ "description": "The region whose grid figure was used. Present only when gridBasis is 'region' (rule W8)."
226
+ },
227
+ "confidence": {
228
+ "type": "string",
229
+ "enum": ["low", "med"],
230
+ "description": "Confidence in the water figure. 'low' by rule; 'med' only with metered site water and a regional grid figure (rule W3). 'high' is not defined for water."
231
+ },
232
+ "comparison": {
233
+ "description": "Level 3 educational comparison in teaspoons (5 mL). Null when waterL is null.",
234
+ "oneOf": [
235
+ { "type": "null" },
236
+ {
237
+ "type": "object",
238
+ "required": ["unit", "value"],
239
+ "additionalProperties": false,
240
+ "properties": {
241
+ "unit": { "const": "teaspoon" },
242
+ "value": { "type": "number", "minimum": 0 }
243
+ }
244
+ }
245
+ ]
246
+ },
247
+ "factorsVersion": {
248
+ "type": "string",
249
+ "pattern": "^2[.][0-9]+[.][0-9]+$",
250
+ "description": "Methodology version whose Table 5 supplied the coefficients."
251
+ }
252
+ },
253
+ "allOf": [
254
+ {
255
+ "if": { "properties": { "gridBasis": { "const": "region" } }, "required": ["gridBasis"] },
256
+ "then": { "required": ["gridRegion"] },
257
+ "else": { "not": { "required": ["gridRegion"] } }
258
+ },
259
+ {
260
+ "if": { "properties": { "waterL": { "type": "null" } }, "required": ["waterL"] },
261
+ "then": {
262
+ "properties": { "rangeL": { "type": "null" }, "comparison": { "type": "null" } }
263
+ },
264
+ "else": {
265
+ "properties": {
266
+ "siteL": { "type": "number" },
267
+ "gridL": { "type": "number" },
268
+ "rangeL": { "type": "object" },
269
+ "comparison": { "type": "object" }
270
+ }
271
+ }
272
+ }
273
+ ]
274
+ },
275
+ "methodologyVersion": {
276
+ "type": "string",
277
+ "pattern": "^2[.][0-9]+[.][0-9]+$",
278
+ "description": "AiEDs methodology version, semver. Must be a 2.x version: the standard states that 1.x is superseded and must not be used for new disclosures, so a 1.x record is not conformant under this schema."
279
+ },
280
+ "source": {
281
+ "type": "string",
282
+ "description": "URI or name of the tool or process that generated this disclosure (e.g. 'aieds-mcp v1.0.0', 'my-energy-meter v2')."
283
+ },
284
+ "generatedAt": {
285
+ "type": "string",
286
+ "format": "date-time",
287
+ "description": "ISO 8601 datetime when this disclosure was generated."
288
+ }
289
+ }
290
+ }