|
| 1 | +--- |
| 2 | +title: "Quickstart: Use GitHub Copilot Agent Mode (Preview)" |
| 3 | +description: Learn how to use GitHub Copilot Agent Mode with the MSSQL extension to connect to databases, explore schemas, and run SQL queries directly from the GitHub Copilot chat in Visual Studio Code. |
| 4 | +author: croblesm |
| 5 | +ms.author: roblescarlos |
| 6 | +ms.reviewer: randolphwest |
| 7 | +ms.date: 06/18/2025 |
| 8 | +ms.service: sql |
| 9 | +ms.subservice: vs-code-sql-extensions |
| 10 | +ms.topic: quickstart |
| 11 | +ms.collection: |
| 12 | + - data-tools |
| 13 | + - ce-skilling-ai-copilot |
| 14 | +ms.custom: |
| 15 | + - build-2025 |
| 16 | +ai-usage: ai-assisted |
| 17 | +--- |
| 18 | + |
| 19 | +# Quickstart: Use GitHub Copilot Agent Mode (Preview) |
| 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. |
| 22 | + |
| 23 | +> [!TIP] |
| 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). |
| 25 | +
|
| 26 | +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](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode#_use-agent-mode). |
| 27 | + |
| 28 | +## What is Agent Mode? |
| 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.*" |
| 31 | + |
| 32 | +:::image type="content" source="media/agent-mode/agent-tool-chat.png" alt-text="Screenshot of GitHub Copilot Agent Mode chat interface." lightbox="media/agent-mode/agent-tool-chat.png"::: |
| 33 | + |
| 34 | +## MSSQL Agent Mode tool reference |
| 35 | + |
| 36 | +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 | + |
| 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"::: |
| 39 | + |
| 40 | +> [!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. |
| 42 | +
|
| 43 | +### Connection management |
| 44 | + |
| 45 | +| Tool name | Description | |
| 46 | +| --- | --- | |
| 47 | +| 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. | |
| 50 | + |
| 51 | +#### Examples |
| 52 | + |
| 53 | +- Connect to my LocalDev environment |
| 54 | +- Disconnect from my current database |
| 55 | +- List my available connection profiles |
| 56 | + |
| 57 | +:::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 | + |
| 59 | +#### How connection logic works |
| 60 | + |
| 61 | +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 | + |
| 63 | +##### Connect via saved profile |
| 64 | + |
| 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. |
| 68 | + |
| 69 | +##### Connect via server/database specification |
| 70 | + |
| 71 | +- 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. |
| 74 | + |
| 75 | +- 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. |
| 79 | + |
| 80 | +- If no profile matches the specified server: |
| 81 | + - GitHub Copilot reports an error. |
| 82 | + |
| 83 | +This flexible matching system allows GitHub Copilot to handle a range of connection scenarios, minimizing user effort while ensuring secure, confirmable actions. |
| 84 | + |
| 85 | +### Schema exploration |
| 86 | + |
| 87 | +| Tool name | Description | |
| 88 | +| --- | --- | |
| 89 | +| show_schema | Displays a high-level diagram of your connected database schema, including tables and relationships. | |
| 90 | + |
| 91 | +#### Examples |
| 92 | + |
| 93 | +- Show me the schema for this database |
| 94 | + |
| 95 | +:::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 | + |
| 97 | +## How tools are managed in Agent Mode |
| 98 | + |
| 99 | +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. |
| 100 | + |
| 101 | +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. |
| 102 | + |
| 103 | +For more on tool visibility and approvals, visit [Manage tool approvals](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode#_manage-tool-approvals). |
| 104 | + |
| 105 | +### Agent Mode confirmation workflow |
| 106 | + |
| 107 | +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: |
| 108 | + |
| 109 | +- **Allow in this session** |
| 110 | +- **Allow in this workspace** |
| 111 | +- **Always allow** |
| 112 | + |
| 113 | +This confirmation step helps ensure secure, intentional interactions with your development environment. |
| 114 | + |
| 115 | +> [!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). |
| 117 | +
|
| 118 | +## Related content |
| 119 | + |
| 120 | +- [Quickstart: Use Chat and inline GitHub Copilot suggestions (Preview)](inline-copilot-suggestions.md) |
| 121 | +- [Quickstart: Generate code (Preview)](code-generation.md) |
| 122 | +- [Quickstart: Use the Schema Explorer and designer (Preview)](schema-explorer-designer.md) |
| 123 | +- [Quickstart: Use the Smart Query Builder (Preview)](smart-query-builder.md) |
| 124 | +- [Quickstart: Query Optimizer Assistant (Preview)](query-optimizer-assistant.md) |
| 125 | +- [Quickstart: Use the Business Logic Explainer (Preview)](business-logic-explainer.md) |
| 126 | +- [Quickstart: Security Analyzer (Preview)](security-analyzer.md) |
| 127 | +- [Quickstart: Localization & Formatting Helper (Preview)](localization-formatting-helper.md) |
| 128 | +- [Quickstart: Generate data for testing and mocking (Preview)](test-and-mocking-data-generator.md) |
| 129 | +- [Limitations and known issues](limitations-and-known-issues.md) |
0 commit comments