@axonity-ai/mcp 0.17.0 → 0.19.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.
Files changed (38) hide show
  1. package/README.md +82 -16
  2. package/dist/errors.js +41 -11
  3. package/dist/errors.js.map +1 -1
  4. package/dist/generated/listFilters.js +23 -1
  5. package/dist/generated/listFilters.js.map +1 -1
  6. package/dist/index.js +250 -27
  7. package/dist/index.js.map +1 -1
  8. package/dist/tools/access.d.ts +19 -0
  9. package/dist/tools/access.js +71 -0
  10. package/dist/tools/access.js.map +1 -0
  11. package/dist/tools/applications.d.ts +24 -0
  12. package/dist/tools/applications.js +145 -0
  13. package/dist/tools/applications.js.map +1 -0
  14. package/dist/tools/concepts.js +68 -3
  15. package/dist/tools/concepts.js.map +1 -1
  16. package/dist/tools/conventions.d.ts +2 -2
  17. package/dist/tools/conventions.js +37 -10
  18. package/dist/tools/conventions.js.map +1 -1
  19. package/dist/tools/dataSources.d.ts +5 -5
  20. package/dist/tools/dataSources.js +38 -14
  21. package/dist/tools/dataSources.js.map +1 -1
  22. package/dist/tools/dataTables.js +7 -5
  23. package/dist/tools/dataTables.js.map +1 -1
  24. package/dist/tools/knowledgeGraph.d.ts +28 -0
  25. package/dist/tools/knowledgeGraph.js +126 -0
  26. package/dist/tools/knowledgeGraph.js.map +1 -0
  27. package/dist/tools/measureFormula.d.ts +5 -5
  28. package/dist/tools/measureFormula.js +33 -12
  29. package/dist/tools/measureFormula.js.map +1 -1
  30. package/dist/tools/queries.d.ts +18 -0
  31. package/dist/tools/queries.js +70 -0
  32. package/dist/tools/queries.js.map +1 -0
  33. package/dist/tools/register.d.ts +12 -0
  34. package/dist/tools/register.js +4 -2
  35. package/dist/tools/register.js.map +1 -1
  36. package/dist/tools/validation.js +21 -3
  37. package/dist/tools/validation.js.map +1 -1
  38. package/package.json +1 -1
