@malloydata/malloyyo 0.2.45 → 0.2.47

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 (2) hide show
  1. package/dist/index.js +42 -37
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -250,7 +250,7 @@ var prompts = {
250
250
  "title": "Inspect a published source"
251
251
  },
252
252
  "list_sources": {
253
- "description": "List the sources you can query, grouped by the model that publishes them, with each model's named queries. Drill into a source with describe_source before writing a query.",
253
+ "description": "List the sources you can query, grouped by the model that publishes them, with each model's named queries. Drill into a source with describe_source before writing a query. A model may also report `dashboards` \u2014 pre-built pages for that model, each with a `url` a person can open; offer one when it already covers the question, and query the sources otherwise.",
254
254
  "title": "List sources"
255
255
  }
256
256
  }
@@ -1812,6 +1812,17 @@ function listSourcesTool(host) {
1812
1812
  }
1813
1813
  m.sources = sources;
1814
1814
  }
1815
+ if (e.dashboards?.length) {
1816
+ const dashboards = /* @__PURE__ */ Object.create(null);
1817
+ for (const d of e.dashboards) {
1818
+ const o = {};
1819
+ if (d.title) o.title = d.title;
1820
+ if (d.description) o.description = d.description;
1821
+ if (d.url) o.url = d.url;
1822
+ dashboards[d.name] = o;
1823
+ }
1824
+ m.dashboards = dashboards;
1825
+ }
1815
1826
  models[e.model_ref] = m;
1816
1827
  }
1817
1828
  return { ok: true, guidance: prompts.explore.guidance, models };
@@ -2574,6 +2585,7 @@ var rendersNoData = (d) => !d.query && (!d.tiles || d.tiles.length === 0);
2574
2585
 
2575
2586
  // src/gather.ts
2576
2587
  var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git"]);
