@duckcodeailabs/dql-mcp 1.2.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/LICENSE +123 -0
- package/dist/context.d.ts +26 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +102 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +34 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/certify.d.ts +31 -0
- package/dist/tools/certify.d.ts.map +1 -0
- package/dist/tools/certify.js +22 -0
- package/dist/tools/certify.js.map +1 -0
- package/dist/tools/get-block.d.ts +55 -0
- package/dist/tools/get-block.d.ts.map +1 -0
- package/dist/tools/get-block.js +46 -0
- package/dist/tools/get-block.js.map +1 -0
- package/dist/tools/lineage-impact.d.ts +15 -0
- package/dist/tools/lineage-impact.d.ts.map +1 -0
- package/dist/tools/lineage-impact.js +45 -0
- package/dist/tools/lineage-impact.js.map +1 -0
- package/dist/tools/query-via-block.d.ts +37 -0
- package/dist/tools/query-via-block.d.ts.map +1 -0
- package/dist/tools/query-via-block.js +56 -0
- package/dist/tools/query-via-block.js.map +1 -0
- package/dist/tools/search-blocks.d.ts +32 -0
- package/dist/tools/search-blocks.d.ts.map +1 -0
- package/dist/tools/search-blocks.js +53 -0
- package/dist/tools/search-blocks.js.map +1 -0
- package/dist/tools/semantic.d.ts +35 -0
- package/dist/tools/semantic.d.ts.map +1 -0
- package/dist/tools/semantic.js +36 -0
- package/dist/tools/semantic.js.map +1 -0
- package/dist/tools/suggest-block.d.ts +48 -0
- package/dist/tools/suggest-block.d.ts.map +1 -0
- package/dist/tools/suggest-block.js +79 -0
- package/dist/tools/suggest-block.js.map +1 -0
- package/dist/tools/util.d.ts +10 -0
- package/dist/tools/util.d.ts.map +1 -0
- package/dist/tools/util.js +28 -0
- package/dist/tools/util.js.map +1 -0
- package/dist/transports/http.d.ts +20 -0
- package/dist/transports/http.d.ts.map +1 -0
- package/dist/transports/http.js +52 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/transports/stdio.d.ts +7 -0
- package/dist/transports/stdio.d.ts.map +1 -0
- package/dist/transports/stdio.js +12 -0
- package/dist/transports/stdio.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and
|
|
10
|
+
distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright
|
|
13
|
+
owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities
|
|
16
|
+
that control, are controlled by, or are under common control with that entity.
|
|
17
|
+
For the purposes of this definition, "control" means (i) the power, direct or
|
|
18
|
+
indirect, to cause the direction or management of such entity, whether by
|
|
19
|
+
contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
20
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
21
|
+
|
|
22
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
|
23
|
+
permissions granted by this License.
|
|
24
|
+
|
|
25
|
+
"Source" form shall mean the preferred form for making modifications, including
|
|
26
|
+
but not limited to software source code, documentation source, and configuration
|
|
27
|
+
files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or
|
|
30
|
+
translation of a Source form, including but not limited to compiled object code,
|
|
31
|
+
generated documentation, and conversions to other media types.
|
|
32
|
+
|
|
33
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made
|
|
34
|
+
available under the License, as indicated by a copyright notice that is included
|
|
35
|
+
in or attached to the work.
|
|
36
|
+
|
|
37
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that
|
|
38
|
+
is based on (or derived from) the Work and for which the editorial revisions,
|
|
39
|
+
annotations, elaborations, or other modifications represent, as a whole, an
|
|
40
|
+
original work of authorship.
|
|
41
|
+
|
|
42
|
+
"Contribution" shall mean any work of authorship, including the original version
|
|
43
|
+
of the Work and any modifications or additions to that Work or Derivative Works
|
|
44
|
+
thereof, that is intentionally submitted to Licensor for inclusion in the Work
|
|
45
|
+
by the copyright owner or by an individual or Legal Entity authorized to submit
|
|
46
|
+
on behalf of the copyright owner.
|
|
47
|
+
|
|
48
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
|
49
|
+
of whom a Contribution has been received by Licensor and subsequently
|
|
50
|
+
incorporated within the Work.
|
|
51
|
+
|
|
52
|
+
2. Grant of Copyright License.
|
|
53
|
+
|
|
54
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
55
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
56
|
+
irrevocable copyright license to reproduce, prepare Derivative Works of,
|
|
57
|
+
publicly display, publicly perform, sublicense, and distribute the Work and such
|
|
58
|
+
Derivative Works in Source or Object form.
|
|
59
|
+
|
|
60
|
+
3. Grant of Patent License.
|
|
61
|
+
|
|
62
|
+
Subject to the terms and conditions of this License, each Contributor hereby
|
|
63
|
+
grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
|
|
64
|
+
irrevocable patent license to make, have made, use, offer to sell, sell, import,
|
|
65
|
+
and otherwise transfer the Work.
|
|
66
|
+
|
|
67
|
+
4. Redistribution.
|
|
68
|
+
|
|
69
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof
|
|
70
|
+
in any medium, with or without modifications, and in Source or Object form,
|
|
71
|
+
provided that You meet the following conditions:
|
|
72
|
+
|
|
73
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of
|
|
74
|
+
this License; and
|
|
75
|
+
|
|
76
|
+
(b) You must cause any modified files to carry prominent notices stating that
|
|
77
|
+
You changed the files; and
|
|
78
|
+
|
|
79
|
+
(c) You must retain, in the Source form of any Derivative Works that You
|
|
80
|
+
distribute, all copyright, patent, trademark, and attribution notices from the
|
|
81
|
+
Source form of the Work, excluding those notices that do not pertain to any part
|
|
82
|
+
of the Derivative Works; and
|
|
83
|
+
|
|
84
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then
|
|
85
|
+
any Derivative Works that You distribute must include a readable copy of the
|
|
86
|
+
attribution notices contained within such NOTICE file, excluding those notices
|
|
87
|
+
that do not pertain to any part of the Derivative Works.
|
|
88
|
+
|
|
89
|
+
5. Submission of Contributions.
|
|
90
|
+
|
|
91
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted
|
|
92
|
+
for inclusion in the Work by You to the Licensor shall be under the terms and
|
|
93
|
+
conditions of this License, without any additional terms or conditions.
|
|
94
|
+
|
|
95
|
+
6. Trademarks.
|
|
96
|
+
|
|
97
|
+
This License does not grant permission to use the trade names, trademarks,
|
|
98
|
+
service marks, or product names of the Licensor, except as required for
|
|
99
|
+
reasonable and customary use in describing the origin of the Work.
|
|
100
|
+
|
|
101
|
+
7. Disclaimer of Warranty.
|
|
102
|
+
|
|
103
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the
|
|
104
|
+
Work on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
|
|
105
|
+
express or implied, including, without limitation, any warranties or conditions
|
|
106
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
|
|
107
|
+
PURPOSE.
|
|
108
|
+
|
|
109
|
+
8. Limitation of Liability.
|
|
110
|
+
|
|
111
|
+
In no event and under no legal theory, whether in tort (including negligence),
|
|
112
|
+
contract, or otherwise, unless required by applicable law, shall any Contributor
|
|
113
|
+
be liable to You for damages, including any direct, indirect, special,
|
|
114
|
+
incidental, or consequential damages of any character arising as a result of this
|
|
115
|
+
License or out of the use or inability to use the Work.
|
|
116
|
+
|
|
117
|
+
9. Accepting Warranty or Additional Liability.
|
|
118
|
+
|
|
119
|
+
While redistributing the Work or Derivative Works thereof, You may choose to
|
|
120
|
+
offer, and charge a fee for, acceptance of support, warranty, indemnity, or
|
|
121
|
+
other liability obligations and/or rights consistent with this License.
|
|
122
|
+
|
|
123
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SemanticLayer, LineageGraph, type DQLManifest } from '@duckcodeailabs/dql-core';
|
|
2
|
+
export interface DQLContextOptions {
|
|
3
|
+
projectRoot: string;
|
|
4
|
+
dqlVersion?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Shared read-only view over a DQL project.
|
|
8
|
+
*
|
|
9
|
+
* Loads the manifest + semantic layer once per MCP session. Tools call
|
|
10
|
+
* {@link refresh} between turns if they need to see edits.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DQLContext {
|
|
13
|
+
readonly projectRoot: string;
|
|
14
|
+
private readonly dqlVersion;
|
|
15
|
+
private _manifest;
|
|
16
|
+
private _semanticLayer;
|
|
17
|
+
private _lineage;
|
|
18
|
+
constructor(options: DQLContextOptions);
|
|
19
|
+
get manifest(): DQLManifest;
|
|
20
|
+
get semanticLayer(): SemanticLayer;
|
|
21
|
+
get lineageGraph(): LineageGraph;
|
|
22
|
+
refresh(): void;
|
|
23
|
+
}
|
|
24
|
+
/** Walk up from `startDir` until a `dql.config.json` is found, else return `startDir`. */
|
|
25
|
+
export declare function findProjectRoot(startDir: string): string;
|
|
26
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,aAAa,EAEb,YAAY,EACZ,KAAK,WAAW,EAIjB,MAAM,0BAA0B,CAAC;AAElC,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,QAAQ,CAA6B;gBAEjC,OAAO,EAAE,iBAAiB;IAKtC,IAAI,QAAQ,IAAI,WAAW,CAG1B;IAED,IAAI,aAAa,IAAI,aAAa,CAGjC;IAED,IAAI,YAAY,IAAI,YAAY,CAG/B;IAED,OAAO,IAAI,IAAI;CAehB;AA8CD,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQxD"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { buildManifest, resolveDbtManifestPath, SemanticLayer, loadSemanticLayerFromDir, LineageGraph, } from '@duckcodeailabs/dql-core';
|
|
4
|
+
/**
|
|
5
|
+
* Shared read-only view over a DQL project.
|
|
6
|
+
*
|
|
7
|
+
* Loads the manifest + semantic layer once per MCP session. Tools call
|
|
8
|
+
* {@link refresh} between turns if they need to see edits.
|
|
9
|
+
*/
|
|
10
|
+
export class DQLContext {
|
|
11
|
+
projectRoot;
|
|
12
|
+
dqlVersion;
|
|
13
|
+
_manifest = null;
|
|
14
|
+
_semanticLayer = null;
|
|
15
|
+
_lineage = null;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.projectRoot = options.projectRoot;
|
|
18
|
+
this.dqlVersion = options.dqlVersion ?? 'mcp';
|
|
19
|
+
}
|
|
20
|
+
get manifest() {
|
|
21
|
+
if (!this._manifest)
|
|
22
|
+
this.refresh();
|
|
23
|
+
return this._manifest;
|
|
24
|
+
}
|
|
25
|
+
get semanticLayer() {
|
|
26
|
+
if (!this._semanticLayer)
|
|
27
|
+
this.refresh();
|
|
28
|
+
return this._semanticLayer;
|
|
29
|
+
}
|
|
30
|
+
get lineageGraph() {
|
|
31
|
+
if (!this._lineage)
|
|
32
|
+
this._lineage = buildGraphFromManifest(this.manifest);
|
|
33
|
+
return this._lineage;
|
|
34
|
+
}
|
|
35
|
+
refresh() {
|
|
36
|
+
const dbtManifestPath = resolveDbtManifestPath(this.projectRoot) ?? undefined;
|
|
37
|
+
this._manifest = buildManifest({
|
|
38
|
+
projectRoot: this.projectRoot,
|
|
39
|
+
dqlVersion: this.dqlVersion,
|
|
40
|
+
dbtManifestPath,
|
|
41
|
+
});
|
|
42
|
+
const semanticDir = resolveSemanticDir(this.projectRoot);
|
|
43
|
+
this._semanticLayer = existsSync(semanticDir)
|
|
44
|
+
? loadSemanticLayerFromDir(semanticDir)
|
|
45
|
+
: new SemanticLayer();
|
|
46
|
+
this._lineage = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function buildGraphFromManifest(manifest) {
|
|
50
|
+
const graph = new LineageGraph();
|
|
51
|
+
for (const node of manifest.lineage.nodes) {
|
|
52
|
+
graph.addNode({
|
|
53
|
+
id: node.id,
|
|
54
|
+
type: node.type,
|
|
55
|
+
name: node.name,
|
|
56
|
+
layer: node.layer,
|
|
57
|
+
domain: node.domain,
|
|
58
|
+
owner: node.owner,
|
|
59
|
+
status: node.status,
|
|
60
|
+
metadata: node.metadata,
|
|
61
|
+
columns: node.columns,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
for (const edge of manifest.lineage.edges) {
|
|
65
|
+
graph.addEdge({
|
|
66
|
+
source: edge.source,
|
|
67
|
+
target: edge.target,
|
|
68
|
+
type: edge.type,
|
|
69
|
+
sourceDomain: edge.sourceDomain,
|
|
70
|
+
targetDomain: edge.targetDomain,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return graph;
|
|
74
|
+
}
|
|
75
|
+
function resolveSemanticDir(projectRoot) {
|
|
76
|
+
const configPath = join(projectRoot, 'dql.config.json');
|
|
77
|
+
if (existsSync(configPath)) {
|
|
78
|
+
try {
|
|
79
|
+
const config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
80
|
+
if (config.semanticLayer?.path) {
|
|
81
|
+
return join(projectRoot, config.semanticLayer.path);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
/* fall through */
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return join(projectRoot, 'semantic-layer');
|
|
89
|
+
}
|
|
90
|
+
/** Walk up from `startDir` until a `dql.config.json` is found, else return `startDir`. */
|
|
91
|
+
export function findProjectRoot(startDir) {
|
|
92
|
+
let current = resolve(startDir);
|
|
93
|
+
while (true) {
|
|
94
|
+
if (existsSync(join(current, 'dql.config.json')))
|
|
95
|
+
return current;
|
|
96
|
+
const parent = dirname(current);
|
|
97
|
+
if (parent === current)
|
|
98
|
+
return resolve(startDir);
|
|
99
|
+
current = parent;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,aAAa,EACb,wBAAwB,EACxB,YAAY,GAKb,MAAM,0BAA0B,CAAC;AAOlC;;;;;GAKG;AACH,MAAM,OAAO,UAAU;IACZ,WAAW,CAAS;IACZ,UAAU,CAAS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AE,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACtD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,CAAC;AAC7C,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC;YAAE,OAAO,OAAO,CAAC;QACjE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,OAAO;YAAE,OAAO,OAAO,CAAC,QAAQ,CAAC,CAAC;QACjD,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @duckcodeailabs/dql-mcp — MCP server exposing DQL blocks, semantic layer,
|
|
3
|
+
* lineage, and governance to LLM agents.
|
|
4
|
+
*/
|
|
5
|
+
export { createDQLMCPServer } from './server.js';
|
|
6
|
+
export { DQLContext, findProjectRoot } from './context.js';
|
|
7
|
+
export type { DQLContextOptions } from './context.js';
|
|
8
|
+
export { runStdio } from './transports/stdio.js';
|
|
9
|
+
export { runLoopbackHTTP } from './transports/http.js';
|
|
10
|
+
export { searchBlocks, searchBlocksInput } from './tools/search-blocks.js';
|
|
11
|
+
export { getBlock, getBlockInput } from './tools/get-block.js';
|
|
12
|
+
export { queryViaBlock, queryViaBlockInput } from './tools/query-via-block.js';
|
|
13
|
+
export { listMetrics, listMetricsInput, listDimensions, listDimensionsInput, } from './tools/semantic.js';
|
|
14
|
+
export { lineageImpact, lineageImpactInput } from './tools/lineage-impact.js';
|
|
15
|
+
export { certify, certifyInput } from './tools/certify.js';
|
|
16
|
+
export { suggestBlock, suggestBlockInput } from './tools/suggest-block.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @duckcodeailabs/dql-mcp — MCP server exposing DQL blocks, semantic layer,
|
|
3
|
+
* lineage, and governance to LLM agents.
|
|
4
|
+
*/
|
|
5
|
+
export { createDQLMCPServer } from './server.js';
|
|
6
|
+
export { DQLContext, findProjectRoot } from './context.js';
|
|
7
|
+
export { runStdio } from './transports/stdio.js';
|
|
8
|
+
export { runLoopbackHTTP } from './transports/http.js';
|
|
9
|
+
export { searchBlocks, searchBlocksInput } from './tools/search-blocks.js';
|
|
10
|
+
export { getBlock, getBlockInput } from './tools/get-block.js';
|
|
11
|
+
export { queryViaBlock, queryViaBlockInput } from './tools/query-via-block.js';
|
|
12
|
+
export { listMetrics, listMetricsInput, listDimensions, listDimensionsInput, } from './tools/semantic.js';
|
|
13
|
+
export { lineageImpact, lineageImpactInput } from './tools/lineage-impact.js';
|
|
14
|
+
export { certify, certifyInput } from './tools/certify.js';
|
|
15
|
+
export { suggestBlock, suggestBlockInput } from './tools/suggest-block.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
export interface CreateServerOptions {
|
|
3
|
+
projectRoot?: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function createDQLMCPServer(options?: CreateServerOptions): McpServer;
|
|
7
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAUpE,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,SAAS,CAyD/E"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { DQLContext, findProjectRoot } from './context.js';
|
|
3
|
+
import { searchBlocks, searchBlocksInput } from './tools/search-blocks.js';
|
|
4
|
+
import { getBlock, getBlockInput } from './tools/get-block.js';
|
|
5
|
+
import { queryViaBlock, queryViaBlockInput } from './tools/query-via-block.js';
|
|
6
|
+
import { listMetrics, listMetricsInput, listDimensions, listDimensionsInput } from './tools/semantic.js';
|
|
7
|
+
import { lineageImpact, lineageImpactInput } from './tools/lineage-impact.js';
|
|
8
|
+
import { certify, certifyInput } from './tools/certify.js';
|
|
9
|
+
import { suggestBlock, suggestBlockInput } from './tools/suggest-block.js';
|
|
10
|
+
export function createDQLMCPServer(options = {}) {
|
|
11
|
+
const projectRoot = options.projectRoot ?? findProjectRoot(process.cwd());
|
|
12
|
+
const ctx = new DQLContext({ projectRoot, dqlVersion: options.version });
|
|
13
|
+
const server = new McpServer({ name: 'dql-mcp', version: options.version ?? '0.1.0' }, {
|
|
14
|
+
instructions: 'DQL exposes certified, git-versioned analytics blocks. Every answer you build ' +
|
|
15
|
+
'should be grounded in a block returned by search_blocks / get_block. Use ' +
|
|
16
|
+
'query_via_block to execute — never fabricate SQL. Use suggest_block when a ' +
|
|
17
|
+
'new question needs a new block; the governance gate returns which rules pass.',
|
|
18
|
+
});
|
|
19
|
+
server.registerTool('search_blocks', { description: 'Find certified DQL blocks by keyword, domain, or status.', inputSchema: searchBlocksInput }, async (args) => wrap(await searchBlocks(ctx, args)));
|
|
20
|
+
server.registerTool('get_block', { description: 'Return full metadata, dependencies, and SQL for a block.', inputSchema: getBlockInput }, async (args) => wrap(await getBlock(ctx, args)));
|
|
21
|
+
server.registerTool('query_via_block', { description: 'Execute a certified block against the local DQL runtime.', inputSchema: queryViaBlockInput }, async (args) => wrap(await queryViaBlock(ctx, args)));
|
|
22
|
+
server.registerTool('list_metrics', { description: 'List semantic-layer metrics, optionally filtered by domain.', inputSchema: listMetricsInput }, async (args) => wrap(await listMetrics(ctx, args)));
|
|
23
|
+
server.registerTool('list_dimensions', { description: 'List semantic-layer dimensions, optionally filtered by domain.', inputSchema: listDimensionsInput }, async (args) => wrap(await listDimensions(ctx, args)));
|
|
24
|
+
server.registerTool('lineage_impact', { description: 'Return upstream/downstream lineage for a block, metric, or model.', inputSchema: lineageImpactInput }, async (args) => wrap(await lineageImpact(ctx, args)));
|
|
25
|
+
server.registerTool('certify', { description: 'Run governance rules against a block and report pass/fail.', inputSchema: certifyInput }, async (args) => wrap(await certify(ctx, args)));
|
|
26
|
+
server.registerTool('suggest_block', { description: 'Write a proposed block to blocks/_drafts/ and return the governance gate result.', inputSchema: suggestBlockInput }, async (args) => wrap(await suggestBlock(ctx, args)));
|
|
27
|
+
return server;
|
|
28
|
+
}
|
|
29
|
+
function wrap(result) {
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: 'text', text: JSON.stringify(result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M,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CACrD,CAAC;IACF,MAAM,CAAC,YAAY,CACjB,SAAS,EACT,EAAE,WAAW,EAAE,4DAA4D,EAAE,WAAW,EAAE,YAAY,EAAE,EACxG,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAC/C,CAAC;IACF,MAAM,CAAC,YAAY,CACjB,eAAe,EACf,EAAE,WAAW,EAAE,kFAAkF,EAAE,WAAW,EAAE,iBAAiB,EAAE,EACnI,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CACpD,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,IAAI,CAAC,MAAe;IAC3B,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;KAC5E,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DQLContext } from '../context.js';
|
|
3
|
+
export declare const certifyInput: {
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
};
|
|
6
|
+
export declare function certify(ctx: DQLContext, args: {
|
|
7
|
+
name: string;
|
|
8
|
+
}): {
|
|
9
|
+
error: string;
|
|
10
|
+
block?: undefined;
|
|
11
|
+
path?: undefined;
|
|
12
|
+
certified?: undefined;
|
|
13
|
+
errors?: undefined;
|
|
14
|
+
warnings?: undefined;
|
|
15
|
+
checkedAt?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
block: string;
|
|
18
|
+
path: string;
|
|
19
|
+
certified: boolean;
|
|
20
|
+
errors: {
|
|
21
|
+
rule: string;
|
|
22
|
+
message: string;
|
|
23
|
+
}[];
|
|
24
|
+
warnings: {
|
|
25
|
+
rule: string;
|
|
26
|
+
message: string;
|
|
27
|
+
}[];
|
|
28
|
+
checkedAt: string;
|
|
29
|
+
error?: undefined;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=certify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"certify.d.ts","sourceRoot":"","sources":["../../src/tools/certify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,wBAAgB,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;EAe9D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Certifier } from '@duckcodeailabs/dql-governance';
|
|
3
|
+
import { manifestBlockToRecord } from './util.js';
|
|
4
|
+
export const certifyInput = {
|
|
5
|
+
name: z.string().describe('Block name to evaluate.'),
|
|
6
|
+
};
|
|
7
|
+
export function certify(ctx, args) {
|
|
8
|
+
const manifestBlock = ctx.manifest.blocks[args.name];
|
|
9
|
+
if (!manifestBlock)
|
|
10
|
+
return { error: `No block named "${args.name}".` };
|
|
11
|
+
const record = manifestBlockToRecord(manifestBlock);
|
|
12
|
+
const result = new Certifier().evaluate(record);
|
|
13
|
+
return {
|
|
14
|
+
block: args.name,
|
|
15
|
+
path: manifestBlock.filePath,
|
|
16
|
+
certified: result.certified,
|
|
17
|
+
errors: result.errors,
|
|
18
|
+
warnings: result.warnings,
|
|
19
|
+
checkedAt: result.checkedAt.toISOString(),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=certify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"certify.js","sourceRoot":"","sources":["../../src/tools/certify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAE3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAElD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yBAAyB,CAAC;CACrD,CAAC;AAEF,MAAM,UAAU,OAAO,CAAC,GAAe,EAAE,IAAsB;IAC7D,MAAM,aAAa,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,aAAa;QAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;IAEvE,MAAM,MAAM,GAAG,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEhD,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,IAAI;QAChB,IAAI,EAAE,aAAa,CAAC,QAAQ;QAC5B,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,EAAE;KAC1C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DQLContext } from '../context.js';
|
|
3
|
+
export declare const getBlockInput: {
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
includeSource: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
};
|
|
7
|
+
export declare function getBlock(ctx: DQLContext, args: {
|
|
8
|
+
name: string;
|
|
9
|
+
includeSource?: boolean;
|
|
10
|
+
}): {
|
|
11
|
+
error: string;
|
|
12
|
+
name?: undefined;
|
|
13
|
+
path?: undefined;
|
|
14
|
+
domain?: undefined;
|
|
15
|
+
owner?: undefined;
|
|
16
|
+
status?: undefined;
|
|
17
|
+
description?: undefined;
|
|
18
|
+
tags?: undefined;
|
|
19
|
+
chartType?: undefined;
|
|
20
|
+
metricRef?: undefined;
|
|
21
|
+
dependencies?: undefined;
|
|
22
|
+
tests?: undefined;
|
|
23
|
+
llmContext?: undefined;
|
|
24
|
+
examples?: undefined;
|
|
25
|
+
invariants?: undefined;
|
|
26
|
+
sql?: undefined;
|
|
27
|
+
source?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
name: string;
|
|
30
|
+
path: string;
|
|
31
|
+
domain: string | null;
|
|
32
|
+
owner: string | null;
|
|
33
|
+
status: string;
|
|
34
|
+
description: string | null;
|
|
35
|
+
tags: string[];
|
|
36
|
+
chartType: string | null;
|
|
37
|
+
metricRef: string | null;
|
|
38
|
+
dependencies: {
|
|
39
|
+
tables: string[];
|
|
40
|
+
refs: string[];
|
|
41
|
+
metrics: string[];
|
|
42
|
+
dimensions: string[];
|
|
43
|
+
};
|
|
44
|
+
tests: string[];
|
|
45
|
+
llmContext: string | null;
|
|
46
|
+
examples: {
|
|
47
|
+
question: string;
|
|
48
|
+
sql?: string;
|
|
49
|
+
}[];
|
|
50
|
+
invariants: string[];
|
|
51
|
+
sql: string;
|
|
52
|
+
source: string | null;
|
|
53
|
+
error?: undefined;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=get-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-block.d.ts","sourceRoot":"","sources":["../../src/tools/get-block.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAO,MAAM,aAAa;;;CAMzB,CAAC;AAEF,wBAAgB,QAAQ,CACtB,GAAG,EAAE,UAAU,EACf,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsChD"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export const getBlockInput = {
|
|
5
|
+
name: z.string().describe('Block name (as shown in search_blocks).'),
|
|
6
|
+
includeSource: z
|
|
7
|
+
.boolean()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe('When true, include the full .dql source text. Default true.'),
|
|
10
|
+
};
|
|
11
|
+
export function getBlock(ctx, args) {
|
|
12
|
+
const block = ctx.manifest.blocks[args.name];
|
|
13
|
+
if (!block) {
|
|
14
|
+
return { error: `No block named "${args.name}". Run search_blocks first.` };
|
|
15
|
+
}
|
|
16
|
+
const absPath = join(ctx.projectRoot, block.filePath);
|
|
17
|
+
const source = args.includeSource !== false && existsSync(absPath)
|
|
18
|
+
? readFileSync(absPath, 'utf-8')
|
|
19
|
+
: null;
|
|
20
|
+
return {
|
|
21
|
+
name: block.name,
|
|
22
|
+
path: block.filePath,
|
|
23
|
+
domain: block.domain ?? null,
|
|
24
|
+
owner: block.owner ?? null,
|
|
25
|
+
status: block.status ?? 'draft',
|
|
26
|
+
description: block.description ?? null,
|
|
27
|
+
tags: block.tags ?? [],
|
|
28
|
+
chartType: block.chartType ?? null,
|
|
29
|
+
metricRef: block.metricRef ?? null,
|
|
30
|
+
dependencies: {
|
|
31
|
+
tables: block.tableDependencies,
|
|
32
|
+
refs: block.refDependencies,
|
|
33
|
+
metrics: block.metricRefs ?? [],
|
|
34
|
+
dimensions: block.dimensionRefs ?? [],
|
|
35
|
+
},
|
|
36
|
+
tests: block.tests,
|
|
37
|
+
// v1.2 Track G — agent-facing metadata. Full payload on get_block so
|
|
38
|
+
// chat cells can few-shot on `examples` and cite `invariants`.
|
|
39
|
+
llmContext: block.llmContext ?? null,
|
|
40
|
+
examples: block.examples ?? [],
|
|
41
|
+
invariants: block.invariants ?? [],
|
|
42
|
+
sql: block.sql,
|
|
43
|
+
source,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=get-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-block.js","sourceRoot":"","sources":["../../src/tools/get-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;IACpE,aAAa,EAAE,CAAC;SACb,OAAO,EAAE;SACT,QAAQ,EAAE;SACV,QAAQ,CAAC,6DAA6D,CAAC;CAC3E,CAAC;AAEF,MAAM,UAAU,QAAQ,CACtB,GAAe,EACf,IAA+C;IAE/C,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,KAAK,EAAE,mBAAmB,IAAI,CAAC,IAAI,6BAA6B,EAAE,CAAC;IAC9E,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACtD,MAAM,MAAM,GACV,IAAI,CAAC,aAAa,KAAK,KAAK,IAAI,UAAU,CAAC,OAAO,CAAC;QACjD,CAAC,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC;QAChC,CAAC,CAAC,IAAI,CAAC;IAEX,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,QAAQ;QACpB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,IAAI;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;QAC1B,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,OAAO;QAC/B,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,IAAI;QACtC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,EAAE;QACtB,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI;QAClC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI;QAClC,YAAY,EAAE;YACZ,MAAM,EAAE,KAAK,CAAC,iBAAiB;YAC/B,IAAI,EAAE,KAAK,CAAC,eAAe;YAC3B,OAAO,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE;YAC/B,UAAU,EAAE,KAAK,CAAC,aAAa,IAAI,EAAE;SACtC;QACD,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,qEAAqE;QACrE,+DAA+D;QAC/D,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;QACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE;QAC9B,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE;QAClC,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DQLContext } from '../context.js';
|
|
3
|
+
export declare const lineageImpactInput: {
|
|
4
|
+
focus: z.ZodString;
|
|
5
|
+
upstreamDepth: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
downstreamDepth: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
paths: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
};
|
|
9
|
+
export declare function lineageImpact(ctx: DQLContext, args: {
|
|
10
|
+
focus: string;
|
|
11
|
+
upstreamDepth?: number;
|
|
12
|
+
downstreamDepth?: number;
|
|
13
|
+
paths?: boolean;
|
|
14
|
+
}): Record<string, unknown>;
|
|
15
|
+
//# sourceMappingURL=lineage-impact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineage-impact.d.ts","sourceRoot":"","sources":["../../src/tools/lineage-impact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,eAAO,MAAM,kBAAkB;;;;;CAQ9B,CAAC;AAEF,wBAAgB,aAAa,CAC3B,GAAG,EAAE,UAAU,EACf,IAAI,EAAE;IACJ,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,2BA+BF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { queryLineage, queryCompleteLineagePaths } from '@duckcodeailabs/dql-core';
|
|
3
|
+
export const lineageImpactInput = {
|
|
4
|
+
focus: z.string().describe('Node id ("block:revenue") or bare name — resolved against the lineage graph.'),
|
|
5
|
+
upstreamDepth: z.number().int().min(0).max(20).optional(),
|
|
6
|
+
downstreamDepth: z.number().int().min(0).max(20).optional(),
|
|
7
|
+
paths: z
|
|
8
|
+
.boolean()
|
|
9
|
+
.optional()
|
|
10
|
+
.describe('When true, include full source→leaf paths (slower on large graphs).'),
|
|
11
|
+
};
|
|
12
|
+
export function lineageImpact(ctx, args) {
|
|
13
|
+
const graph = ctx.lineageGraph;
|
|
14
|
+
const result = queryLineage(graph, {
|
|
15
|
+
focus: args.focus,
|
|
16
|
+
upstreamDepth: args.upstreamDepth,
|
|
17
|
+
downstreamDepth: args.downstreamDepth,
|
|
18
|
+
});
|
|
19
|
+
if (!result.focalNode) {
|
|
20
|
+
return { error: `No node matches "${args.focus}".` };
|
|
21
|
+
}
|
|
22
|
+
const response = {
|
|
23
|
+
focalNode: result.focalNode,
|
|
24
|
+
nodeCount: result.graph.nodes.length,
|
|
25
|
+
edgeCount: result.graph.edges.length,
|
|
26
|
+
nodes: result.graph.nodes,
|
|
27
|
+
edges: result.graph.edges,
|
|
28
|
+
};
|
|
29
|
+
if (args.paths) {
|
|
30
|
+
const paths = queryCompleteLineagePaths(graph, result.focalNode.id);
|
|
31
|
+
if (paths) {
|
|
32
|
+
response.upstreamPaths = paths.upstreamPaths.map(formatPath);
|
|
33
|
+
response.downstreamPaths = paths.downstreamPaths.map(formatPath);
|
|
34
|
+
response.layerSummary = paths.layerSummary;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return response;
|
|
38
|
+
}
|
|
39
|
+
function formatPath(path) {
|
|
40
|
+
return {
|
|
41
|
+
chain: path.nodes.map((n) => `${n.type}:${n.name}`).join(' → '),
|
|
42
|
+
layers: path.layers,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=lineage-impact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineage-impact.js","sourceRoot":"","sources":["../../src/tools/lineage-impact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGnF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8EAA8E,CAAC;IAC1G,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GA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AAG,CAAC,UAAU,CAAC,CAAC;YAC7D,QAAQ,CAAC,eAAe,GAAG,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;YACjE,QAAQ,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,UAAU,CAAC,IAAoF;IACtG,OAAO;QACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QAC/D,MAAM,EAAE,IAAI,CAAC,MAAM;KACpB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { DQLContext } from '../context.js';
|
|
3
|
+
export declare const queryViaBlockInput: {
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
serverUrl: z.ZodOptional<z.ZodString>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Execute a certified block by name. Delegates SQL prep + warehouse execution
|
|
10
|
+
* to the local-runtime HTTP server, so results honor the same semantic resolver
|
|
11
|
+
* and connection config as the notebook UI — the agent never sees raw SQL.
|
|
12
|
+
*/
|
|
13
|
+
export declare function queryViaBlock(ctx: DQLContext, args: {
|
|
14
|
+
name: string;
|
|
15
|
+
limit?: number;
|
|
16
|
+
serverUrl?: string;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
error: string;
|
|
19
|
+
block?: undefined;
|
|
20
|
+
blockPath?: undefined;
|
|
21
|
+
rowCount?: undefined;
|
|
22
|
+
durationMs?: undefined;
|
|
23
|
+
columns?: undefined;
|
|
24
|
+
rows?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
block: string;
|
|
27
|
+
blockPath: string;
|
|
28
|
+
rowCount: number;
|
|
29
|
+
durationMs: number | null;
|
|
30
|
+
columns: {
|
|
31
|
+
name: string;
|
|
32
|
+
type?: string;
|
|
33
|
+
}[];
|
|
34
|
+
rows: unknown[][];
|
|
35
|
+
error?: undefined;
|
|
36
|
+
}>;
|
|
37
|
+
//# sourceMappingURL=query-via-block.d.ts.map
|