Skip to content

Provide Language Model Tools for LLM/VS Code Agent to Manage .NET#2557

Open
nagilson wants to merge 51 commits intodotnet:mainfrom
nagilson:nagilson-mcp-for-installing
Open

Provide Language Model Tools for LLM/VS Code Agent to Manage .NET#2557
nagilson wants to merge 51 commits intodotnet:mainfrom
nagilson:nagilson-mcp-for-installing

Conversation

@nagilson
Copy link
Copy Markdown
Member

@nagilson nagilson commented Feb 6, 2026

Add Language Model Tools for AI Agent Integration in VS Code

Summary

This PR adds Language Model Tools (languageModelTools) support to the .NET Install Tool extension, enabling AI agents like GitHub Copilot to help users manage .NET installations through natural language interactions.

This is an improvement upon #2375 (inspired by a convo with Rich) - at the time of that PR, agents couldn't directly invoke vscode contributing commands, so this approach used an MCP server and a subprocess that could communicate with the MCP server. Now there's a more robust way of doing this.

I also messed around with the agent window and setting up repos myself before adding this. The agent seemed to get very confused on what the existingPath setting did amongst other things, and it didn't understand how the dotnet hive / muxer worked and what installs were available where, and how they were used. I was somewhat inspired by a 'dogfooding' effort we did to try to use our own tooling. I've improved its knowledge of .NET now.

Changes

New Features

Language Model Tools (6 tools)

Added support for VS Code's languageModelTools contribution point.
See https://code.visualstudio.com/api/extension-guides/ai/tools

Most Important Files

vscode-dotnet-runtime-extension/package.json <-- (defines tools)
vscode-dotnet-runtime-extension/src/LanguageModelTools.ts <-- implements tools
vscode-dotnet-runtime-extension/src/SettingsInfoContent.ts

Tools added:
install_dotnet_sdk
list_available_dotnet_versions_to_install
find_dotnet_executable_path
uninstall_dotnet
get_settings_info_for_dotnet_installation_management
list_installed_dotnet_versions

Tested

  • I made sure that running vscode unelevated didn't confuse the llm when the tools require an admin prompt dialog box to continue.
  • I tested failure modes to see if the AI agent can properly recover using our errors (obviously hard to do for every error, which I did not)
  • I tested unsupported scenarios to make sure we don't make the llm worse for unsupported scenarios and instead guide it in the right direction
  • Before and after versions - before it would run several commands to check the machine state and require user permission, when the data was already available via our extension without requiring permission. The agent also preferred winget in the past even for admin installs of the SDK but it now prefers admin installed SDKs and local runtimes as that is what the extension supports. This is intentional.
  • Trying to manage out of support versions / global.json pinned versions - it took tweaking for the llm to not be annoying/reject requests/use latest instead.

Example:
📦 It can install SDK / Find Installs

Before:
https://github.com/user-attachments/assets/5f45102a-77da-40a4-ba04-0229ace06748%20%20

Agent has to wait for 2 separate commands + approval to run from the user (tedious and disrupts workflow) to get info it already has
Now:
https://github.com/user-attachments/assets/781b2318-2515-4bad-b1e5-84b0cdce0ba7%20
https://github.com/user-attachments/assets/cb6c7fb8-b1f6-43ff-870b-1cae71441258
The agent is more consistently aware (from my anecdotal testing) of what installs the user might need and informs the user. This happened sometimes for me prior but not always, as shown in the ss above.

🐧 Linux PPA

Before the LLM always used install scripts with claude opus 4.5, 4.6, chat codex 5. Sometimes this hit pathing issues.
Now it correctly follows our guidance, and tries to run the commands to either set up backport PPA or use the official feeds:
image

🗺️ Global.Json Paths Feature

If the user tries to use their own custom SDK it helps point them to the new 'paths' feature in global.json.

image

⚠️ Errors Propagate

This text shows the LLM is able to receive the errors we return and move forward/provide guidance.
image

--

These can be disabled in the extension settings of the .NET Install Tool:
image

Guidance

I followed the best practices as outlined by Anthropic to write these tools.
https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices
https://resources.anthropic.com/hubfs/The-Complete-Guide-to-Building-Skill-for-Claude.pdf
https://code.claude.com/docs/en/memory#write-effective-instructions

…nstall

# Add Language Model Tools for AI Agent Integration

## Summary

This PR adds Language Model Tools (`languageModelTools`) support to the .NET Install Tool extension, enabling AI agents like GitHub Copilot to help users manage .NET installations through natural language interactions.

This is an improvement upon dotnet#2375 - at the time of that PR, agents couldn't directly invoke vscode contributing commands, so this approach used an MCP server and a subprocess that could communicate with the MCP server. Now there's a more robust way of doing this.

## Changes

### New Features

#### Language Model Tools (6 tools)
Added support for VS Code's `languageModelTools` contribution point with the following tools:

