Skip to content

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

Open
nagilson wants to merge 91 commits into
dotnet:mainfrom
nagilson:nagilson-mcp-for-installing
Open

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

Conversation

@nagilson

@nagilson nagilson commented Feb 6, 2026

Copy link
Copy Markdown
Member

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 (7 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
get_recommended_sdk_version

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
Comment thread 1pr-azure-pipeline.yml Outdated
Comment thread vscode-dotnet-runtime-extension/src/LanguageModelTools.ts Outdated
nagilson and others added 6 commits June 8, 2026 13:17
only 1xx versions are supported by the built in ppa feeds.
We should fix this, I'm not going to do it here or now. I think this was added here to make a minimal diff at the time.
this made it invalid json
…x if major or major.minor only format provided
.split returns 1 no matter what so the 0 condition was wrong.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 8, 2026 20:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 27 changed files in this pull request and generated 5 comments.

Comment thread vscode-dotnet-runtime-extension/src/LanguageModelTools.ts
Comment thread vscode-dotnet-runtime-extension/src/SettingsInfoContent.ts
Comment thread vscode-dotnet-runtime-extension/src/LanguageModelTools.ts
Comment thread vscode-dotnet-runtime-extension/src/SettingsInfoContent.ts Outdated
Copilot AI review requested due to automatic review settings June 8, 2026 21:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 26 out of 30 changed files in this pull request and generated 3 comments.

Comment thread vscode-dotnet-runtime-library/src/Utils/TypescriptUtilities.ts Outdated
Comment thread vscode-dotnet-runtime-extension/src/test/functional/index.ts
Comment thread vscode-dotnet-runtime-extension/package.json
Copilot AI review requested due to automatic review settings June 8, 2026 23:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 34 out of 38 changed files in this pull request and generated 2 comments.

Comment on lines +6 to 9
import * as os from 'os';
import * as path from 'path';
import { IEventStream } from '../EventStream/EventStream';
import
Comment on lines +43 to +51
"languageModelTools": [
{
"name": "install_dotnet_sdk",
"when": "config.dotnetAcquisitionExtension.enableLanguageModelTools",
"displayName": "Install .NET SDK",
"toolReferenceName": "installDotNetSdk",
"canBeReferencedInPrompt": true,
"icon": "$(tools)",
"userDescription": "Installs a .NET SDK system-wide for building and running .NET projects",
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.

7 participants