@malloy-publisher/server 0.0.382-dev → 0.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.
Files changed (175) hide show
  1. package/README.docker.md +145 -20
  2. package/README.md +65 -12
  3. package/dist/app/api-doc.html +5 -0
  4. package/dist/app/api-doc.yaml +3903 -583
  5. package/dist/app/assets/EnvironmentPage-DiUgLuCH.js +1 -0
  6. package/dist/app/assets/HomePage-MhhjhnFj.js +1 -0
  7. package/dist/app/assets/LightMode-BEyvNUzT.js +1 -0
  8. package/dist/app/assets/MainPage-D4Cfee9o.js +2 -0
  9. package/dist/app/assets/MaterializationsPage-nGgGqwSN.js +1 -0
  10. package/dist/app/assets/ModelPage-DLAcEw-F.js +1 -0
  11. package/dist/app/assets/PackagePage-Df0ikH7w.js +1 -0
  12. package/dist/app/assets/RouteError-BFQwtroH.js +1 -0
  13. package/dist/app/assets/ThemeEditorPage-OoskoQYN.js +1 -0
  14. package/dist/app/assets/WorkbookPage-CpFgvUDC.js +1 -0
  15. package/dist/app/assets/{core-CjeTkq8O.es-BqRc6yhC.js → core-lb28vQkR.es-BoVSOc75.js} +1 -1
  16. package/dist/app/assets/github-dark-DenFmJkN.es-DHJKELXO.js +1 -0
  17. package/dist/app/assets/index-5eLCcNmP.css +1 -0
  18. package/dist/app/assets/index-6ypuFH6g.js +1774 -0
  19. package/dist/app/assets/index-B8pnU_V_.js +615 -0
  20. package/dist/app/assets/index-BImcHmVP.js +1 -0
  21. package/dist/app/assets/index-DSoCUF-f.js +2725 -0
  22. package/dist/app/assets/index-DfqzSItA.js +2 -0
  23. package/dist/app/assets/index-w_0OQJgZ.js +23 -0
  24. package/dist/app/index.html +8 -4
  25. package/dist/cpufeatures-1yrn0vtw.node +0 -0
  26. package/dist/default-publisher.config.json +23 -0
  27. package/dist/{instrumentation.js → instrumentation.mjs} +10631 -10573
  28. package/dist/package_load_worker.mjs +15219 -0
  29. package/dist/runtime/publisher.js +331 -0
  30. package/dist/{server.js → server.mjs} +115548 -49590
  31. package/dist/sshcrypto-vd2k5hq9.node +0 -0
  32. package/package.json +41 -28
  33. package/publisher.config.example.bigquery.json +33 -0
  34. package/publisher.config.example.duckdb.json +23 -0
  35. package/.eslintrc.json +0 -44
  36. package/.prettierignore +0 -1
  37. package/.prettierrc +0 -4
  38. package/build.ts +0 -38
  39. package/dist/app/assets/HomePage-Dn3E4CuB.js +0 -1
  40. package/dist/app/assets/MainPage-BzB3yoqi.js +0 -2
  41. package/dist/app/assets/ModelPage-C9O_sAXT.js +0 -1
  42. package/dist/app/assets/PackagePage-DcxKEjBX.js +0 -1
  43. package/dist/app/assets/ProjectPage-BDj307rF.js +0 -1
  44. package/dist/app/assets/RouteError-DAShbVCG.js +0 -1
  45. package/dist/app/assets/WorkbookPage-Cs_XYEaB.js +0 -1
  46. package/dist/app/assets/index-15BOvhp0.js +0 -456
  47. package/dist/app/assets/index-Bb2jqquW.js +0 -676
  48. package/dist/app/assets/index-CMlGQMcl.css +0 -1
  49. package/dist/app/assets/index-D68X76-7.js +0 -1276
  50. package/dist/app/assets/index.umd-DGBekgSu.js +0 -1145
  51. package/dxt/malloy_bridge.py +0 -354
  52. package/dxt/manifest.json +0 -22
  53. package/eslint.config.mjs +0 -76
  54. package/k6-tests/README.md +0 -144
  55. package/k6-tests/bun.lock +0 -797
  56. package/k6-tests/load-test/load-test-crud-connections.ts +0 -263
  57. package/k6-tests/load-test/load-test-crud-packages.ts +0 -461
  58. package/k6-tests/load-test/load-test-crud-projects.ts +0 -160
  59. package/k6-tests/load-test/load-test-crud.ts +0 -142
  60. package/k6-tests/load-test/load-test.ts +0 -784
  61. package/k6-tests/package.json +0 -27
  62. package/k6-tests/scripts/run-with-otel.sh +0 -50
  63. package/k6-tests/smoke-test/smoke-test.ts +0 -158
  64. package/k6-tests/tsconfig.json +0 -29
  65. package/k6-tests/utils/client_factory.ts +0 -128
  66. package/k6-tests/utils/common.ts +0 -489
  67. package/k6-tests/utils/logger.ts +0 -62
  68. package/k6-tests/utils/types.d.ts +0 -35
  69. package/malloy_mcp.dxt +0 -0
  70. package/publisher.config.json +0 -33
  71. package/src/config.spec.ts +0 -850
  72. package/src/config.ts +0 -305
  73. package/src/constants.ts +0 -10
  74. package/src/controller/compile.controller.ts +0 -35
  75. package/src/controller/connection.controller.ts +0 -515
  76. package/src/controller/database.controller.ts +0 -21
  77. package/src/controller/manifest.controller.ts +0 -29
  78. package/src/controller/materialization.controller.ts +0 -125
  79. package/src/controller/model.controller.ts +0 -107
  80. package/src/controller/package.controller.ts +0 -182
  81. package/src/controller/query.controller.ts +0 -60
  82. package/src/controller/watch-mode.controller.ts +0 -98
  83. package/src/data_styles.ts +0 -71
  84. package/src/dto/connection.dto.spec.ts +0 -131
  85. package/src/dto/connection.dto.ts +0 -174
  86. package/src/dto/index.ts +0 -2
  87. package/src/dto/package.dto.spec.ts +0 -42
  88. package/src/dto/package.dto.ts +0 -12
  89. package/src/dto/validate.spec.ts +0 -76
  90. package/src/dto/validate.ts +0 -31
  91. package/src/errors.ts +0 -116
  92. package/src/health.ts +0 -189
  93. package/src/instrumentation.ts +0 -148
  94. package/src/logger.ts +0 -154
  95. package/src/mcp/error_messages.ts +0 -199
  96. package/src/mcp/handler_utils.ts +0 -239
  97. package/src/mcp/mcp_constants.ts +0 -22
  98. package/src/mcp/prompts/handlers.ts +0 -84
  99. package/src/mcp/prompts/index.ts +0 -11
  100. package/src/mcp/prompts/prompt_definitions.ts +0 -160
  101. package/src/mcp/prompts/prompt_service.ts +0 -67
  102. package/src/mcp/prompts/utils.ts +0 -62
  103. package/src/mcp/resource_metadata.ts +0 -47
  104. package/src/mcp/resources/model_resource.ts +0 -153
  105. package/src/mcp/resources/notebook_resource.ts +0 -137
  106. package/src/mcp/resources/package_resource.ts +0 -370
  107. package/src/mcp/resources/project_resource.ts +0 -184
  108. package/src/mcp/resources/query_resource.ts +0 -117
  109. package/src/mcp/resources/source_resource.ts +0 -141
  110. package/src/mcp/resources/view_resource.ts +0 -136
  111. package/src/mcp/server.ts +0 -62
  112. package/src/mcp/tools/discovery_tools.ts +0 -258
  113. package/src/mcp/tools/execute_query_tool.ts +0 -265
  114. package/src/server.ts +0 -1195
  115. package/src/service/connection.spec.ts +0 -1331
  116. package/src/service/connection.ts +0 -1511
  117. package/src/service/connection_service.spec.ts +0 -641
  118. package/src/service/connection_service.ts +0 -181
  119. package/src/service/db_utils.spec.ts +0 -714
  120. package/src/service/db_utils.ts +0 -1227
  121. package/src/service/filter.spec.ts +0 -447
  122. package/src/service/filter.ts +0 -337
  123. package/src/service/filter_integration.spec.ts +0 -825
  124. package/src/service/gcs_s3_utils.ts +0 -427
  125. package/src/service/manifest_service.spec.ts +0 -201
  126. package/src/service/manifest_service.ts +0 -106
  127. package/src/service/materialization_service.spec.ts +0 -648
  128. package/src/service/materialization_service.ts +0 -929
  129. package/src/service/materialized_table_gc.spec.ts +0 -383
  130. package/src/service/materialized_table_gc.ts +0 -279
  131. package/src/service/model.spec.ts +0 -257
  132. package/src/service/model.ts +0 -1069
  133. package/src/service/package.spec.ts +0 -236
  134. package/src/service/package.ts +0 -463
  135. package/src/service/project.ts +0 -681
  136. package/src/service/project_compile.spec.ts +0 -197
  137. package/src/service/project_store.spec.ts +0 -859
  138. package/src/service/project_store.ts +0 -1531
  139. package/src/service/quoting.ts +0 -41
  140. package/src/service/resolve_project.ts +0 -13
  141. package/src/storage/BaseRepository.ts +0 -31
  142. package/src/storage/DatabaseInterface.ts +0 -180
  143. package/src/storage/StorageManager.mock.ts +0 -59
  144. package/src/storage/StorageManager.ts +0 -210
  145. package/src/storage/duckdb/ConnectionRepository.ts +0 -141
  146. package/src/storage/duckdb/DuckDBConnection.ts +0 -177
  147. package/src/storage/duckdb/DuckDBManifestStore.ts +0 -70
  148. package/src/storage/duckdb/DuckDBRepository.ts +0 -224
  149. package/src/storage/duckdb/ManifestRepository.ts +0 -119
  150. package/src/storage/duckdb/MaterializationRepository.ts +0 -249
  151. package/src/storage/duckdb/PackageRepository.ts +0 -135
  152. package/src/storage/duckdb/ProjectRepository.ts +0 -148
  153. package/src/storage/duckdb/manifest_store.spec.ts +0 -133
  154. package/src/storage/duckdb/schema.ts +0 -147
  155. package/src/storage/ducklake/DuckLakeManifestStore.ts +0 -146
  156. package/src/utils.ts +0 -13
  157. package/tests/fixtures/persist-test/data/orders.csv +0 -5
  158. package/tests/fixtures/persist-test/persist_test.malloy +0 -11
  159. package/tests/fixtures/persist-test/publisher.json +0 -5
  160. package/tests/fixtures/publisher.config.json +0 -15
  161. package/tests/harness/e2e.ts +0 -96
  162. package/tests/harness/mcp_test_setup.ts +0 -344
  163. package/tests/harness/mocks.ts +0 -37
  164. package/tests/harness/rest_e2e.ts +0 -68
  165. package/tests/harness/uris.ts +0 -31
  166. package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +0 -470
  167. package/tests/integration/mcp/mcp_execute_query_tool.integration.spec.ts +0 -434
  168. package/tests/integration/mcp/mcp_resource.integration.spec.ts +0 -663
  169. package/tests/integration/mcp/mcp_transport.integration.spec.ts +0 -122
  170. package/tests/integration/mcp/setup.spec.ts +0 -5
  171. package/tests/unit/duckdb/attached_databases.test.ts +0 -1132
  172. package/tests/unit/ducklake/ducklake.test.ts +0 -950
  173. package/tests/unit/mcp/prompt_definitions.test.ts +0 -102
  174. package/tests/unit/mcp/prompt_happy.test.ts +0 -51
  175. package/tsconfig.json +0 -32
