@malloy-publisher/server 0.0.226 → 0.0.227

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 (69) hide show
  1. package/README.md +2 -11
  2. package/dist/package_load_worker.mjs +86 -24
  3. package/dist/server.mjs +655 -6994
  4. package/package.json +1 -4
  5. package/src/health.ts +3 -8
  6. package/src/mcp/error_messages.ts +8 -37
  7. package/src/mcp/handler_utils.ts +10 -129
  8. package/src/mcp/mcp_constants.ts +0 -16
  9. package/src/mcp/{agent_server.protocol.spec.ts → server.protocol.spec.ts} +14 -12
  10. package/src/mcp/server.ts +29 -37
  11. package/src/mcp/skills/build_skills_bundle.ts +1 -1
  12. package/src/mcp/skills/skills_bundle.json +1 -1
  13. package/src/mcp/tools/docs_search_tool.ts +1 -1
  14. package/src/mcp/tools/execute_query_tool.ts +2 -2
  15. package/src/mcp/tools/get_context_eval.ts +3 -3
  16. package/src/mcp/tools/get_context_tool.spec.ts +196 -1
  17. package/src/mcp/tools/get_context_tool.ts +165 -67
  18. package/src/package_load/package_load_pool.ts +3 -0
  19. package/src/package_load/package_load_worker.ts +68 -24
  20. package/src/package_load/protocol.ts +16 -0
  21. package/src/package_load/rpc_wait_accountant.spec.ts +109 -0
  22. package/src/package_load/rpc_wait_accountant.ts +76 -0
  23. package/src/package_load_metrics.spec.ts +114 -0
  24. package/src/package_load_metrics.ts +127 -0
  25. package/src/pg_helpers.spec.ts +2 -206
  26. package/src/pg_helpers.ts +4 -120
  27. package/src/server.ts +0 -16
  28. package/src/service/environment.ts +1 -1
  29. package/src/service/package.ts +82 -42
  30. package/src/test_helpers/metrics_harness.ts +40 -0
  31. package/tests/harness/mcp_test_setup.ts +1 -1
  32. package/tests/integration/mcp/mcp_transport.integration.spec.ts +7 -31
  33. package/tests/integration/watch-mode/watch_mode.integration.spec.ts +0 -6
  34. package/dxt/malloy_bridge.py +0 -354
  35. package/dxt/manifest.json +0 -22
  36. package/src/dto/connection.dto.spec.ts +0 -186
  37. package/src/dto/connection.dto.ts +0 -308
  38. package/src/dto/index.ts +0 -2
  39. package/src/dto/package.dto.spec.ts +0 -42
  40. package/src/dto/package.dto.ts +0 -27
  41. package/src/dto/validate.spec.ts +0 -76
  42. package/src/dto/validate.ts +0 -31
  43. package/src/ducklake_version.spec.ts +0 -43
  44. package/src/ducklake_version.ts +0 -26
  45. package/src/mcp/agent_server.spec.ts +0 -18
  46. package/src/mcp/agent_server.ts +0 -144
  47. package/src/mcp/prompts/handlers.ts +0 -84
  48. package/src/mcp/prompts/index.ts +0 -11
  49. package/src/mcp/prompts/prompt_definitions.ts +0 -160
  50. package/src/mcp/prompts/prompt_service.ts +0 -67
  51. package/src/mcp/prompts/utils.ts +0 -62
  52. package/src/mcp/resource_metadata.ts +0 -47
  53. package/src/mcp/resources/environment_resource.ts +0 -187
  54. package/src/mcp/resources/model_resource.ts +0 -155
  55. package/src/mcp/resources/notebook_resource.ts +0 -137
  56. package/src/mcp/resources/package_resource.ts +0 -373
  57. package/src/mcp/resources/query_resource.ts +0 -122
  58. package/src/mcp/resources/source_resource.ts +0 -141
  59. package/src/mcp/resources/view_resource.ts +0 -136
  60. package/src/mcp/tools/discovery_tools.ts +0 -280
  61. package/src/storage/BaseRepository.ts +0 -31
  62. package/src/storage/StorageManager.mock.ts +0 -50
  63. package/tests/harness/e2e.ts +0 -96
  64. package/tests/harness/mocks.ts +0 -39
  65. package/tests/harness/uris.ts +0 -31
  66. package/tests/integration/mcp/mcp_resource.integration.spec.ts +0 -655
  67. package/tests/integration/mcp/setup.spec.ts +0 -5
  68. package/tests/unit/mcp/prompt_definitions.test.ts +0 -102
  69. package/tests/unit/mcp/prompt_happy.test.ts +0 -51
