Skip to content

Commit 93ba07e

Browse files
authored
feat(nx-mcp): rework nx_workspace with more parameters (#2903)
1 parent 8433d19 commit 93ba07e

File tree

7 files changed

+462
-61
lines changed

7 files changed

+462
-61
lines changed

apps/nx-mcp-e2e/src/nx-project-details-compressed-targets.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,18 +371,18 @@ describe('nx_project_details compressed targets', () => {
371371
expect(targetsBlock).toBeDefined();
372372
expect(targetsBlock).toContain('Available Targets (compressed view)');
373373
expect(targetsBlock).toContain(
374-
"To see full configuration for a specific target, call this tool again with filter='targets.TARGET_NAME'",
374+
"To see full configuration for a specific target, call this tool again with select='targets.TARGET_NAME'",
375375
);
376-
expect(targetsBlock).toMatch(/Example: filter='targets\.\w+'/);
376+
expect(targetsBlock).toMatch(/Example: select='targets\.\w+'/);
377377
});
378378

379-
it('should return full unabridged target when using filter parameter', () => {
379+
it('should return full unabridged target when using select parameter', () => {
380380
const result = invokeMCPInspectorCLI(
381381
testWorkspacePath,
382382
'--method tools/call',
383383
'--tool-name nx_project_details',
384384
`--tool-arg projectName="${workspaceName}"`,
385-
'--tool-arg filter="targets.target-nx-executor"',
385+
'--tool-arg select="targets.target-nx-executor"',
386386
);
387387

388388
expect(result.content).toHaveLength(1);

apps/nx-mcp-e2e/src/nx-project-details-pagination.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ describe('nx_project_details pagination', () => {
164164
expect(projectDetails).toContain('(continued)');
165165
});
166166

167-
it('should not paginate small content from filter', () => {
167+
it('should not paginate small content from select', () => {
168168
const result = invokeMCPInspectorCLI(
169169
testWorkspacePath,
170170
'--method tools/call',
171171
'--tool-name nx_project_details',
172172
`--tool-arg projectName="${workspaceName}"`,
173-
'--tool-arg filter="name"',
173+
'--tool-arg select="name"',
174174
);
175175

176176
expect(result.content).toHaveLength(1);
@@ -183,13 +183,13 @@ describe('nx_project_details pagination', () => {
183183
expect(hasContinuedLabel(text)).toBe(false);
184184
});
185185

186-
it('should handle pagination with filter parameter', () => {
186+
it('should handle pagination with select parameter', () => {
187187
const result = invokeMCPInspectorCLI(
188188
testWorkspacePath,
189189
'--method tools/call',
190190
'--tool-name nx_project_details',
191191
`--tool-arg projectName="${workspaceName}"`,
192-
'--tool-arg filter="targets"',
192+
'--tool-arg select="targets"',
193193
);
194194

195195
expect(result.content.length).toBe(2);
@@ -254,13 +254,13 @@ describe('nx_project_details pagination', () => {
254254
expect(hasTruncationIndicator(projectDetails)).toBe(false);
255255
});
256256

257-
it('should handle filter with undefined value correctly', () => {
257+
it('should handle select with undefined value correctly', () => {
258258
const result = invokeMCPInspectorCLI(
259259
testWorkspacePath,
260260
'--method tools/call',
261261
'--tool-name nx_project_details',
262262
`--tool-arg projectName="${workspaceName}"`,
263-
'--tool-arg filter="nonexistent.field"',
263+
'--tool-arg select="nonexistent.field"',
264264
);
265265

266266
expect(result.isError).toBe(true);

apps/nx-mcp-e2e/src/nx-project-details-filter.test.ts renamed to apps/nx-mcp-e2e/src/nx-project-details-select.test.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import {
1010
import { rmSync } from 'node:fs';
1111
import { join } from 'node:path';
1212

13-
describe('nx_project_details filter', () => {
13+
describe('nx_project_details select', () => {
1414
let invokeMCPInspectorCLI: Awaited<
1515
ReturnType<typeof createInvokeMCPInspectorCLI>
1616
>;
17-
const workspaceName = uniq('nx-mcp-project-details-filter');
17+
const workspaceName = uniq('nx-mcp-project-details-select');
1818
const testWorkspacePath = join(e2eCwd, workspaceName);
1919

2020
beforeAll(async () => {
@@ -33,7 +33,7 @@ describe('nx_project_details filter', () => {
3333
rmSync(testWorkspacePath, { recursive: true, force: true });
3434
});
3535

36-
it('should return full project details when no filter is provided', () => {
36+
it('should return full project details when no select is provided', () => {
3737
const result = invokeMCPInspectorCLI(
3838
testWorkspacePath,
3939
'--method tools/call',
@@ -61,16 +61,16 @@ describe('nx_project_details filter', () => {
6161
expect(result.content[2]?.text).toContain('External Dependencies:');
6262
});
6363

64-
it('should filter to root path using dot notation', () => {
64+
it('should select to root path using dot notation', () => {
6565
const result = invokeMCPInspectorCLI(
6666
testWorkspacePath,
6767
'--method tools/call',
6868
'--tool-name nx_project_details',
6969
`--tool-arg projectName="${workspaceName}"`,
70-
'--tool-arg filter="root"',
70+
'--tool-arg select="root"',
7171
);
7272

73-
// Should have 1 content block with the filtered value
73+
// Should have 1 content block with the selected value
7474
expect(result.content).toHaveLength(1);
7575
const text = result.content[0]?.text;
7676
// Should start with "Project Details: " prefix and contain the root value
@@ -81,13 +81,13 @@ describe('nx_project_details filter', () => {
8181
expect(text).not.toContain('"name"');
8282
});
8383

84-
it('should filter to name field', () => {
84+
it('should select to name field', () => {
8585
const result = invokeMCPInspectorCLI(
8686
testWorkspacePath,
8787
'--method tools/call',
8888
'--tool-name nx_project_details',
8989
`--tool-arg projectName="${workspaceName}"`,
90-
'--tool-arg filter="name"',
90+
'--tool-arg select="name"',
9191
);
9292

9393
expect(result.content).toHaveLength(1);
@@ -96,13 +96,13 @@ describe('nx_project_details filter', () => {
9696
expect(text).toContain(`"${workspaceName}"`);
9797
});
9898

99-
it('should filter to nested targets.build path', () => {
99+
it('should select to nested targets.build path', () => {
100100
const result = invokeMCPInspectorCLI(
101101
testWorkspacePath,
102102
'--method tools/call',
103103
'--tool-name nx_project_details',
104104
`--tool-arg projectName="${workspaceName}"`,
105-
'--tool-arg filter="targets.build"',
105+
'--tool-arg select="targets.build"',
106106
);
107107

108108
expect(result.content).toHaveLength(1);
@@ -114,13 +114,13 @@ describe('nx_project_details filter', () => {
114114
expect(text).not.toContain('"targets"');
115115
});
116116

117-
it('should filter to deeply nested targets.build.executor path', () => {
117+
it('should select to deeply nested targets.build.executor path', () => {
118118
const result = invokeMCPInspectorCLI(
119119
testWorkspacePath,
120120
'--method tools/call',
121121
'--tool-name nx_project_details',
122122
`--tool-arg projectName="${workspaceName}"`,
123-
'--tool-arg filter="targets.build.executor"',
123+
'--tool-arg select="targets.build.executor"',
124124
);
125125

126126
expect(result.content).toHaveLength(1);
@@ -130,13 +130,13 @@ describe('nx_project_details filter', () => {
130130
expect(text).not.toContain('"options"');
131131
});
132132

133-
it('should filter to tags array', () => {
133+
it('should select to tags array', () => {
134134
const result = invokeMCPInspectorCLI(
135135
testWorkspacePath,
136136
'--method tools/call',
137137
'--tool-name nx_project_details',
138138
`--tool-arg projectName="${workspaceName}"`,
139-
'--tool-arg filter="tags"',
139+
'--tool-arg select="tags"',
140140
);
141141

142142
expect(result.content).toHaveLength(1);
@@ -147,13 +147,13 @@ describe('nx_project_details filter', () => {
147147
expect(text).toContain(']');
148148
});
149149

150-
it('should filter to array element using bracket notation tags[0]', () => {
150+
it('should select to array element using bracket notation tags[0]', () => {
151151
const result = invokeMCPInspectorCLI(
152152
testWorkspacePath,
153153
'--method tools/call',
154154
'--tool-name nx_project_details',
155155
`--tool-arg projectName="${workspaceName}"`,
156-
'--tool-arg filter="tags[0]"',
156+
'--tool-arg select="tags[0]"',
157157
);
158158

159159
expect(result.content).toHaveLength(1);
@@ -169,7 +169,7 @@ describe('nx_project_details filter', () => {
169169
'--method tools/call',
170170
'--tool-name nx_project_details',
171171
`--tool-arg projectName="${workspaceName}"`,
172-
'--tool-arg filter="nonexistent.path.to.nowhere"',
172+
'--tool-arg select="nonexistent.path.to.nowhere"',
173173
);
174174

175175
expect(result.isError).toBe(true);
@@ -184,7 +184,7 @@ describe('nx_project_details filter', () => {
184184
'--method tools/call',
185185
'--tool-name nx_project_details',
186186
'--tool-arg projectName="nonexistent-project"',
187-
'--tool-arg filter="root"',
187+
'--tool-arg select="root"',
188188
);
189189

190190
expect(result.isError).toBe(true);

apps/nx-mcp-e2e/src/nx-workspace-filter.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('nx_workspace filter', () => {
6161
'--tool-name nx_workspace',
6262
);
6363

64-
const content = result.content[1]?.text || '';
64+
const content = result.content[0]?.text || '';
6565
expect(content).toContain(`<${workspaceName}>`);
6666
expect(content).toContain('<admin-app>');
6767
expect(content).toContain('<shared-ui>');
@@ -76,7 +76,7 @@ describe('nx_workspace filter', () => {
7676
'--tool-arg filter="admin-app,shared-ui"',
7777
);
7878

79-
const content = result.content[1]?.text || '';
79+
const content = result.content[0]?.text || '';
8080
expect(content).toContain('<admin-app>');
8181
expect(content).toContain('<shared-ui>');
8282
expect(content).not.toContain('<e2e-app>');
@@ -91,7 +91,7 @@ describe('nx_workspace filter', () => {
9191
'--tool-arg filter="*-app"',
9292
);
9393

94-
const content = result.content[1]?.text || '';
94+
const content = result.content[0]?.text || '';
9595
expect(content).toContain('<admin-app>');
9696
expect(content).toContain('<e2e-app>');
9797
expect(content).not.toContain('<shared-ui>');
@@ -105,7 +105,7 @@ describe('nx_workspace filter', () => {
105105
'--tool-arg filter="tag:type:ui"',
106106
);
107107

108-
const content = result.content[1]?.text || '';
108+
const content = result.content[0]?.text || '';
109109
expect(content).toContain('<shared-ui>');
110110
expect(content).not.toContain('<admin-app>');
111111
expect(content).not.toContain('<e2e-app>');
@@ -119,7 +119,7 @@ describe('nx_workspace filter', () => {
119119
'--tool-arg filter="libs/*"',
120120
);
121121

122-
const content = result.content[1]?.text || '';
122+
const content = result.content[0]?.text || '';
123123
expect(content).toContain('<shared-ui>');
124124
expect(content).not.toContain('<admin-app>');
125125
expect(content).not.toContain('<e2e-app>');
@@ -133,7 +133,7 @@ describe('nx_workspace filter', () => {
133133
'--tool-arg filter="*,!tag:e2e"',
134134
);
135135

136-
const content = result.content[1]?.text || '';
136+
const content = result.content[0]?.text || '';
137137
expect(content).toContain(`<${workspaceName}>`);
138138
expect(content).toContain('<admin-app>');
139139
expect(content).toContain('<shared-ui>');

0 commit comments

Comments
 (0)