@nexgen-os/mcp 0.4.1 → 0.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.
- package/README.md +3 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +2 -2
- package/dist/tools/modules.js +18 -2
- package/dist/tools/write.js +34 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -171,6 +171,8 @@ client can ask before calling them.
|
|
|
171
171
|
| `add_participant` | A participant joins a project with its place (`join_project()`), given as a point or found through the configured geocoder chain |
|
|
172
172
|
| `declare_meter` | A meter by its identifier in a scheme, which checks it (`declare_meter()`) |
|
|
173
173
|
| `install_device` | A device, from a product of the catalogue or with a stated power (`install_device()`) |
|
|
174
|
+
| `import_project` | A project described as data — participants, meters, devices, identifiers — through the same functions (`importProject()`); given again, it creates only what is new; `dry_run` writes nothing |
|
|
175
|
+
| `import_project_sheet` | A project sheet ([`@nexgen-os/project-sheet`](../formats/project-sheet/README.md)), as the text of the CSV a spreadsheet saves (`sheet`) or as its `.xlsx` workbook in base64 (`workbook`, the worksheet named by `worksheet`, the first otherwise), each of its projects imported as `import_project` does (`importProjectSheet()`); a sheet with a cell it cannot read is refused whole, `sheet_unreadable`, each problem with its line |
|
|
174
176
|
| `store_series` | Values through `store()`, each dated at the start of its interval, with their source |
|
|
175
177
|
| `import_series` | The readings of a file read by its format library — `homeassistant` — written through `store()` |
|
|
176
178
|
| `create_api_key` · `revoke_api_key` | A key issued by a person who holds `members.manage`, signed in, with capabilities they hold (`data.read`, `data.write`…), and its withdrawal; a key does not issue keys |
|
|
@@ -182,7 +184,7 @@ its code as a prefix; a module that is not installed offers none.
|
|
|
182
184
|
| Module | Tools |
|
|
183
185
|
|---|---|
|
|
184
186
|
| `kpis` | `kpis_of` (the indicators of an object, `kpis.of()`), `kpis_compute` (one kept as a figure, `kpis.compute()`) |
|
|
185
|
-
| `solar` | `solar_estimates`, `solar_size` (a named criterion, [0045](../../docs/decisions/0045-to-size-is-one-gesture.md)), `solar_estimate_yield` (a named profile) |
|
|
187
|
+
| `solar` | `solar_estimates`, `solar_describe_system` (a PV system and its arrays, each with its azimuth and tilt), `solar_size` (a named criterion, [0045](../../docs/decisions/0045-to-size-is-one-gesture.md)), `solar_estimate_yield` (a named profile) |
|
|
186
188
|
| `battery` | `battery_estimates`, `battery_size` |
|
|
187
189
|
| `charging` | `charging_sessions`, `charging_limit`, `charging_size` |
|
|
188
190
|
| `community` | `community_settlements`, `community_settle` (by the sharing engine the person configured) |
|
package/dist/server.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { type Computations, type Geocoder, type Session } from '@nexgen-os/core'
|
|
|
12
12
|
import type { Tool } from './tools/tool.js';
|
|
13
13
|
export declare const SERVER_NAME = "@nexgen-os/mcp";
|
|
14
14
|
/** Repeated from `package.json`, so that a bundle without a manifest still says what it is; a test keeps them equal. */
|
|
15
|
-
export declare const SERVER_VERSION = "0.
|
|
15
|
+
export declare const SERVER_VERSION = "0.5.1";
|
|
16
16
|
export declare const INSTRUCTIONS: string;
|
|
17
17
|
export interface ServerOptions {
|
|
18
18
|
/** The modules installed on the database; their tools are offered. None: the core's tools only. */
|
package/dist/server.js
CHANGED
|
@@ -15,10 +15,10 @@ import { MODULE_TOOLS, moduleToolsFor } from './tools/modules.js';
|
|
|
15
15
|
import { WRITE_TOOLS } from './tools/write.js';
|
|
16
16
|
export const SERVER_NAME = '@nexgen-os/mcp';
|
|
17
17
|
/** Repeated from `package.json`, so that a bundle without a manifest still says what it is; a test keeps them equal. */
|
|
18
|
-
export const SERVER_VERSION = '0.
|
|
18
|
+
export const SERVER_VERSION = '0.5.1';
|
|
19
19
|
export const INSTRUCTIONS = [
|
|
20
20
|
'Nexgen OS is a world model for energy assets in the person\'s own Postgres: organisations, projects, participants, their meters, devices and series. You act as that person: what you see and change is what row level security lets them see and change. There is no agent role and no back door. Dates are ISO, identifiers uuids, a value is dated at the start of its interval, an azimuth in degrees clockwise from true north.',
|
|
21
|
-
'A first session. (1) status, then list_organisations and list_projects: everything belongs to an organisation. (2) list_participants: a participant without a time zone has no daily readings; say so. (3) Describe with a source: add_participant with its place, declare_meter, install_device, store_series or import_series. (4) Compute as a module does: solar_estimate_yield, solar_size, battery_size and charging_size with a criterion the person chose, community_settle, kpis_compute; read back with read_series, solar_estimates, kpis_of. (5) Show what you attached and what the estimate read, then propose with actions_propose; the person validates.',
|
|
21
|
+
'A first session. (1) status, then list_organisations and list_projects: everything belongs to an organisation. (2) list_participants: a participant without a time zone has no daily readings; say so. (3) Describe with a source: add_participant with its place, declare_meter, install_device, solar_describe_system, store_series or import_series. (4) Compute as a module does: solar_estimate_yield, solar_size, battery_size and charging_size with a criterion the person chose, community_settle, kpis_compute; read back with read_series, solar_estimates, kpis_of. (5) Show what you attached and what the estimate read, then propose with actions_propose; the person validates.',
|
|
22
22
|
'Never compute a figure yourself and write it as if a module had; never assume a country, a currency, a language or a time zone; never send the data anywhere the person did not configure.',
|
|
23
23
|
'When the database refuses, the message starts with a name — time_zone_required, read_only, not_allowed, api_key_revoked — followed by a sentence saying what to do. Report it to the person; do not retry blindly or work around it.',
|
|
24
24
|
].join('\n\n');
|
package/dist/tools/modules.js
CHANGED
|
@@ -62,13 +62,29 @@ export const MODULE_TOOLS = [
|
|
|
62
62
|
writes: true,
|
|
63
63
|
run: ({ db, computations }, a) => core.compute(db, computations, 'solar.size', a),
|
|
64
64
|
}),
|
|
65
|
+
tool({
|
|
66
|
+
name: 'solar_describe_system',
|
|
67
|
+
title: 'Describe a PV system',
|
|
68
|
+
module: 'solar',
|
|
69
|
+
description: 'A PV system of a participant as the solar module reads it: a device of type solar, its DC power, and its arrays, each with its own azimuth (degrees clockwise from true north, 180 faces south) and tilt (degrees from horizontal) as the person stated them. Then solar_estimate_yield computes its yield.',
|
|
70
|
+
input: z.object({
|
|
71
|
+
participant_id: uuid, name: z.string().min(1), kwp: z.number().positive(),
|
|
72
|
+
arrays: z.array(z.object({
|
|
73
|
+
name: z.string().min(1), azimuth_deg: z.number().min(0).max(360), tilt_deg: z.number().min(0).max(90),
|
|
74
|
+
kwp: z.number().positive().optional(), mounting: z.string().optional(),
|
|
75
|
+
})).min(1),
|
|
76
|
+
installed_on: z.string().optional(),
|
|
77
|
+
}),
|
|
78
|
+
writes: true,
|
|
79
|
+
run: ({ db }, a) => core.describePvSystem(db, a),
|
|
80
|
+
}),
|
|
65
81
|
tool({
|
|
66
82
|
name: 'solar_estimate_yield',
|
|
67
83
|
title: 'Estimate a PV yield',
|
|
68
84
|
module: 'solar',
|
|
69
|
-
description: 'The yield of a PV system over whole years, with a named profile (pvgis_like by default, pvwatts, or an engine), kept in solar.estimates with what it was computed from. It reaches PVGIS on the Internet unless the profile computes here.',
|
|
85
|
+
description: 'The yield of a PV system over whole years, with a named profile (pvgis_like by default, pvwatts, or an engine), kept in solar.estimates with what it was computed from. pvgis_like without years gives the mean of every year PVGIS covers. The system loss is the place\'s system_loss, read by parameter_of() (14 % at the generic level); set it on the system, its participant, its project or its organisation, never invent one. It reaches PVGIS on the Internet unless the profile computes here.',
|
|
70
86
|
input: z.object({
|
|
71
|
-
deviceId: uuid, years: z.object({ from: z.number().int(), to: z.number().int() }), profileCode: z.string().optional(),
|
|
87
|
+
deviceId: uuid, years: z.object({ from: z.number().int(), to: z.number().int() }).optional(), profileCode: z.string().optional(),
|
|
72
88
|
raddatabase: z.string().optional(), typicalYear: z.boolean().optional(), anchor: z.enum(['pvgis', 'none']).optional(),
|
|
73
89
|
engine: z.object({ name: engineName }).optional(), replaces: uuid.optional(),
|
|
74
90
|
}),
|
package/dist/tools/write.js
CHANGED
|
@@ -7,6 +7,8 @@ import * as core from '@nexgen-os/core';
|
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { tool } from './tool.js';
|
|
9
9
|
const uuid = z.string().uuid();
|
|
10
|
+
/** Base64 as a file travels in JSON: its alphabet, padding at the end, line breaks allowed. */
|
|
11
|
+
const BASE64 = /^[A-Za-z0-9+/\r\n]*={0,2}\s*$/;
|
|
10
12
|
const date = z.string().regex(/^\d{4}-\d{2}-\d{2}$/).describe('An ISO date, 2026-06-15');
|
|
11
13
|
const target = {
|
|
12
14
|
object_kind: z.enum(['organisation', 'project', 'participant', 'meter', 'device']).describe('What the series is about'),
|
|
@@ -69,6 +71,38 @@ export const WRITE_TOOLS = [
|
|
|
69
71
|
writes: true,
|
|
70
72
|
run: ({ db }, a) => core.installDevice(db, a),
|
|
71
73
|
}),
|
|
74
|
+
tool({
|
|
75
|
+
name: 'import_project',
|
|
76
|
+
title: 'Import a project described as data',
|
|
77
|
+
description: 'A project described as data — its participants with their place and time zone, the meters they carry, the devices behind them, and the identifiers each is known by elsewhere — written through create_project(), join_project(), declare_meter(), install_device() and add_identifier() (importProject()). Each object is looked for first, by an identifier it carries, then by its name in its parent (a meter by its scheme and identifier): the same description given again creates nothing. Run it with dry_run first and show the person what it would create. The country is the person\'s, never assumed.',
|
|
78
|
+
input: z.object({
|
|
79
|
+
organisation_id: uuid,
|
|
80
|
+
description: z.record(z.string(), z.unknown()).describe('{ name, country, kind?, start_date?, identifiers?: [{ scheme, value }], participants?: [{ name, category?, time_zone?, place?, identifiers?, meters?: [{ identifier, scheme, direction?, resource?, valid_from?, name?, identifiers? }], devices?: [{ device_type, name, rated_power_kw?, unit_count?, installed_on?, source_code?, identifiers? }] }] }'),
|
|
81
|
+
dry_run: z.boolean().default(false).describe('Look for everything, write nothing'),
|
|
82
|
+
}),
|
|
83
|
+
writes: true,
|
|
84
|
+
run: ({ db }, a) => core.importProject(db, a.organisation_id, a.description, { dryRun: a.dry_run }),
|
|
85
|
+
}),
|
|
86
|
+
tool({
|
|
87
|
+
name: 'import_project_sheet',
|
|
88
|
+
title: 'Import a project sheet',
|
|
89
|
+
description: 'A project sheet — the table of the template of @nexgen-os/project-sheet: one row per meter or device of a participant, columns project, country, participant, its place, meter_scheme, meter_identifier, device_type, device_name… — read, then each project of it imported as import_project does (importProjectSheet()). Give it as the person saved it: `sheet`, the text of a CSV, or `workbook`, the bytes of an .xlsx workbook in base64, with `worksheet` naming the worksheet when it is not the first. A sheet with a cell that cannot be read is refused whole, sheet_unreadable, naming each problem with its line: show them to the person, never correct a cell yourself. Run it with dry_run first. The country is the sheet\'s, never assumed.',
|
|
90
|
+
input: z.object({
|
|
91
|
+
organisation_id: uuid,
|
|
92
|
+
sheet: z.string().optional().describe('The text of a CSV sheet, its header first; comma, semicolon or tab separated'),
|
|
93
|
+
workbook: z.string().max(14_000_000).regex(BASE64).optional().describe('The bytes of an .xlsx workbook, in base64'),
|
|
94
|
+
worksheet: z.string().min(1).optional().describe('The worksheet of the workbook that holds the sheet, by its name; the first one otherwise'),
|
|
95
|
+
dry_run: z.boolean().default(false).describe('Look for everything, write nothing'),
|
|
96
|
+
}),
|
|
97
|
+
writes: true,
|
|
98
|
+
run: ({ db }, a) => {
|
|
99
|
+
if ((a.sheet === undefined) === (a.workbook === undefined)) {
|
|
100
|
+
throw new core.GestureError('sheet_required: give the sheet once, as the text of a CSV (sheet) or as an .xlsx workbook in base64 (workbook)');
|
|
101
|
+
}
|
|
102
|
+
const sheet = a.workbook === undefined ? a.sheet : new Uint8Array(Buffer.from(a.workbook, 'base64'));
|
|
103
|
+
return core.importProjectSheet(db, a.organisation_id, sheet, { dryRun: a.dry_run, ...(a.worksheet === undefined ? {} : { worksheet: a.worksheet }) });
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
72
106
|
tool({
|
|
73
107
|
name: 'store_series',
|
|
74
108
|
title: 'Store series values',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexgen-os/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "MCP server for Nexgen OS: let an AI agent describe, equip and study energy assets, as the person who asked it, under row level security.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@modelcontextprotocol/sdk": "1.31.0",
|
|
50
|
-
"@nexgen-os/core": "^0.
|
|
50
|
+
"@nexgen-os/core": "^0.5.0",
|
|
51
51
|
"zod": "4.6.2",
|
|
52
52
|
"pg": "^8.23.1"
|
|
53
53
|
}
|