package/README.md CHANGED
@@ -124,14 +124,7 @@ For more information on how to configure OpenTelemetry collectors, please refer
124
124
 
125
125
  ## MCP Prompt Capability
126
126
 
127
- Publisher's MCP interface exposes **LLM-ready prompts** for explaining, generating, translating and summarising Malloy code.
128
-
129
- | Prompt ID | Purpose |
130
- | ---------------------------------------------- | ----------------------------------------------------------------- |
131
- | `explain-malloy-query@1.0.0` | Explain a Malloy query (sources, transformations, output). |
132
- | `generate-malloy-query-from-description@1.0.0` | Create Malloy based on a natural-language goal and model context. |
133
- | `translate-sql-to-malloy@1.0.0` | Convert SQL into Malloy using a model for schema reference. |
134
- | `summarize-malloy-model@1.0.0` | Summarise a Malloy model (purpose, entities, joins). |
127
+ Publisher's MCP interface exposes the bundled agent **skills** (under [`skills/`](../../skills/)) as **LLM-ready prompts**, so hosts that ingest MCP but do not load skill files can pull the same guidance. For authoring or contributing skills, see [`docs/agent-skills/`](../../docs/agent-skills/).
135
128
 
136
129
  List prompts:
137
130
 
@@ -142,9 +135,7 @@ mcp-client prompts/list
142
135
  Get a prompt:
143
136
 
144
137
  ```bash
145
- mcp-client prompts/get \
146
- --name explain-malloy-query@1.0.0 \
147
- --arguments '{"query_code":"from flights"}'
138
+ mcp-client prompts/get --name malloy-analysis
148
139
  ```
149
140
 
150
141
  These calls return `messages` ready for your LLM chat completion.
@@ -12147,6 +12147,47 @@ function errMessage(err) {
12147
12147
  return err instanceof Error ? err.message : String(err);
12148
12148
  }
12149
12149
 
12150
+ // src/package_load/rpc_wait_accountant.ts
12151
+ class RpcWaitAccountant {
12152
+ now;
12153
+ inFlight = 0;
12154
+ waitStartMs = 0;
12155
+ accumMs = 0;
12156
+ startedCount = 0;
12157
+ activeJobId;
12158
+ constructor(now = () => performance.now()) {
12159
+ this.now = now;
12160
+ }
12161
+ begin(jobId) {
12162
+ this.activeJobId = jobId;
12163
+ this.inFlight = 0;
12164
+ this.waitStartMs = 0;
12165
+ this.accumMs = 0;
12166
+ this.startedCount = 0;
12167
+ }
12168
+ noteStart(jobId) {
12169
+ if (jobId !== this.activeJobId)
12170
+ return;
12171
+ if (this.inFlight === 0)
12172
+ this.waitStartMs = this.now();
12173
+ this.inFlight += 1;
12174
+ this.startedCount += 1;
12175
+ }
12176
+ noteSettle(jobId) {
12177
+ if (jobId !== this.activeJobId)
12178
+ return;
12179
+ this.inFlight -= 1;
12180
+ if (this.inFlight === 0)
12181
+ this.accumMs += this.now() - this.waitStartMs;
12182
+ }
12183
+ get waitMs() {
12184
+ return this.accumMs;
12185
+ }
12186
+ get fetches() {
12187
+ return this.startedCount;
12188
+ }
12189
+ }
12190
+
12150
12191
  // src/package_load/package_load_worker.ts
12151
12192
  if (!parentPort) {
12152
12193
  throw new Error("package_load_worker.ts must be loaded inside a worker_threads Worker");
@@ -12168,6 +12209,7 @@ function callMain(send) {
12168
12209
  send(requestId);
12169
12210
  });