@@ -345,8 +345,9 @@ made any time before you attach them.
345
345
  then wire with the \`attach_*\` tools — see Wiring.
346
346
  - A reference doc has NO kind any more. What used to be a semantic note lives
347
347
  in the model itself: a word is a concept (\`create_concept\`), a table card
348
- is the table's description and grain, a source query is the table's
349
- \`provenance\`, an example question is a measure's \`questions\`. The
348
+ is the table's description and grain, a source query is a query of its
349
+ own (\`create_query\`, the table's \`fillingQueryId\`), an example question
350
+ is a measure's \`questions\`. The
350
351
  platform refuses \`semanticKind\`, \`semanticDetails\`, \`subjectTableId\`
351
352
  and \`subjectSourceId\` on a reference doc, and says where each one went.
352
353
  Building the SEMANTIC MODEL? Read \`axonity_semantic_conventions\` first —
@@ -970,6 +971,15 @@ the rows; the rows come from \`read_data_table\`.
970
971
  the box, call \`list_toolbox_dependent_tools\` — it names the tools that would
971
972
  start failing at run time with a bare 401.
972
973
 
974
+ ## Who may read what
975
+ Every policy, skill, reference doc and table carries a label: \`level\`
976
+ (public, internal, confidential) and \`audienceIds\`, whom it is meant for. An
977
+ agent and a workflow carry a \`clearance\`; so does your token, and you read
978
+ with it. Look audience ids up with \`list_audiences\` — never guess one, and
979
+ compare on id, never on name. \`level: null\` makes a thing readable by nobody.
980
+ Narrowing a label is always allowed; widening it is a colleague's act, never
981
+ yours.
982
+
973
983
  ## Tenant
974
984
  - Your token fixes the tenant. You cannot act across tenants; never send a
975
985
  tenant id in a body.
@@ -1013,7 +1023,7 @@ const SEMANTIC_KNOWLEDGE_UNAVAILABLE = "## Semantic knowledge — NOT AVAILABLE\
1013
1023
  "The rules for writing the semantic layer could not be read from this deploy " +
1014
1024
  `(\`GET ${SEMANTIC_KNOWLEDGE_ROUTE}\`). This connector does not carry a copy ` +
1015
1025
  "of them. Do not build the semantic model — no concept, no measure, no " +
1016
- "table provenance — until they can be read: call " +
1026
+ "query — until they can be read: call " +
1017
1027
  "`axonity_semantic_conventions` again, and if it still fails, report it " +
1018
1028
  "rather than deciding what the knowledge should say yourself.";
1019
1029
  /**
@@ -1065,11 +1075,21 @@ columns and the dimensions each table reaches.
1065
1075
  - **Derived** — arithmetic over other measures by name: a sum over two facts,
1066
1076
  a margin, a share of the total with \`ignore\`.
1067
1077
  - **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
1078
+ running total, measured in a calendar of the workspace's date table.
1079
+
1080
+ **Time runs over one date table.** One table per workspace is the date table
1081
+ (\`dateTable: true\`, a row per day), and its \`calendars\` say which column
1082
+ holds the year, quarter, month, week and day — a production calendar is just
1083
+ another calendar. Every fact reaches it through its own time axis, so a week
1084
+ means the same thing to each of them. A series runs over the calendar's
1085
+ periods: a period without rows is shown empty, not left out. A window's total
1086
+ is the window ending at the end of the period asked for; a running total per
1087
+ month is the standing at the end of each month, never their sum. A fact kept
1088
+ per month is not asked per week (\`grain_too_fine\`).
1089
+
1090
+ **Row logic belongs in the query that fills the table, not in a measure.** A
1091
+ value per row (net = gross − discount) is a column, added to that query's
1092
+ \`sql\` and described like any other column. A measure is computed
1073
1093
  per question — period, grain, split, filters — and is never stored.
1074
1094
 
1075
1095
  **How a number is computed.** Each leaf is aggregated on its own table, over
@@ -1083,8 +1103,15 @@ rests on itself, euros added to dogs, a format that does not fit what the
1083
1103
  number counts: each is refused with a code. \`validate_measure\` returns them
1084
1104
  before you save; repair on the code before asking a person.
1085
1105
 
1106
+ **Explain a number by its parts.** \`query_measures\` with \`explain: true\`
1107
+ gives what each part of the formula answered, on the total and per period and
1108
+ group. Use it to say why a number moved, instead of reading rows.
1109
+
1086
1110
  **Order.** Base measures first, each with its \`quantity\`; then the derived
1087
- ones; \`validate_measure\` before every save; publish from the bottom up.
1111
+ ones; \`validate_measure\` before every save; publish from the bottom up — a
1112
+ published measure over an unpublished one is refused. A measure knows what
1113
+ rests on it (\`usedBy\`, \`dashboards\` on \`read_measure\`): read that before
1114
+ you change or delete one, because those numbers move with it.
1088
1115
  `;
1089
1116
  /** Read this deploy's semantic-knowledge rules, or say why not. Exported for testing. */
1090
1117
  export async function readSemanticKnowledgeRules(client) {
@@ -1112,7 +1139,7 @@ export function registerConventions(server, client) {
1112
1139
  ],
1113
1140
  }));
1114
1141
  server.tool("axonity_semantic_conventions", "Read BEFORE building a workspace's semantic model: the tables with " +
1115
- "their provenance and grain, the measures, and the concepts that say " +
1142
+ "the queries that fill them and their grain, the measures, and the concepts that say " +
1116
1143
  "what a word or a number means. Returns this deploy's rules for writing " +
1117
1144
  "it: what a concept owes, what a measure's description and questions " +
1118
1145
  "must say, and what a table's grain must say about one row. Read live " +
@@ -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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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,sFAAsF;QACtF,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"}
@@ -10,11 +10,11 @@
10
10
  * shows, and duplicating a dashboard.
11
11
  *
12
12
  * **There are no sync tools any more.** A sync was a separate object beside
13
- * the table it filled; the semantic model made it the table's own
14
- * `provenance` (source, query, grain, key, mode, schedule), so a changed query
15
- * goes through the same approval as a changed column. Filling a table is now
16
- * `create_data_table` / `update_data_table` with `provenance`, and running it
17
- * early is `refresh_data_table` (tools/dataTables.ts). A measure is no longer
13
+ * the table it filled. The semantic model first made it the table's own
14
+ * `provenance`; axonity-flow#2013 then moved the source, SQL and grain into a
15
+ * named query (tools/queries.ts), leaving the table its `filledBy`,
16
+ * `fillingQueryId` and `rhythm`. Running a fill early is `refresh_data_table`
17
+ * (tools/dataTables.ts). A measure is no longer
18
18
  * a field on a table either: it is its own versioned entity (`create_measure`
19
19
  * and the rest of the generic family).
20
20
  *
@@ -10,11 +10,11 @@
10
10
  * shows, and duplicating a dashboard.
11
11
  *
12
12
  * **There are no sync tools any more.** A sync was a separate object beside
13
- * the table it filled; the semantic model made it the table's own
14
- * `provenance` (source, query, grain, key, mode, schedule), so a changed query
15
- * goes through the same approval as a changed column. Filling a table is now
16
- * `create_data_table` / `update_data_table` with `provenance`, and running it
17
- * early is `refresh_data_table` (tools/dataTables.ts). A measure is no longer
13
+ * the table it filled. The semantic model first made it the table's own
14
+ * `provenance`; axonity-flow#2013 then moved the source, SQL and grain into a
15
+ * named query (tools/queries.ts), leaving the table its `filledBy`,
16
+ * `fillingQueryId` and `rhythm`. Running a fill early is `refresh_data_table`
17
+ * (tools/dataTables.ts). A measure is no longer
18
18
  * a field on a table either: it is its own versioned entity (`create_measure`
19
19
  * and the rest of the generic family).
20
20
  *
@@ -57,14 +57,15 @@ export function registerDataSourceTools(server, client) {
57
57
  "query. `containerWord` is what this warehouse calls the container " +
58
58
  "(\"dataset\" on BigQuery, \"schema\" on PostgreSQL). Column types are " +
59
59
  "the warehouse's own names, passed through. Read this before writing a " +
60
- "query or a table's provenance, rather than guessing table names. " +
60
+ "query, rather than guessing table names. " +
61
61
  "On a source restricted to `policy.allowedDatasets` it reads those " +
62
62
  "datasets one by one, so it answers even when the key may not list " +
63
63
  "the whole project.", { id: SOURCE_ID }, async ({ id }) => guard(async () => jsonResult(await client.get(`${SOURCES}/${id}/schema`))));
64
64
  server.tool("query_data_source", "Run a READ-ONLY SQL query against the warehouse and get the rows back. " +
65
65
  "For looking — checking what a warehouse table holds, trying the " +
66
- "query a table's provenance will run. To fill a table regularly, give " +
67
- "it a `provenance` (create_data_table / update_data_table). " +
66
+ "statement before it becomes a query. To fill a table regularly, make " +
67
+ "it a query (create_query, try it with test_query) and point the table " +
68
+ "at it: `filledBy: \"query\"`, `fillingQueryId`, `rhythm`. " +
68
69
  "\n\nTHE ROWS ARE CAPPED. `truncated: true` means rows were left out: " +
69
70
  "`rowCount` is what came back, `totalRows` is what matched. Never report " +
70
71
  "a count or a total off a truncated answer — aggregate in the SQL " +
@@ -86,7 +87,7 @@ export function registerDataSourceTools(server, client) {
86
87
  .int()
87
88
  .optional()
88
89
  .describe("How many rows you want back. Clamped by the platform — a bigger " +
89
- "answer belongs in a table with provenance, not in a response."),
90
+ "answer belongs in a table filled by a query, not in a response."),
90
91
  }, async ({ id, sql, maxRows }) => guard(async () => jsonResult(await client.post(`${SOURCES}/${id}/query`, {
91
92
  sql,
92
93
  ...(maxRows !== undefined ? { maxRows } : {}),
@@ -103,7 +104,11 @@ export function registerMeasureTools(server, client) {
103
104
  "this table, and create_measure defines one. Read this for the column " +
104
105
  "names a measure's formula, `splitBy` or `filters` may use — or " +
105
106
  "get_measure_formula_spec({ includeWorkspace: true }) for every " +
106
- "table's columns at once.", {
107
+ "table's columns at once. " +
108
+ "\n\nOn the workspace's date table it also says `dateTable: true` and " +
109
+ "its `calendars`, each naming the column that holds the year, quarter, " +
110
+ "month, week and day: what a time window (shift, to_date, rolling, " +
111
+ "running) can be measured in.", {
107
112
  tableId: z.string().describe("The dynamic table's id."),
108
113
  useDraft: z
109
114
  .boolean()
@@ -115,7 +120,7 @@ export function registerMeasureTools(server, client) {
115
120
  "own. Read-only. This is where a dashboard's numbers come from. " +
116
121
  "\n\nEach question is " +
117
122
  "`{ key, measure, tableId?, period?, start?, end?, compare?, grain?, " +
118
- "splitBy?, filters?, limit?, useDraft? }`. `key` is your own label and " +
123
+ "splitBy?, filters?, limit?, useDraft?, useDraftChain?, explain? }`. `key` is your own label and " +
119
124
  "comes back on the answer. `measure` is the measure's NAME — its " +
120
125
  "handle, unique in the workspace (list_measures); `tableId` is " +
121
126
  "optional and no longer what finds it. `period` is one of: " +
@@ -124,16 +129,35 @@ export function registerMeasureTools(server, client) {
124
129
  "(YYYY-MM-DD) for a custom range. `compare` is none, previous_period or " +
125
130
  "previous_year. `grain` (none, auto, day, week, month, quarter, year) " +
126
131
  "draws a series. `splitBy` names a column to group by; `limit` (1-50) " +
127
- "keeps the largest groups. " +
132
+ "keeps the largest groups. `useDraft` reads this measure's draft; " +
133
+ "`useDraftChain` also the drafts of the measures UNDER it — each part's " +
134
+ "`readFrom` then says which version it read. " +
128
135
  "\n\nA MEASURE OVER OTHER MEASURES is computed per group: each of " +
129
136
  "its parts is aggregated on its own table, and the formula is applied " +
130
137
  "to the results. Its TOTAL is computed again over the whole period, " +
131
138
  "never added up from the groups — the total of a margin % is total " +
132
139
  "margin over total revenue, not the average of the monthly " +
133
140
  "percentages. Report the total you are given; do not sum the series. " +
134
- "read_measure shows which parts a number is made of. " +
141
+ "A time window is the window ENDING at the end of the period asked " +
142
+ "for, and a running total per month is the standing at the end of " +
143
+ "each month, not their sum. " +
144
+ "\n\nTO EXPLAIN A NUMBER, ask `explain: true`: the answer's `leaves` " +
145
+ "are the parts of the formula (table, aggregation, conditions, window) " +
146
+ "and `parts` holds what each part gave for the total, in the order of " +
147
+ "`leaves` — and each point of `series` and each entry of `groups` " +
148
+ "carries its own `parts`. \"The margin fell\" is not an explanation; " +
149
+ "\"revenue held and cost rose\" is. Use it instead of reading rows. " +
135
150
  "\n\nONE BAD QUESTION DOES NOT FAIL THE CALL: every answer carries " +
136
- "`ok`, and `ok: false` comes with an `error` of its own. Check each one. " +
151
+ "`ok`, and `ok: false` comes with an `error` of its own and, where it " +
152
+ "has one, a `code` from get_measure_formula_spec — `grain_too_fine` " +
153
+ "(a fact kept per month asked per week: ask a coarser grain), " +
154
+ "`unreachable_dimension`, or `breaks_measure` (a column, table or " +
155
+ "relationship it reads is gone: the measure must be repaired, not the " +
156
+ "question). Check each one. `warnings` do not make it wrong but are " +
157
+ "worth saying: `empty_leaf` means one PART found no rows in this " +
158
+ "period — in a sum that side counts as nought, which is also what a " +
159
+ "feed that stopped loading looks like. A period with no rows in a " +
160
+ "series is shown empty, not left out. " +
137
161
  "\n\n`freshAsOf` says how old the newest row behind the number is; " +
138
162
  "`certified: false` means it was computed from a draft; `tables` names " +
139
163
  "every table the number came from. Say so when you " +
@@ -1 +1 @@
1
- {"version":3,"file":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,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;aAC5B,QAAQ,EAAE;aACV,QAAQ,CAAC,+DAA+D,CAAC;KAC7E,EACD,KAAK,EAAE,IAAI,EAAE,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"}
@@ -159,17 +159,19 @@ export function registerDataTableTools(server, client) {
159
159
  // The page envelope is forwarded WHOLE — unwrapping to `items` would
160
160
  // rebuild the silent truncation this tool exists to avoid.
161
161
  jsonResult(await client.get(`${BASE}/${tableId}/rows`, { q, limit, cursor }))));
162
- server.tool("refresh_data_table", "Fill a table from its source NOW instead of at its next scheduled time. " +
163
- "Replaces run_data_source_sync: a table's fill is its own `provenance` " +
164
- "now, not a separate sync. " +
162
+ server.tool("refresh_data_table", "Fill a table from its query NOW instead of at its next scheduled time " +
163
+ "— or at all, for a table with no `rhythm`, which fills only when " +
164
+ "asked. Replaces run_data_source_sync: what fills a table is the query " +
165
+ "its `fillingQueryId` names, not a separate sync. " +
165
166
  "\n\nTHIS DOES NOT WAIT FOR THE RESULT. The query can take tens of " +
166
167
  "seconds, so the platform brings the table's next fill forward and its " +
167
168
  "scheduler runs it. The response is the table, with `fill.nextAt` set " +
168
169
  "to now. To see how it went, read_data_table again after a moment: " +
169
170
  "`fill.lastAt`, `fill.lastRowCount` and `fill.lastError` describe the " +
170
171
  "run. " +
171
- "\n\nRefused with a 422 when the table has no `provenance` — its rows " +
172
- "come from a workflow or an author, and there is nothing to run.", { id: z.string().describe("The table's id.") }, async ({ id }) => guard(async () => jsonResult(await client.post(`${BASE}/${id}/refresh`))));
172
+ "\n\nRefused with a 422 when the table is not filled by a query " +
173
+ "(`filledBy` is `author` or `workflow`) — its rows come from a workflow " +
174
+ "or an author, and there is nothing to run.", { id: z.string().describe("The table's id.") }, async ({ id }) => guard(async () => jsonResult(await client.post(`${BASE}/${id}/refresh`))));
173
175
  server.tool("list_data_table_tools", "Which tools this table yields, and which of them a RUN can actually " +
174
176
  "reach. Read-only. " +
175
177
  "\n\nA published table mints its own CRUD tools, so giving an agent " +
@@ -1 +1 @@
1
- {"version":3,"file":"dataTables.js","sourceRoot":"","sources":["../../src/tools/dataTables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,IAAI,GAAG,qBAAqB,CAAC;AAEnC;;;;;;;GAOG;AACH,MAAM,KAAK,GAAG;IACZ,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,QAAQ,CACP,qEAAqE;QACnE,wEAAwE;QACxE,wEAAwE;QACxE,oDAAoD,CACvD;IACH,UAAU,EAAE,CAAC;SACV,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,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,EAC9C,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CACf,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Reading what the platform has learned: the knowledge graph (axonity-mcp#88,
3
+ * S5; the platform half is axonity-flow#1918).
4
+ *
5
+ * Runs, documents and colleagues teach the workspace facts. Each fact has a
6
+ * certainty, a validity, the topics it belongs to and the passages it was
7
+ * learned from. These tools let an agent look — to check what a run learned,
8
+ * or why an answer said what it said.
9
+ *
10
+ * **It reads with the token's clearance.** The platform filters every read in
11
+ * its own queries: a fact the token may not read is not in a search, not in
12
+ * its topic, and not found by id. So an empty answer is an answer about what
13
+ * THIS TOKEN may see, and the descriptions say so.
14
+ *
15
+ * **Looking, never judging.** Confirming, rejecting, correcting, archiving,
16
+ * relabelling and erasing a fact, answering a decision or a learning round:
17
+ * all of that ends with a person by design, and `test/denyList.ts` records it.
18
+ * So do the work lists of the Oversight screen — they hold only what the
19
+ * reader maintains or was handed, and a token maintains nothing, so a tool
20
+ * over them could only ever answer an empty list.
21
+ *
22
+ * **The module can be off.** Every route here sits behind the Cortex module;
23
+ * switched off, each answers 403 with the module's sentence, which
24
+ * `ForbiddenError` turns into plain words rather than "your token may not".
25
+ */
26
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
27
+ import type { AxonityClient } from "../client.js";
28
+ export declare function registerKnowledgeGraphTools(server: McpServer, client: AxonityClient): void;
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Reading what the platform has learned: the knowledge graph (axonity-mcp#88,
3
+ * S5; the platform half is axonity-flow#1918).
4
+ *
5
+ * Runs, documents and colleagues teach the workspace facts. Each fact has a
6
+ * certainty, a validity, the topics it belongs to and the passages it was
7
+ * learned from. These tools let an agent look — to check what a run learned,
8
+ * or why an answer said what it said.
9
+ *
10
+ * **It reads with the token's clearance.** The platform filters every read in
11
+ * its own queries: a fact the token may not read is not in a search, not in
12
+ * its topic, and not found by id. So an empty answer is an answer about what
13
+ * THIS TOKEN may see, and the descriptions say so.
14
+ *
15
+ * **Looking, never judging.** Confirming, rejecting, correcting, archiving,
16
+ * relabelling and erasing a fact, answering a decision or a learning round:
17
+ * all of that ends with a person by design, and `test/denyList.ts` records it.
18
+ * So do the work lists of the Oversight screen — they hold only what the
19
+ * reader maintains or was handed, and a token maintains nothing, so a tool
20
+ * over them could only ever answer an empty list.
21
+ *
22
+ * **The module can be off.** Every route here sits behind the Cortex module;
23
+ * switched off, each answers 403 with the module's sentence, which
24
+ * `ForbiddenError` turns into plain words rather than "your token may not".
25
+ */
26
+ import { z } from "zod";
27
+ import { guard, jsonResult } from "./result.js";
28
+ const KNOWLEDGE = "/api/v1/knowledge";
29
+ /** Said on every tool: an empty answer is about the token, not the graph. */
30
+ const CLEARANCE_NOTE = "\n\nYOU READ WITH YOUR TOKEN'S CLEARANCE: what it may not read is " +
31
+ "left out entirely, so an empty answer means nothing THIS TOKEN may see, " +
32
+ "not that nothing was learned. If Cortex is switched off in the " +
33
+ "workspace, the call is refused and says so.";
34
+ const PAGE_NOTE = "\n\nTHE RESPONSE IS ONE PAGE: { items, nextCursor, pageSize, hasMore }. " +
35
+ "While hasMore is true you have not seen them all — pass nextCursor back " +
36
+ "as cursor for the next page. Never build a cursor yourself, and never " +
37
+ "count from one page.";
38
+ const LIMIT = z
39
+ .number()
40
+ .int()
41
+ .optional()
42
+ .describe("Page size. Omit for the platform's default.");
43
+ const CURSOR = z
44
+ .string()
45
+ .optional()
46
+ .describe("The previous response's nextCursor, to get the next page. Omit for the " +
47
+ "first page.");
48
+ const AS_OF = z
49
+ .string()
50
+ .optional()
51
+ .describe("A date (YYYY-MM-DD): answer as the graph stood at the end of that day — " +
52
+ "what was valid then. Omit for now.");
53
+ export function registerKnowledgeGraphTools(server, client) {
54
+ server.tool("search_knowledge_graph", "Search what the workspace has learned, with a question in plain words. " +
55
+ "Read-only. The same search an agent in a run gets. " +
56
+ "\n\nThe answer lands on up to eight places (`landing`), each a fact " +
57
+ "or a topic with what hangs around it. A fact never comes bare: its " +
58
+ "`certainty`, `status`, validity (`validFrom`, `validUntil`), its " +
59
+ "topics and its `passages` — the evidence, each with its source, the " +
60
+ "source's score and a date. Report a fact with its certainty and " +
61
+ "source, not as plain truth. `tips` are facts below the threshold for " +
62
+ "an answer; they are only shown to someone who maintains them. " +
63
+ "\n\nUse read_fact for one fact's full card and read_source for where " +
64
+ "it came from." +
65
+ CLEARANCE_NOTE, {
66
+ q: z.string().describe("The question, in plain words (at most 2000 characters)."),
67
+ asOf: AS_OF,
68
+ }, async ({ q, asOf }) => guard(async () => jsonResult(await client.get(`${KNOWLEDGE}/search`, { q, as_of: asOf }))));
69
+ server.tool("list_knowledge_topics", "The topics of the knowledge graph, newest first, each with its summary, " +
70
+ "its label and how many facts it holds. Read-only. A topic is a " +
71
+ "subject facts are grouped under; list_topic_facts opens one." +
72
+ PAGE_NOTE +
73
+ CLEARANCE_NOTE, { limit: LIMIT, cursor: CURSOR }, async ({ limit, cursor }) => guard(async () => jsonResult(await client.get(`${KNOWLEDGE}/topics`, { limit, cursor }))));
74
+ server.tool("list_topic_facts", "The facts of one topic, each with its certainty, status, label and " +
75
+ "validity. Read-only. read_fact gives one fact's passages, sources " +
76
+ "and history." +
77
+ PAGE_NOTE +
78
+ CLEARANCE_NOTE, {
79
+ topicId: z
80
+ .string()
81
+ .describe("The topic's id, from list_knowledge_topics or a search."),
82
+ limit: LIMIT,
83
+ cursor: CURSOR,
84
+ }, async ({ topicId, limit, cursor }) => guard(async () => jsonResult(await client.get(`${KNOWLEDGE}/topics/${topicId}/facts`, { limit, cursor }))));
85
+ server.tool("read_fact", "One fact's whole card. Read-only. Beside the text and its certainty: " +
86
+ "`passages` (the evidence, each with its source), `topics` and " +
87
+ "`about` (what it is about), `formulations` (other ways it was said), " +
88
+ "`provenance` (which run or document taught it), `events` (its " +
89
+ "history: learned, confirmed, corrected, archived), `knownSince`, " +
90
+ "`shelfLifeUntil`, and whether it waits on a person (`doubtful`, " +
91
+ "`pendingCorrection`, `questionOpen`). " +
92
+ "\n\nTo check what a run learned, look for that run in `provenance` " +
93
+ "and `events[].runId`. A fact this token may not read answers as not " +
94
+ "found, exactly like one that does not exist." +
95
+ CLEARANCE_NOTE, { id: z.string().describe("The fact's id, from a search or a topic.") }, async ({ id }) => guard(async () => jsonResult(await client.get(`${KNOWLEDGE}/facts/${id}`))));
96
+ server.tool("read_source", "Where facts came from: one source's card. Read-only. Its type and " +
97
+ "score (`score`, and the `startScore` its type gave it), how often it " +
98
+ "was right, wrong or silent (`nRight`, `nWrong`, `nSilent`), whether " +
99
+ "its score is pinned, how many facts rest on it, and its history. A " +
100
+ "fact's passages name their source by id." +
101
+ CLEARANCE_NOTE, { id: z.string().describe("The source's id, from a fact's passages.") }, async ({ id }) => guard(async () => jsonResult(await client.get(`${KNOWLEDGE}/sources/${id}`))));
102
+ server.tool("list_knowledge_tree", "One level of the knowledge graph's tree: the top layer, or the " +
103
+ "children of `parent`. Read-only. Each node is a group or a topic, " +
104
+ "with its summary, label, fact count and `hasChildren` — call again " +
105
+ "with its id as `parent` to go one level down." +
106
+ PAGE_NOTE +
107
+ CLEARANCE_NOTE, {
108
+ parent: z
109
+ .string()
110
+ .optional()
111
+ .describe("The node to open. Omit for the top layer."),
112
+ limit: LIMIT,
113
+ cursor: CURSOR,
114
+ }, async ({ parent, limit, cursor }) => guard(async () => jsonResult(await client.get(`${KNOWLEDGE}/tree`, { parent, limit, cursor }))));
115
+ server.tool("list_related_topics", "The topics and groups nearest to one node of the tree, nearest first — " +
116
+ "at most five, so the answer is always complete (`nextCursor` is " +
117
+ "always null). Read-only. Use it to step sideways from a topic." +
118
+ CLEARANCE_NOTE, { nodeId: z.string().describe("A topic or group id, from the tree or a search.") }, async ({ nodeId }) => guard(async () => jsonResult(await client.get(`${KNOWLEDGE}/tree/${nodeId}/related`))));
119
+ server.tool("list_archived_facts", "What was archived recently (the platform keeps them visible for a " +
120
+ "while, thirty days to start with), so a second pair of eyes can look " +
121
+ "afterwards. Read-only. Restoring one is a colleague's decision, not " +
122
+ "something a token can do: report what you found." +
123
+ PAGE_NOTE +
124
+ CLEARANCE_NOTE, { limit: LIMIT, cursor: CURSOR }, async ({ limit, cursor }) => guard(async () => jsonResult(await client.get(`${KNOWLEDGE}/archived`, { limit, cursor }))));
125
+ }
126
+ //# sourceMappingURL=knowledgeGraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"knowledgeGraph.js","sourceRoot":"","sources":["../../src/tools/knowledgeGraph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,SAAS,GAAG,mBAAmB,CAAC;AAEtC,6EAA6E;AAC7E,MAAM,cAAc,GAClB,oEAAoE;IACpE,0EAA0E;IAC1E,iEAAiE;IACjE,6CAA6C,CAAC;AAEhD,MAAM,SAAS,GACb,0EAA0E;IAC1E,0EAA0E;IAC1E,wEAAwE;IACxE,sBAAsB,CAAC;AAEzB,MAAM,KAAK,GAAG,CAAC;KACZ,MAAM,EAAE;KACR,GAAG,EAAE;KACL,QAAQ,EAAE;KACV,QAAQ,CAAC,6CAA6C,CAAC,CAAC;AAE3D,MAAM,MAAM,GAAG,CAAC;KACb,MAAM,EAAE;KACR,QAAQ,EAAE;KACV,QAAQ,CACP,yEAAyE;IACvE,aAAa,CAChB,CAAC;AAEJ,MAAM,KAAK,GAAG,CAAC;KACZ,MAAM,EAAE;KACR,QAAQ,EAAE;KACV,QAAQ,CACP,0EAA0E;IACxE,oCAAoC,CACvC,CA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**Checking is the platform's too.** `validate_measure` forwards to
18
18
  * `POST /measures/validate`, the route the editor calls while somebody types,
19
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.
20
+ * acceptable. `read_measure` asks that same route for the leaves a stored tree
21
+ * folds down to; the text is the platform's own `formula` on the measure.
22
22
  *
23
23
  * The one rule held HERE is the shape of a write: a measure is written as
24
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.
25
+ * with `legacy_field`. The platform refuses them too since its form writes only
26
+ * `expression`; the check stays here because a `definition` WITHOUT
27
+ * `expression` is still stored there as a `sum` nobody wrote.
28
28
  */
29
29
  import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
30
30
  import type { AxonityClient } from "../client.js";
@@ -17,14 +17,14 @@
17
17
  * **Checking is the platform's too.** `validate_measure` forwards to
18
18
  * `POST /measures/validate`, the route the editor calls while somebody types,
19
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.
20
+ * acceptable. `read_measure` asks that same route for the leaves a stored tree
21
+ * folds down to; the text is the platform's own `formula` on the measure.
22
22
  *
23
23
  * The one rule held HERE is the shape of a write: a measure is written as
24
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.
25
+ * with `legacy_field`. The platform refuses them too since its form writes only
26
+ * `expression`; the check stays here because a `definition` WITHOUT
27
+ * `expression` is still stored there as a `sum` nobody wrote.
28
28
  */
29
29
  import { z } from "zod";
30
30
  import { guard, jsonResult } from "./result.js";
@@ -82,12 +82,18 @@ export function assertFormulaShape(fields) {
82
82
  /**
83
83
  * The stored tree, written back as text with its leaves, by the platform.
84
84
  *
85
+ * The text is the measure's own `formula` — the platform writes it on every
86
+ * read since phase 4 — and the validate route's only where a deploy does not
87
+ * carry it yet. The leaves always come from the validate route: a read of the
88
+ * measure does not fold it.
89
+ *
85
90
  * Best effort, and said so: a read must not fail because the explanation
86
91
  * could not be produced. When it cannot, the measure comes back as stored with
87
- * a sentence saying why its formula text is missing.
92
+ * a sentence saying why its leaves are missing.
88
93
  */
89
94
  async function explainFormula(client, measure, useDraftChain) {
90
95
  const expression = measure.definition?.expression;
96
+ const ownText = typeof measure.formula === "string" && measure.formula !== "" ? measure.formula : null;
91
97
  if (expression === undefined || expression === null) {
92
98
  return {
93
99
  formula: null,
@@ -106,7 +112,7 @@ async function explainFormula(client, measure, useDraftChain) {
106
112
  }));
107
113
  return {
108
114
  formula: {
109
- text: checked.formula,
115
+ text: ownText ?? checked.formula,
110
116
  tree: expression,
111
117
  leaves: checked.leaves ?? [],
112
118
  quantity: checked.quantity ?? null,
@@ -117,8 +123,8 @@ async function explainFormula(client, measure, useDraftChain) {
117
123
  }
118
124
  catch (err) {
119
125
  return {
120
- formula: { text: null, tree: expression },
121
- formulaNote: "The formula text and its leaves could not be read from this deploy " +
126
+ formula: { text: ownText, tree: expression },
127
+ formulaNote: `The ${ownText === null ? "formula text and its leaves" : "leaves"} could not be read from this deploy ` +
122
128
  `(\`POST ${VALIDATE_ROUTE}\`: ${err instanceof Error ? err.message : String(err)}). ` +
123
129
  "The stored tree is above.",
124
130
  };
@@ -138,7 +144,8 @@ export function registerMeasureFormulaTools(server, client) {
138
144
  "(`not_yet_supported`) — do not use it. " +
139
145
  "\n\n`includeWorkspace: true` adds THIS workspace's vocabulary as " +
140
146
  "`workspace`: its measures (name, label, quantity, status), its tables " +
141
- "and columns, and which dimensions each table reaches — the names a " +
147
+ "and columns, which dimensions each table reaches, and the date " +
148
+ "table's calendars with the grains each one has — the names a " +
142
149
  "formula may use. The answer is then `{ spec, workspace }`; without " +
143
150
  "it, the spec itself.", {
144
151
  includeWorkspace: z
@@ -182,7 +189,16 @@ export function registerMeasureFormulaTools(server, client) {
182
189
  "message), `too_complex` (give a part its own name), " +
183
190
  "`quantity_mismatch` (adding euros to dogs, or a format that does not " +
184
191
  "fit), `unreachable_dimension` (declare the relationship, or write " +
185
- "`ignore` to mean the total on purpose), `not_yet_supported`. " +
192
+ "`ignore` to mean the total on purpose), `no_date_table` / " +
193
+ "`no_time_axis` (a time window needs the workspace's date table and a " +
194
+ "time axis on the table the part reads), `calendar_missing_grain` / " +
195
+ "`unknown_calendar` (map the grain in the calendar, or name one that " +
196
+ "exists), `stock_over_time` (a running total of a `latest` or `first` " +
197
+ "means nothing), `not_yet_supported`. " +
198
+ "\n\nEach leaf also says what it was read from (`readFrom`: every " +
199
+ "measure walked to reach it, then the table, each with the version " +
200
+ "read) and over which `window` — shift, to_date, rolling, running, " +
201
+ "with its calendar. Empty `window` is the period asked for. " +
186
202
  "`quantity_generic` is a warning: the migration left the placeholder " +
187
203
  "quantity — say what the number counts.", {
188
204
  expression: z
@@ -219,7 +235,12 @@ export function registerMeasureFormulaTools(server, client) {
219
235
  "folds down to, each on its own table — `formula.quantity`, and " +
220
236
  "`formula.problems`: a measure that rests on a column or measure that " +
221
237
  "has since gone says so here. `readsTables` follows from the leaves; " +
222
- "there is no home table.", {
238
+ "there is no home table. " +
239
+ "\n\nWHAT IT IS CONNECTED TO: `dependsOn` is every measure it rests " +
240
+ "on — the whole chain, which publishing checks; `usedBy` every " +
241
+ "measure that rests on IT; `dashboards` every dashboard with a tile " +
242
+ "on it. Read `usedBy` and `dashboards` before you change or delete a " +
243
+ "measure: those numbers move with it.", {
223
244
  id: z.string().describe("The measure's id."),
224
245
  useDraftChain: z
225
246
  .boolean()