2588
+ var DEVCONTAINER_PATH = ".devcontainer/devcontainer.json";
2577
2589
  function gatherDirectory(dir) {
2578
2590
  const files = [];
2579
2591
  const walk = (cur) => {
@@ -2591,6 +2603,10 @@ function gatherDirectory(dir) {
2591
2603
  }
2592
2604
  };
2593
2605
  walk(dir);
2606
+ const devcontainer = join2(dir, ...DEVCONTAINER_PATH.split("/"));
2607
+ if (existsSync2(devcontainer)) {
2608
+ files.push({ path: DEVCONTAINER_PATH, content: readFileSync2(devcontainer, "utf8") });
2609
+ }
2594
2610
  const configPath = join2(dir, "malloy-config.json");
2595
2611
  const config = existsSync2(configPath) ? readFileSync2(configPath, "utf8") : void 0;
2596
2612
  return { files, config };
@@ -2885,7 +2901,7 @@ function clearCreds(url6) {
2885
2901
  }
2886
2902
 
2887
2903
  // package.json
2888
- var version = "0.2.45";
2904
+ var version = "0.2.47";
2889
2905
 
2890
2906
  // src/http.ts
2891
2907
  var USER_AGENT = `malloyyo/${version}`;
@@ -3141,8 +3157,8 @@ Run: malloyyo login ${target.name}`);
3141
3157
  import fs4 from "node:fs";
3142
3158
  import path5 from "node:path";
3143
3159
  import url4 from "node:url";
3144
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3145
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3160
+ import { McpServer } from "@modelcontextprotocol/server";
3161
+ import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
3146
3162
  import {
3147
3163
  MalloyConfig as MalloyConfig2,
3148
3164
  Runtime as Runtime2,
@@ -3151,9 +3167,8 @@ import {
3151
3167
 
3152
3168
  // ../mcp-engine/dist/mcp-sdk.js
3153
3169
  import {
3154
- CallToolRequestSchema,
3155
- ListToolsRequestSchema
3156
- } from "@modelcontextprotocol/sdk/types.js";
3170
+ fromJsonSchema
3171
+ } from "@modelcontextprotocol/server";
3157
3172
  var HOST_ONLY2 = "host_only";
3158
3173
  function toContent(result) {
3159
3174
  const { malloy_text, [HOST_ONLY2]: _hostOnly, ...rest } = result;
@@ -3165,37 +3180,28 @@ function toContent(result) {
3165
3180
  }
3166
3181
  return { content, structuredContent: { ...rest } };
3167
3182
  }
3168
- function lowLevel(server) {
3169
- return "server" in server ? server.server : server;
3183
+ var PASS_THROUGH = {
3184
+ getValidator: () => (input) => ({ valid: true, data: input, errorMessage: void 0 })
3185
+ };
3186
+ function publishedSchema(schema) {
3187
+ return fromJsonSchema(schema, PASS_THROUGH);
3170
3188
  }
3171
3189
  function attachSurface(server, surface, opts = {}) {
3172
- const s = lowLevel(server);
3173
- const byName = new Map(surface.tools.map((t) => [t.name, t]));
3174
- s.setRequestHandler(ListToolsRequestSchema, async () => ({
3175
- tools: surface.tools.map((t) => ({
3176
- name: t.name,
3177
- title: t.title,
3178
- description: t.description,
3179
- inputSchema: t.inputSchema
3180
- }))
3181
- }));
3182
- s.setRequestHandler(CallToolRequestSchema, async (req) => {
3183
- const tool = byName.get(req.params.name);
3184
- if (!tool) {
3185
- return {
3186
- content: [{ type: "text", text: `unknown tool: ${req.params.name}` }],
3187
- isError: true
3188
- };
3189
- }
3190
- const result = await tool.handler(
3191
- req.params.arguments ?? {}
3190
+ for (const tool of surface.tools) {
3191
+ server.registerTool(
3192
+ tool.name,
3193
+ {
3194
+ title: tool.title,
3195
+ description: tool.description,
3196
+ inputSchema: publishedSchema(tool.inputSchema)
3197
+ },
3198
+ // Compile/run failures are data (problems[]), never protocol errors.
3199
+ async (args) => toContent(await tool.handler(args ?? {}))
3192
3200
  );
3193
- return toContent(result);
3194
- });
3195
- if (opts.registerSkillsAsPrompts && "registerPrompt" in server) {
3196
- const mcp = server;
3201
+ }
3202
+ if (opts.registerSkillsAsPrompts) {
3197
3203
  for (const skill of surface.skills) {
3198
- mcp.registerPrompt(
3204
+ server.registerPrompt(
3199
3205
  skill.name,
3200
3206
  { title: skill.name, description: skill.description },
3201
3207
  () => ({
@@ -3204,7 +3210,7 @@ function attachSurface(server, surface, opts = {}) {
3204
3210
  ]
3205
3211
  })
3206
3212
  );
3207
- mcp.registerResource(
3213
+ server.registerResource(
3208
3214
  skill.name,
3209
3215
  `malloy-skill://${skill.name}`,
3210
3216
  { title: skill.name, description: skill.description, mimeType: "text/markdown" },
@@ -3329,8 +3335,7 @@ async function serveMcp(opts) {
3329
3335
  const server = new McpServer(
3330
3336
  { name: serverName, version: opts.version },
3331
3337
  {
3332
- instructions: renderInstructions(surface.instructions, instanceName) + MODE_STUB[mode],
3333
- capabilities: { tools: {}, prompts: {}, resources: {} }
3338
+ instructions: renderInstructions(surface.instructions, instanceName) + MODE_STUB[mode]
3334
3339
  }
3335
3340
  );
3336
3341
  attachSurface(server, surface, { registerSkillsAsPrompts: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloyyo",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
4
4
  "description": "Publish Malloy models to a Malloyyo instance",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "@malloydata/malloy-connections": "^0.0.431",
40
40
  "@malloydata/malloy-filter": "^0.0.431",
41
41
  "@malloydata/render": "^0.0.431",
42
- "@modelcontextprotocol/sdk": "^1.29.0",
42
+ "@modelcontextprotocol/server": "^2.0.0",
43
43
  "commander": "^12.1.0",
44
44
  "esbuild": "^0.24.0",
45
45
  "react": "19.2.4",