Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/rush-plugins/rush-azure-storage-build-cache-plugin](./rush-plugins/rush-azure-storage-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-azure-storage-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-azure-storage-build-cache-plugin) | | [@rushstack/rush-azure-storage-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-azure-storage-build-cache-plugin) |
| [/rush-plugins/rush-buildxl-graph-plugin](./rush-plugins/rush-buildxl-graph-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-buildxl-graph-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-buildxl-graph-plugin) | | [@rushstack/rush-buildxl-graph-plugin](https://www.npmjs.com/package/@rushstack/rush-buildxl-graph-plugin) |
| [/rush-plugins/rush-http-build-cache-plugin](./rush-plugins/rush-http-build-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-http-build-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-http-build-cache-plugin) | | [@rushstack/rush-http-build-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-http-build-cache-plugin) |
| [/rush-plugins/rush-mcp-docs-plugin](./rush-plugins/rush-mcp-docs-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-mcp-docs-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-mcp-docs-plugin) | [changelog](./rush-plugins/rush-mcp-docs-plugin/CHANGELOG.md) | [@rushstack/rush-mcp-docs-plugin](https://www.npmjs.com/package/@rushstack/rush-mcp-docs-plugin) |
| [/rush-plugins/rush-redis-cobuild-plugin](./rush-plugins/rush-redis-cobuild-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-redis-cobuild-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-redis-cobuild-plugin) | | [@rushstack/rush-redis-cobuild-plugin](https://www.npmjs.com/package/@rushstack/rush-redis-cobuild-plugin) |
| [/rush-plugins/rush-resolver-cache-plugin](./rush-plugins/rush-resolver-cache-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-resolver-cache-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-resolver-cache-plugin) | | [@rushstack/rush-resolver-cache-plugin](https://www.npmjs.com/package/@rushstack/rush-resolver-cache-plugin) |
| [/rush-plugins/rush-serve-plugin](./rush-plugins/rush-serve-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Frush-serve-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Frush-serve-plugin) | | [@rushstack/rush-serve-plugin](https://www.npmjs.com/package/@rushstack/rush-serve-plugin) |
Expand Down
2 changes: 0 additions & 2 deletions apps/rush-mcp-server/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
/lib-*/**/test/
*.test.js

!*.mock.json

# NOTE: These don't need to be specified, because NPM includes them automatically.
#
# package.json
Expand Down
Empty file modified apps/rush-mcp-server/bin/mcp-server
100644 → 100755
Empty file.
4 changes: 1 addition & 3 deletions apps/rush-mcp-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import {
RushMigrateProjectTool,
RushCommandValidatorTool,
RushWorkspaceDetailsTool,
RushProjectDetailsTool,
RushDocsTool
RushProjectDetailsTool
} from './tools';
import { RushMcpPluginLoader } from './pluginFramework/RushMcpPluginLoader';

Expand Down Expand Up @@ -41,7 +40,6 @@ export class RushMCPServer extends McpServer {
this._tools.push(new RushCommandValidatorTool());
this._tools.push(new RushWorkspaceDetailsTool());
this._tools.push(new RushProjectDetailsTool());
this._tools.push(new RushDocsTool());
}

private _registerTools(): void {
Expand Down
1 change: 0 additions & 1 deletion apps/rush-mcp-server/src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ export * from './project-details.tool';
export * from './rush-command-validator.tool';
export * from './workspace-details';
export * from './conflict-resolver.tool';
export * from './docs.tool';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/mcp-server",
"comment": "Move the `rush docs` tool to a plugin package `@rushstack/rush-mcp-docs-plugin`",
"type": "patch"
}
],
"packageName": "@rushstack/mcp-server"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/rush-mcp-docs-plugin",
"comment": "Add rush docs mcp plugin",
"type": "minor"
}
],
"packageName": "@rushstack/rush-mcp-docs-plugin"
}
10 changes: 5 additions & 5 deletions common/config/rush/nonbrowser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
},
{
"name": "@rushstack/mcp-server",
"allowedCategories": [ "tests" ]
"allowedCategories": [ "libraries", "tests" ]
},
{
"name": "@rushstack/module-minifier",
Expand Down Expand Up @@ -490,6 +490,10 @@
"name": "buttono",
"allowedCategories": [ "tests" ]
},
{
"name": "chokidar",
"allowedCategories": [ "libraries" ]
},
{
"name": "cli-table",
"allowedCategories": [ "libraries" ]
Expand Down Expand Up @@ -658,10 +662,6 @@
"name": "https-proxy-agent",
"allowedCategories": [ "libraries" ]
},
{
"name": "chokidar",
"allowedCategories": [ "libraries" ]
},
{
"name": "ignore",
"allowedCategories": [ "libraries" ]
Expand Down
25 changes: 22 additions & 3 deletions common/config/subspaces/default/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This is a workaround for https://github.com/eslint/eslint/issues/3458
require('local-eslint-config/patch/modern-module-resolution');
// This is a workaround for https://github.com/microsoft/rushstack/issues/3021
require('local-eslint-config/patch/custom-config-package-names');

module.exports = {
extends: [
'local-eslint-config/profile/node',
'local-eslint-config/mixins/friendly-locals',
'local-eslint-config/mixins/tsdoc'
],
parserOptions: { tsconfigRootDir: __dirname }
};
37 changes: 37 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# THIS IS A STANDARD TEMPLATE FOR .npmignore FILES IN THIS REPO.

# Ignore all files by default, to avoid accidentally publishing unintended files.
*

# Use negative patterns to bring back the specific things we want to publish.
!/bin/**
!/lib/**
!/lib-*/**
!/dist/**

!CHANGELOG.md
!CHANGELOG.json
!heft-plugin.json
!rush-plugin-manifest.json
!ThirdPartyNotice.txt

# Ignore certain patterns that should not get published.
/dist/*.stats.*
/lib/**/test/
/lib-*/**/test/
*.test.js

# NOTE: These don't need to be specified, because NPM includes them automatically.
#
# package.json
# README.md
# LICENSE

# ---------------------------------------------------------------------------
# DO NOT MODIFY ABOVE THIS LINE! Add any project-specific overrides below.
# ---------------------------------------------------------------------------

!rush-mcp-plugin.json
!*.schema.json

!*.mock.json
24 changes: 24 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@rushstack/rush-mcp-docs-plugin

Copyright (c) Microsoft Corporation. All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 3 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @rushstack/rush-mcp-docs-plugin

The @rushstack/rush-mcp-docs-plugin package provides a documentation query tool for Rush.
7 changes: 7 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/config/rig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// The "rig.json" file directs tools to look for their config files in an external package.
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",

"rigPackageName": "local-node-rig"
}
28 changes: 28 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@rushstack/rush-mcp-docs-plugin",
"version": "0.0.0",
"description": "Docs plugin for @rushstack/mcp-server",
"repository": {
"url": "https://github.com/microsoft/rushstack.git",
"type": "git",
"directory": "rush-plugins/rush-mcp-docs-plugin"
},
"homepage": "https://rushjs.io",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"license": "MIT",
"scripts": {
"build": "heft build --clean",
"_phase:build": "heft run --only build -- --clean",
"_phase:test": "heft run --only test -- --clean"
},
"dependencies": {
"@rushstack/node-core-library": "workspace:*",
"@rushstack/mcp-server": "workspace:*"
},
"devDependencies": {
"@rushstack/heft": "workspace:*",
"local-node-rig": "workspace:*",
"local-eslint-config": "workspace:*"
}
}
24 changes: 24 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/rush-mcp-plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Every plugin package must contain a "rush-mcp-plugin.json" manifest in the top-level folder
* (next to package.json).
*/
{
/**
* A name that uniquely identifies your plugin. Generally this should be the same name as
* the NPM package. If two NPM packages have the same pluginName, they cannot be loaded together.
*/
"pluginName": "rush-mcp-docs-plugin",

/**
* (OPTIONAL) Indicates that your plugin accepts a config file. The MCP server will load this
* file and provide it to the plugin.
*
* The config file path will be `<rush-repo>/common/config/rush-mcp/<plugin-name>.json`.
*/
// "configFileSchema": "./lib/rush-mcp-example-plugin.schema.json",

/**
* The entry point, whose default export should be a class that implements
*/
"entryPoint": "./lib/index.js"
}
28 changes: 28 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/src/DocsPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type { IRushMcpPlugin, RushMcpPluginSession } from '@rushstack/mcp-server';
import { DocsTool } from './DocsTool';

