@malloy-publisher/server 0.0.382-dev → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.docker.md +145 -20
- package/README.md +65 -12
- package/dist/app/api-doc.html +5 -0
- package/dist/app/api-doc.yaml +3929 -534
- package/dist/app/assets/EnvironmentPage-CHq5BF4l.js +1 -0
- package/dist/app/assets/HomePage-CIp-pJCa.js +1 -0
- package/dist/app/assets/LightMode-mHHPjEeA.js +1 -0
- package/dist/app/assets/MainPage-CylxO5Yu.js +2 -0
- package/dist/app/assets/MaterializationsPage-a0vjqxib.js +1 -0
- package/dist/app/assets/ModelPage-Cz-MrSZQ.js +1 -0
- package/dist/app/assets/PackagePage-Cdg5D7AN.js +1 -0
- package/dist/app/assets/RouteError-B5SIyn6G.js +1 -0
- package/dist/app/assets/ThemeEditorPage-B62rRc-y.js +1 -0
- package/dist/app/assets/WorkbookPage-45cG1Gx6.js +1 -0
- package/dist/app/assets/{core-CjeTkq8O.es-BqRc6yhC.js → core-DyU47reh.es-DY9b3WjS.js} +1 -1
- package/dist/app/assets/github-dark-DenFmJkN.es-DHJKELXO.js +1 -0
- package/dist/app/assets/index-5eLCcNmP.css +1 -0
- package/dist/app/assets/index-C5ClsnS7.js +1774 -0
- package/dist/app/assets/index-DF9tVqwN.js +1 -0
- package/dist/app/assets/index-DSoCUF-f.js +2725 -0
- package/dist/app/assets/index-DgVRz2wm.js +2 -0
- package/dist/app/assets/index-P-pF8nU5.js +632 -0
- package/dist/app/assets/index-w_0OQJgZ.js +23 -0
- package/dist/app/index.html +8 -4
- package/dist/cpufeatures-1yrn0vtw.node +0 -0
- package/dist/default-publisher.config.json +23 -0
- package/dist/{instrumentation.js → instrumentation.mjs} +10631 -10573
- package/dist/package_load_worker.mjs +15219 -0
- package/dist/runtime/publisher.js +331 -0
- package/dist/{server.js → server.mjs} +141276 -74705
- package/dist/sshcrypto-vd2k5hq9.node +0 -0
- package/package.json +41 -28
- package/publisher.config.example.bigquery.json +33 -0
- package/publisher.config.example.duckdb.json +23 -0
- package/.eslintrc.json +0 -44
- package/.prettierignore +0 -1
- package/.prettierrc +0 -4
- package/build.ts +0 -38
- package/dist/app/assets/HomePage-Dn3E4CuB.js +0 -1
- package/dist/app/assets/MainPage-BzB3yoqi.js +0 -2
- package/dist/app/assets/ModelPage-C9O_sAXT.js +0 -1
- package/dist/app/assets/PackagePage-DcxKEjBX.js +0 -1
- package/dist/app/assets/ProjectPage-BDj307rF.js +0 -1
- package/dist/app/assets/RouteError-DAShbVCG.js +0 -1
- package/dist/app/assets/WorkbookPage-Cs_XYEaB.js +0 -1
- package/dist/app/assets/index-15BOvhp0.js +0 -456
- package/dist/app/assets/index-Bb2jqquW.js +0 -676
- package/dist/app/assets/index-CMlGQMcl.css +0 -1
- package/dist/app/assets/index-D68X76-7.js +0 -1276
- package/dist/app/assets/index.umd-DGBekgSu.js +0 -1145
- package/dxt/malloy_bridge.py +0 -354
- package/dxt/manifest.json +0 -22
- package/eslint.config.mjs +0 -76
- package/k6-tests/README.md +0 -144
- package/k6-tests/bun.lock +0 -797
- package/k6-tests/load-test/load-test-crud-connections.ts +0 -263
- package/k6-tests/load-test/load-test-crud-packages.ts +0 -461
- package/k6-tests/load-test/load-test-crud-projects.ts +0 -160
- package/k6-tests/load-test/load-test-crud.ts +0 -142
- package/k6-tests/load-test/load-test.ts +0 -784
- package/k6-tests/package.json +0 -27
- package/k6-tests/scripts/run-with-otel.sh +0 -50
- package/k6-tests/smoke-test/smoke-test.ts +0 -158
- package/k6-tests/tsconfig.json +0 -29
- package/k6-tests/utils/client_factory.ts +0 -128
- package/k6-tests/utils/common.ts +0 -489
- package/k6-tests/utils/logger.ts +0 -62
- package/k6-tests/utils/types.d.ts +0 -35
- package/malloy_mcp.dxt +0 -0
- package/publisher.config.json +0 -33
- package/src/config.spec.ts +0 -850
- package/src/config.ts +0 -305
- package/src/constants.ts +0 -10
- package/src/controller/compile.controller.ts +0 -35
- package/src/controller/connection.controller.ts +0 -515
- package/src/controller/database.controller.ts +0 -21
- package/src/controller/manifest.controller.ts +0 -29
- package/src/controller/materialization.controller.ts +0 -125
- package/src/controller/model.controller.ts +0 -107
- package/src/controller/package.controller.ts +0 -182
- package/src/controller/query.controller.ts +0 -60
- package/src/controller/watch-mode.controller.ts +0 -98
- package/src/data_styles.ts +0 -71
- package/src/dto/connection.dto.spec.ts +0 -131
- package/src/dto/connection.dto.ts +0 -174
- package/src/dto/index.ts +0 -2
- package/src/dto/package.dto.spec.ts +0 -42
- package/src/dto/package.dto.ts +0 -12
- package/src/dto/validate.spec.ts +0 -76
- package/src/dto/validate.ts +0 -31
- package/src/errors.ts +0 -116
- package/src/health.ts +0 -189
- package/src/instrumentation.ts +0 -148
- package/src/logger.ts +0 -154
- package/src/mcp/error_messages.ts +0 -199
- package/src/mcp/handler_utils.ts +0 -239
- package/src/mcp/mcp_constants.ts +0 -22
- package/src/mcp/prompts/handlers.ts +0 -84
- package/src/mcp/prompts/index.ts +0 -11
- package/src/mcp/prompts/prompt_definitions.ts +0 -160
- package/src/mcp/prompts/prompt_service.ts +0 -67
- package/src/mcp/prompts/utils.ts +0 -62
- package/src/mcp/resource_metadata.ts +0 -47
- package/src/mcp/resources/model_resource.ts +0 -153
- package/src/mcp/resources/notebook_resource.ts +0 -137
- package/src/mcp/resources/package_resource.ts +0 -370
- package/src/mcp/resources/project_resource.ts +0 -184
- package/src/mcp/resources/query_resource.ts +0 -117
- package/src/mcp/resources/source_resource.ts +0 -141
- package/src/mcp/resources/view_resource.ts +0 -136
- package/src/mcp/server.ts +0 -62
- package/src/mcp/tools/discovery_tools.ts +0 -258
- package/src/mcp/tools/execute_query_tool.ts +0 -265
- package/src/server.ts +0 -1195
- package/src/service/connection.spec.ts +0 -1331
- package/src/service/connection.ts +0 -1511
- package/src/service/connection_service.spec.ts +0 -641
- package/src/service/connection_service.ts +0 -181
- package/src/service/db_utils.spec.ts +0 -714
- package/src/service/db_utils.ts +0 -1227
- package/src/service/filter.spec.ts +0 -447
- package/src/service/filter.ts +0 -337
- package/src/service/filter_integration.spec.ts +0 -825
- package/src/service/gcs_s3_utils.ts +0 -427
- package/src/service/manifest_service.spec.ts +0 -201
- package/src/service/manifest_service.ts +0 -106
- package/src/service/materialization_service.spec.ts +0 -648
- package/src/service/materialization_service.ts +0 -929
- package/src/service/materialized_table_gc.spec.ts +0 -383
- package/src/service/materialized_table_gc.ts +0 -279
- package/src/service/model.spec.ts +0 -257
- package/src/service/model.ts +0 -1069
- package/src/service/package.spec.ts +0 -236
- package/src/service/package.ts +0 -463
- package/src/service/project.ts +0 -681
- package/src/service/project_compile.spec.ts +0 -197
- package/src/service/project_store.spec.ts +0 -859
- package/src/service/project_store.ts +0 -1531
- package/src/service/quoting.ts +0 -41
- package/src/service/resolve_project.ts +0 -13
- package/src/storage/BaseRepository.ts +0 -31
- package/src/storage/DatabaseInterface.ts +0 -180
- package/src/storage/StorageManager.mock.ts +0 -59
- package/src/storage/StorageManager.ts +0 -210
- package/src/storage/duckdb/ConnectionRepository.ts +0 -141
- package/src/storage/duckdb/DuckDBConnection.ts +0 -177
- package/src/storage/duckdb/DuckDBManifestStore.ts +0 -70
- package/src/storage/duckdb/DuckDBRepository.ts +0 -224
- package/src/storage/duckdb/ManifestRepository.ts +0 -119
- package/src/storage/duckdb/MaterializationRepository.ts +0 -249
- package/src/storage/duckdb/PackageRepository.ts +0 -135
- package/src/storage/duckdb/ProjectRepository.ts +0 -148
- package/src/storage/duckdb/manifest_store.spec.ts +0 -133
- package/src/storage/duckdb/schema.ts +0 -147
- package/src/storage/ducklake/DuckLakeManifestStore.ts +0 -146
- package/src/utils.ts +0 -13
- package/tests/fixtures/persist-test/data/orders.csv +0 -5
- package/tests/fixtures/persist-test/persist_test.malloy +0 -11
- package/tests/fixtures/persist-test/publisher.json +0 -5
- package/tests/fixtures/publisher.config.json +0 -15
- package/tests/harness/e2e.ts +0 -96
- package/tests/harness/mcp_test_setup.ts +0 -344
- package/tests/harness/mocks.ts +0 -37
- package/tests/harness/rest_e2e.ts +0 -68
- package/tests/harness/uris.ts +0 -31
- package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +0 -470
- package/tests/integration/mcp/mcp_execute_query_tool.integration.spec.ts +0 -434
- package/tests/integration/mcp/mcp_resource.integration.spec.ts +0 -663
- package/tests/integration/mcp/mcp_transport.integration.spec.ts +0 -122
- package/tests/integration/mcp/setup.spec.ts +0 -5
- package/tests/unit/duckdb/attached_databases.test.ts +0 -1132
- package/tests/unit/ducklake/ducklake.test.ts +0 -950
- package/tests/unit/mcp/prompt_definitions.test.ts +0 -102
- package/tests/unit/mcp/prompt_happy.test.ts +0 -51
- package/tsconfig.json +0 -32
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { logger } from "../../logger";
|
|
5
|
-
import { ProjectStore } from "../../service/project_store";
|
|
6
|
-
import { getMalloyErrorDetails, type ErrorDetails } from "../error_messages";
|
|
7
|
-
import { buildMalloyUri, getModelForQuery } from "../handler_utils";
|
|
8
|
-
import { MCP_ERROR_MESSAGES } from "../mcp_constants";
|
|
9
|
-
|
|
10
|
-
// Zod shape defining required/optional params for executeQuery
|
|
11
|
-
const executeQueryShape = {
|
|
12
|
-
// projectName is required; other fields mirror SDK expectations
|
|
13
|
-
projectName: z
|
|
14
|
-
.string()
|
|
15
|
-
.describe(
|
|
16
|
-
"Project name. Project names are listed in the malloy resource list.",
|
|
17
|
-
),
|
|
18
|
-
packageName: z
|
|
19
|
-
.string()
|
|
20
|
-
.describe(
|
|
21
|
-
"Package containing the model. Package names are listed in the malloy resource list.",
|
|
22
|
-
),
|
|
23
|
-
modelPath: z.string().describe("Path to the .malloy model file"),
|
|
24
|
-
query: z.string().optional().describe("Ad-hoc Malloy query code"),
|
|
25
|
-
sourceName: z.string().optional().describe("Source name for a view"),
|
|
26
|
-
queryName: z.string().optional().describe("Named query or view"),
|
|
27
|
-
filterParams: z
|
|
28
|
-
.record(z.union([z.string(), z.array(z.string())]))
|
|
29
|
-
.optional()
|
|
30
|
-
.describe(
|
|
31
|
-
"Filter parameter values keyed by filter name. Used with sources that declare #(filter) annotations.",
|
|
32
|
-
),
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
// Type inference is handled automatically by the MCP server based on the executeQueryShape
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Registers the malloy_executeQuery tool with the MCP server.
|
|
39
|
-
*/
|
|
40
|
-
export function registerExecuteQueryTool(
|
|
41
|
-
mcpServer: McpServer,
|
|
42
|
-
projectStore: ProjectStore,
|
|
43
|
-
): void {
|
|
44
|
-
mcpServer.tool(
|
|
45
|
-
"malloy_executeQuery",
|
|
46
|
-
"Executes a Malloy query (either ad-hoc or a named query/view defined in a model) against the specified model and returns the results as JSON.",
|
|
47
|
-
executeQueryShape,
|
|
48
|
-
/** Handles requests for the malloy_executeQuery tool */
|
|
49
|
-
async (params) => {
|
|
50
|
-
// Destructure projectName as well
|
|
51
|
-
const {
|
|
52
|
-
projectName,
|
|
53
|
-
packageName,
|
|
54
|
-
modelPath,
|
|
55
|
-
query,
|
|
56
|
-
sourceName,
|
|
57
|
-
queryName,
|
|
58
|
-
filterParams,
|
|
59
|
-
} = params;
|
|
60
|
-
|
|
61
|
-
logger.info("[MCP Tool executeQuery] Received params:", { params });
|
|
62
|
-
|
|
63
|
-
const hasAdhocQuery = !!query;
|
|
64
|
-
const hasNamedQuery = !!queryName;
|
|
65
|
-
|
|
66
|
-
if (!hasAdhocQuery && !hasNamedQuery) {
|
|
67
|
-
throw new McpError(
|
|
68
|
-
ErrorCode.InvalidParams,
|
|
69
|
-
MCP_ERROR_MESSAGES.MISSING_REQUIRED_PARAMS,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
if (hasAdhocQuery && hasNamedQuery) {
|
|
73
|
-
throw new McpError(
|
|
74
|
-
ErrorCode.InvalidParams,
|
|
75
|
-
MCP_ERROR_MESSAGES.MUTUALLY_EXCLUSIVE_PARAMS,
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
// Zod/SDK handles missing required fields (packageName, modelPath) based on the shape
|
|
79
|
-
|
|
80
|
-
// --- Get Package and Model ---
|
|
81
|
-
logger.info(
|
|
82
|
-
`[MCP Tool executeQuery] Calling getModelForQuery for ${projectName}/${packageName}/${modelPath}`,
|
|
83
|
-
);
|
|
84
|
-
const modelResult = await getModelForQuery(
|
|
85
|
-
projectStore,
|
|
86
|
-
projectName,
|
|
87
|
-
packageName,
|
|
88
|
-
modelPath,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
// Handle errors during package/model access (e.g., not found, initial compilation)
|
|
92
|
-
if ("error" in modelResult) {
|
|
93
|
-
// Format error details as structured JSON
|
|
94
|
-
const errorJson = JSON.stringify(
|
|
95
|
-
{
|
|
96
|
-
error: modelResult.error.message,
|
|
97
|
-
suggestions: modelResult.error.suggestions,
|
|
98
|
-
},
|
|
99
|
-
null,
|
|
100
|
-
2,
|
|
101
|
-
);
|
|
102
|
-
return {
|
|
103
|
-
isError: true,
|
|
104
|
-
// Return as application/json nested inside a 'resource' type
|
|
105
|
-
content: [
|
|
106
|
-
{
|
|
107
|
-
type: "resource", // Use 'resource' type
|
|
108
|
-
resource: {
|
|
109
|
-
type: "application/json", // Actual content type
|
|
110
|
-
uri: "error://executeQuery/modelAccess", // Placeholder URI
|
|
111
|
-
text: errorJson,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// --- Execute Query ---
|
|
119
|
-
const { model } = modelResult;
|
|
120
|
-
logger.info(
|
|
121
|
-
`[MCP Tool executeQuery] Model found. Proceeding to execute query.`,
|
|
122
|
-
);
|
|
123
|
-
try {
|
|
124
|
-
// If ad-hoc query is provided, use it directly in the 3rd arg
|
|
125
|
-
if (query) {
|
|
126
|
-
const { result } = await model.getQueryResults(
|
|
127
|
-
undefined,
|
|
128
|
-
undefined,
|
|
129
|
-
query,
|
|
130
|
-
filterParams,
|
|
131
|
-
);
|
|
132
|
-
const { validateRenderTags } = await import(
|
|
133
|
-
"@malloydata/render-validator"
|
|
134
|
-
);
|
|
135
|
-
const renderLogs = validateRenderTags(result);
|
|
136
|
-
|
|
137
|
-
const baseUriComponents = {
|
|
138
|
-
project: projectName,
|
|
139
|
-
package: packageName,
|
|
140
|
-
resourceType: "models" as const,
|
|
141
|
-
resourceName: modelPath,
|
|
142
|
-
};
|
|
143
|
-
const resultUri = buildMalloyUri(baseUriComponents, "result");
|
|
144
|
-
const resultString = JSON.stringify(result, null, 2);
|
|
145
|
-
|
|
146
|
-
const content = [
|
|
147
|
-
{
|
|
148
|
-
type: "resource" as const,
|
|
149
|
-
resource: {
|
|
150
|
-
type: "application/json",
|
|
151
|
-
uri: resultUri,
|
|
152
|
-
text: resultString,
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
];
|
|
156
|
-
|
|
157
|
-
if (renderLogs.length > 0) {
|
|
158
|
-
return {
|
|
159
|
-
isError: false,
|
|
160
|
-
content: [
|
|
161
|
-
...content,
|
|
162
|
-
{
|
|
163
|
-
type: "text" as const,
|
|
164
|
-
text: `Render tag warnings:\n${JSON.stringify(renderLogs, null, 2)}`,
|
|
165
|
-
},
|
|
166
|
-
],
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return { isError: false, content };
|
|
171
|
-
} else if (queryName) {
|
|
172
|
-
const { result } = await model.getQueryResults(
|
|
173
|
-
sourceName,
|
|
174
|
-
queryName,
|
|
175
|
-
undefined,
|
|
176
|
-
filterParams,
|
|
177
|
-
);
|
|
178
|
-
const { validateRenderTags } = await import(
|
|
179
|
-
"@malloydata/render-validator"
|
|
180
|
-
);
|
|
181
|
-
const renderLogs = validateRenderTags(result);
|
|
182
|
-
|
|
183
|
-
const baseUriComponents = {
|
|
184
|
-
project: projectName,
|
|
185
|
-
package: packageName,
|
|
186
|
-
resourceType: "models" as const,
|
|
187
|
-
resourceName: modelPath,
|
|
188
|
-
};
|
|
189
|
-
const resultUri = buildMalloyUri(baseUriComponents, "result");
|
|
190
|
-
const resultString = JSON.stringify(result, null, 2);
|
|
191
|
-
|
|
192
|
-
const content = [
|
|
193
|
-
{
|
|
194
|
-
type: "resource" as const,
|
|
195
|
-
resource: {
|
|
196
|
-
type: "application/json",
|
|
197
|
-
uri: resultUri,
|
|
198
|
-
text: resultString,
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
];
|
|
202
|
-
|
|
203
|
-
if (renderLogs.length > 0) {
|
|
204
|
-
return {
|
|
205
|
-
isError: false,
|
|
206
|
-
content: [
|
|
207
|
-
...content,
|
|
208
|
-
{
|
|
209
|
-
type: "text" as const,
|
|
210
|
-
text: `Render tag warnings:\n${JSON.stringify(renderLogs, null, 2)}`,
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return { isError: false, content };
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// If execution reaches this point, something has gone wrong with
|
|
220
|
-
// the earlier parameter validation logic. Throw an explicit error
|
|
221
|
-
// so the return type is never 'undefined' from the compiler's
|
|
222
|
-
// perspective.
|
|
223
|
-
throw new McpError(
|
|
224
|
-
ErrorCode.InternalError,
|
|
225
|
-
"Unreachable executeQuery code path – parameters were not validated correctly.",
|
|
226
|
-
);
|
|
227
|
-
} catch (queryError) {
|
|
228
|
-
// Handle query execution errors (syntax errors, invalid queries, etc.)
|
|
229
|
-
logger.error(
|
|
230
|
-
`[MCP Server Error] Error executing query in ${projectName}/${packageName}/${modelPath}:`,
|
|
231
|
-
{ error: queryError },
|
|
232
|
-
);
|
|
233
|
-
const errorDetails: ErrorDetails = getMalloyErrorDetails(
|
|
234
|
-
"executeQuery",
|
|
235
|
-
`${projectName}/${packageName}/${modelPath}`, // Include project
|
|
236
|
-
queryError,
|
|
237
|
-
);
|
|
238
|
-
|
|
239
|
-
// Format error details as structured JSON
|
|
240
|
-
const errorJson = JSON.stringify(
|
|
241
|
-
{
|
|
242
|
-
error: errorDetails.message,
|
|
243
|
-
suggestions: errorDetails.suggestions,
|
|
244
|
-
},
|
|
245
|
-
null,
|
|
246
|
-
2,
|
|
247
|
-
);
|
|
248
|
-
return {
|
|
249
|
-
isError: true,
|
|
250
|
-
// Return as application/json nested inside a 'resource' type
|
|
251
|
-
content: [
|
|
252
|
-
{
|
|
253
|
-
type: "resource", // Use 'resource' type
|
|
254
|
-
resource: {
|
|
255
|
-
type: "application/json", // Actual content type
|
|
256
|
-
uri: "error://executeQuery/queryExecution", // Placeholder URI
|
|
257
|
-
text: errorJson,
|
|
258
|
-
},
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
);
|
|
265
|
-
}
|