@malloy-publisher/server 0.0.195 → 0.0.197-dev
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/dist/app/api-doc.yaml +213 -214
- package/dist/app/assets/EnvironmentPage-1j6QDWAy.js +1 -0
- package/dist/app/assets/HomePage-DMop21VG.js +1 -0
- package/dist/app/assets/MainPage-BbE8ETz1.js +2 -0
- package/dist/app/assets/ModelPage-D2jvfe3t.js +1 -0
- package/dist/app/assets/PackagePage-BbnhGoD3.js +1 -0
- package/dist/app/assets/{RouteError-DefbDO7F.js → RouteError-D3LGEZ3i.js} +1 -1
- package/dist/app/assets/WorkbookPage-DttVIj4u.js +1 -0
- package/dist/app/assets/{core-BrfQApxh.es-DnvCX4oH.js → core-w79IMXAG.es-Bd0UlzOL.js} +1 -1
- package/dist/app/assets/{index-Bu0ub036.js → index-5K9YjIxF.js} +117 -117
- package/dist/app/assets/{index-CkzK3JIl.js → index-C513UodQ.js} +1 -1
- package/dist/app/assets/{index-CoA6HIGS.js → index-DIgzgp69.js} +1 -1
- package/dist/app/assets/{index.umd-B6Ms2PpL.js → index.umd-BMeMPq_9.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/server.mjs +1352 -1310
- package/package.json +2 -2
- package/publisher.config.json +2 -2
- package/src/config.spec.ts +74 -66
- package/src/config.ts +50 -47
- package/src/controller/compile.controller.ts +10 -7
- package/src/controller/connection.controller.ts +79 -58
- package/src/controller/database.controller.ts +10 -7
- package/src/controller/manifest.controller.ts +23 -14
- package/src/controller/materialization.controller.ts +14 -14
- package/src/controller/model.controller.ts +35 -20
- package/src/controller/package.controller.ts +83 -49
- package/src/controller/query.controller.ts +11 -8
- package/src/controller/watch-mode.controller.ts +35 -29
- package/src/errors.ts +2 -2
- package/src/mcp/error_messages.ts +2 -2
- package/src/mcp/handler_utils.ts +23 -20
- package/src/mcp/mcp_constants.ts +1 -1
- package/src/mcp/prompts/handlers.ts +3 -3
- package/src/mcp/prompts/prompt_service.ts +5 -5
- package/src/mcp/prompts/utils.ts +12 -12
- package/src/mcp/resource_metadata.ts +3 -3
- package/src/mcp/resources/environment_resource.ts +187 -0
- package/src/mcp/resources/model_resource.ts +19 -17
- package/src/mcp/resources/notebook_resource.ts +13 -13
- package/src/mcp/resources/package_resource.ts +30 -27
- package/src/mcp/resources/query_resource.ts +15 -10
- package/src/mcp/resources/source_resource.ts +10 -10
- package/src/mcp/resources/view_resource.ts +11 -11
- package/src/mcp/server.ts +16 -14
- package/src/mcp/tools/discovery_tools.ts +67 -49
- package/src/mcp/tools/execute_query_tool.ts +14 -14
- package/src/server.ts +175 -159
- package/src/service/connection.spec.ts +158 -133
- package/src/service/connection.ts +42 -39
- package/src/service/connection_config.spec.ts +13 -11
- package/src/service/connection_config.ts +28 -19
- package/src/service/connection_service.spec.ts +63 -43
- package/src/service/connection_service.ts +106 -89
- package/src/service/{project.ts → environment.ts} +92 -77
- package/src/service/{project_compile.spec.ts → environment_compile.spec.ts} +1 -1
- package/src/service/{project_store.spec.ts → environment_store.spec.ts} +99 -83
- package/src/service/{project_store.ts → environment_store.ts} +373 -327
- package/src/service/manifest_service.spec.ts +15 -15
- package/src/service/manifest_service.ts +26 -21
- package/src/service/materialization_service.spec.ts +93 -59
- package/src/service/materialization_service.ts +71 -62
- package/src/service/materialized_table_gc.spec.ts +15 -15
- package/src/service/materialized_table_gc.ts +3 -3
- package/src/service/model.ts +4 -4
- package/src/service/package.spec.ts +2 -2
- package/src/service/package.ts +23 -21
- package/src/service/resolve_environment.ts +15 -0
- package/src/storage/DatabaseInterface.ts +34 -25
- package/src/storage/StorageManager.mock.ts +3 -3
- package/src/storage/StorageManager.ts +64 -28
- package/src/storage/duckdb/ConnectionRepository.ts +13 -11
- package/src/storage/duckdb/DuckDBConnection.ts +1 -1
- package/src/storage/duckdb/DuckDBManifestStore.ts +6 -6
- package/src/storage/duckdb/DuckDBRepository.ts +47 -47
- package/src/storage/duckdb/{ProjectRepository.ts → EnvironmentRepository.ts} +35 -35
- package/src/storage/duckdb/ManifestRepository.ts +21 -20
- package/src/storage/duckdb/MaterializationRepository.ts +31 -28
- package/src/storage/duckdb/PackageRepository.ts +11 -11
- package/src/storage/duckdb/manifest_store.spec.ts +2 -2
- package/src/storage/duckdb/schema.ts +20 -20
- package/src/storage/ducklake/DuckLakeManifestStore.ts +20 -11
- package/tests/fixtures/publisher.config.json +1 -1
- package/tests/harness/e2e.ts +1 -1
- package/tests/harness/mcp_test_setup.ts +12 -24
- package/tests/harness/mocks.ts +10 -8
- package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +4 -4
- package/tests/integration/mcp/mcp_execute_query_tool.integration.spec.ts +28 -49
- package/tests/integration/mcp/mcp_resource.integration.spec.ts +39 -47
- package/tests/integration/mcp/mcp_transport.integration.spec.ts +1 -1
- package/tests/unit/duckdb/attached_databases.test.ts +51 -33
- package/tests/unit/ducklake/ducklake.test.ts +24 -22
- package/tests/unit/mcp/prompt_happy.test.ts +8 -8
- package/dist/app/assets/HomePage-DbZS0N7G.js +0 -1
- package/dist/app/assets/MainPage-CBuWkbmr.js +0 -2
- package/dist/app/assets/ModelPage-Bt37smot.js +0 -1
- package/dist/app/assets/PackagePage-DLZe50WG.js +0 -1
- package/dist/app/assets/ProjectPage-FQTEPXP4.js +0 -1
- package/dist/app/assets/WorkbookPage-CkAo16ar.js +0 -1
- package/src/mcp/resources/project_resource.ts +0 -184
- package/src/service/resolve_project.ts +0 -13
package/src/mcp/server.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import {
|
|
2
|
+
import { EnvironmentStore } from "../service/environment_store";
|
|
3
3
|
|
|
4
4
|
import { formatDuration, logger } from "../logger";
|
|
5
5
|
import { registerPromptCapability } from "./prompts/prompt_service.js";
|
|
6
|
+
import { registerEnvironmentResource } from "./resources/environment_resource";
|
|
6
7
|
import { registerModelResource } from "./resources/model_resource";
|
|
7
8
|
import { registerNotebookResource } from "./resources/notebook_resource";
|
|
8
9
|
import { registerPackageResource } from "./resources/package_resource";
|
|
9
|
-
import { registerProjectResource } from "./resources/project_resource";
|
|
10
10
|
import { registerQueryResource } from "./resources/query_resource";
|
|
11
11
|
import { registerSourceResource } from "./resources/source_resource";
|
|
12
12
|
import { registerViewResource } from "./resources/view_resource";
|
|
@@ -20,38 +20,40 @@ export const testServerInfo = {
|
|
|
20
20
|
description: "Provides access to Malloy models and query execution via MCP.",
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
export function initializeMcpServer(
|
|
23
|
+
export function initializeMcpServer(
|
|
24
|
+
environmentStore: EnvironmentStore,
|
|
25
|
+
): McpServer {
|
|
24
26
|
logger.info("[MCP Init] Starting initializeMcpServer...");
|
|
25
27
|
const startTime = performance.now();
|
|
26
28
|
|
|
27
29
|
const mcpServer = new McpServer(testServerInfo);
|
|
28
30
|
|
|
29
|
-
logger.info("[MCP Init] Registering
|
|
30
|
-
|
|
31
|
+
logger.info("[MCP Init] Registering environment resource...");
|
|
32
|
+
registerEnvironmentResource(mcpServer, environmentStore);
|
|
31
33
|
logger.info("[MCP Init] Registering package resource...");
|
|
32
|
-
registerPackageResource(mcpServer,
|
|
34
|
+
registerPackageResource(mcpServer, environmentStore);
|
|
33
35
|
|
|
34
36
|
// Register more specific templates first
|
|
35
37
|
logger.info("[MCP Init] Registering notebook resource...");
|
|
36
|
-
registerNotebookResource(mcpServer,
|
|
38
|
+
registerNotebookResource(mcpServer, environmentStore);
|
|
37
39
|
logger.info("[MCP Init] Registering source resource...");
|
|
38
|
-
registerSourceResource(mcpServer,
|
|
40
|
+
registerSourceResource(mcpServer, environmentStore);
|
|
39
41
|
logger.info("[MCP Init] Registering query resource...");
|
|
40
|
-
registerQueryResource(mcpServer,
|
|
42
|
+
registerQueryResource(mcpServer, environmentStore);
|
|
41
43
|
logger.info("[MCP Init] Registering view resource...");
|
|
42
|
-
registerViewResource(mcpServer,
|
|
44
|
+
registerViewResource(mcpServer, environmentStore);
|
|
43
45
|
|
|
44
46
|
// Register the general model template last among resource types
|
|
45
47
|
logger.info("[MCP Init] Registering model resource...");
|
|
46
|
-
registerModelResource(mcpServer,
|
|
48
|
+
registerModelResource(mcpServer, environmentStore);
|
|
47
49
|
|
|
48
50
|
logger.info("[MCP Init] Registering executeQuery tool...");
|
|
49
|
-
registerExecuteQueryTool(mcpServer,
|
|
51
|
+
registerExecuteQueryTool(mcpServer, environmentStore);
|
|
50
52
|
|
|
51
|
-
registerTools(mcpServer,
|
|
53
|
+
registerTools(mcpServer, environmentStore);
|
|
52
54
|
|
|
53
55
|
logger.info("[MCP Init] Registering prompt capability...");
|
|
54
|
-
registerPromptCapability(mcpServer,
|
|
56
|
+
registerPromptCapability(mcpServer, environmentStore);
|
|
55
57
|
|
|
56
58
|
const endTime = performance.now();
|
|
57
59
|
logger.info(`[MCP Init] Finished initializeMcpServer`, {
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { EnvironmentStore } from "../../service/environment_store";
|
|
4
4
|
import { buildMalloyUri } from "../handler_utils";
|
|
5
5
|
|
|
6
6
|
const listPackagesShape = {
|
|
7
|
-
|
|
8
|
-
projectName: z
|
|
7
|
+
environmentName: z
|
|
9
8
|
.string()
|
|
10
9
|
.describe(
|
|
11
|
-
"
|
|
10
|
+
"Environment name. Names are listed in the malloy_environmentList tool.",
|
|
12
11
|
),
|
|
13
12
|
};
|
|
14
13
|
type listPackagesParams = z.infer<z.ZodObject<typeof listPackagesShape>>;
|
|
15
14
|
|
|
16
15
|
const getModelsShape = {
|
|
17
|
-
|
|
18
|
-
projectName: z
|
|
16
|
+
environmentName: z
|
|
19
17
|
.string()
|
|
20
18
|
.describe(
|
|
21
|
-
"
|
|
19
|
+
"Environment name. Names are listed in the malloy_environmentList tool.",
|
|
22
20
|
),
|
|
23
21
|
packageName: z
|
|
24
22
|
.string()
|
|
@@ -29,10 +27,10 @@ const getModelsShape = {
|
|
|
29
27
|
type getModelsParams = z.infer<z.ZodObject<typeof getModelsShape>>;
|
|
30
28
|
|
|
31
29
|
const getModelTextShape = {
|
|
32
|
-
|
|
30
|
+
environmentName: z
|
|
33
31
|
.string()
|
|
34
32
|
.describe(
|
|
35
|
-
"
|
|
33
|
+
"Environment name. Names are listed in the malloy_environmentList tool.",
|
|
36
34
|
),
|
|
37
35
|
packageName: z
|
|
38
36
|
.string()
|
|
@@ -48,48 +46,53 @@ const getModelTextShape = {
|
|
|
48
46
|
type getModelTextParams = z.infer<z.ZodObject<typeof getModelTextShape>>;
|
|
49
47
|
|
|
50
48
|
/**
|
|
51
|
-
* Registers
|
|
52
|
-
*
|
|
49
|
+
* Registers Malloy discovery tools with the MCP server.
|
|
50
|
+
* Lists environments and packages for navigation.
|
|
53
51
|
*/
|
|
54
52
|
export function registerTools(
|
|
55
53
|
mcpServer: McpServer,
|
|
56
|
-
|
|
54
|
+
environmentStore: EnvironmentStore,
|
|
57
55
|
): void {
|
|
58
56
|
mcpServer.tool(
|
|
59
|
-
"
|
|
60
|
-
"Lists all Malloy
|
|
57
|
+
"malloy_environmentList",
|
|
58
|
+
"Lists all Malloy environments",
|
|
61
59
|
{},
|
|
62
60
|
async () => {
|
|
63
61
|
console.log(
|
|
64
|
-
"[MCP LOG] Entering ListResources (
|
|
62
|
+
"[MCP LOG] Entering ListResources (environment) handler (listing ALL packages)...",
|
|
65
63
|
);
|
|
66
|
-
const
|
|
67
|
-
(await
|
|
68
|
-
.filter((
|
|
69
|
-
.map((
|
|
70
|
-
name:
|
|
71
|
-
|
|
64
|
+
const allEnvironments = await Promise.all(
|
|
65
|
+
(await environmentStore.listEnvironments())
|
|
66
|
+
.filter((environment) => environment.name)
|
|
67
|
+
.map((environment) => ({
|
|
68
|
+
name: environment.name,
|
|
69
|
+
environment: environmentStore.getEnvironment(
|
|
70
|
+
environment.name!,
|
|
71
|
+
false,
|
|
72
|
+
),
|
|
72
73
|
})),
|
|
73
74
|
);
|
|
74
75
|
|
|
75
|
-
console.log(
|
|
76
|
+
console.log(
|
|
77
|
+
`[MCP LOG] Found ${allEnvironments.length} environments defined.`,
|
|
78
|
+
);
|
|
76
79
|
|
|
77
80
|
const mappedResources = await Promise.all(
|
|
78
|
-
|
|
79
|
-
const name =
|
|
80
|
-
const
|
|
81
|
-
const metadata =
|
|
81
|
+
allEnvironments.map(async (environment) => {
|
|
82
|
+
const name = environment.name;
|
|
83
|
+
const environmentInstance = await environment.environment;
|
|
84
|
+
const metadata =
|
|
85
|
+
await environmentInstance.reloadEnvironmentMetadata();
|
|
82
86
|
const readme = metadata.readme;
|
|
83
87
|
return {
|
|
84
88
|
name,
|
|
85
|
-
type: "
|
|
89
|
+
type: "environment",
|
|
86
90
|
description: readme || "NO Description available",
|
|
87
91
|
};
|
|
88
92
|
}),
|
|
89
93
|
);
|
|
90
|
-
// console.log(mappedResources);
|
|
91
94
|
console.log(
|
|
92
|
-
`[MCP LOG] ListResources (
|
|
95
|
+
`[MCP LOG] ListResources (environment): Returning ${mappedResources.length} package resources.`,
|
|
93
96
|
);
|
|
94
97
|
return {
|
|
95
98
|
content: [
|
|
@@ -97,7 +100,7 @@ export function registerTools(
|
|
|
97
100
|
type: "resource",
|
|
98
101
|
resource: {
|
|
99
102
|
type: "application/json",
|
|
100
|
-
uri: buildMalloyUri({}, "
|
|
103
|
+
uri: buildMalloyUri({}, "environment"),
|
|
101
104
|
text: JSON.stringify(mappedResources),
|
|
102
105
|
},
|
|
103
106
|
},
|
|
@@ -108,15 +111,18 @@ export function registerTools(
|
|
|
108
111
|
|
|
109
112
|
mcpServer.tool(
|
|
110
113
|
"malloy_packageList",
|
|
111
|
-
"Lists all Malloy packages within
|
|
114
|
+
"Lists all Malloy packages within an environment",
|
|
112
115
|
listPackagesShape,
|
|
113
116
|
async (params: listPackagesParams) => {
|
|
114
|
-
const {
|
|
117
|
+
const { environmentName } = params;
|
|
115
118
|
console.log(
|
|
116
|
-
"[MCP LOG] Entering ListResources (
|
|
119
|
+
"[MCP LOG] Entering ListResources (environment) handler (listing ALL packages)...",
|
|
117
120
|
);
|
|
118
|
-
const
|
|
119
|
-
|
|
121
|
+
const environment = await environmentStore.getEnvironment(
|
|
122
|
+
environmentName,
|
|
123
|
+
false,
|
|
124
|
+
);
|
|
125
|
+
const packages = await environment.listPackages();
|
|
120
126
|
console.log(`[MCP LOG] Found ${packages.length} packages defined.`);
|
|
121
127
|
const mappedResources = packages.map((pkg) => ({
|
|
122
128
|
modelPath: pkg.name,
|
|
@@ -124,7 +130,7 @@ export function registerTools(
|
|
|
124
130
|
description: pkg.description,
|
|
125
131
|
}));
|
|
126
132
|
console.log(
|
|
127
|
-
`[MCP LOG] ListResources (
|
|
133
|
+
`[MCP LOG] ListResources (environment): Returning ${mappedResources.length} package resources.`,
|
|
128
134
|
);
|
|
129
135
|
return {
|
|
130
136
|
content: [
|
|
@@ -132,7 +138,10 @@ export function registerTools(
|
|
|
132
138
|
type: "resource",
|
|
133
139
|
resource: {
|
|
134
140
|
type: "application/json",
|
|
135
|
-
uri: buildMalloyUri(
|
|
141
|
+
uri: buildMalloyUri(
|
|
142
|
+
{ environment: environmentName },
|
|
143
|
+
"package",
|
|
144
|
+
),
|
|
136
145
|
text: JSON.stringify(mappedResources),
|
|
137
146
|
},
|
|
138
147
|
},
|
|
@@ -146,12 +155,15 @@ export function registerTools(
|
|
|
146
155
|
"Lists resources within a package",
|
|
147
156
|
getModelsShape,
|
|
148
157
|
async (params: getModelsParams) => {
|
|
149
|
-
const {
|
|
158
|
+
const { environmentName, packageName } = params;
|
|
150
159
|
console.log(
|
|
151
|
-
"[MCP LOG] Entering GetResources (
|
|
160
|
+
"[MCP LOG] Entering GetResources (environment) handler (listing ALL packages)...",
|
|
161
|
+
);
|
|
162
|
+
const environment = await environmentStore.getEnvironment(
|
|
163
|
+
environmentName,
|
|
164
|
+
false,
|
|
152
165
|
);
|
|
153
|
-
const
|
|
154
|
-
const pkg = await project.getPackage(packageName, false);
|
|
166
|
+
const pkg = await environment.getPackage(packageName, false);
|
|
155
167
|
const models = await pkg.listModels();
|
|
156
168
|
console.log(`[MCP LOG] Found ${models.length} models defined.`);
|
|
157
169
|
const mappedResources = models.map((model) => ({
|
|
@@ -159,7 +171,7 @@ export function registerTools(
|
|
|
159
171
|
type: "model",
|
|
160
172
|
}));
|
|
161
173
|
console.log(
|
|
162
|
-
`[MCP LOG] ListResources (
|
|
174
|
+
`[MCP LOG] ListResources (environment): Returning ${mappedResources.length} package resources.`,
|
|
163
175
|
);
|
|
164
176
|
return {
|
|
165
177
|
content: [
|
|
@@ -168,7 +180,10 @@ export function registerTools(
|
|
|
168
180
|
resource: {
|
|
169
181
|
type: "application/json",
|
|
170
182
|
uri: buildMalloyUri(
|
|
171
|
-
{
|
|
183
|
+
{
|
|
184
|
+
environment: environmentName,
|
|
185
|
+
package: packageName,
|
|
186
|
+
},
|
|
172
187
|
"model",
|
|
173
188
|
),
|
|
174
189
|
text: JSON.stringify(mappedResources),
|
|
@@ -184,14 +199,17 @@ export function registerTools(
|
|
|
184
199
|
"Gets the raw text content of a model file",
|
|
185
200
|
getModelTextShape,
|
|
186
201
|
async (params: getModelTextParams) => {
|
|
187
|
-
const {
|
|
202
|
+
const { environmentName, packageName, modelPath } = params;
|
|
188
203
|
console.log(
|
|
189
|
-
`[MCP LOG] Entering GetModelText handler for ${
|
|
204
|
+
`[MCP LOG] Entering GetModelText handler for ${environmentName}/${packageName}/${modelPath}...`,
|
|
190
205
|
);
|
|
191
206
|
|
|
192
207
|
try {
|
|
193
|
-
const
|
|
194
|
-
|
|
208
|
+
const environment = await environmentStore.getEnvironment(
|
|
209
|
+
environmentName,
|
|
210
|
+
false,
|
|
211
|
+
);
|
|
212
|
+
const pkg = await environment.getPackage(packageName, false);
|
|
195
213
|
const model = pkg.getModel(modelPath);
|
|
196
214
|
|
|
197
215
|
if (!model) {
|
|
@@ -218,7 +236,7 @@ export function registerTools(
|
|
|
218
236
|
type: "text/plain",
|
|
219
237
|
uri: buildMalloyUri(
|
|
220
238
|
{
|
|
221
|
-
|
|
239
|
+
environment: environmentName,
|
|
222
240
|
package: packageName,
|
|
223
241
|
model: modelPath,
|
|
224
242
|
},
|
|
@@ -241,7 +259,7 @@ export function registerTools(
|
|
|
241
259
|
type: "text/plain",
|
|
242
260
|
uri: buildMalloyUri(
|
|
243
261
|
{
|
|
244
|
-
|
|
262
|
+
environment: environmentName,
|
|
245
263
|
package: packageName,
|
|
246
264
|
model: modelPath,
|
|
247
265
|
},
|
|
@@ -2,18 +2,18 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
2
2
|
import { ErrorCode, McpError } from "@modelcontextprotocol/sdk/types.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { logger } from "../../logger";
|
|
5
|
-
import {
|
|
5
|
+
import { EnvironmentStore } from "../../service/environment_store";
|
|
6
6
|
import { getMalloyErrorDetails, type ErrorDetails } from "../error_messages";
|
|
7
7
|
import { buildMalloyUri, getModelForQuery } from "../handler_utils";
|
|
8
8
|
import { MCP_ERROR_MESSAGES } from "../mcp_constants";
|
|
9
9
|
|
|
10
10
|
// Zod shape defining required/optional params for executeQuery
|
|
11
11
|
const executeQueryShape = {
|
|
12
|
-
//
|
|
13
|
-
|
|
12
|
+
// environmentName is required; other fields mirror SDK expectations
|
|
13
|
+
environmentName: z
|
|
14
14
|
.string()
|
|
15
15
|
.describe(
|
|
16
|
-
"
|
|
16
|
+
"Environment name. Names are listed in the malloy resource list.",
|
|
17
17
|
),
|
|
18
18
|
packageName: z
|
|
19
19
|
.string()
|
|
@@ -39,7 +39,7 @@ const executeQueryShape = {
|
|
|
39
39
|
*/
|
|
40
40
|
export function registerExecuteQueryTool(
|
|
41
41
|
mcpServer: McpServer,
|
|
42
|
-
|
|
42
|
+
environmentStore: EnvironmentStore,
|
|
43
43
|
): void {
|
|
44
44
|
mcpServer.tool(
|
|
45
45
|
"malloy_executeQuery",
|
|
@@ -47,9 +47,9 @@ export function registerExecuteQueryTool(
|
|
|
47
47
|
executeQueryShape,
|
|
48
48
|
/** Handles requests for the malloy_executeQuery tool */
|
|
49
49
|
async (params) => {
|
|
50
|
-
// Destructure
|
|
50
|
+
// Destructure environmentName as well
|
|
51
51
|
const {
|
|
52
|
-
|
|
52
|
+
environmentName,
|
|
53
53
|
packageName,
|
|
54
54
|
modelPath,
|
|
55
55
|
query,
|
|
@@ -79,11 +79,11 @@ export function registerExecuteQueryTool(
|
|
|
79
79
|
|
|
80
80
|
// --- Get Package and Model ---
|
|
81
81
|
logger.info(
|
|
82
|
-
`[MCP Tool executeQuery] Calling getModelForQuery for ${
|
|
82
|
+
`[MCP Tool executeQuery] Calling getModelForQuery for ${environmentName}/${packageName}/${modelPath}`,
|
|
83
83
|
);
|
|
84
84
|
const modelResult = await getModelForQuery(
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
environmentStore,
|
|
86
|
+
environmentName,
|
|
87
87
|
packageName,
|
|
88
88
|
modelPath,
|
|
89
89
|
);
|
|
@@ -135,7 +135,7 @@ export function registerExecuteQueryTool(
|
|
|
135
135
|
const renderLogs = validateRenderTags(result);
|
|
136
136
|
|
|
137
137
|
const baseUriComponents = {
|
|
138
|
-
|
|
138
|
+
environment: environmentName,
|
|
139
139
|
package: packageName,
|
|
140
140
|
resourceType: "models" as const,
|
|
141
141
|
resourceName: modelPath,
|
|
@@ -181,7 +181,7 @@ export function registerExecuteQueryTool(
|
|
|
181
181
|
const renderLogs = validateRenderTags(result);
|
|
182
182
|
|
|
183
183
|
const baseUriComponents = {
|
|
184
|
-
|
|
184
|
+
environment: environmentName,
|
|
185
185
|
package: packageName,
|
|
186
186
|
resourceType: "models" as const,
|
|
187
187
|
resourceName: modelPath,
|
|
@@ -227,12 +227,12 @@ export function registerExecuteQueryTool(
|
|
|
227
227
|
} catch (queryError) {
|
|
228
228
|
// Handle query execution errors (syntax errors, invalid queries, etc.)
|
|
229
229
|
logger.error(
|
|
230
|
-
`[MCP Server Error] Error executing query in ${
|
|
230
|
+
`[MCP Server Error] Error executing query in ${environmentName}/${packageName}/${modelPath}:`,
|
|
231
231
|
{ error: queryError },
|
|
232
232
|
);
|
|
233
233
|
const errorDetails: ErrorDetails = getMalloyErrorDetails(
|
|
234
234
|
"executeQuery",
|
|
235
|
-
`${
|
|
235
|
+
`${environmentName}/${packageName}/${modelPath}`, // Include environment
|
|
236
236
|
queryError,
|
|
237
237
|
);
|
|
238
238
|
|