PHPackages                             ineersa/database-extension - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. ineersa/database-extension

ActiveSymfony-ai-mate[Database &amp; ORM](/categories/database)

ineersa/database-extension
==========================

Database extension for Symfony AI Mate - MCP tools and resources for database workflows

v0.8.0(2mo ago)2683↑275%MITPHPPHP &gt;=8.2CI passing

Since Apr 4Pushed 2mo agoCompare

[ Source](https://github.com/ineersa/database-extension)[ Packagist](https://packagist.org/packages/ineersa/database-extension)[ RSS](/packages/ineersa-database-extension/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (20)Versions (4)Used By (0)

Database Extension for Symfony AI Mate
======================================

[](#database-extension-for-symfony-ai-mate)

Safe, read-only database access for AI assistants running inside [Symfony AI Mate](https://symfony.com/doc/current/ai/components/mate.html). Connects through your application's existing [DoctrineBundle](https://github.com/doctrine/DoctrineBundle) DBAL configuration — no standalone MCP server or custom database config required.

Capabilities
------------

[](#capabilities)

CapabilityTypeDescription`database-query`ToolRun validated read-only SQL queries for debugging and data inspection`database-schema`ToolInspect schema objects in summary, columns, or full detail`db://{connection}`ResourceDiscovery summary for one connection: tables, views, routines, and metadataAll capabilities use the host application's Doctrine DBAL connections. When `connection` is omitted, the default Doctrine connection is used automatically.

Supported Databases
-------------------

[](#supported-databases)

- **MySQL** 8.0+
- **PostgreSQL** 16+
- **SQLite** 3+

Requirements
------------

[](#requirements)

- PHP 8.2+
- Symfony 7.3+ or 8.0+
- Doctrine DBAL 4.0+
- DoctrineBundle 2.14+ (must be installed and configured in the host application)

Installation
------------

[](#installation)

```
composer require --dev matesofmate/database-extension

# Discover the new capabilities
vendor/bin/mate discover
```

The extension detects DoctrineBundle automatically. If DoctrineBundle is not installed or configured, no database capabilities are exposed — the extension stays silent rather than offering broken tools.

Read-Only Safety
----------------

[](#read-only-safety)

Query execution is protected by two independent layers:

1. **Driver-level read-only mode** — A DBAL middleware sets the database session to read-only (`SET SESSION transaction_read_only = 1` on MySQL, `SET default_transaction_read_only = on` on PostgreSQL, `PRAGMA query_only = ON` on SQLite) before any query runs.
2. **Defensive query validation** — Before execution, every query is checked for:
    - Write keywords (`INSERT`, `UPDATE`, `DELETE`, `DROP`, `ALTER`, `CREATE`, `TRUNCATE`, etc.)
    - Transaction control (`COMMIT`, `ROLLBACK`, `TRANSACTION`)
    - Multiple statements (semicolon-separated)
    - Unbounded `SELECT` without `WHERE` or `LIMIT`

All queries execute inside a transaction that is always rolled back, regardless of outcome.

Tool Reference
--------------

[](#tool-reference)

### `database-query`

[](#database-query)

Run a read-only SQL query against a Doctrine DBAL connection.

ParameterTypeRequiredDefaultDescription`query`stringyes—SQL query to validate and execute`connection`stringnodefault connectionDoctrine DBAL connection nameReturns query result rows in TOON format. Long text values (&gt;200 characters) are truncated to `` in multi-row results to reduce token usage.

### `database-schema`

[](#database-schema)

Inspect database schema objects with configurable detail and filtering.

ParameterTypeRequiredDefaultDescription`connection`stringnodefault connectionDoctrine DBAL connection name`filter`stringno`""`Object name filter`detail`stringno`summary`Detail level: `summary`, `columns`, `full``matchMode`stringno`contains`Filter matching: `contains`, `prefix`, `exact`, `glob``includeViews`boolno`false`Include views in the response`includeRoutines`boolno`false`Include procedures/functions/sequences/triggers### `db://{connection}`

[](#dbconnection)

Resource template returning a discovery summary for a single connection. Includes connection metadata (driver, platform, server version), table names, view names, and routine names.

Scope
-----

[](#scope)

- **Single summary resource** — One `db://{connection}` resource per connection. Per-table, per-view, or per-routine resources are not included.
- **No PII redaction** — Query results are returned as-is. Sensitive data filtering is not implemented.
- **Doctrine-only** — All database access goes through DoctrineBundle DBAL. There is no custom or standalone connection path.
- **MySQL, PostgreSQL, SQLite** — Other engines supported by Doctrine DBAL may work but are not tested.
- **Standalone MCP server** — For a separate MCP process with YAML connection config, optional PII redaction, and SQL Server support, see [ineersa/mcp-sql-server](https://github.com/ineersa/mcp-sql-server).

How It Works
------------

[](#how-it-works)

```
┌──────────────┐      ┌─────────────────────────┐      ┌──────────────────┐
│  Mate AI     │─────▶│ DatabaseQueryTool       │─────▶│ SafeQueryExecutor│
│  Assistant   │      │ DatabaseSchemaTool      │─────▶│ DatabaseSchema   │
│              │      │ ConnectionResource      │─────▶│ Service          │
└──────────────┘      └─────────────────────────┘      └────────┬─────────┘
                                                                │
                                                                ▼
              ┌───────────────────────────────────────────────────────────┐
              │ ConnectionResolver                                          │
              │   Injected container: ApplicationContainerFactory::create() │
              │   (boots App\Kernel or MATE_SYMFONY_KERNEL_CLASS once)      │
              │   → application container (DoctrineBundle lives here)       │
              └─────────────────────────────┬─────────────────────────────┘
                                            │
                                            ▼
                                  ┌──────────────────┐
                                  │ ReadOnly         │
                                  │ Middleware       │
                                  │ (rebuilt conn.)  │
                                  └────────┬─────────┘
                                           ▼
              ┌────────────────────────────────────────────────────────────┐
              │ DoctrineBundle DBAL connections (MySQL · PostgreSQL · SQLite)│
              └────────────────────────────────────────────────────────────┘

```

Symfony AI Mate’s MCP container does not register DoctrineBundle, so **`ConnectionResolver`** cannot use Mate’s own **`service_container`** to reach DBAL. Instead, **`ApplicationContainerFactory::create()`** boots the project’s **`App\Kernel`** once per process (or the class from **`MATE_SYMFONY_KERNEL_CLASS`**) and injects that **application** **`ContainerInterface`**, where `doctrine` / `doctrine.dbal.*` services actually live. Connection names and metadata come from DoctrineBundle on that container; each resolved connection is rebuilt through read-only DBAL middleware before any query or schema operation runs.

Contributing
------------

[](#contributing)

### Running Tests

[](#running-tests)

Tests run inside Docker containers against real MySQL, PostgreSQL, and SQLite databases. Docker and Docker Compose are the only host-level requirements.

```
# Run the default test suite (PHP 8.2 / Symfony ^7.3)
composer test

# Run the full matrix (PHP 8.2/Symfony ^7.3, PHP 8.3/Symfony ^7.3, PHP 8.4/Symfony ^8.0)
composer test:docker

# Run a single matrix entry
bash tests/bin/run-docker-phpunit.sh php82
bash tests/bin/run-docker-phpunit.sh php83
bash tests/bin/run-docker-phpunit.sh php84
```

The Docker Compose stack (`docker-compose.test.yaml`) starts MySQL 8.0, PostgreSQL 16, and an appropriately versioned PHP container. Database services start with health checks; tests begin only after the databases are ready.

### Code Quality

[](#code-quality)

```
# Lint (runs in PHP 8.2 Docker container)
composer lint

# Auto-fix code style and refactorings
composer fix
```

Local-only variants that skip Docker are available for faster iteration:

```
composer lint:local    # Runs Rector, PHP CS Fixer, PHPStan on host PHP
composer fix:local     # Applies Rector and PHP CS Fixer fixes on host PHP
composer test:local    # Runs PHPUnit on host PHP (requires local database setup)
```

### Coverage

[](#coverage)

```
# Generate coverage reports (HTML + Clover) in coverage/
composer coverage
```

### CI

[](#ci)

GitHub Actions runs on every push and pull request:

- **Lint** — `composer lint` (PHP 8.2 Docker container)
- **Test matrix** — PHP 8.2/Symfony ^7.3, PHP 8.3/Symfony ^7.3, PHP 8.4/Symfony ^8.0

See `.github/workflows/ci.yml`.

Resources
---------

[](#resources)

- [Symfony AI Mate Docs](https://symfony.com/doc/current/ai/components/mate.html)
- [Creating MCP Extensions](https://symfony.com/doc/current/ai/components/mate/extensions.html)
- [MatesOfMate Contributing Guide](https://github.com/matesofmate/.github/blob/main/CONTRIBUTING.md)
- [Extension template documentation](TEMPLATE.md)

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance86

Actively maintained with recent releases

Popularity22

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Total

2

Last Release

73d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86f5d21ab3c3ddca3f9af93bbcd79813a7db4eb17b179476538741519621ba7a?d=identicon)[ineersa](/maintainers/ineersa)

---

Top Contributors

[![ineersa](https://avatars.githubusercontent.com/u/4228843?v=4)](https://github.com/ineersa "ineersa (22 commits)")

---

Tags

symfonymcpaiai assistantmate

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ineersa-database-extension/health.svg)

```
[![Health](https://phpackages.com/badges/ineersa-database-extension/health.svg)](https://phpackages.com/packages/ineersa-database-extension)
```

###  Alternatives

[mahocommerce/maho

Free and open source ecommerce platform, created in 2024 on the M1 platform, PHP 8.3+

1396.0k48](/packages/mahocommerce-maho)[flow-php/doctrine-dbal-bulk

Bulk inserts and updates for Doctrine DBAL

14385.8k4](/packages/flow-php-doctrine-dbal-bulk)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
