Skip to content

Commit 94a1b9c

Browse files
authored
readme updates, including description of sse support (#59)
* readme updates, including sse support * clarify * clarifications
1 parent 65926e7 commit 94a1b9c

File tree

1 file changed

+63
-45
lines changed

1 file changed

+63
-45
lines changed

README.md

Lines changed: 63 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
## Overview
2525

26-
**Postgres Pro** is an open source Model Context Protocol (MCP) server built to support you and your AI agents throughout the **entire development process**—from initial coding, through testing and deployment, and to production tuning and maintenance.
26+
**Postgres MCP Pro** is an open source Model Context Protocol (MCP) server built to support you and your AI agents throughout the **entire development process**—from initial coding, through testing and deployment, and to production tuning and maintenance.
2727

28-
Postgres Pro does much more than wrap a database connection.
28+
Postgres MCP Pro does much more than wrap a database connection.
2929

3030
Features include:
3131

@@ -70,16 +70,18 @@ Features include:
7070
</tr>
7171
</table>
7272

73-
For additional background on why we built Postgres Pro, see [our launch blog post](https://www.crystaldba.ai/blog/post/announcing-postgres-mcp-server-pro).
73+
Postgres MCP Pro supports both the [Standard Input/Output (stdio)](https://modelcontextprotocol.io/docs/concepts/transports#standard-input%2Foutput-stdio) and [Server-Sent Events (SSE)](https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse) transports, for flexibility in different environments.
74+
75+
For additional background on why we built Postgres MCP Pro, see [our launch blog post](https://www.crystaldba.ai/blog/post/announcing-postgres-mcp-server-pro).
7476

7577
## Demo
7678

7779
*From Unusable to Lightning Fast*
7880

7981
- **Challenge:** We generated a movie app using an AI assistant, but the SQLAlchemy ORM code ran painfully slowly
80-
- **Solution:** Using Postgres Pro with Cursor, we fixed the performance issues in minutes
82+
- **Solution:** Using Postgres MCP Pro with Cursor, we fixed the performance issues in minutes
8183

82-
**We used the Cursor AI agent and Postgres Pro to:**
84+
**We used the Cursor AI agent and Postgres MCP Pro to:**
8385
- 🚀 Fix performance - including ORM queries, indexing, and caching
8486
- 🛠️ Fix bugs that require connecting data to code
8587
- 🧠 Add new features from single prompts
@@ -112,12 +114,12 @@ However, it often makes sense to use whichever method you are most familiar with
112114

113115
### Installation
114116

115-
Choose one of the following methods to install Postgres Pro:
117+
Choose one of the following methods to install Postgres MCP Pro:
116118

117119
#### Option 1: Using Docker
118120

119-
Pull the Postgres Pro MCP server Docker image.
120-
This image contains all necessary dependencies, providing a reliable way to run Postgres Pro in a variety of environments.
121+
Pull the Postgres MCP Pro MCP server Docker image.
122+
This image contains all necessary dependencies, providing a reliable way to run Postgres MCP Pro in a variety of environments.
121123

122124
```bash
123125
docker pull crystaldba/postgres-mcp
@@ -126,13 +128,13 @@ docker pull crystaldba/postgres-mcp
126128

127129
#### Option 2: Using Python
128130

129-
If you have `pipx` installed you can install Postgres Pro with:
131+
If you have `pipx` installed you can install Postgres MCP Pro with:
130132

131133
```bash
132134
pipx install postgres-mcp
133135
```
134136

135-
Otherwise, install Postgres Pro with `uv`:
137+
Otherwise, install Postgres MCP Pro with `uv`:
136138

137139
```bash
138140
uv pip install postgres-mcp
@@ -143,12 +145,12 @@ If you need to install `uv`, see the [uv installation instructions](https://docs
143145

144146
### Configure Your AI Assistant
145147

146-
We provide full instructions for configuring Postgres Pro with Claude Desktop.
148+
We provide full instructions for configuring Postgres MCP Pro with Claude Desktop.
147149
Many MCP clients have similar configuration files, you can adapt these steps to work with the client of your choice.
148150

149151
#### Claude Desktop Configuration
150152

151-
You will need to edit the Claude Desktop configuration file to add Postgres Pro.
153+
You will need to edit the Claude Desktop configuration file to add Postgres MCP Pro.
152154
The location of this file depends on your operating system:
153155
- MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
154156
- Windows: `%APPDATA%/Claude/claude_desktop_config.json`
@@ -181,7 +183,7 @@ You will now edit the `mcpServers` section of the configuration file.
181183
}
182184
```
183185

184-
The Postgres Pro Docker image will automatically remap the hostname `localhost` to work from inside of the container.
186+
The Postgres MCP Pro Docker image will automatically remap the hostname `localhost` to work from inside of the container.
185187

186188
- MacOS/Windows: Uses `host.docker.internal` automatically
187189
- Linux: Uses `172.17.0.1` or the appropriate host address automatically
@@ -234,7 +236,7 @@ Replace `postgresql://...` with your [Postgres database connection URI](https://
234236

235237
##### Access Mode
236238

237-
Postgres Pro supports multiple *access modes* to give you control over the operations that the AI agent can perform on the database:
239+
Postgres MCP Pro supports multiple *access modes* to give you control over the operations that the AI agent can perform on the database:
238240
- **Unrestricted Mode**: Allows full read/write access to modify data and schema. It is suitable for development environments.
239241
- **Restricted Mode**: Limits operations to read-only transactions and imposes constraints on resource utilization (presently only execution time). It is suitable for production environments.
240242

@@ -251,35 +253,51 @@ Many MCP clients have similar configuration files to Claude Desktop, and you can
251253

252254
## SSE Transport
253255

254-
Postgres Pro supports the SSE transport, which allows you to connect to the server using a web browser.
255-
To use the SSE transport, you need to start the server with the `--transport sse` flag.
256+
Postgres MCP Pro supports the [SSE transport](https://modelcontextprotocol.io/docs/concepts/transports#server-sent-events-sse), which allows multiple MCP clients to share one server, possibly a remote server.
257+
To use the SSE transport, you need to start the server with the `--transport=sse` option.
258+
259+
For example, with Docker run:
256260

257261
```bash
258-
docker run -p 8000:8000 -e DATABASE_URI=postgresql://username:password@localhost:5432/dbname crystaldba/postgres-mcp --transport sse
262+
docker run -p 8000:8000 \
263+
-e DATABASE_URI=postgresql://username:password@localhost:5432/dbname \
264+
crystaldba/postgres-mcp --access-mode=unrestricted --transport=sse
259265
```
260266

261267
Then update your MCP client configuration to call the the MCP server.
262-
For example, in Windsurf's `mcp_config.json` you can put:
268+
For example, in Cursor's `mcp.json` or Cline's `cline_mcp_settings.json` you can put:
263269

264270
```json
265271
{
266272
"mcpServers": {
267273
"postgres": {
268274
"type": "sse",
269-
"serverUrl": "http://localhost:8000/sse"
275+
"url": "http://localhost:8000/sse"
270276
}
271277
}
272278
}
273279
```
274280

281+
For Windsurf, the format in `mcp_config.json` is slightly different:
282+
283+
```json
284+
{
285+
"mcpServers": {
286+
"postgres": {
287+
"type": "sse",
288+
"serverUrl": "http://localhost:8000/sse"
289+
}
290+
}
291+
}
292+
```
275293

276294
## Postgres Extension Installation (Optional)
277295

278296
To enable index tuning and comprehensive performance analysis you need to load the `pg_statements` and `hypopg` extensions on your database.
279297

280-
- The `pg_statements` extension allows Postgres Pro to analyze query execution statistics.
298+
- The `pg_statements` extension allows Postgres MCP Pro to analyze query execution statistics.
281299
For example, this allows it to understand which queries are running slow or consuming significant resources.
282-
- The `hypopg` extension allows Postgres Pro to simulate the behavior of the Postgres query planner after adding indexes.
300+
- The `hypopg` extension allows Postgres MCP Pro to simulate the behavior of the Postgres query planner after adding indexes.
283301

284302
### Installing extensions on AWS RDS, Azure SQL, or Google Cloud SQL
285303

@@ -328,12 +346,12 @@ Ask:
328346

329347
The [MCP standard](https://modelcontextprotocol.io/) defines various types of endpoints: Tools, Resources, Prompts, and others.
330348

331-
Postgres Pro provides functionality via [MCP tools](https://modelcontextprotocol.io/docs/concepts/tools) alone.
349+
Postgres MCP Pro provides functionality via [MCP tools](https://modelcontextprotocol.io/docs/concepts/tools) alone.
332350
We chose this approach because the [MCP client ecosystem](https://modelcontextprotocol.io/clients) has widespread support for MCP tools.
333351
This contrasts with the approach of other Postgres MCP servers, including the [Reference Postgres MCP Server](https://github.com/modelcontextprotocol/servers/tree/main/src/postgres), which use [MCP resources](https://modelcontextprotocol.io/docs/concepts/resources) to expose schema information.
334352

335353

336-
Postgres Pro Tools:
354+
Postgres MCP Pro Tools:
337355

338356
| Tool Name | Description |
339357
|-----------|-------------|
@@ -369,36 +387,36 @@ Postgres Pro Tools:
369387
**Postgres Utilities**
370388
- [Dexter](https://github.com/DexterDB/dexter). A tool for generating and testing hypothetical indexes on PostgreSQL.
371389
- [PgHero](https://github.com/ankane/pghero). A performance dashboard for Postgres, with recommendations.
372-
Postgres Pro incorporates health checks from PgHero.
390+
Postgres MCP Pro incorporates health checks from PgHero.
373391
- [PgTune](https://github.com/le0pard/pgtune?tab=readme-ov-file). Heuristics for tuning Postgres configuration.
374392

375393
## Frequently Asked Questions
376394

377-
*How is Postgres Pro different from other Postgres MCP servers?*
395+
*How is Postgres MCP Pro different from other Postgres MCP servers?*
378396
There are many MCP servers allow an AI agent to run queries against a Postgres database.
379-
Postgres Pro does that too, but also adds tools for understanding and improving the performance of your Postgres database.
397+
Postgres MCP Pro does that too, but also adds tools for understanding and improving the performance of your Postgres database.
380398
For example, it implements a version of the [Anytime Algorithm of Database Tuning Advisor for Microsoft SQL Server](https://www.microsoft.com/en-us/research/wp-content/uploads/2020/06/Anytime-Algorithm-of-Database-Tuning-Advisor-for-Microsoft-SQL-Server.pdf), a modern industrial-strength algorithm for automatic index tuning.
381399

382-
| Postgres Pro | Other Postgres MCP Servers |
400+
| Postgres MCP Pro | Other Postgres MCP Servers |
383401
|--------------|----------------------------|
384402
| ✅ Deterministic database health checks | ❌ Unrepeatable LLM-generated health queries |
385403
| ✅ Principled indexing search strategies | ❌ Gen-AI guesses at indexing improvements |
386404
| ✅ Workload analysis to find top problems | ❌ Inconsistent problem analysis |
387405
| ✅ Simulates performance improvements | ❌ Try it yourself and see if it works |
388406

389-
Postgres Pro complements generative AI by adding deterministic tools and classical optimization algorithms
407+
Postgres MCP Pro complements generative AI by adding deterministic tools and classical optimization algorithms
390408
The combination is both reliable and flexible.
391409

392410

393411
*Why are MCP tools needed when the LLM can reason, generate SQL, etc?*
394412
LLMs are invaluable for tasks that involve ambiguity, reasoning, or natural language.
395413
When compared to procedural code, however, they can be slow, expensive, non-deterministic, and sometimes produce unreliable results.
396414
In the case of database tuning, we have well established algorithms, developed over decades, that are proven to work.
397-
Postgres Pro lets you combine the best of both worlds by pairing LLMs with classical optimization algorithms and other procedural tools.
415+
Postgres MCP Pro lets you combine the best of both worlds by pairing LLMs with classical optimization algorithms and other procedural tools.
398416

399-
*How do you test Postgres Pro?*
400-
Testing is critical to ensuring that Postgres Pro is reliable and accurate.
401-
We are building out a suite of AI-generated adversarial workloads designed to challenge Postgres Pro and ensure it performs under a broad variety of scenarios.
417+
*How do you test Postgres MCP Pro?*
418+
Testing is critical to ensuring that Postgres MCP Pro is reliable and accurate.
419+
We are building out a suite of AI-generated adversarial workloads designed to challenge Postgres MCP Pro and ensure it performs under a broad variety of scenarios.
402420

403421
*What Postgres versions are supported?*
404422
Our testing presently focuses on Postgres 15, 16, and 17.
@@ -417,19 +435,19 @@ You can also contact us on [Discord](https://discord.gg/4BEHC7ZM).
417435

418436
## Technical Notes
419437

420-
This section includes a high-level overview technical considerations that influenced the design of Postgres Pro.
438+
This section includes a high-level overview technical considerations that influenced the design of Postgres MCP Pro.
421439

422440
### Index Tuning
423441

424442
Developers know that missing indexes are one of the most common causes of database performance issues.
425443
Indexes provide access methods that allow Postgres to quickly locate data that is required to execute a query.
426444
When tables are small, indexes make little difference, but as the size of the data grows, the difference in algorithmic complexity between a table scan and an index lookup becomes significant (typically *O*(*n*) vs *O*(*log* *n*), potentially more if joins on multiple tables are involved).
427445

428-
Generating suggested indexes in Postgres Pro proceeds in several stages:
446+
Generating suggested indexes in Postgres MCP Pro proceeds in several stages:
429447

430448
1. *Identify SQL queries in need of tuning*.
431449
If you know you are having a problem with a specific SQL query you can provide it.
432-
Postgres Pro can also analyze the workload to identify index tuning targets.
450+
Postgres MCP Pro can also analyze the workload to identify index tuning targets.
433451
To do this, it relies on the `pg_stat_statements` extension, which records the runtime and resource consumption of each query.
434452

435453
A query is a candidate for index tuning if it is a top resource consumer, either on a per-execution basis or in aggregate.
@@ -438,7 +456,7 @@ Generating suggested indexes in Postgres Pro proceeds in several stages:
438456
Agents may also call `get_top_queries`, which accepts a parameter for mean vs. total execution time, then pass these queries `analyze_query_indexes` to get index recommendations.
439457

440458
Sophisticated index tuning systems use "workload compression" to produce a representative subset of queries that reflects the characteristics of the workload as a whole, reducing the problem for downstream algorithms.
441-
Postgres Pro performs a limited form of workload compression by normalizing queries so that those generated from the same template appear as one.
459+
Postgres MCP Pro performs a limited form of workload compression by normalizing queries so that those generated from the same template appear as one.
442460
It weights each query equally, a simplification that works when the benefits to indexing are large.
443461

444462
2. *Generate candidate indexes*
@@ -491,7 +509,7 @@ This give the LLM additional context that it can use when responding to the inde
491509
### Database Health
492510

493511
Database health checks identify tuning opportunities and maintenance needs before they lead to critical issues.
494-
In the present release, Postgres Pro adapts the database health checks directly from [PgHero](https://github.com/ankane/pghero).
512+
In the present release, Postgres MCP Pro adapts the database health checks directly from [PgHero](https://github.com/ankane/pghero).
495513
We are working to fully validate these checks and may extend them in the future.
496514

497515
- *Index Health*. Looks for unused indexes, duplicate indexes, and indexes that are bloated. Bloated indexes make inefficient use of database pages.
@@ -516,7 +534,7 @@ We are working to fully validate these checks and may extend them in the future.
516534

517535
### Postgres Client Library
518536

519-
Postgres Pro uses [psycopg3](https://www.psycopg.org/) to connect to Postgres using asynchronous I/O.
537+
Postgres MCP Pro uses [psycopg3](https://www.psycopg.org/) to connect to Postgres using asynchronous I/O.
520538
Under the hood, psycopg3 uses the [libpq](https://www.postgresql.org/docs/current/libpq.html) library to connect to Postgres, providing access to the full Postgres feature set and an underlying implementation fully supported by the Postgres community.
521539

522540
Some other Python-based MCP servers use [asyncpg](https://github.com/MagicStack/asyncpg), which may simplify installation by eliminating the `libpq` dependency.
@@ -529,7 +547,7 @@ We remain open to revising this decision in the future.
529547

530548
### Connection Configuration
531549

532-
Like the [Reference PostgreSQL MCP Server](https://github.com/modelcontextprotocol/servers/tree/main/src/postgres), Postgres Pro takes Postgres connection information at startup.
550+
Like the [Reference PostgreSQL MCP Server](https://github.com/modelcontextprotocol/servers/tree/main/src/postgres), Postgres MCP Pro takes Postgres connection information at startup.
533551
This is convenient for users who always connect to the same database but can be cumbersome when users switch databases.
534552

535553
An alternative approach, taken by [PG-MCP](https://github.com/stuzero/pg-mcp-server), is provide connection details via MCP tool calls at the time of use.
@@ -566,15 +584,15 @@ AI amplifies longstanding challenges of protecting databases from a range of thr
566584
Whether the threat is accidental or malicious, a similar security framework applies, with aims that fall into three categories: confidentiality, integrity, and availability.
567585
The familiar tension between convenience and safety is also evident and pronounced.
568586

569-
Postgres Pro's protected SQL execution mode focuses on integrity.
587+
Postgres MCP Pro's protected SQL execution mode focuses on integrity.
570588
In the context of MCP, we are most concerned with LLM-generated SQL causing damage—for example, unintended data modification or deletion, or other changes that might circumvent an organization's change management process.
571589

572590
The simplest way to provide integrity is to ensure that all SQL executed against the database is read-only.
573591
One way to do this is by creating a database user with read-only access permissions.
574592
While this is a good approach, many find this cumbersome in practice.
575-
Postgres does not provide a way to place a connection or session into read-only mode, so Postgres Pro uses a more complex approach to ensure read-only SQL execution on top of a read-write connection.
593+
Postgres does not provide a way to place a connection or session into read-only mode, so Postgres MCP Pro uses a more complex approach to ensure read-only SQL execution on top of a read-write connection.
576594

577-
Postgres provides a read-only transaction mode that prevents data and schema modifications.
595+
Postgres MCP Provides a read-only transaction mode that prevents data and schema modifications.
578596
Like the [Reference PostgreSQL MCP Server](https://github.com/modelcontextprotocol/servers/tree/main/src/postgres), we use read-only transactions to provide protected SQL execution.
579597

580598
To make this mechanism robust, we need to ensure that the SQL does not somehow circumvent the read-only transaction mode, say by issuing a `COMMIT` or `ROLLBACK` statement and then beginning a new transaction.
@@ -590,7 +608,7 @@ We reject any SQL that contains `commit` or `rollback` statements.
590608
Helpfully, the popular Postgres stored procedure languages, including PL/pgSQL and PL/Python, do not allow for `COMMIT` or `ROLLBACK` statements.
591609
If you have unsafe stored procedure languages enabled on your database, then our read-only protections could be circumvented.
592610

593-
At present, Postgres Pro provides two levels of protection for the database, one at either extreme of the convenience/safety spectrum.
611+
At present, Postgres MCP Pro provides two levels of protection for the database, one at either extreme of the convenience/safety spectrum.
594612
- "Unrestricted" provides maximum flexibility.
595613
It is suitable for development environments where speed and flexibility are paramount, and where there is no need to protect valuable or sensitive data.
596614
- "Restricted" provides a balance between flexibility and safety.
@@ -604,9 +622,9 @@ Restricted mode is limited to read-only operations, and we limit query execution
604622
We may add measures in the future to make sure that restricted mode is safe to use with production databases.
605623

606624

607-
## Postgres Pro Development
625+
## Postgres MCP Pro Development
608626

609-
The instructions below are for developers who want to work on Postgres Pro, or users who prefer to install Postgres Pro from source.
627+
The instructions below are for developers who want to work on Postgres MCP Pro, or users who prefer to install Postgres MCP Pro from source.
610628

611629
### Local Development Setup
612630

0 commit comments

Comments
 (0)