@axonity-ai/mcp 0.16.0 → 0.17.0
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 +10 -0
- package/dist/contract.js +2 -0
- package/dist/contract.js.map +1 -1
- package/dist/index.js +46 -18
- package/dist/index.js.map +1 -1
- package/dist/tools/conventions.d.ts +8 -0
- package/dist/tools/conventions.js +53 -3
- package/dist/tools/conventions.js.map +1 -1
- package/dist/tools/dataSources.js +10 -1
- package/dist/tools/dataSources.js.map +1 -1
- package/dist/tools/measureFormula.d.ts +46 -0
- package/dist/tools/measureFormula.js +239 -0
- package/dist/tools/measureFormula.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -284,6 +284,16 @@ across these routes — the tool parameter names say which.
|
|
|
284
284
|
It names the concept it means in `concept`, and the questions it answers
|
|
285
285
|
in `questions`. `read_measure_design` now returns a table's columns and
|
|
286
286
|
time axis only; `list_measures({ tableId })` says which measures read it.
|
|
287
|
+
- **A measure is one formula**, `definition.expression`:
|
|
288
|
+
`sum(orders.amount)`, `[revenue_d2c] + [revenue_retail]`,
|
|
289
|
+
`divide([cm1], [net_revenue])`. `get_measure_formula_spec` is the only
|
|
290
|
+
list of its words — the platform's own, the one its editor shows — and
|
|
291
|
+
with `includeWorkspace: true` also this workspace's measures, tables and
|
|
292
|
+
columns. `validate_measure` checks a formula without saving it and answers
|
|
293
|
+
with every problem by code. `read_measure` returns the formula as text
|
|
294
|
+
beside the stored tree and the aggregations it folds down to. The fields
|
|
295
|
+
from before the formula (`tableId`, `clearTable`, `aggregation`,
|
|
296
|
+
`column`, `numerator`, `denominator`) are refused with `legacy_field`.
|
|
287
297
|
- **Concepts**: `list_concepts`, `create_concept`, `update_concept`,
|
|
288
298
|
`delete_concept` — kind (concept, state, metric, rule), name, meaning,
|
|
289
299
|
synonyms, what it refers to, owner. They are rows of one table the
|
package/dist/contract.js
CHANGED
|
@@ -90,6 +90,8 @@ export const PROBE_VARIANTS = [
|
|
|
90
90
|
// validate_workflow — exactly one of the two, never both.
|
|
91
91
|
{ document: undefined },
|
|
92
92
|
{ workflowId: undefined },
|
|
93
|
+
// get_measure_formula_spec — the workspace's vocabulary only when asked.
|
|
94
|
+
{ includeWorkspace: true },
|
|
93
95
|
];
|
|
94
96
|
/**
|
|
95
97
|
* Every route this build's tools call, found by replaying them.
|
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoB/D;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,UAAU,GAA4B;IACjD,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG;IAChF,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG;IACzE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;IAC1E,YAAY,EAAE,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG;IAC/D,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,EAAE,qBAAqB,EAAE,CAAC;IAC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,CAAC,SAAS,CAAC;IAE9E,GAAG,CACD,uCAAuC,OAAO,CAAC,MAAM,iBAAiB;QACpE,oBAAoB;QACpB,cAAc,KAAK,KAAK,WAAW,QAAQ,OAAO,CAAC,MAAM,IAAI;QAC7D,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5D,0EAA0E;QAC1E,kEAAkE;QAClE,8DAA8D,CACjE,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import { reportContractSkew } from "./contract.js";
|
|
|
25
25
|
import { registerConventions } from "./tools/conventions.js";
|
|
26
26
|
import { registerDashboardTools, registerDataSourceTools, registerMeasureTools, } from "./tools/dataSources.js";
|
|
27
27
|
import { registerDataTableTools } from "./tools/dataTables.js";
|
|
28
|
+
import { assertFormulaShape, registerMeasureFormulaTools } from "./tools/measureFormula.js";
|
|
28
29
|
import { assertPlaceholderCredentials } from "./tools/credentials.js";
|
|
29
30
|
import { registerAttachTools, registerCatalogTools, registerConnectorTools, registerDependencyTools, registerPersonaTools, } from "./tools/extras.js";
|
|
30
31
|
import { registerAuthoringSpecTools } from "./tools/authoringSpec.js";
|
|
@@ -62,6 +63,41 @@ const PROVENANCE_NOTE = "WHERE THE ROWS COME FROM — `provenance`, for a dynami
|
|
|
62
63
|
"\n\nMEASURES ARE NOT ON THE TABLE. A measure is its own entity " +
|
|
63
64
|
"(create_measure); a table carries only its `timeAxis` " +
|
|
64
65
|
"(`{ column, grain }`), which every measure over it reads.";
|
|
66
|
+
/**
|
|
67
|
+
* What writing a measure takes (axonity-flow#1908). The contract, not a manual:
|
|
68
|
+
* the words of the formula are in get_measure_formula_spec and nowhere else.
|
|
69
|
+
*/
|
|
70
|
+
const MEASURE_NOTE = "READ get_measure_formula_spec FIRST; never write a function, operator or " +
|
|
71
|
+
"grain from memory. A measure is ONE formula, `definition.expression`, " +
|
|
72
|
+
"as text or as the stored tree. Four kinds, one grammar: " +
|
|
73
|
+
"\n- a BASE aggregates one COLUMN of one table: " +
|
|
74
|
+
"`sum(orders.amount) where orders.channel = 'd2c'`. It reads a column, " +
|
|
75
|
+
"never a calculation per row — a value per row belongs in the table's " +
|
|
76
|
+
"source query (`provenance.sql`), as a column of its own; " +
|
|
77
|
+
"\n- a DERIVED measure computes with other measures by name: " +
|
|
78
|
+
"`[revenue_d2c] + [revenue_retail]`, `divide([cm1], [net_revenue])`, " +
|
|
79
|
+
"`divide([revenue_d2c], [net_revenue] ignore orders.channel)` for a share " +
|
|
80
|
+
"of the total. Two fact tables may meet in one number; they are never " +
|
|
81
|
+
"joined; " +
|
|
82
|
+
"\n- TIME (`shift`, `to_date`, `rolling`) and CUMULATIVE (`running`): " +
|
|
83
|
+
"use them only where the spec marks them `available`. " +
|
|
84
|
+
"\n\nBuild bottom-up: the base measures first, each with its `quantity` " +
|
|
85
|
+
"(what it counts: EUR, customers, orders), then the derived ones; " +
|
|
86
|
+
"validate_measure before every save, and publish from the bottom up. " +
|
|
87
|
+
"\n\nFields: `label` (what a tile shows), `description` (what the number " +
|
|
88
|
+
"means — mandatory, an agent reads it to decide whether this is the " +
|
|
89
|
+
"number asked for), `definition`, `concept` (the NAME of the concept this " +
|
|
90
|
+
"number means — it must exist, create_concept first, and a derived " +
|
|
91
|
+
"measure needs one too), `questions` (what it answers, in the words " +
|
|
92
|
+
"someone would ask) and optionally `name`, the handle — derived from the " +
|
|
93
|
+
"label when omitted and unique in the workspace. `definition` is " +
|
|
94
|
+
"`{ expression, quantity?, format?, direction?, target?, watchMargin? }`; " +
|
|
95
|
+
"`quantity` is derived for a formula over measures. " +
|
|
96
|
+
"\n\nThe fields from before the formula — `tableId`, `clearTable`, " +
|
|
97
|
+
"`definition.aggregation`, `column`, `numerator`, `denominator` — are " +
|
|
98
|
+
"refused with `legacy_field`. " +
|
|
99
|
+
"\n\nIt is a DRAFT until published: request_publish_measure. Only a " +
|
|
100
|
+
"published measure gives a certified number.";
|
|
65
101
|
/**
|
|
66
102
|
* The entities the connector covers. Core entities (C4), memory entities (C5)
|
|
67
103
|
* — skills, policies, reference docs — which have the same draft→publish
|
|
@@ -185,24 +221,15 @@ const ENTITIES = [
|
|
|
185
221
|
label: "measures (the agreed definition of one number in the model)",
|
|
186
222
|
deleteVersionParam: "expectedVersion",
|
|
187
223
|
listPaging: { defaultPageSize: 20, maxPageSize: 200 },
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
"
|
|
195
|
-
"
|
|
196
|
-
"
|
|
197
|
-
"denominator?, filters?, format?, direction?, target?, watchMargin? }`: " +
|
|
198
|
-
"aggregation is sum, average, count, count_distinct, min, max, latest " +
|
|
199
|
-
"(the value at the last date of each period — for a stock) or ratio " +
|
|
200
|
-
"(numerator ÷ denominator, each `{ aggregation, column?, table?, " +
|
|
201
|
-
"filters? }`). A filter is `{ column, operator, value }`. Column names " +
|
|
202
|
-
"come from read_measure_design. A wrong combination is refused with a " +
|
|
203
|
-
"422 that says why. " +
|
|
204
|
-
"\n\nIt is a DRAFT until published: request_publish_measure. Only a " +
|
|
205
|
-
"published measure gives a certified number.",
|
|
224
|
+
// read_measure is in tools/measureFormula.ts: it asks the platform to
|
|
225
|
+
// write the stored tree back as formula text, which a plain GET cannot.
|
|
226
|
+
readable: false,
|
|
227
|
+
guardFields: assertFormulaShape,
|
|
228
|
+
createNote: MEASURE_NOTE,
|
|
229
|
+
updateWarning: MEASURE_NOTE +
|
|
230
|
+
" `tableId` and `clearTable` are gone: a measure has no home table, " +
|
|
231
|
+
"the tables it reads follow from its formula. Sending `definition` " +
|
|
232
|
+
"replaces it whole, so send the `expression` with it.",
|
|
206
233
|
},
|
|
207
234
|
// The three below arrived with axonity-flow#1849 (axonity-mcp#78). None is
|
|
208
235
|
// versioned or publish-approved: a change is live the moment it is saved, so
|
|
@@ -342,6 +369,7 @@ export function registerAll(server, client) {
|
|
|
342
369
|
registerDataTableTools(server, client);
|
|
343
370
|
registerDataSourceTools(server, client);
|
|
344
371
|
registerMeasureTools(server, client);
|
|
372
|
+
registerMeasureFormulaTools(server, client);
|
|
345
373
|
registerDashboardTools(server, client);
|
|
346
374
|
registerConceptTools(server, client);
|
|
347
375
|
registerComponentTools(server, client);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,sBAAsB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O,CAAC,KAAK,CAAC,wCAAwC,EAAE,GAAG,CAAC,CAAC;QAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -55,6 +55,14 @@ export declare const PLACEMENT_ROUTE = "/api/v1/authoring/prompt-placement";
|
|
|
55
55
|
export declare const SEMANTIC_KNOWLEDGE_ROUTE = "/api/v1/authoring/semantic-knowledge";
|
|
56
56
|
/** Read this deploy's placement rules, or say why not. Exported for testing. */
|
|
57
57
|
export declare function readPlacementRules(client: AxonityClient): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* How a measure is built and computed (axonity-flow#1908), carried by the
|
|
60
|
+
* connector beside the served rules. It names no word of the formula: those are
|
|
61
|
+
* in `get_measure_formula_spec`, the platform's one list. What it keeps is what
|
|
62
|
+
* the spec does not say — where a calculation belongs, and how a number made
|
|
63
|
+
* of parts is computed — so an agent does not have to infer it from recipes.
|
|
64
|
+
*/
|
|
65
|
+
export declare const MEASURE_FORMULA_SECTION = "## A measure is one formula\n\nThe words of a formula \u2014 functions, operators, grains, limits, every refusal\ncode with its fix, and recipes \u2014 are in `get_measure_formula_spec`. Read it\nbefore writing a measure, and never write a word from memory. With\n`includeWorkspace: true` it also lists this workspace's measures, tables,\ncolumns and the dimensions each table reaches.\n\n**Four kinds, one grammar.**\n\n- **Base** \u2014 one aggregation over one column of one table, optionally with\n `where`. It reads a column, never a calculation per row.\n- **Derived** \u2014 arithmetic over other measures by name: a sum over two facts,\n a margin, a share of the total with `ignore`.\n- **Time** and **cumulative** \u2014 the same measure in another window, or a\n running total. Use them only where the spec marks them `available`.\n\n**Row logic belongs in the table's source query, not in a measure.** A value\nper row (net = gross \u2212 discount) is a column, added to the table's\n`provenance.sql` and described like any other column. A measure is computed\nper question \u2014 period, grain, split, filters \u2014 and is never stored.\n\n**How a number is computed.** Each leaf is aggregated on its own table, over\nthe dimensions it reaches through declared many-to-one relationships. The\nresults are combined per group; two fact tables are never joined to each\nother. The formula is then applied per group, and the TOTAL is computed again\nover the whole period \u2014 never the sum or the average of the groups.\n\n**Refused, never guessed.** A dimension a leaf cannot reach, a measure that\nrests on itself, euros added to dogs, a format that does not fit what the\nnumber counts: each is refused with a code. `validate_measure` returns them\nbefore you save; repair on the code before asking a person.\n\n**Order.** Base measures first, each with its `quantity`; then the derived\nones; `validate_measure` before every save; publish from the bottom up.\n";
|
|
58
66
|
/** Read this deploy's semantic-knowledge rules, or say why not. Exported for testing. */
|
|
59
67
|
export declare function readSemanticKnowledgeRules(client: AxonityClient): Promise<string>;
|
|
60
68
|
export declare function registerConventions(server: McpServer, client: AxonityClient): void;
|
|
@@ -1043,9 +1043,57 @@ async function readServedRules(client, route, what, unavailable) {
|
|
|
1043
1043
|
export async function readPlacementRules(client) {
|
|
1044
1044
|
return readServedRules(client, PLACEMENT_ROUTE, "prompt-element placement rules", PLACEMENT_UNAVAILABLE);
|
|
1045
1045
|
}
|
|
1046
|
+
/**
|
|
1047
|
+
* How a measure is built and computed (axonity-flow#1908), carried by the
|
|
1048
|
+
* connector beside the served rules. It names no word of the formula: those are
|
|
1049
|
+
* in `get_measure_formula_spec`, the platform's one list. What it keeps is what
|
|
1050
|
+
* the spec does not say — where a calculation belongs, and how a number made
|
|
1051
|
+
* of parts is computed — so an agent does not have to infer it from recipes.
|
|
1052
|
+
*/
|
|
1053
|
+
export const MEASURE_FORMULA_SECTION = `## A measure is one formula
|
|
1054
|
+
|
|
1055
|
+
The words of a formula — functions, operators, grains, limits, every refusal
|
|
1056
|
+
code with its fix, and recipes — are in \`get_measure_formula_spec\`. Read it
|
|
1057
|
+
before writing a measure, and never write a word from memory. With
|
|
1058
|
+
\`includeWorkspace: true\` it also lists this workspace's measures, tables,
|
|
1059
|
+
columns and the dimensions each table reaches.
|
|
1060
|
+
|
|
1061
|
+
**Four kinds, one grammar.**
|
|
1062
|
+
|
|
1063
|
+
- **Base** — one aggregation over one column of one table, optionally with
|
|
1064
|
+
\`where\`. It reads a column, never a calculation per row.
|
|
1065
|
+
- **Derived** — arithmetic over other measures by name: a sum over two facts,
|
|
1066
|
+
a margin, a share of the total with \`ignore\`.
|
|
1067
|
+
- **Time** and **cumulative** — the same measure in another window, or a
|
|
1068
|
+
running total. Use them only where the spec marks them \`available\`.
|
|
1069
|
+
|
|
1070
|
+
**Row logic belongs in the table's source query, not in a measure.** A value
|
|
1071
|
+
per row (net = gross − discount) is a column, added to the table's
|
|
1072
|
+
\`provenance.sql\` and described like any other column. A measure is computed
|
|
1073
|
+
per question — period, grain, split, filters — and is never stored.
|
|
1074
|
+
|
|
1075
|
+
**How a number is computed.** Each leaf is aggregated on its own table, over
|
|
1076
|
+
the dimensions it reaches through declared many-to-one relationships. The
|
|
1077
|
+
results are combined per group; two fact tables are never joined to each
|
|
1078
|
+
other. The formula is then applied per group, and the TOTAL is computed again
|
|
1079
|
+
over the whole period — never the sum or the average of the groups.
|
|
1080
|
+
|
|
1081
|
+
**Refused, never guessed.** A dimension a leaf cannot reach, a measure that
|
|
1082
|
+
rests on itself, euros added to dogs, a format that does not fit what the
|
|
1083
|
+
number counts: each is refused with a code. \`validate_measure\` returns them
|
|
1084
|
+
before you save; repair on the code before asking a person.
|
|
1085
|
+
|
|
1086
|
+
**Order.** Base measures first, each with its \`quantity\`; then the derived
|
|
1087
|
+
ones; \`validate_measure\` before every save; publish from the bottom up.
|
|
1088
|
+
`;
|
|
1046
1089
|
/** Read this deploy's semantic-knowledge rules, or say why not. Exported for testing. */
|
|
1047
1090
|
export async function readSemanticKnowledgeRules(client) {
|
|
1048
|
-
|
|
1091
|
+
const rules = await readServedRules(client, SEMANTIC_KNOWLEDGE_ROUTE, "rules for writing the semantic layer", SEMANTIC_KNOWLEDGE_UNAVAILABLE);
|
|
1092
|
+
// Without the served rules the answer is "do not build", and a section on
|
|
1093
|
+
// how to build measures beside it would contradict that.
|
|
1094
|
+
if (rules === SEMANTIC_KNOWLEDGE_UNAVAILABLE)
|
|
1095
|
+
return rules;
|
|
1096
|
+
return `${rules}\n\n${MEASURE_FORMULA_SECTION}`;
|
|
1049
1097
|
}
|
|
1050
1098
|
export function registerConventions(server, client) {
|
|
1051
1099
|
server.tool("axonity_conventions", "Read the authoring conventions BEFORE creating or updating anything: the " +
|
|
@@ -1068,8 +1116,10 @@ export function registerConventions(server, client) {
|
|
|
1068
1116
|
"what a word or a number means. Returns this deploy's rules for writing " +
|
|
1069
1117
|
"it: what a concept owes, what a measure's description and questions " +
|
|
1070
1118
|
"must say, and what a table's grain must say about one row. Read live " +
|
|
1071
|
-
"from the platform on every call, with its rulesVersion.
|
|
1072
|
-
"
|
|
1119
|
+
"from the platform on every call, with its rulesVersion. Ends with how " +
|
|
1120
|
+
"a measure is built as one formula and how a number made of parts is " +
|
|
1121
|
+
"computed; the formula's words are in get_measure_formula_spec. Not " +
|
|
1122
|
+
"needed for anything else.", {}, async () => ({
|
|
1073
1123
|
content: [{ type: "text", text: await readSemanticKnowledgeRules(client) }],
|
|
1074
1124
|
}));
|
|
1075
1125
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conventions.js","sourceRoot":"","sources":["../../src/tools/conventions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAMH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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0BAA0B,CAAC,MAAqB;IACpE,MAAM,KAAK,GAAG,MAAM,eAAe,CACjC,MAAM,EACN,wBAAwB,EACxB,sCAAsC,EACtC,8BAA8B,CAC/B,CAAC;IACF,0EAA0E;IAC1E,yDAAyD;IACzD,IAAI,KAAK,KAAK,8BAA8B;QAAE,OAAO,KAAK,CAAC;IAC3D,OAAO,GAAG,KAAK,OAAO,uBAAuB,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAiB,EAAE,MAAqB;IAC1E,MAAM,CAAC,IAAI,CACT,qBAAqB,EACrB,2EAA2E;QACzE,2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5E,uEAAuE;QACvE,uEAAuE;QACvE,uEAAuE;QACvE,+DAA+D,EACjE,EAAE,EACF,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,GAAG,WAAW,KAAK,MAAM,kBAAkB,CAAC,MAAM,CAAC,EAAE;aAC5D;SACF;KACF,CAAC,CACH,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,8BAA8B,EAC9B,qEAAqE;QACnE,sEAAsE;QACtE,yEAAyE;QACzE,sEAAsE;QACtE,uEAAuE;QACvE,wEAAwE;QACxE,sEAAsE;QACtE,qEAAqE;QACrE,2BAA2B,EAC7B,EAAE,EACF,KAAK,IAAI,EAAE,CAAC,CAAC;QACX,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC,MAAM,CAAC,EAAE,CAAC;KACrF,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -101,7 +101,9 @@ export function registerMeasureTools(server, client) {
|
|
|
101
101
|
"\n\nTHE MEASURES ARE NOT HERE. A measure belongs to the model, not " +
|
|
102
102
|
"to one table: list_measures({ tableId }) answers which measures read " +
|
|
103
103
|
"this table, and create_measure defines one. Read this for the column " +
|
|
104
|
-
"names a measure's
|
|
104
|
+
"names a measure's formula, `splitBy` or `filters` may use — or " +
|
|
105
|
+
"get_measure_formula_spec({ includeWorkspace: true }) for every " +
|
|
106
|
+
"table's columns at once.", {
|
|
105
107
|
tableId: z.string().describe("The dynamic table's id."),
|
|
106
108
|
useDraft: z
|
|
107
109
|
.boolean()
|
|
@@ -123,6 +125,13 @@ export function registerMeasureTools(server, client) {
|
|
|
123
125
|
"previous_year. `grain` (none, auto, day, week, month, quarter, year) " +
|
|
124
126
|
"draws a series. `splitBy` names a column to group by; `limit` (1-50) " +
|
|
125
127
|
"keeps the largest groups. " +
|
|
128
|
+
"\n\nA MEASURE OVER OTHER MEASURES is computed per group: each of " +
|
|
129
|
+
"its parts is aggregated on its own table, and the formula is applied " +
|
|
130
|
+
"to the results. Its TOTAL is computed again over the whole period, " +
|
|
131
|
+
"never added up from the groups — the total of a margin % is total " +
|
|
132
|
+
"margin over total revenue, not the average of the monthly " +
|
|
133
|
+
"percentages. Report the total you are given; do not sum the series. " +
|
|
134
|
+
"read_measure shows which parts a number is made of. " +
|
|
126
135
|
"\n\nONE BAD QUESTION DOES NOT FAIL THE CALL: every answer carries " +
|
|
127
136
|
"`ok`, and `ok: false` comes with an `error` of its own. Check each one. " +
|
|
128
137
|
"\n\n`freshAsOf` says how old the newest row behind the number is; " +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataSources.js","sourceRoot":"","sources":["../../src/tools/dataSources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,OAAO,GAAG,sBAAsB,CAAC;AACvC,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AAEpC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,C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AI,CACT,mBAAmB,EACnB,yEAAyE;QACvE,kEAAkE;QAClE,uEAAuE;QACvE,6DAA6D;QAC7D,uEAAuE;QACvE,0EAA0E;QAC1E,mEAAmE;QACnE,2CAA2C;QAC3C,sEAAsE;QACtE,yEAAyE;QACzE,uEAAuE;QACvE,oEAAoE;QACpE,sEAAsE;QACtE,qCAAqC,EACvC;QACE,EAAE,EAAE,SAAS;QACb,GAAG,EAAE,CAAC;aACH,MAAM,EAAE;aACR,QAAQ,CACP,iEAAiE;YAC/D,iEAAiE;YACjE,cAAc,CACjB;QACH,OAAO,EAAE,CAAC;aACP,MAAM,EAAE;aACR,GAAG,EAAE;aACL,QAAQ,EAAE;aACV,QAAQ,CACP,kEAAkE;YAChE,+DAA+D,CAClE;KACJ,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,CAC7B,KAAK,CAAC,KAAK,IAAI,EAAE,CACf,UAAU,CACR,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,IAAI,EAAE,QAAQ,EAAE;QAC1C,GAAG;QACH,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC,CACH,CACF,CACJ,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,OAAO,GACX,qEAAqE;IACrE,sDAAsD,CAAC;AAEzD,MAAM,UAAU,oBAAoB,CAClC,MAAiB,EACjB,MAAqB;IAErB,MAAM,CAAC,IAAI,CACT,qBAAqB,EACrB,wEAAwE;QACtE,wBAAwB;QACxB,qEAAqE;QACrE,uEAAuE;QACvE,uEAAuE;QACvE,iEAAiE,
|
|
1
|
+
{"version":3,"file":"dataSources.js","sourceRoot":"","sources":["../../src/tools/dataSources.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,CAAC,EAAE,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,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAC3F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,MAAiB,EACjB,MAAqB;IAErB,MAAM,CAAC,IAAI,CACT,qBAAqB,EACrB,0EAA0E;QACxE,qDAAqD,EACvD;QACE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wBAAwB,CAAC;QACjD,IAAI,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,mDAAmD,CAAC;KACjE,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CACrB,KAAK,CAAC,KAAK,IAAI,EAAE,CACf,UAAU,CACR,MAAM,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC9E,CACF,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A measure is one formula (axonity-mcp#83, the connector half of phase 1 of
|
|
3
|
+
* axonity-flow#1908).
|
|
4
|
+
*
|
|
5
|
+
* A measure used to be one aggregation over one table, or a division of two
|
|
6
|
+
* parts. It is now ONE expression over the model — `[net_revenue] -
|
|
7
|
+
* [variable_costs]`, `divide([cm1], [net_revenue])` — stored as a tree of ids
|
|
8
|
+
* and shown as text of names, the two one-to-one.
|
|
9
|
+
*
|
|
10
|
+
* **The words of the formula are not here.** They come from
|
|
11
|
+
* `GET /measures/formula-spec`, which the platform generates from the module
|
|
12
|
+
* that also parses — the same list its editor shows. A copy in this connector
|
|
13
|
+
* would be a second list, and two lists drift: the reason
|
|
14
|
+
* `get_workflow_authoring_spec` exists. `get_measure_formula_spec` forwards it
|
|
15
|
+
* untouched.
|
|
16
|
+
*
|
|
17
|
+
* **Checking is the platform's too.** `validate_measure` forwards to
|
|
18
|
+
* `POST /measures/validate`, the route the editor calls while somebody types,
|
|
19
|
+
* so an agent and a person can never disagree about whether a formula is
|
|
20
|
+
* acceptable. `read_measure` asks that same route to write the stored tree back
|
|
21
|
+
* as text, rather than this connector unparsing it.
|
|
22
|
+
*
|
|
23
|
+
* The one rule held HERE is the shape of a write: a measure is written as
|
|
24
|
+
* `definition.expression`, and the fields from before the formula are refused
|
|
25
|
+
* with `legacy_field`. The platform still accepts them while its own form is
|
|
26
|
+
* replaced; an agent has no such form to keep working, and a measure written
|
|
27
|
+
* the old way today is one that has to be migrated again.
|
|
28
|
+
*/
|
|
29
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
30
|
+
import type { AxonityClient } from "../client.js";
|
|
31
|
+
/** The language: every word, operator, grain, limit, code and recipe. */
|
|
32
|
+
export declare const FORMULA_SPEC_ROUTE = "/api/v1/measures/formula-spec";
|
|
33
|
+
/** The vocabulary of THIS workspace: its measures, tables, columns, calendars. */
|
|
34
|
+
export declare const FORMULA_SYMBOLS_ROUTE = "/api/v1/measures/formula-symbols";
|
|
35
|
+
/** Check a formula without saving it. */
|
|
36
|
+
export declare const VALIDATE_ROUTE = "/api/v1/measures/validate";
|
|
37
|
+
/**
|
|
38
|
+
* Refuse a measure write in the shape from before the formula.
|
|
39
|
+
*
|
|
40
|
+
* Throws with `legacy_field` — the platform's own code for it, so an agent
|
|
41
|
+
* that repairs on codes reads the same word from either side. A `definition`
|
|
42
|
+
* without `expression` is refused too: the platform would quietly store it as
|
|
43
|
+
* a `sum`, which is a definition nobody wrote.
|
|
44
|
+
*/
|
|
45
|
+
export declare function assertFormulaShape(fields: Record<string, unknown>): void;
|
|
46
|
+
export declare function registerMeasureFormulaTools(server: McpServer, client: AxonityClient): void;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A measure is one formula (axonity-mcp#83, the connector half of phase 1 of
|
|
3
|
+
* axonity-flow#1908).
|
|
4
|
+
*
|
|
5
|
+
* A measure used to be one aggregation over one table, or a division of two
|
|
6
|
+
* parts. It is now ONE expression over the model — `[net_revenue] -
|
|
7
|
+
* [variable_costs]`, `divide([cm1], [net_revenue])` — stored as a tree of ids
|
|
8
|
+
* and shown as text of names, the two one-to-one.
|
|
9
|
+
*
|
|
10
|
+
* **The words of the formula are not here.** They come from
|
|
11
|
+
* `GET /measures/formula-spec`, which the platform generates from the module
|
|
12
|
+
* that also parses — the same list its editor shows. A copy in this connector
|
|
13
|
+
* would be a second list, and two lists drift: the reason
|
|
14
|
+
* `get_workflow_authoring_spec` exists. `get_measure_formula_spec` forwards it
|
|
15
|
+
* untouched.
|
|
16
|
+
*
|
|
17
|
+
* **Checking is the platform's too.** `validate_measure` forwards to
|
|
18
|
+
* `POST /measures/validate`, the route the editor calls while somebody types,
|
|
19
|
+
* so an agent and a person can never disagree about whether a formula is
|
|
20
|
+
* acceptable. `read_measure` asks that same route to write the stored tree back
|
|
21
|
+
* as text, rather than this connector unparsing it.
|
|
22
|
+
*
|
|
23
|
+
* The one rule held HERE is the shape of a write: a measure is written as
|
|
24
|
+
* `definition.expression`, and the fields from before the formula are refused
|
|
25
|
+
* with `legacy_field`. The platform still accepts them while its own form is
|
|
26
|
+
* replaced; an agent has no such form to keep working, and a measure written
|
|
27
|
+
* the old way today is one that has to be migrated again.
|
|
28
|
+
*/
|
|
29
|
+
import { z } from "zod";
|
|
30
|
+
import { guard, jsonResult } from "./result.js";
|
|
31
|
+
const MEASURES = "/api/v1/measures";
|
|
32
|
+
/** The language: every word, operator, grain, limit, code and recipe. */
|
|
33
|
+
export const FORMULA_SPEC_ROUTE = `${MEASURES}/formula-spec`;
|
|
34
|
+
/** The vocabulary of THIS workspace: its measures, tables, columns, calendars. */
|
|
35
|
+
export const FORMULA_SYMBOLS_ROUTE = `${MEASURES}/formula-symbols`;
|
|
36
|
+
/** Check a formula without saving it. */
|
|
37
|
+
export const VALIDATE_ROUTE = `${MEASURES}/validate`;
|
|
38
|
+
/** Top-level fields from before the formula: the measure's "home table". */
|
|
39
|
+
const LEGACY_TOP = ["tableId", "clearTable"];
|
|
40
|
+
/** Fields inside `definition` that the formula replaces. */
|
|
41
|
+
const LEGACY_DEFINITION = ["aggregation", "column", "numerator", "denominator"];
|
|
42
|
+
/** Present in the sense that matters: sent, and not a null that clears nothing. */
|
|
43
|
+
function isSent(value) {
|
|
44
|
+
return value !== undefined && value !== null && value !== false;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Refuse a measure write in the shape from before the formula.
|
|
48
|
+
*
|
|
49
|
+
* Throws with `legacy_field` — the platform's own code for it, so an agent
|
|
50
|
+
* that repairs on codes reads the same word from either side. A `definition`
|
|
51
|
+
* without `expression` is refused too: the platform would quietly store it as
|
|
52
|
+
* a `sum`, which is a definition nobody wrote.
|
|
53
|
+
*/
|
|
54
|
+
export function assertFormulaShape(fields) {
|
|
55
|
+
const found = LEGACY_TOP.filter((key) => isSent(fields[key]));
|
|
56
|
+
const definition = fields.definition;
|
|
57
|
+
if (definition !== undefined && definition !== null) {
|
|
58
|
+
if (typeof definition !== "object" || Array.isArray(definition)) {
|
|
59
|
+
throw new Error("`definition` must be an object with an `expression`.");
|
|
60
|
+
}
|
|
61
|
+
const def = definition;
|
|
62
|
+
found.push(...LEGACY_DEFINITION.filter((key) => isSent(def[key])).map((key) => `definition.${key}`));
|
|
63
|
+
if (found.length === 0 && !isSent(def.expression)) {
|
|
64
|
+
throw new Error("legacy_field: `definition` has no `expression`. A measure is one " +
|
|
65
|
+
"formula — send it as `definition.expression`, e.g. " +
|
|
66
|
+
'"sum(orders.amount)" or "[net_revenue] - [variable_costs]". ' +
|
|
67
|
+
"Read get_measure_formula_spec for the words, and check it with " +
|
|
68
|
+
"validate_measure first.");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (found.length === 0)
|
|
72
|
+
return;
|
|
73
|
+
throw new Error(`legacy_field: ${found.map((f) => `\`${f}\``).join(", ")} ` +
|
|
74
|
+
`${found.length === 1 ? "is" : "are"} the shape from before the formula. ` +
|
|
75
|
+
"A measure is one `definition.expression` now, and the tables it reads " +
|
|
76
|
+
"follow from it: `sum(orders.amount)` instead of `tableId` + " +
|
|
77
|
+
"`aggregation` + `column`, `divide(sum(a.x), sum(b.y))` instead of a " +
|
|
78
|
+
"`numerator` and a `denominator`, `… where table.column = 'value'` " +
|
|
79
|
+
"for a condition on one part. Remove these fields and write the " +
|
|
80
|
+
"formula — validate_measure checks it before you save.");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The stored tree, written back as text with its leaves, by the platform.
|
|
84
|
+
*
|
|
85
|
+
* Best effort, and said so: a read must not fail because the explanation
|
|
86
|
+
* could not be produced. When it cannot, the measure comes back as stored with
|
|
87
|
+
* a sentence saying why its formula text is missing.
|
|
88
|
+
*/
|
|
89
|
+
async function explainFormula(client, measure, useDraftChain) {
|
|
90
|
+
const expression = measure.definition?.expression;
|
|
91
|
+
if (expression === undefined || expression === null) {
|
|
92
|
+
return {
|
|
93
|
+
formula: null,
|
|
94
|
+
formulaNote: "This measure has no formula yet — it is still in the shape from " +
|
|
95
|
+
"before the formula. Write one with update_measure " +
|
|
96
|
+
"(`definition.expression`).",
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
const checked = (await client.post(VALIDATE_ROUTE, {
|
|
101
|
+
expression,
|
|
102
|
+
measureId: typeof measure.id === "string" ? measure.id : undefined,
|
|
103
|
+
quantity: measure.definition?.quantity ?? undefined,
|
|
104
|
+
format: measure.definition?.format ?? undefined,
|
|
105
|
+
useDraftChain,
|
|
106
|
+
}));
|
|
107
|
+
return {
|
|
108
|
+
formula: {
|
|
109
|
+
text: checked.formula,
|
|
110
|
+
tree: expression,
|
|
111
|
+
leaves: checked.leaves ?? [],
|
|
112
|
+
quantity: checked.quantity ?? null,
|
|
113
|
+
problems: checked.problems ?? [],
|
|
114
|
+
chain: useDraftChain ? "drafts" : "published",
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
return {
|
|
120
|
+
formula: { text: null, tree: expression },
|
|
121
|
+
formulaNote: "The formula text and its leaves could not be read from this deploy " +
|
|
122
|
+
`(\`POST ${VALIDATE_ROUTE}\`: ${err instanceof Error ? err.message : String(err)}). ` +
|
|
123
|
+
"The stored tree is above.",
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export function registerMeasureFormulaTools(server, client) {
|
|
128
|
+
server.tool("get_measure_formula_spec", "The ONLY valid list of words for a measure's formula — read it BEFORE " +
|
|
129
|
+
"create_measure or update_measure, and never write a function, " +
|
|
130
|
+
"operator or grain from memory. Read-only. " +
|
|
131
|
+
"\n\nServed by the platform from the code that parses a formula, so it " +
|
|
132
|
+
"is the same list its formula editor shows: per word its signature, " +
|
|
133
|
+
"what it returns, its quantity rule and an example; the operators, " +
|
|
134
|
+
"grains and limits; every refusal `code` with `when` and `fix`; " +
|
|
135
|
+
"`recipes` for the numbers a management team asks for (a sum over two " +
|
|
136
|
+
"facts, a margin %, a share of the total); and `buildOrder`. A word " +
|
|
137
|
+
"with `available: false` is coming and is refused by name " +
|
|
138
|
+
"(`not_yet_supported`) — do not use it. " +
|
|
139
|
+
"\n\n`includeWorkspace: true` adds THIS workspace's vocabulary as " +
|
|
140
|
+
"`workspace`: its measures (name, label, quantity, status), its tables " +
|
|
141
|
+
"and columns, and which dimensions each table reaches — the names a " +
|
|
142
|
+
"formula may use. The answer is then `{ spec, workspace }`; without " +
|
|
143
|
+
"it, the spec itself.", {
|
|
144
|
+
includeWorkspace: z
|
|
145
|
+
.boolean()
|
|
146
|
+
.optional()
|
|
147
|
+
.describe("Also return this workspace's measures, tables, columns and " +
|
|
148
|
+
"reachable dimensions. Defaults to false."),
|
|
149
|
+
useDraftChain: z
|
|
150
|
+
.boolean()
|
|
151
|
+
.optional()
|
|
152
|
+
.describe("With includeWorkspace: include tables and measures that were never " +
|
|
153
|
+
"published. Defaults to false — a published number reads " +
|
|
154
|
+
"published definitions."),
|
|
155
|
+
}, async ({ includeWorkspace, useDraftChain }) => guard(async () => {
|
|
156
|
+
const spec = await client.get(FORMULA_SPEC_ROUTE);
|
|
157
|
+
if (!includeWorkspace)
|
|
158
|
+
return jsonResult(spec);
|
|
159
|
+
const workspace = await client.get(FORMULA_SYMBOLS_ROUTE, {
|
|
160
|
+
useDraftChain: useDraftChain ?? false,
|
|
161
|
+
});
|
|
162
|
+
return jsonResult({ spec, workspace });
|
|
163
|
+
}));
|
|
164
|
+
server.tool("validate_measure", "Check a measure's formula WITHOUT saving it — call it before every " +
|
|
165
|
+
"create_measure and update_measure. Read-only. The same check the " +
|
|
166
|
+
"platform's editor runs while somebody types. " +
|
|
167
|
+
"\n\nAnswers `{ ok, formula, expression, quantity, leaves, problems }`: " +
|
|
168
|
+
"`formula` is the one spelling of it (names resolved, the brackets " +
|
|
169
|
+
"that apply shown); `expression` the tree that would be stored; " +
|
|
170
|
+
"`quantity` what the number counts, derived; `leaves` every " +
|
|
171
|
+
"aggregation it folds down to — table, aggregation, column, the " +
|
|
172
|
+
"conditions and ignored dimensions on that part, and the measures " +
|
|
173
|
+
"walked to reach it. " +
|
|
174
|
+
"\n\nEach problem has a `code`, a `message` and `where` (an `offset` " +
|
|
175
|
+
"in the text, or a `path` in the tree). `severity: error` blocks " +
|
|
176
|
+
"saving; a warning does not. Repair on the code — " +
|
|
177
|
+
"get_measure_formula_spec lists every one with its `fix` — before you " +
|
|
178
|
+
"ask a person: `parse_error` (the message says what was expected " +
|
|
179
|
+
"where), `unknown_measure` / `unknown_table` / `unknown_column` " +
|
|
180
|
+
"(similar names are suggested), `ambiguous_column` (write " +
|
|
181
|
+
"table.column), `column_kind`, `arity`, `cycle` (the chain is in the " +
|
|
182
|
+
"message), `too_complex` (give a part its own name), " +
|
|
183
|
+
"`quantity_mismatch` (adding euros to dogs, or a format that does not " +
|
|
184
|
+
"fit), `unreachable_dimension` (declare the relationship, or write " +
|
|
185
|
+
"`ignore` to mean the total on purpose), `not_yet_supported`. " +
|
|
186
|
+
"`quantity_generic` is a warning: the migration left the placeholder " +
|
|
187
|
+
"quantity — say what the number counts.", {
|
|
188
|
+
expression: z
|
|
189
|
+
.union([z.string(), z.record(z.unknown())])
|
|
190
|
+
.describe("The formula, as text (`divide([cm1], [net_revenue])`) or as the " +
|
|
191
|
+
"stored tree."),
|
|
192
|
+
measureId: z
|
|
193
|
+
.string()
|
|
194
|
+
.optional()
|
|
195
|
+
.describe("The measure being edited, when there is one — it is what makes a " +
|
|
196
|
+
"reference back to itself a `cycle`."),
|
|
197
|
+
quantity: z
|
|
198
|
+
.string()
|
|
199
|
+
.optional()
|
|
200
|
+
.describe("What the number counts, when you have said (EUR, customers, " +
|
|
201
|
+
"orders). Required on save for a single aggregation."),
|
|
202
|
+
format: z
|
|
203
|
+
.record(z.unknown())
|
|
204
|
+
.optional()
|
|
205
|
+
.describe("How it will be shown, as on the measure's `definition.format` — " +
|
|
206
|
+
"checked against what the number counts."),
|
|
207
|
+
useDraftChain: z
|
|
208
|
+
.boolean()
|
|
209
|
+
.optional()
|
|
210
|
+
.describe("Read the DRAFTS of the measures underneath instead of their " +
|
|
211
|
+
"published versions. Defaults to false, because a published " +
|
|
212
|
+
"number reads published definitions."),
|
|
213
|
+
}, async (body) => guard(async () => jsonResult(await client.post(VALIDATE_ROUTE, body))));
|
|
214
|
+
server.tool("read_measure", "Read one measure by id, including its current draft and version. Read " +
|
|
215
|
+
"before you update — you need the current version. " +
|
|
216
|
+
"\n\nIts formula comes back twice, from the platform: `formula.text` " +
|
|
217
|
+
"with names, as you would write it, and `formula.tree`, the stored " +
|
|
218
|
+
"form with ids. Beside them `formula.leaves` — the aggregations it " +
|
|
219
|
+
"folds down to, each on its own table — `formula.quantity`, and " +
|
|
220
|
+
"`formula.problems`: a measure that rests on a column or measure that " +
|
|
221
|
+
"has since gone says so here. `readsTables` follows from the leaves; " +
|
|
222
|
+
"there is no home table.", {
|
|
223
|
+
id: z.string().describe("The measure's id."),
|
|
224
|
+
useDraftChain: z
|
|
225
|
+
.boolean()
|
|
226
|
+
.optional()
|
|
227
|
+
.describe("Resolve the measures it rests on from their drafts instead of " +
|
|
228
|
+
"their published versions. Defaults to false; set it for a " +
|
|
229
|
+
"measure whose parts were never published, or their names " +
|
|
230
|
+
"cannot be shown."),
|
|
231
|
+
}, async ({ id, useDraftChain }) => guard(async () => {
|
|
232
|
+
const measure = (await client.get(`${MEASURES}/${id}`));
|
|
233
|
+
return jsonResult({
|
|
234
|
+
...measure,
|
|
235
|
+
...(await explainFormula(client, measure, useDraftChain ?? false)),
|
|
236
|
+
});
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=measureFormula.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measureFormula.js","sourceRoot":"","sources":["../../src/tools/measureFormula.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AAEpC,yEAAyE;AACzE,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,QAAQ,eAAe,CAAC;AAC7D,kFAAkF;AAClF,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,QAAQ,kBAAkB,CAAC;AACnE,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,QAAQ,WAAW,CAAC;AAErD,4EAA4E;AAC5E,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,YAAY,CAAU,CAAC;AACtD,4DAA4D;AAC5D,M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EAAE,CAAC;aACb,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CACP,8DAA8D;YAC5D,6DAA6D;YAC7D,qCAAqC,CACxC;KACJ,EACD,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,CACvF,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,cAAc,EACd,wEAAwE;QACtE,oDAAoD;QACpD,sEAAsE;QACtE,oEAAoE;QACpE,oEAAoE;QACpE,iEAAiE;QACjE,uEAAuE;QACvE,sEAAsE;QACtE,yBAAyB,EAC3B;QACE,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;QAC5C,aAAa,EAAE,CAAC;aACb,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CACP,gEAAgE;YAC9D,4DAA4D;YAC5D,2DAA2D;YAC3D,kBAAkB,CACrB;KACJ,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,CAC9B,KAAK,CAAC,KAAK,IAAI,EAAE;QACf,MAAM,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,QAAQ,IAAI,EAAE,EAAE,CAAC,CAAkB,CAAC;QACzE,OAAO,UAAU,CAAC;YAChB,GAAG,OAAO;YACV,GAAG,CAAC,MAAM,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,IAAI,KAAK,CAAC,CAAC;SACnE,CAAC,CAAC;IACL,CAAC,CAAC,CACL,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axonity-ai/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Model Context Protocol server for Axonity Flow — lets an external agent (e.g. Claude Code) read, draft, and update workflows, agents and tools in an Axonity tenant.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|