@@ -1,47 +0,0 @@
1
- import type { ResourceMetadata as SdkResourceMetadata } from "@modelcontextprotocol/sdk/server/mcp";
2
-
3
- // Define the specific resource types expected as keys
4
- type McpResourceType = "model" | "source" | "view" | "query" | "notebook";
5
-
6
- // Descriptions and usage guidance for different Malloy resource types.
7
- // Sourced from documentation and adapted for MCP client context.
8
- // Type assertion ensures compatibility with the SDK's ResourceMetadata,
9
- // which might include optional fields or an index signature.
10
- export const RESOURCE_METADATA: Record<
11
- McpResourceType | "package" | "project",
12
- SdkResourceMetadata // Use the imported SDK type here
13
- > = {
14
- model: {
15
- description:
16
- "A blueprint organizing your data tables, their connections, and reusable calculations (like 'revenue'). Models contain Sources, Views, and saved Queries.",
17
- usage: "This is your main map. Use its `definition` to see the available Sources, Views, and Queries inside (identified by their names or URIs). You can then fetch details for those specific items using `GetResource`. Use the `malloy_executeQuery` tool with queries defined here to get results, typically as structured data tables (JSON). The results might also include styling information suggesting visualizations.",
18
- },
19
- source: {
20
- description:
21
- "Represents a table or dataset (like 'orders'), including its columns and any attached calculations (dimensions/measures) or Views.",
22
- usage: "Examine the `definition` to understand the structure of this data and see available Views. Use `GetResource` on a View's URI to inspect it, or use the `malloy_executeQuery` tool (referencing the source and potentially a view) to get data results (JSON).",
23
- },
24
- view: {
25
- description:
26
- "A saved recipe within a Source for a specific analysis (like 'Top 10 Products').",
27
- usage: "Run this predefined analysis using the `malloy_executeQuery` tool (referencing the parent source/model and this view's name) to get results, typically structured data tables (JSON), sometimes with visualization hints.",
28
- },
29
- query: {
30
- description:
31
- "Similar to a View, a saved recipe for an analysis, usually stored directly in a Model.",
32
- usage: "Run this standard report using the `malloy_executeQuery` tool (referencing the parent model and this query's name) to get results, typically structured data tables (JSON), sometimes with visualization hints.",
33
- },
34
- notebook: {
35
- description:
36
- "An interactive document combining notes (Markdown text), Malloy code, and potentially saved queries or results.",
37
- usage: "Read the `definition` to explore the analysis steps, notes (Markdown), and code. Identify queries within the notebook cells that you can run using the `malloy_executeQuery` tool to get results (JSON data, visualization hints).",
38
- },
39
- package: {
40
- description: "A folder grouping related Models and Notebooks.",
41
- usage: "Use `ListResources` on this Package's URI to discover the Models and Notebooks it contains. You can then use `GetResource` on those items' URIs to explore them further.",
42
- },
43
- project: {
44
- description: "The main workspace folder holding Packages, Models, etc.",
45
- usage: "Use `ListResources` on this Project's URI to see the Packages inside and begin navigating your data assets.",
46
- },
47
- };
@@ -1,153 +0,0 @@
1
- import {
2
- McpServer,
3
- ResourceTemplate,
4
- } from "@modelcontextprotocol/sdk/server/mcp.js";
5
- import { ProjectStore } from "../../service/project_store";
6
- import {
7
- ModelNotFoundError,
8
- PackageNotFoundError,
9
- ModelCompilationError,
10
- } from "../../errors";
11
- import { handleResourceGet, McpGetResourceError } from "../handler_utils";
12
- import { RESOURCE_METADATA } from "../resource_metadata";
13
- import {
14
- getNotFoundError,
15
- getMalloyErrorDetails,
16
- getInternalError,
17
- } from "../error_messages";
18
- import type { components } from "../../api"; // Import the components type
19
-
20
- /**
21
- * Registers the Malloy Model resource type with the MCP server.
22
- * Handles getting details for a specific model.
23
- */
24
- export function registerModelResource(
25
- mcpServer: McpServer,
26
- projectStore: ProjectStore,
27
- ): void {
28
- mcpServer.resource(
29
- "model",
30
- new ResourceTemplate(
31
- "malloy://project/{projectName}/package/{packageName}/models/{modelPath}",
32
- { list: undefined }, // No list handler for individual models
33
- ),
34
- /** Handles GetResource requests for specific Malloy Models */
35
- (uri, params) =>
36
- handleResourceGet(
37
- uri,
38
- params,
39
- "model",
40
- async ({
41
- projectName,
42
- packageName,
43
- modelPath,
44
- }: {
45
- projectName?: unknown;
46
- packageName?: unknown;
47
- modelPath?: unknown;
48
- }) => {
49
- try {
50
- // Validate all parameters
51
- if (typeof projectName !== "string") {
52
- throw new Error("Invalid project name parameter.");
53
- }
54
- if (typeof packageName !== "string") {
55
- throw new Error("Invalid package name parameter.");
56
- }
57
- if (typeof modelPath !== "string") {
58
- throw new Error("Invalid model path parameter.");
59
- }
60
-
61
- // *** UPDATED LOGIC using ProjectStore ***
62
- // getProject can throw ProjectNotFoundError (though unlikely if name is 'home')
63
- const project = await projectStore.getProject(
64
- projectName,
65
- false,
66
- );
67
- // getPackage can throw PackageNotFoundError
68
- const pkg = await project.getPackage(packageName, false);
69
- // getModel is SYNCHRONOUS
70
- const modelInstance = pkg.getModel(modelPath);
71
- // *** END UPDATED LOGIC ***
72
-
73
- if (
74
- !modelInstance ||
75
- modelInstance.getModelType() === "notebook"
76
- ) {
77
- // Explicitly throw the expected error if not found or wrong type
78
- throw new ModelNotFoundError(modelPath);
79
- }
80
-
81
- // modelInstance.getModel() is ASYNC and can throw ModelCompilationError
82
- const compiledModelDefinition: components["schemas"]["CompiledModel"] =
83
- await modelInstance.getModel();
84
-
85
- // Strip implicit filters from agent-facing responses
86
- if (compiledModelDefinition.sources) {
87
- for (const source of compiledModelDefinition.sources) {
88
- if (source.filters) {
89
- source.filters = source.filters.filter(
90
- (f) => !f.implicit,
91
- );
92
- }
93
- }
94
- }
95
-
96
- return compiledModelDefinition;
97
- } catch (error) {
98
- let errorDetails;
99
- // Provide specific context for error messages
100
- // Use validated string parameters here
101
- const safeProjectName =
102
- typeof projectName === "string" ? projectName : "unknown";
103
- const safePackageName =
104
- typeof packageName === "string" ? packageName : "unknown";
105
- const safeModelPath =
106
- typeof modelPath === "string" ? modelPath : "unknown";
107
-
108
- const notFoundContext = `Model '${safeModelPath}' in package '${safePackageName}' for project '${safeProjectName}'`;
109
- const malloyErrorContext = `${safeProjectName}/${safePackageName}/${safeModelPath}`;
110
-
111
- if (error instanceof PackageNotFoundError) {
112
- // Package not found during getPackage call
113
- errorDetails = getNotFoundError(
114
- `Package '${safePackageName}' in project '${safeProjectName}'`,
115
- );
116
- } else if (error instanceof ModelNotFoundError) {
117
- // Model not found (either from getModel or type check)
118
- errorDetails = getNotFoundError(notFoundContext);
119
- } else if (error instanceof ModelCompilationError) {
120
- // Compilation error when fetching model definition
121
- errorDetails = getMalloyErrorDetails(
122
- "GetResource (model)",
123
- malloyErrorContext,
124
- error,
125
- );
126
- } else if (error instanceof Error) {
127
- // Catch invalid param errors or other generic errors
128
- // Provide a clearer message differentiating param errors
129
- if (error.message.includes("parameter")) {
130
- errorDetails = getNotFoundError(
131
- `Invalid identifier parameter provided for URI ${uri.href}: ${error.message}`,
132
- );
133
- } else {
134
- errorDetails = getInternalError(
135
- "GetResource (model) - Unexpected Error",
136
- error,
137
- );
138
- }
139
- } else {
140
- // Fallback for truly unexpected non-Error throws
141
- errorDetails = getInternalError(
142
- "GetResource (model)",
143
- error,
144
- );
145
- }
146
- // Wrap and re-throw for handleResourceGet
147
- throw new McpGetResourceError(errorDetails);
148
- }
149
- },
150
- RESOURCE_METADATA.model,
151
- ),
152
- );
153
- }
@@ -1,137 +0,0 @@
1
- import {
2
- McpServer,
3
- ResourceTemplate,
4
- } from "@modelcontextprotocol/sdk/server/mcp.js";
5
- import { URL } from "url";
6
- import type { components } from "../../api"; // Need this for CompiledModel type
7
- import {
8
- ModelCompilationError,
9
- ModelNotFoundError,
10
- PackageNotFoundError,
11
- } from "../../errors";
12
- import { logger } from "../../logger";
13
- import { ProjectStore } from "../../service/project_store";
14
- import {
15
- getInternalError,
16
- getMalloyErrorDetails,
17
- getNotFoundError,
18
- } from "../error_messages";
19
- import { handleResourceGet, McpGetResourceError } from "../handler_utils";
20
- import { RESOURCE_METADATA } from "../resource_metadata";
21
-
22
- // Define the expected parameter types
23
- type NotebookParams = {
24
- projectName?: unknown;
25
- packageName?: unknown;
26
- notebookName?: unknown;
27
- };
28
-
29
- /**
30
- * Registers the Malloy Notebook resource type.
31
- * Handles getting details for a specific notebook.
32
- */
33
- export function registerNotebookResource(
34
- mcpServer: McpServer,
35
- projectStore: ProjectStore,
36
- ): void {
37
- mcpServer.resource(
38
- "notebook",
39
- new ResourceTemplate(
40
- "malloy://project/{projectName}/package/{packageName}/notebooks/{notebookName}",
41
- { list: undefined }, // Listing notebooks is not supported via this template
42
- ),
43
- (uri, params) =>
44
- handleResourceGet(
45
- uri,
46
- params as NotebookParams,
47
- "notebook",
48
- async (
49
- { projectName, packageName, notebookName }: NotebookParams,
50
- uri: URL,
51
- ) => {
52
- if (
53
- typeof projectName !== "string" ||
54
- typeof packageName !== "string" ||
55
- typeof notebookName !== "string"
56
- ) {
57
- throw new Error("Invalid parameters for notebook resource.");
58
- }
59
-
60
- let modelInstance;
61
- try {
62
- const project = await projectStore.getProject(
63
- projectName,
64
- false,
65
- );
66
- const pkg = await project.getPackage(packageName, false);
67
- // Get the model instance using the notebookName as the path
68
- modelInstance = pkg.getModel(notebookName);
69
-
70
- // Check if it exists and is actually a notebook
71
- if (
72
- !modelInstance ||
73
- modelInstance.getModelType() !== "notebook"
74
- ) {
75
- const isNotebookError =
76
- modelInstance?.getModelType() !== "notebook";
77
- const errorDetails = getNotFoundError(
78
- `Notebook '${notebookName}' in package '${packageName}' project '${projectName}'${
79
- isNotebookError ? " (not a .malloynb file)" : ""
80
- }`,
81
- );
82
- throw new McpGetResourceError(errorDetails);
83
- }
84
-
85
- // Now try to get the actual notebook content
86
- const notebookContent: components["schemas"]["RawNotebook"] =
87
- await modelInstance.getNotebook();
88
- return notebookContent;
89
- } catch (error) {
90
- if (error instanceof McpGetResourceError) {
91
- throw error; // Re-throw if already formatted by checks above
92
- }
93
-
94
- // Handle specific errors like PackageNotFoundError or ModelCompilationError
95
- if (error instanceof PackageNotFoundError) {
96
- throw new McpGetResourceError(
97
- getNotFoundError(
98
- `Package '${packageName}' in project '${projectName}'`,
99
- ),
100
- );
101
- }
102
- // Handle ModelCompilationError from modelInstance.getModel()
103
- if (error instanceof ModelCompilationError) {
104
- const malloyErrorContext = `${projectName}/${packageName}/${notebookName}`;
105
- throw new McpGetResourceError(
106
- getMalloyErrorDetails(
107
- "GetResource (notebook compilation)",
108
- malloyErrorContext,
109
- error,
110
- ),
111
- );
112
- }
113
- // Handle ModelNotFoundError specifically from pkg.getModel()
114
- if (error instanceof ModelNotFoundError) {
115
- throw new McpGetResourceError(
116
- getNotFoundError(
117
- `Notebook '${notebookName}' not found in package '${packageName}' project '${projectName}'`,
118
- ),
119
- );
120
- }
121
-
122
- // Handle other unexpected errors
123
- logger.error(
124
- `[MCP Server Error] Error fetching notebook '${notebookName}' from ${uri.href}:`,
125
- { error },
126
- );
127
- const fallbackErrorDetails = getInternalError(
128
- `GetResource (notebook: ${uri.href})`,
129
- error,
130
- );
131
- throw new McpGetResourceError(fallbackErrorDetails);
132
- }
133
- },
134
- RESOURCE_METADATA.notebook,
135
- ),
136
- );
137
- }