Skip to content

[mcp-server] Add more tools to mcp server#5215

Merged
octogonz merged 3 commits intomicrosoft:mainfrom
L-Qun:main
May 2, 2025
Merged

[mcp-server] Add more tools to mcp server#5215
octogonz merged 3 commits intomicrosoft:mainfrom
L-Qun:main

Conversation

@L-Qun
Copy link
Contributor

@L-Qun L-Qun commented May 1, 2025

prompt tools screenshots
1. Which other projects does ‘rush-lib-test’ depend on? Please show them in the form of a directory tree. rush_project_details image
2. Which other projects does ‘rush-lib-test’ depend on, including transitive dependencies? Please display them in the form of a directory tree rush_workspace_details image
3. Please add the React dependency to the rush-lib-test project. rush_command_validator image
4. Please help move the @rushstack/eslint-config project to the build-tests-subspace directory. rush_migrate_project image
5. Please help me resolve the conflict /path/to/your/project/pnpm-lock.yaml rush_pnpm_lock_file_conflict_resolver
6. Does Rush have a command called install-autoinstaller? rush_docs image

): Promise<ICommandResult> {
const commandPath: string = this._resolveCommand(command);

const result: child_process.SpawnSyncReturns<string> = Executable.spawnSync(commandPath, args, options);
Copy link
Collaborator

@octogonz octogonz May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be rewritten to use Executable.spawn(); otherwise the "async" function will block the MCP server process.

@L-Qun

type: 'text',
text:
`Project "${projectName}" migrated to subspace "${targetSubspaceName}" successfully. ` +
`You can ask whether user wants to run "rush update --subspace ${targetSubspaceName}" to update the project. ` +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`You can ask whether user wants to run "rush update --subspace ${targetSubspaceName}" to update the project. ` +
`You can ask whether the user wants to run "rush update --subspace ${targetSubspaceName}" to update the project. ` +

content: [
{
type: 'text',
text: `The package "${packageName}" does not exist in the Rush workspace. You can retrive package name from 'package.json' file in the project folder.`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: `The package "${packageName}" does not exist in the Rush workspace. You can retrive package name from 'package.json' file in the project folder.`
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.`

super({
name: 'rush_docs',
description:
'Search and retrieve relevant sections from Rush official documentation based on user queries.',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'Search and retrieve relevant sections from Rush official documentation based on user queries.',
'Search and retrieve relevant sections from the official Rush documentation based on user queries.',


public async executeAsync({ userQuery }: { userQuery: string }): Promise<CallToolResult> {
// An example of a knowledge base that can run, but needs to be replaced with Microsoft’s service.
const response: Response = await fetch('http://47.120.46.115/search', {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change this demo so that it doesn't rely on a black box.

If the code behind 47.120.46.115 is not too complex, maybe we could make it open source, or host it on the rushjs.io server. Otherwise, what happens 3 years from now when someone tries the demo? Most likely that IP address won't be running any more. 😄

But for demo/example purposes, it probably would be sufficient to rewrite this function so that it replies with static responses, e.g. from a JSON file.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idea would be to use the duckduckgo.com web search:

const https = require('https');

const query = 'dogs';
const url = `https://api.duckduckgo.com/?q=${encodeURIComponent(query)}&format=json`;

https.get(url, (res) => {
  let data = '';

  res.on('data', (chunk) => {
    data += chunk;
  });

  res.on('end', () => {
    try {
      const json = JSON.parse(data);
      console.log('Heading:', json.Heading);
      console.log('Abstract:', json.Abstract);
      console.log('Abstract URL:', json.AbstractURL);

      if (json.RelatedTopics && json.RelatedTopics.length > 0) {
        console.log('\nRelated Topics:');
        json.RelatedTopics.forEach((topic, index) => {
          if (topic.Text && topic.FirstURL) {
            console.log(`${index + 1}. ${topic.Text}`);
            console.log(topic.FirstURL);
          }
        });
      }
    } catch (e) {
      console.error('Error parsing JSON:', e.message);
    }
  });
}).on('error', (err) => {
  console.error('Request failed:', err.message);
});

Output:

Heading: Dog
Abstract: 
Abstract URL: https://en.wikipedia.org/wiki/Dog_(disambiguation)

Related Topics:
1. Dog A domesticated descendant of the gray wolf.
https://duckduckgo.com/Dog
2. Diogenes of Sinope An ancient Greek philosopher and one of the founders of Cynicism.
https://duckduckgo.com/Diogenes
3. Hot dog A dish consisting of a grilled, steamed, or boiled sausage served in the slit of a partially...
https://duckduckgo.com/Hot_dog

text:
`Project "${projectName}" migrated to subspace "${targetSubspaceName}" successfully. ` +
`You can ask whether user wants to run "rush update --subspace ${targetSubspaceName}" to update the project. ` +
`If user says "yes" you can run "rush update --subspace ${targetSubspaceName}" directly for them.`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`If user says "yes" you can run "rush update --subspace ${targetSubspaceName}" directly for them.`
`If the user says "yes", you can run "rush update --subspace ${targetSubspaceName}" directly for them.`

"allowedCategories": [ "libraries", "tests", "vscode-extensions" ]
},
{
"name": "zod",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to nonbrowser-approved-packages.json

@octogonz octogonz merged commit 780f3d1 into microsoft:main May 2, 2025
4 checks passed
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage May 2, 2025
L-Qun added a commit to L-Qun/rushstack that referenced this pull request May 2, 2025
L-Qun added a commit to L-Qun/rushstack that referenced this pull request May 2, 2025
L-Qun added a commit to L-Qun/rushstack that referenced this pull request May 2, 2025
L-Qun added a commit to L-Qun/rushstack that referenced this pull request May 2, 2025
L-Qun added a commit to L-Qun/rushstack that referenced this pull request May 2, 2025
octogonz pushed a commit that referenced this pull request May 7, 2025
* Follow-ups to #5215

* Follow-ups to #5215

* Follow-ups to #5215

* Follow-ups to #5215
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants