Skip to content

Commit ad87240

Browse files
committed
Follow-ups to #5215
1 parent 780f3d1 commit ad87240

File tree

5 files changed

+36
-15
lines changed

5 files changed

+36
-15
lines changed

apps/rush-mcp-server/src/tools/docs.tool.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// See LICENSE in the project root for license information.
33

44
import { z } from 'zod';
5+
import { JsonFile } from '@rushstack/node-core-library';
6+
import path from 'path';
57

68
import { BaseTool, type CallToolResult } from './base.tool';
79

@@ -20,30 +22,35 @@ export class RushDocsTool extends BaseTool {
2022
super({
2123
name: 'rush_docs',
2224
description:
23-
'Search and retrieve relevant sections from Rush official documentation based on user queries.',
25+
'Search and retrieve relevant sections from the official Rush documentation based on user queries.',
2426
schema: {
2527
userQuery: z.string().describe('The user query to search for relevant documentation sections.')
2628
}
2729
});
2830
}
2931

30-
public async executeAsync({ userQuery }: { userQuery: string }): Promise<CallToolResult> {
31-
// An example of a knowledge base that can run, but needs to be replaced with Microsoft’s service.
32-
const response: Response = await fetch('http://47.120.46.115/search', {
33-
method: 'POST',
34-
headers: {
35-
'Content-Type': 'application/json'
36-
},
37-
body: JSON.stringify({ query: userQuery, topK: 10 })
38-
});
32+
// TODO: replace with Microsoft's service
33+
private searchDocs(query: string): IDocsResult {
34+
const startTime = Date.now();
35+
36+
const results = JsonFile.load(path.join(__dirname, '../rush-doc-fragment.mock.json'));
37+
38+
return {
39+
query,
40+
results,
41+
count: results.length,
42+
searchTimeMs: Date.now() - startTime
43+
};
44+
}
3945

40-
const result: IDocsResult = (await response.json()) as IDocsResult;
46+
public async executeAsync({ userQuery }: { userQuery: string }): Promise<CallToolResult> {
47+
const docSearchResult: IDocsResult = this.searchDocs(userQuery);
4148

4249
return {
4350
content: [
4451
{
4552
type: 'text',
46-
text: result.results.map((item) => item.text).join('\n')
53+
text: docSearchResult.results.map((item) => item.text).join('\n\n')
4754
}
4855
]
4956
};

apps/rush-mcp-server/src/tools/migrate-project.tool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ export class RushMigrateProjectTool extends BaseTool {
125125
type: 'text',
126126
text:
127127
`Project "${projectName}" migrated to subspace "${targetSubspaceName}" successfully. ` +
128-
`You can ask whether user wants to run "rush update --subspace ${targetSubspaceName}" to update the project. ` +
129-
`If user says "yes" you can run "rush update --subspace ${targetSubspaceName}" directly for them.`
128+
`You can ask whether the user wants to run "rush update --subspace ${targetSubspaceName}" to update the project. ` +
129+
`If the user says "yes", you can run "rush update --subspace ${targetSubspaceName}" directly for them.`
130130
}
131131
]
132132
};

apps/rush-mcp-server/src/tools/rush-command-validator.tool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class RushCommandValidatorTool extends BaseTool {
8888
content: [
8989
{
9090
type: 'text',
91-
text: `The package "${packageName}" does not exist in the Rush workspace. You can retrive package name from 'package.json' file in the project folder.`
91+
text: `The package "${packageName}" does not exist in the Rush workspace. You can retrieve the package name from the 'package.json' file in the project folder.`
9292
}
9393
]
9494
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@rushstack/mcp-server",
5+
"comment": "Follow-ups to #5215",
6+
"type": "patch"
7+
}
8+
],
9+
"packageName": "@rushstack/mcp-server"
10+
}

common/config/rush/nonbrowser-approved-packages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,10 @@
969969
{
970970
"name": "xmldoc",
971971
"allowedCategories": [ "libraries" ]
972+
},
973+
{
974+
"name": "zod",
975+
"allowedCategories": [ "libraries" ]
972976
}
973977
]
974978
}

0 commit comments

Comments
 (0)