Skip to main content
Glama
receptopalak

PostGIS MCP Server

by receptopalak
README.md
# PostGIS MCP Server

[English](#english) | [Türkçe](#türkçe)

<a name="english"></a>
# PostGIS MCP Server

This project is a server application that provides PostGIS database connection using Model Context Protocol (MCP).

## 🚀 Features

- Developed with TypeScript
- Model Context Protocol (MCP) integration
- PostGIS database support
- Configuration for development and production environments
- Hot-reload support

## 📋 Requirements

- Node.js (v14 or higher)
- PostgreSQL (with PostGIS extension)
- npm or yarn

## 🛠️ Installation

1. Clone the project:
```bash
git clone https://github.com/receptopalak/postgis-mcp.git
cd postgis-mcp
```

2. Install dependencies:
```bash
npm install
```

3. Create `.env` file:
```env
NODE_ENV=development
DB_URL_1=postgres://user:password@host:5432/database_one
DB_URL_2=postgres://user:password@host:5432/database_two
DB_URL_3=postgres://user:password@host:5432/database_three
```

Legacy single-database `DB_HOST` / `DB_NAME` / `DB_USER` / `DB_PASSWORD` variables are still supported as a fallback.

4. Optional: customize table/domain aliases in `domain-aliases.json` to improve natural-language table selection.

## 🚀 Usage

### Development Mode
```bash
npm run dev
```

### Production Mode
```bash
npm run build
npm start
```

## 🔧 MCP Configuration

You can use the following example configuration for MCP server:

```json
{
  "mcpServers": {
    "postgis": {
      "command": "npx",
      "args": ["tsx", "server.ts"],
      "env": {
        "NODE_ENV": "development",
        "DB_URL_1": "postgres://user:pass@host:5432/db_one",
        "DB_URL_2": "postgres://user:pass@host:5432/db_two"
      }
    }
  }
}
```

## 📦 Dependencies

- @modelcontextprotocol/sdk: ^1.12.1
- dotenv: ^16.5.0
- pg: ^8.16.0
- zod: ^3.25.64

## 🤝 Contributing

1. Fork this repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'feat: Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## 📝 License

This project is licensed under the ISC License. See the `LICENSE` file for more information.

## 📧 Contact

Project Owner - [@receptopalak](https://github.com/receptopalak)

Project Link: [https://github.com/receptopalak/postgis-mcp](https://github.com/receptopalak/postgis-mcp)

---

<a name="türkçe"></a>
# PostGIS MCP Server

Bu proje, Model Context Protocol (MCP) kullanarak PostGIS veritabanı bağlantısını sağlayan bir sunucu uygulamasıdır.

## 🚀 Özellikler

- TypeScript ile geliştirilmiş
- Model Context Protocol (MCP) entegrasyonu
- PostGIS veritabanı desteği
- Geliştirme ve üretim ortamları için yapılandırma
- Hot-reload desteği

## 📋 Gereksinimler

- Node.js (v14 veya üzeri)
- PostgreSQL (PostGIS eklentisi ile)
- npm veya yarn

## 🛠️ Kurulum

1. Projeyi klonlayın:
```bash
git clone https://github.com/receptopalak/postgis-mcp.git
cd postgis-mcp
```

2. Bağımlılıkları yükleyin:
```bash
npm install
```

3. `.env` dosyası oluşturun:
```env
NODE_ENV=development
DB_URL_1=postgres://user:password@host:5432/database_one
DB_URL_2=postgres://user:password@host:5432/database_two
DB_URL_3=postgres://user:password@host:5432/database_three
```

Eski tek veritabanlı `DB_HOST` / `DB_NAME` / `DB_USER` / `DB_PASSWORD` değişkenleri de fallback olarak desteklenir.

4. Opsiyonel: doğal dilde tablo seçimini iyileştirmek için `domain-aliases.json` dosyasını özelleştirin.

## 🚀 Kullanım

### Geliştirme Modu
```bash
npm run dev
```

### Üretim Modu
```bash
npm run build
npm start
```

## 🔧 MCP Yapılandırması

MCP sunucu yapılandırması için aşağıdaki örnek yapılandırmayı kullanabilirsiniz:

```json
{
  "mcpServers": {
    "postgis": {
      "command": "npx",
      "args": ["tsx", "server.ts"],
      "env": {
        "NODE_ENV": "development",
        "DB_URL_1": "postgres://user:pass@host:5432/db_one",
        "DB_URL_2": "postgres://user:pass@host:5432/db_two"
      }
    }
  }
}
```

## 📦 Bağımlılıklar

- @modelcontextprotocol/sdk: ^1.12.1
- dotenv: ^16.5.0
- pg: ^8.16.0
- zod: ^3.25.64

## 🤝 Katkıda Bulunma

1. Bu depoyu fork edin
2. Yeni bir özellik dalı oluşturun (`git checkout -b feature/amazing-feature`)
3. Değişikliklerinizi commit edin (`git commit -m 'feat: Add some amazing feature'`)
4. Dalınıza push edin (`git push origin feature/amazing-feature`)
5. Bir Pull Request oluşturun

## 📝 Lisans

Bu proje ISC lisansı altında lisanslanmıştır. Daha fazla bilgi için `LICENSE` dosyasına bakın.

## 📧 İletişim

Proje Sahibi - [@receptopalak](https://github.com/receptopalak)

Proje Linki: [https://github.com/receptopalak/postgis-mcp](https://github.com/receptopalak/postgis-mcp) 

TDQS

B3.1/5.0

Scored across 22 tools

Disambiguation5/5

Every tool has a clearly distinct purpose targeting specific PostGIS operations like geometry creation, analysis, spatial queries, and database management. There is no overlap; for example, 'create-point' and 'create-puffer' serve different functions, and descriptions help differentiate even similar-sounding tools like 'geometry-info' and 'get-table-info'.

Naming Consistency5/5

Tool names follow a consistent verb-noun pattern with hyphens throughout, such as 'create-point', 'calculate-distance', and 'validate-geometry'. This predictable naming scheme makes it easy for agents to understand and select tools without confusion or mixed conventions.

Tool Count4/5

With 22 tools, the count is slightly high but reasonable for a comprehensive PostGIS server covering geometry operations, spatial analysis, raster data, and database utilities. It might feel heavy, but each tool appears to earn its place in the domain without being excessive.

Completeness5/5

The tool set provides complete coverage for PostGIS operations, including CRUD-like functions (e.g., create, analyze, validate), spatial calculations (e.g., distance, intersection), database management (e.g., test-connection, get-table-info), and advanced features like natural language querying. No obvious gaps are present for the domain.

Maintenance

ActivityInactive
ResponsivenessNo issues