12170
12211
  }
12212
+ var schemaWait = new RpcWaitAccountant;
12171
12213
  function dispatchMainResponse(message) {
12172
12214
  if (message.type === "schema-for-tables-response" || message.type === "schema-for-sql-response" || message.type === "read-url-response" || message.type === "connection-metadata-response") {
12173
12215
  const pending = pendingRpc.get(message.requestId);
@@ -12202,31 +12244,42 @@ class ProxyConnection {
12202
12244
  return this.digest;
12203
12245
  }
12204
12246
  async fetchSchemaForTables(tables, options) {
12205
- const response = await callMain((requestId) => {
12206
- const req = {
12207
- type: "schema-for-tables",
12208
- requestId,
12209
- jobId: this.jobId,
12210
- connectionName: this.name,
12211
- tables,
12212
- options: serializeFetchOptions(options)
12213
- };
12214
- port.postMessage(req);
12215
- });
12216
- return { schemas: response.schemas, errors: response.errors };
12247
+ schemaWait.noteStart(this.jobId);
12248
+ try {
12249
+ const response = await callMain((requestId) => {
12250
+ const req = {
12251
+ type: "schema-for-tables",
12252
+ requestId,
12253
+ jobId: this.jobId,
12254
+ connectionName: this.name,
12255
+ tables,
12256
+ options: serializeFetchOptions(options)
12257
+ };
12258
+ port.postMessage(req);
12259
+ });
12260
+ return { schemas: response.schemas, errors: response.errors };
12261
+ } finally {
12262
+ schemaWait.noteSettle(this.jobId);
12263
+ }
12217
12264
  }
12218
12265
  async fetchSchemaForSQLStruct(sentence, options) {
12219
- const response = await callMain((requestId) => {
12220
- const req = {
12221
- type: "schema-for-sql",
12222
- requestId,
12223
- jobId: this.jobId,
12224
- connectionName: this.name,
12225
- sentence,
12226
- options: serializeFetchOptions(options)
12227
- };
12228
- port.postMessage(req);
12229
- });
12266
+ schemaWait.noteStart(this.jobId);
12267
+ let response;
12268
+ try {
12269
+ response = await callMain((requestId) => {
12270
+ const req = {
12271
+ type: "schema-for-sql",
12272
+ requestId,
12273
+ jobId: this.jobId,
12274
+ connectionName: this.name,
12275
+ sentence,
12276
+ options: serializeFetchOptions(options)
12277
+ };
12278
+ port.postMessage(req);
12279
+ });
12280
+ } finally {
12281
+ schemaWait.noteSettle(this.jobId);
12282
+ }
12230
12283
  if (response.error !== undefined)
12231
12284
  return { error: response.error };
12232
12285
  if (response.structDef === undefined) {
@@ -12559,13 +12612,22 @@ async function loadPackage(job) {
12559
12612
  const malloyConfig = buildWorkerMalloyConfig(job);
12560
12613
  const allFiles = await listPackageFiles(job.packagePath);
12561
12614
  const modelPaths = filterModelPaths(allFiles);
12615
+ const compileRegionStart = performance.now();
12616
+ schemaWait.begin(job.requestId);
12562
12617
  const models = await Promise.all(modelPaths.map((modelPath) => compileOneModel(job, malloyConfig, modelPath)));
12618
+ const loadEnd = performance.now();
12619
+ const schemaFetchDurationMs = schemaWait.waitMs;
12563
12620
  return {
12564
12621
  type: "load-package-result",
12565
12622
  requestId: job.requestId,
12566
12623
  packageMetadata,
12567
12624
  models,
12568
- loadDurationMs: performance.now() - loadStart
12625
+ loadDurationMs: loadEnd - loadStart,
12626
+ timings: {
12627
+ compileDurationMs: Math.max(0, loadEnd - compileRegionStart - schemaFetchDurationMs),
12628
+ schemaFetchDurationMs,
12629
+ schemaFetchCount: schemaWait.fetches
12630
+ }
12569
12631
  };
12570
12632
  }
12571
12633
  function serializeError(error) {