Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
GitHub Copilot Agent Mode brings a contextual, action-driven chat experience into the MSSQL extension for Visual Studio Code. With Agent Mode, GitHub Copilot can go beyond suggesting code—it can securely execute real database tasks using natural language prompts or built-in tools. You can list all your connections, connect to specific server/databases, and explore schemas without leaving your editor.
Tip
You don't need to mention a participant like @mssql to use SQL tools in Agent Mode. Once the MSSQL extension is active, its tools are automatically available in the Agent Mode interface. For more information, see Agent Mode Tools.
These actions are powered by tools contributed by the MSSQL extension and surfaced directly within GitHub Copilot's Agent Mode. For more information on how Agent Mode works, see the Visual Studio Code documentation on Agent Mode.
What is Agent Mode?
Agent Mode enables GitHub Copilot to go beyond suggesting code. It can now perform secure, confirmed actions inside your SQL development environment, using either chat variables like #mssql_connect, or natural phrases like:
Connect to my Library database using my LocalDev profile
MSSQL Agent Mode tool reference
This section provides a detailed reference for the SQL-specific tools available in GitHub Copilot Agent Mode. The MSSQL extension contributes these tools, enabling GitHub Copilot to execute actions through chat variables or natural language prompts. All tools require user confirmation before execution.
Tip
You can also use chat variables like #mssql_connect to invoke these tools directly, or write prompts in natural language such as:
Connect to my development database
GitHub Copilot handles tool selection automatically.
Connection management
| Tool name | Description |
|---|---|
connect |
Establishes a database connection using a saved connection profile or a specified server/database pair. |
disconnect |
Terminates the current active connection session. |
change_database |
Changes the database for an existing connection session. |
get_connection_details |
Gets connection details for a specific MSSQL connection. |
list_servers |
Lists all saved SQL Server connection profiles in your environment. |
list_databases |
Lists all available databases for a connected MSSQL server. |
Examples
The following phrases can be used to interact with GitHub Copilot.
- Connect to my LocalDev environment
- Disconnect from my current database
- List my available connection profiles
- List all databases in the localhost server
- Set the active connection to localhost
- Set AdventureWorks as the active database
- Get the connection string for AdventureWorks on localhost
How connection logic works
GitHub Copilot Agent Mode supports flexible ways to connect to your SQL database, either by referencing saved profiles or by specifying a server and database directly. Here's how the connection logic works:
When you connect via saved profile:
- A user can connect by referencing the name of a saved connection profile.
- GitHub Copilot uses the
mssql_list_serverstool to verify the profile exists. - The
mssql_connecttool then uses the savedprofileIdand its parameters to establish the connection.
When you connect via server/database specification:
If a saved profile matches both the specified server and database:
- GitHub Copilot uses
mssql_list_serversto find the match. - It then calls
mssql_connectusing the full profile.
- GitHub Copilot uses
If a saved profile matches only the server:
- GitHub Copilot finds the matching server profile.
- It attempts to connect by substituting the user-requested database into that profile.
- If the connection fails, an error is shown.
If no profile matches the specified server:
- GitHub Copilot reports an error.
This flexible matching system allows GitHub Copilot to handle a range of connection scenarios, minimizing user effort while ensuring secure, confirmable actions.
Schema exploration
| Tool name | Description |
|---|---|
show_schema |
Displays a high-level diagram of your connected database schema, including tables and relationships. |
list_schemas |
Lists all schemas in a database for a connected MSSQL server. |
list_tables |
Lists all tables in a database for a connected MSSQL server. |
list_views |
Lists all views in a database for a connected MSSQL server. |
list_functions |
Lists all functions in a database for a connected MSSQL server. |
Examples
The following phrases can be used to interact with GitHub Copilot.
- Show me the schema for this database
- Show me all tables in the current database
- List all views from this MSSQL database
- Give me a list of all the functions available in this schema
- What schemas are available in this database?
Query execution
| Tool name | Description |
|---|---|
run_query |
Executes a SQL query against the connected database. |
Examples
The following phrases can be used to interact with GitHub Copilot.
- Give me the top five posts published this week
- Execute the current file to find how many comments each post has
- Get all categories along with the number of posts in each
How tools are managed in Agent Mode
GitHub Copilot can invoke MSSQL-specific tools and other extension-contributed tools while processing your request. These tools are visible in the Agent Mode interface under the Tools menu, where you can enable or disable specific tools.
When a tool is invoked—especially if it interacts with your machine or database—GitHub Copilot prompts for confirmation to ensure secure execution. You can allow the tool for just the current session, the workspace, or approve it permanently.
For more on tool visibility and approvals, visit Manage tool approvals.
Agent Mode confirmation workflow
When GitHub Copilot selects a tool, it prompts you with a confirmation dialog showing details about the requested action. You must explicitly approve the request before it can execute any commands that interact with your machine or database:
- Allow in this session
- Allow in this workspace
- Always allow
This confirmation step helps ensure secure, intentional interactions with your development environment.
Note
For more information on how confirmation works across all tools in Agent Mode, see the Visual Studio Code documentation on tool approvals.
Related content
- Quickstart: Use chat and inline GitHub Copilot suggestions
- Quickstart: Use GitHub Copilot slash commands
- Quickstart: Generate code
- Quickstart: Use the schema explorer and designer
- Quickstart: Use the smart query builder
- Quickstart: Query optimizer assistant
- Quickstart: Use the business logic explainer
- Quickstart: Security analyzer
- Quickstart: Localization and formatting helper
- Quickstart: Generate data for testing and mocking
- Limitations and known issues