PHPackages                             izzuddinmohsin/neuron-sqlserver-toolkit - 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. izzuddinmohsin/neuron-sqlserver-toolkit

ActiveLibrary[Database &amp; ORM](/categories/database)

izzuddinmohsin/neuron-sqlserver-toolkit
=======================================

SQL Server / Azure SQL Database Toolkit for Neuron AI - The PHP Agentic Framework

v1.0.0(4mo ago)00[1 issues](https://github.com/izzuddinmohsin/SQLServerToolkit-neuron-ai/issues)MITPHPPHP ^8.1

Since Feb 15Pushed 4mo agoCompare

[ Source](https://github.com/izzuddinmohsin/SQLServerToolkit-neuron-ai)[ Packagist](https://packagist.org/packages/izzuddinmohsin/neuron-sqlserver-toolkit)[ RSS](/packages/izzuddinmohsin-neuron-sqlserver-toolkit/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

SQL Server Toolkit for Neuron AI
================================

[](#sql-server-toolkit-for-neuron-ai)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)[![PHP Version](https://camo.githubusercontent.com/04744bae0a61d2ffe29c26f07a9612eae20445fc6feaeb77b3af1f0e9be6447c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3838393242462e737667)](https://php.net/)

A SQL Server / Azure SQL Database toolkit for [Neuron AI](https://github.com/neuron-core/neuron-ai) — the PHP Agentic Framework. Gives your AI agents the ability to discover database schema, execute read queries, and perform write operations on SQL Server databases.

> Adapted from Neuron AI's built-in MySQL Toolkit with full SQL Server compatibility, including schema-awareness, views discovery, positional parameters, and SQL Server-specific security hardening.

Features
--------

[](#features)

- **Schema Discovery** — Automatically discovers tables, views, columns, relationships, indexes, and constraints
- **Views Support** — Discovers and distinguishes between tables and views (read-only indicator for LLM)
- **Read Queries** — Safe SELECT query execution with security validation
- **Write Operations** — INSERT, UPDATE, DELETE, and MERGE support with SCOPE\_IDENTITY() for identity columns
- **Security Hardened** — Blocks dangerous operations like `xp_cmdshell`, `OPENROWSET`, `SELECT INTO`, DDL statements
- **Positional Parameters** — Uses `?` placeholders (required for SQL Server PDO driver compatibility)
- **Azure SQL Compatible** — Works with both on-premise SQL Server and Azure SQL Database
- **LLM-Optimized Output** — Schema output formatted with SQL Server-specific guidelines (TOP, GETDATE, LEN, etc.)

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

[](#requirements)

- PHP 8.1+
- PDO SQL Server driver (`pdo_sqlsrv`)
- [Neuron AI](https://github.com/neuron-core/neuron-ai) ^2.0

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

[](#installation)

```
composer require izzuddinmohsin/neuron-sqlserver-toolkit
```

### PDO SQL Server Driver Setup

[](#pdo-sql-server-driver-setup)

**Windows:**Download [Microsoft Drivers for PHP for SQL Server](https://learn.microsoft.com/en-us/sql/connect/php/download-drivers-php-sql-server) and enable in `php.ini`:

```
extension=php_pdo_sqlsrv_83_ts.dll
extension=php_sqlsrv_83_ts.dll
```

**Linux (Ubuntu/Debian):**

```
# Install Microsoft ODBC Driver
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install -y msodbcsql18

# Install PHP extensions
pecl install sqlsrv pdo_sqlsrv
echo "extension=pdo_sqlsrv.so" >> $(php -i | grep "Loaded Configuration" | sed -e "s|.*:\s*||")
```

Quick Start
-----------

[](#quick-start)

```
use IzzuddinMohsin\NeuronSQLServer\SQLServerToolkit;
use NeuronAI\Agent;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Providers\Anthropic\Anthropic;
use NeuronAI\SystemPrompt;
use PDO;

class DataAnalystAgent extends Agent
{
    protected function provider(): AIProviderInterface
    {
        return new Anthropic(
            key: env('ANTHROPIC_API_KEY'),
            model: 'claude-sonnet-4-5-20250929',
        );
    }

    protected function instructions(): string
    {
        return (string) new SystemPrompt(
            background: ['You are a data analyst expert working with SQL Server databases.'],
        );
    }

    protected function tools(): array
    {
        $pdo = new PDO(
            'sqlsrv:Server=localhost;Database=mydb',
            'username',
            'password',
            [
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            ]
        );

        return [
            SQLServerToolkit::make($pdo),
        ];
    }
}
```

### Laravel Integration

[](#laravel-integration)

```
use IzzuddinMohsin\NeuronSQLServer\SQLServerToolkit;
use Illuminate\Support\Facades\DB;

// In your Agent's tools() method:
protected function tools(): array
{
    return [
        SQLServerToolkit::make(
            DB::connection('sqlsrv')->getPdo()
        ),
    ];
}
```

> **Note:** Return the toolkit instance directly — the framework will bootstrap it internally and register the guidelines automatically. You don't need to call `->provide()`.

Usage
-----

[](#usage)

### Discover All Tables and Views

[](#discover-all-tables-and-views)

```
// Discover everything in the database
SQLServerToolkit::make($pdo);
```

### Discover Specific Tables/Views Only

[](#discover-specific-tablesviews-only)

```
// Only discover these specific tables and views
SQLServerToolkit::make($pdo, [
    'users',
    'orders',
    'view_active_customers',
]);
```

### Exclude the Write Tool

[](#exclude-the-write-tool)

If you want read-only access, use the toolkit's `exclude()` method:

```
use IzzuddinMohsin\NeuronSQLServer\SQLServerWriteTool;

// Read-only: exclude the write tool
SQLServerToolkit::make($pdo)
    ->exclude([SQLServerWriteTool::class]),
```

### Azure SQL Connection

[](#azure-sql-connection)

```
$pdo = new PDO(
    'sqlsrv:Server=myserver.database.windows.net;Database=mydb;Encrypt=yes;TrustServerCertificate=no',
    'username@myserver',
    'password',
    [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    ]
);

SQLServerToolkit::make($pdo);
```

SQL Server vs MySQL Differences
-------------------------------

[](#sql-server-vs-mysql-differences)

This toolkit handles the key differences between SQL Server and MySQL automatically. The LLM receives SQL Server-specific guidelines, but here's a reference:

FeatureMySQLSQL ServerLimit rows`LIMIT 10``TOP 10`Auto increment`AUTO_INCREMENT``IDENTITY(1,1)`Current datetime`NOW()``GETDATE()`String length`LENGTH()``LEN()`String concat`CONCAT()` or `||``CONCAT()` or `+`Table quoting``table```[table]`Boolean type`BOOLEAN` / `TINYINT(1)``BIT`Schema prefixNot requiredRequired (e.g., `dbo.table`)Parameters (PDO)Named (`:name`)Positional (`?`)Last insert ID`lastInsertId()``SCOPE_IDENTITY()`Security
--------

[](#security)

### Read Tool (SQLServerSelectTool)

[](#read-tool-sqlserverselecttool)

StatusStatements✅ Allowed`SELECT`, `WITH` (CTE)❌ Blocked`INSERT`, `UPDATE`, `DELETE`, `DROP`, `CREATE`, `ALTER`, `TRUNCATE`, `MERGE`, `EXEC`, `EXECUTE`, `sp_executesql`, `xp_cmdshell`, `OPENROWSET`, `OPENDATASOURCE`, `BULK`, `INTO`### Write Tool (SQLServerWriteTool)

[](#write-tool-sqlserverwritetool)

StatusStatements✅ Allowed`INSERT`, `UPDATE`, `DELETE`, `MERGE`❌ Blocked`DROP`, `CREATE`, `ALTER`, `GRANT`, `REVOKE`, `TRUNCATE`, `EXEC`, `EXECUTE`, `sp_executesql`, `xp_cmdshell`, `OPENROWSET`, `OPENDATASOURCE`, `BULK`### Additional Security Measures

[](#additional-security-measures)

- All queries use **parameterized statements** to prevent SQL injection
- SQL comments are stripped before validation
- The PDO instance can use **dedicated credentials** with limited database permissions
- `SELECT INTO` is blocked to prevent table creation through the read tool

Toolkit Components
------------------

[](#toolkit-components)

ToolDescription`SQLServerSchemaTool`Discovers database structure (tables, views, columns, relationships, indexes, constraints)`SQLServerSelectTool`Executes read-only SELECT queries with positional parameters`SQLServerWriteTool`Executes write operations (INSERT, UPDATE, DELETE, MERGE) with positional parametersTroubleshooting
---------------

[](#troubleshooting)

### Error: "could not find driver"

[](#error-could-not-find-driver)

Install the PDO SQL Server driver. See the [Installation](#pdo-sql-server-driver-setup) section.

### Error: "Invalid object name"

[](#error-invalid-object-name)

Use schema-qualified table names: `dbo.TableName` instead of just `TableName`.

### Error: "Login failed for user"

[](#error-login-failed-for-user)

Verify your connection string and credentials. For Azure SQL, ensure your IP is allowed in the firewall rules.

### Empty results from queries

[](#empty-results-from-queries)

An empty array `[]` is a valid result meaning no records matched. The toolkit instructs the LLM not to retry on empty results.

### Connection timeout

[](#connection-timeout)

Add timeout to your connection string:

```
$pdo = new PDO(
    'sqlsrv:Server=localhost;Database=mydb;LoginTimeout=30',
    $user,
    $pass
);
```

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Credits
-------

[](#credits)

- Adapted from [Neuron AI](https://github.com/neuron-core/neuron-ai) MySQL Toolkit by [Inspector.dev](https://inspector.dev)
- SQL Server adaptation by [Izzuddin Mohsin](https://github.com/izzuddinmohsin)

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance75

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

137d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f15353f2f7ec69d95003d7a9edfb2b1b47381c639f8e147de82ecc1af837622c?d=identicon)[izzuddinmohsin](/maintainers/izzuddinmohsin)

---

Top Contributors

[![izzuddinmohsin](https://avatars.githubusercontent.com/u/134830784?v=4)](https://github.com/izzuddinmohsin "izzuddinmohsin (3 commits)")

---

Tags

ai-agentazure-sqldatabaseneuron-aipdophpsql-servertoolkitphpdatabasepdosql servertoolkitai-agentneuron-aiazure-sql

### Embed Badge

![Health badge](/badges/izzuddinmohsin-neuron-sqlserver-toolkit/health.svg)

```
[![Health](https://phpackages.com/badges/izzuddinmohsin-neuron-sqlserver-toolkit/health.svg)](https://phpackages.com/packages/izzuddinmohsin-neuron-sqlserver-toolkit)
```

###  Alternatives

[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k23.2k](/packages/clouddueling-mysqldump-php)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1816.5k12](/packages/popphp-pop-db)[riverside/php-orm

PHP ORM micro-library and query builder

111.3k](/packages/riverside-php-orm)

PHPackages © 2026

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