AI extensibility in VS Code
Visual Studio Code has many AI features to improve your coding experience, such as code completions, or natural language chat. You can further extend the built-in capabilities, for example by contributing tools for agent mode, or adding AI-powered features to your VS Code extension.
Depending on your use case, you have the following options for extending AI in your VS Code extension:
-
Agent mode tool: use the Language Model Tool API to contribute a tool for agent mode that is invoked automatically based on the user's prompt. Integrate deeply in VS Code by using other extension APIs in your tool.
-
MCP tool: automatically register external MCP tools that can then be used in agent mode. As an extension developer, you can register an MCP tool as part of your extension. MCP tools run outside of the VS Code extension host and don't have access to the VS Code extension APIs.
-
Chat participant: use the Chat and Language Model APIs to create a chat participant for ask mode that enables users to ask domain-specific questions by using natural language.
-
Use AI model: use the Language Model API and the VS Code extension APIs to build custom AI-powered features into your extension and enhance editor-specific interactions.
Alternatively, you can also build a GitHub Copilot Extension, implemented as a GitHub App with additional capabilities. Copilot Extensions work across all supported IDEs and GitHub, but don't have access to functionalities specific to VS Code. Get more info about Copilot Extensions in the GitHub documentation.
Use cases
Here are some examples of how you can use AI in your VS Code extension:
-
Docs querying: use Retrieval-Augmented Generation (RAG) to query a third-party documentation service and generate responses based on the retrieved information.
-
AI-assisted coding: use the AI model to provide editor annotations to provide coding suggestions.
-
AI-powered reviews: use the AI model to review your code for security vulnerabilities or performance improvements.
-
Data retrieval: query a database or third-party data service to retrieve information about a specific topic.
-
Enterprise coding assistant: get chat responses that are grounded in the data of your enterprise and are aware of the specific coding guidelines your company follows.
-
Enhance extensions: use the Language Model API to add AI-powered features to your existing VS Code extensions.
There are several examples already available in the Visual Studio Marketplace that extend AI in VS Code:
-
Agent mode tools: Go to the Marketplace or search for the
language-model-tools
tag in the Extensions view. -
Chat participants: Go to the Marketplace or search for the
chat-participant
tag in the Extensions view.
Get started with AI extensibility in VS Code
To get started with extending AI in your VS Code extension, explore the following resources:
-
Chat sample: sample code for building a VS Code extension that contributes an agent mode tool and chat participant.
-
MCP extension sample: sample code for building a VS Code extension that registers an MCP tool.
-
Tutorial: AI-powered code annotations: step-by-step guide to implement a VS Code extension that uses the Language Model API to generate code annotations in the editor to help improve your code.
-
Tutorial: Code tutor chat participant: step-by-step guide to implement a code tutor chat participant that enables users to ask for explaining a technical topic by using natural language in the Chat view in VS Code.
-
Extension guides: Learn how to use the Tools API Chat API and Language Model API.