- Flexible integration through chat participants, agent mode, and MCP servers.
- Strict security control through read-only or read-write access modes.
- Advanced real-time SQL performance analysis and explanation capabilities.
- Optimized compatibility for Visual Studio Code and Cursor environments.
If you've considered how to leverage the power of artificial intelligence in your enterprise databases, you probably already know that Microsoft Copilot and PostgreSQL extensions make an unbeatable team. It's not just about writing code; it's about having an assistant that understands your data structure and helps you navigate it without having to memorize every table or column name.
To get started, it's crucial to understand that integration isn't a one-way process. It offers various entry points depending on whether you prefer to chat with your database, automate complex tasks, or analyze the performance of your SQL queries in real time. Let's break down, step by step, how to set up this entire ecosystem so you can start working like a true pro.
Prerequisites for operation

Before you dive in, there are a couple of things that need to be ready. First, you need to have the PostgreSQL extension installed and, very importantly, have at least one database connection already configured and working. Without an active connection, the AI won't have anywhere to look.
Regarding the development environment, you have two main options. If you use Visual Studio Code , you'll need to install GitHub Copilot or GitHub Copilot Chat and ensure your subscription is up to date. On the other hand, if you choose Cursor , you'll save yourself some steps since the artificial intelligence is built-in and activates automatically.
PostgreSQL AI Access Routes

Depending on what you need to do at any given time, you have several ways to interact with AI. Wanting a quick answer is not the same as wanting to automate an entire workflow.
- Chat participant @pgsql: This option is exclusive to Visual Studio Code. It allows you to ask direct questions about your database schema by typing @pgsql in the chat, which returns answers based on the actual context of your tables.
- Agent Mode: Available in both VS Code and Cursor. It's ideal for multi-step tasks. Activate it by right-clicking on a database node in the connection tree and selecting the option to connect the AI.
- Editor actions: Once you have an SQL script open, you can use the context menu to request the AI to... Explain the query, suggest a more efficient rewrite or analyze performance by running an EXPLAIN ANALYZE.
- MCP Server: For those seeking a more technical integration, the extension acts as a Model Context Protocol server provider, allowing other compatible hosts to use PostgreSQL tools externally.
Permissions and access mode management

A critical point is security. We don't want the AI to delete an entire table due to a misunderstanding. To avoid surprises, there's the pgsql.copilot.accessMode setting , which defines what the assistant can do.
By default, the system operates in Read/Write (rw) mode , which allows data modification and DDL execution, although it always requires explicit confirmation. If you prefer to play it safe, you can switch to Read-Only (ro) , limiting AI to executing SELECT, SHOW, EXPLAIN, and simple schema inspection.
The most interesting aspect is that you can apply these rules globally or customize access for each connection . In the connection dialog box, you can force a specific database to always be read-only, regardless of the editor's general settings.
Advanced settings and extra features

For those who want to fine-tune the experience, there are several technical configuration options. For example, `pgsql.copilot.enable` allows you to enable or disable the entire integration, while `pgsql.copilot.autoAttachQuery` controls whether your query text is automatically sent when analyzing execution plans.
In addition, there are very useful tools integrated into other panels. The Query Plan Viewer lets you analyze complex execution data with a single click, and the Server Panel offers direct buttons to query Copilot about processes, waits, or system metrics. Even the Schema Viewer can generate visual representations of table relationships using agent mode.
Outside the realm of databases, it's worth remembering that Copilot also enhances the Microsoft 365 suite , assisting with writing documents in Word, analyzing data in Excel, or summarizing endless threads in Outlook and Teams, creating a fully connected work environment.
Properly configuring these tools allows you to transform a static database into a dynamic and conversational resource , optimizing everything from query writing to performance auditing through precise control of access permissions and the selection of the most appropriate entry point for the task.
Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.