You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tools/visual-studio-code-extensions/github-copilot/agent-mode.md
+76-20Lines changed: 76 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Learn how to use GitHub Copilot Agent Mode with the MSSQL extension
4
4
author: croblesm
5
5
ms.author: roblescarlos
6
6
ms.reviewer: randolphwest
7
-
ms.date: 06/18/2025
7
+
ms.date: 07/23/2025
8
8
ms.service: sql
9
9
ms.subservice: vs-code-sql-extensions
10
10
ms.topic: quickstart
@@ -18,7 +18,7 @@ ai-usage: ai-assisted
18
18
19
19
# Quickstart: Use GitHub Copilot Agent Mode (Preview)
20
20
21
-
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.
21
+
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.
22
22
23
23
> [!TIP]
24
24
> 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](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode#_agent-mode-tools).
@@ -27,57 +27,81 @@ These actions are powered by tools contributed by the MSSQL extension and surfac
27
27
28
28
## What is Agent Mode?
29
29
30
-
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.*"
30
+
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:
31
+
32
+
```copilot-prompt
33
+
Connect to my Library database using my LocalDev profile
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.
37
41
38
-
:::image type="content" source="media/agent-mode/agent-tools.png" alt-text="Screenshot of list of SQL-specific tools contributed by the MSSQL extension in Copilot Agent Mode." lightbox="media/agent-mode/agent-tools.png":::
42
+
:::image type="content" source="media/agent-mode/agent-tools.png" alt-text="Screenshot of list of SQL-specific tools contributed by the MSSQL extension in Copilot Agent Mode.":::
39
43
40
44
> [!TIP]
41
-
> 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.
45
+
> You can also use chat variables like `#mssql_connect` to invoke these tools directly, or write prompts in natural language such as:
| connect_server | Establishes a database connection using a saved connection profile or a specified server/database pair. |
48
-
| disconnect_server | Terminates the current active connection session. |
49
-
| list_servers | Lists all saved SQL Server connection profiles in your environment. |
57
+
| `connect` | Establishes a database connection using a saved connection profile or a specified server/database pair. |
58
+
| `disconnect` | Terminates the current active connection session. |
59
+
| `change_database` | Changes the database for an existing connection session. |
60
+
| `get_connection_details` | Gets connection details for a specific MSSQL connection. |
61
+
| `list_servers` | Lists all saved SQL Server connection profiles in your environment. |
62
+
| `list_databases` | Lists all available databases for a connected MSSQL server. |
50
63
51
64
#### Examples
52
65
66
+
The following phrases can be used to interact with GitHub Copilot.
67
+
68
+
```copilot-prompt
53
69
- Connect to my LocalDev environment
54
70
- Disconnect from my current database
55
71
- List my available connection profiles
72
+
- List all databases in the localhost server
73
+
- Set the active connection to localhost
74
+
- Set AdventureWorks as the active database
75
+
- Get the connection string for AdventureWorks on localhost
76
+
```
56
77
57
78
:::image type="content" source="media/agent-mode/agent-tool-connect.png" alt-text="Screenshot of example using an agent tool to connect to a database in the GitHub Copilot chat." lightbox="media/agent-mode/agent-tool-connect.png":::
58
79
59
80
#### How connection logic works
60
81
61
82
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:
62
83
63
-
##### Connect via saved profile
84
+
When you connect via saved profile:
64
85
65
-
- A user can connect by referencing the name of a saved connection profile.
66
-
- GitHub Copilot uses the `mssql_list_servers` tool to verify the profile exists.
67
-
- The `mssql_connect` tool then uses the saved `profileId` and its parameters to establish the connection.
86
+
1. A user can connect by referencing the name of a saved connection profile.
87
+
1. GitHub Copilot uses the `mssql_list_servers` tool to verify the profile exists.
88
+
1. The `mssql_connect` tool then uses the saved `profileId` and its parameters to establish the connection.
68
89
69
-
##### Connect via server/database specification
90
+
When you connect via server/database specification:
70
91
71
92
- If a saved profile matches both the specified server and database:
72
-
- GitHub Copilot uses `mssql_list_servers` to find the match.
73
-
- It then calls `mssql_connect` using the full profile.
93
+
94
+
1. GitHub Copilot uses `mssql_list_servers` to find the match.
95
+
1. It then calls `mssql_connect` using the full profile.
74
96
75
97
- If a saved profile matches only the server:
76
-
- GitHub Copilot finds the matching server profile.
77
-
- It attempts to connect by substituting the user-requested database into that profile.
78
-
- If the connection fails, an error is shown.
98
+
99
+
1. GitHub Copilot finds the matching server profile.
100
+
1. It attempts to connect by substituting the user-requested database into that profile.
101
+
1. If the connection fails, an error is shown.
79
102
80
103
- If no profile matches the specified server:
104
+
81
105
- GitHub Copilot reports an error.
82
106
83
107
This flexible matching system allows GitHub Copilot to handle a range of connection scenarios, minimizing user effort while ensuring secure, confirmable actions.
@@ -86,14 +110,46 @@ This flexible matching system allows GitHub Copilot to handle a range of connect
86
110
87
111
| Tool name | Description |
88
112
| --- | --- |
89
-
| show_schema | Displays a high-level diagram of your connected database schema, including tables and relationships. |
113
+
|`show_schema`| Displays a high-level diagram of your connected database schema, including tables and relationships. |
114
+
|`list_schemas`| Lists all schemas in a database for a connected MSSQL server. |
115
+
|`list_tables`| Lists all tables in a database for a connected MSSQL server. |
116
+
|`list_views`| Lists all views in a database for a connected MSSQL server. |
117
+
|`list_functions`| Lists all functions in a database for a connected MSSQL server. |
90
118
91
119
#### Examples
92
120
121
+
The following phrases can be used to interact with GitHub Copilot.
122
+
123
+
```copilot-prompt
93
124
- Show me the schema for this database
125
+
- Show me all tables in the current database
126
+
- List all views from this MSSQL database
127
+
- Give me a list of all the functions available in this schema
128
+
- What schemas are available in this database?
129
+
```
94
130
95
131
:::image type="content" source="media/agent-mode/agent-tool-schema.gif" alt-text="Screenshot of animation showing the database schema visualizer tool in Copilot Agent Mode." lightbox="media/agent-mode/agent-tool-schema.gif":::
96
132
133
+
### Query execution
134
+
135
+
| Tool name | Description |
136
+
| --- | --- |
137
+
|`run_query`| Executes a SQL query against the connected database. |
138
+
139
+
#### Examples
140
+
141
+
The following phrases can be used to interact with GitHub Copilot.
142
+
143
+
```copilot-prompt
144
+
- Give me the top five posts published this week
145
+
- Execute the current file to find how many comments each post has
146
+
- Get all categories along with the number of posts in each
147
+
```
148
+
149
+
:::image type="content" source="media/agent-mode/agent-tool-run-query-1.png" alt-text="Screenshot of example using an agent tool to connect to a database and retrieve data." lightbox="media/agent-mode/agent-tool-run-query-1.png":::
150
+
151
+
:::image type="content" source="media/agent-mode/agent-tool-run-query-2.png" alt-text="Screenshot of another example using an agent tool to connect to a database and retrieve data." lightbox="media/agent-mode/agent-tool-run-query-2.png":::
152
+
97
153
## How tools are managed in Agent Mode
98
154
99
155
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.
@@ -113,7 +169,7 @@ When GitHub Copilot selects a tool, it prompts you with a confirmation dialog sh
113
169
This confirmation step helps ensure secure, intentional interactions with your development environment.
114
170
115
171
> [!NOTE]
116
-
> For more information on how confirmation works across all tools in Agent Mode, see the [official VS Code documentation on tool approvals](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode#_manage-tool-approvals).
172
+
> For more information on how confirmation works across all tools in Agent Mode, see the [Visual Studio Code documentation on tool approvals](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode#_manage-tool-approvals).
0 commit comments