Metadata-Version: 2.4
Name: db-adapter
Version: 1.0.0
Summary: MCP server that provides PostgreSQL database access tools for AI agents (read-only)
Author-email: Husni Robani <v.husni.robani@banksinarmas.com>
License: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Requires-Python: >=3.10
Requires-Dist: asyncpg>=0.29.0
Requires-Dist: mcp>=1.0.0
Description-Content-Type: text/markdown

# MCP Database Server

MCP server that provides read-only PostgreSQL database access for AI agents.

## Tools

| Tool | Description |
|------|-------------|
| `list_tables` | List all tables with row counts |
| `describe_table` | Get schema: columns, types, foreign keys, indexes |
| `run_select_query` | Execute read-only SELECT queries |

INSERT/UPDATE/DELETE are blocked for safety.

## Configuration

| Variable | Required | Default | Description |
|---|---|---|---|
| `DATABASE_POSTGRESQL_HOST` | Yes | — | PostgreSQL host |
| `DATABASE_POSTGRESQL_PORT` | Yes | — | PostgreSQL port |
| `DATABASE_POSTGRESQL_USERNAME` | Yes | — | Database user |
| `DATABASE_POSTGRESQL_PASSWORD` | No | — | Database password |
| `DATABASE_POSTGRESQL_NAME` | Yes | — | Database name |
| `DATABASE_POSTGRESQL_SCHEMA` | No | `public` | Schema for table discovery |

## Usage

### Claude Desktop

Add to `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "db": {
      "command": "uvx",
      "args": ["db-adapter"],
      "env": {
        "DATABASE_POSTGRESQL_HOST": "localhost",
        "DATABASE_POSTGRESQL_PORT": "5432",
        "DATABASE_POSTGRESQL_USERNAME": "postgres",
        "DATABASE_POSTGRESQL_PASSWORD": "postgres",
        "DATABASE_POSTGRESQL_NAME": "mydb"
      }
    }
  }
}
```

### opencode

Add to `opencode.json`:

```json
{
  "mcp": {
    "db": {
      "type": "local",
      "command": ["uvx", "db-adapter"],
      "enabled": true,
      "environment": {
        "DATABASE_POSTGRESQL_HOST": "localhost",
        "DATABASE_POSTGRESQL_PORT": "5432",
        "DATABASE_POSTGRESQL_USERNAME": "postgres",
        "DATABASE_POSTGRESQL_PASSWORD": "postgres",
        "DATABASE_POSTGRESQL_NAME": "mydb"
      }
    }
  }
}
```

Environment variables can be omitted to inherit from your shell.

## Requirements

- Python >= 3.10
- PostgreSQL database