export interface IDocsPluginConfigFile {}

export class DocsPlugin implements IRushMcpPlugin {
public session: RushMcpPluginSession;
public configFile: IDocsPluginConfigFile | undefined = undefined;

public constructor(session: RushMcpPluginSession, configFile: IDocsPluginConfigFile | undefined) {
this.session = session;
this.configFile = configFile;
}

public async onInitializeAsync(): Promise<void> {
this.session.registerTool(
{
toolName: 'rush_docs',
description:
'Search and retrieve relevant sections from the official Rush documentation based on user queries.'
},
new DocsTool(this)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import { z } from 'zod';
import type { IRushMcpTool, RushMcpPluginSession, CallToolResult, zodModule } from '@rushstack/mcp-server';
import { JsonFile } from '@rushstack/node-core-library';
import path from 'path';

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

interface IDocsResult {
query: string;
Expand All @@ -17,15 +17,22 @@ interface IDocsResult {
searchTimeMs: number;
}

export class RushDocsTool extends BaseTool {
public constructor() {
super({
name: 'rush_docs',
description:
'Search and retrieve relevant sections from the official Rush documentation based on user queries.',
schema: {
userQuery: z.string().describe('The user query to search for relevant documentation sections.')
}
export class DocsTool implements IRushMcpTool<DocsTool['schema']> {
public readonly plugin: DocsPlugin;
public readonly session: RushMcpPluginSession;

public constructor(plugin: DocsPlugin) {
this.plugin = plugin;
this.session = plugin.session;
}

// ZOD relies on type inference generate a messy expression in the .d.ts file
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
public get schema() {
const zod: typeof zodModule = this.session.zod;

return zod.object({
userQuery: zod.string().describe('The user query to search for relevant documentation sections.')
});
}

Expand All @@ -34,7 +41,7 @@ export class RushDocsTool extends BaseTool {
const startTime: number = Date.now();

const results: IDocsResult['results'] = JsonFile.load(
path.join(__dirname, '../rush-doc-fragment.mock.json')
path.join(__dirname, './rush-doc-fragment.mock.json')
);

return {
Expand All @@ -45,7 +52,7 @@ export class RushDocsTool extends BaseTool {
};
}

public async executeAsync({ userQuery }: { userQuery: string }): Promise<CallToolResult> {
public async executeAsync({ userQuery }: zodModule.infer<DocsTool['schema']>): Promise<CallToolResult> {
const docSearchResult: IDocsResult = this._searchDocs(userQuery);

return {
Expand Down
14 changes: 14 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import type { RushMcpPluginSession, RushMcpPluginFactory } from '@rushstack/mcp-server';
import { DocsPlugin, type IDocsPluginConfigFile } from './DocsPlugin';

function createPlugin(
session: RushMcpPluginSession,
configFile: IDocsPluginConfigFile | undefined
): DocsPlugin {
return new DocsPlugin(session, configFile);
}

export default createPlugin satisfies RushMcpPluginFactory<IDocsPluginConfigFile>;
3 changes: 3 additions & 0 deletions rush-plugins/rush-mcp-docs-plugin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/local-node-rig/profiles/default/tsconfig-base.json"
}
Loading