| Tool | Purpose |
|------|---------|
| `installDotNetSdk` | Install .NET SDK system-wide (MSI on Windows, PKG on macOS, apt/yum on Linux) |
| `listDotNetVersions` | List available .NET SDK/Runtime versions from Microsoft with support phase info |
| `listInstalledDotNetVersions` | Query installed SDKs/Runtimes for a given dotnet executable |
| `findDotNetPath` | Find existing .NET installations that meet version/architecture requirements |
| `uninstallDotNet` | Uninstall .NET SDK or Runtime versions |
| `getDotNetSettingsInfo` | Comprehensive guide about settings, installation types, and troubleshooting |

Each tool includes:
- Detailed `modelDescription` with OS-specific guidance (MSI/PKG/apt/yum installers)
- User-friendly `userDescription`
- JSON schema for parameters
- Comprehensive error handling with troubleshooting tips

#### Comprehensive AI Agent Documentation
The `getDotNetSettingsInfo` tool returns a detailed guide covering:
- Difference between LOCAL (extension-managed) vs GLOBAL (system-wide) installs
- `existingDotnetPath` setting explanation (commonly misunderstood)
- SDK vs Runtime versioning relationship
- `global.json` file handling
- Common user scenarios and troubleshooting
- "Uninstall trick" for registering global SDKs not in the extension's list
its hard to verify since it involves installing / uninstalling  from the system state and requires user interaction. This may be overkill and im open to removing some of this.
This  allows the extension to run properly on the new  version of code + node js + ts that supports llm features
@nagilson nagilson requested a review from a team February 13, 2026 20:47
nagilson added 11 commits March 30, 2026 13:40
The plugin import is very old and was used during tslint to eslint migration so we don't need that
the new CI image doesn't have dotnet preinstalled
this made which dotnet fail so it didn't try to read the symlink
causing the test to fail
why don't we want it to do that by default:
1. it wont show up in the terminal
2. users might have to configure the path or the results will be less consistent
3. this way it will always use the officially supported method to install .net (install scripts are not rly recommended)

without the text it just ignores the guidance we give it.
@nagilson nagilson requested review from a team, baronfel, lbussell, richlander and webreidi March 31, 2026 20:12
@lbussell
Copy link
Copy Markdown
Member

@nagilson This is a very large pull request. To help reviewers, consider adding a list of agent tools this PR adds, along with their inputs and outputs (in a comment or in the PR body). That would make it easier to review the design of the tools.

@nagilson
Copy link
Copy Markdown
Member Author

nagilson commented Mar 31, 2026

To help reviewers, consider adding a list of agent tools this PR adds, along with their inputs and outputs (in a comment or in the PR body).

Thanks, @lbussell - the Most Important Files section outlines the files that define the tools, but I'll update the PR description a little more to include the tools from the package.json file. Hopefully this helps in the review process, good suggestion!

@richlander
Copy link
Copy Markdown
Member

These are new: https://github.com/dotnet/core/tree/main/release-notes/10.0/distros

@nagilson
Copy link
Copy Markdown
Member Author

These are new: https://github.com/dotnet/core/tree/main/release-notes/10.0/distros

I see, these outline the dependencies that each distro needs? That's quite cool. I would love to link https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-install?tabs=dotnet10&pivots=os-linux-ubuntu-2504#dependencies-1 the dependencies section in all the docs here, and the LLM would hopefully easily consume that info.

@richlander
Copy link
Copy Markdown
Member

I'm going to write a skill to consume that information. as well. I haven't figured out how to do that yet. I'll tell you when that happens. I have a skill to produce the infrormation.

@richlander
Copy link
Copy Markdown
Member

The overall workflow looks good and I'm curious to see it in action. I've haven't experienced sudo in any AI environment yet. It is an important experience. It would be good to include a clear doc on how that works and what the gotchas are. It has a UAC feel to it w/o the UAC infra.

Copy link
Copy Markdown
Contributor

@webreidi webreidi left a comment

Choose a reason for hiding this comment

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

Looks great! Works great!

@nagilson
Copy link
Copy Markdown
Member Author

nagilson commented Mar 31, 2026

I've haven't experienced sudo in any AI environment yet. It is an important experience.

That's a great point. I looked at the experience again. The sudo experience right now:
VS Code pauses and introduces a button to focus the terminal, telling you to please prompt in the terminal. It then works once you do that. It seems to be smart enough to reuse the terminal after that.

I'm hesitant to add a doc since this will likely evolve as VS Code improves their terminal built in tooling for sudo commands, and it's not something we own per se, it's somewhat up to the agent definition and vscode. This only happens when we can't run the commands for the user because the distro is unknown / wsl, but I'm glad to see the experience is working here.

@richlander
Copy link
Copy Markdown
Member

I wasn't asking you to write a doc. This is a trust boundary issue. At the very least, it makes sense to point to a doc that the VSC team maintains. Either way, we should get a review from @blowdart. This is a new experience.

@JakeRadMSFT
Copy link
Copy Markdown
Member

Try using it with any repo that needs multiple runtimes and it'll fail if you try to run or run tests from a runtime that doesn't match the sdk.

global sdks can't / won't find "local" runtimes. It's not a pattern that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants