# sprocguard

> sprocguard is an MCP server for databases. Capture what a SQL Server stored procedure does today and verify changes against it. It runs locally on your machine and is started by your AI client.

- **Kind:** MCP server
- **Platforms:** CLI, Windows, Linux, macOS
- **Repository:** https://github.com/jheysonjhordyhuarauyariquelme/sprocguard
- **MCP Registry name:** io.github.JheysonJhordyHuarauyaRiquelme/sprocguard
- **Categories:** [databases](https://ai-powered.com/categories/databases), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-14

## About

Stored procedures often hold business rules with no tests, and an AI agent asked to optimise one can quietly change a rounding rule or an error path. sprocguard records characterization (golden master) baselines: result sets, return values, OUTPUT parameters, errors raised, and rows inserted, updated or deleted in each written table, including via called procedures and triggers.

Each case runs twice so values that change by themselves, such as IDENTITY values, NEWID() and run-time dates, are detected and ignored. Verification then reports each behaviour difference and exits with code 2 if something changed. Its safety model rolls every execution back inside a nested transaction, refuses databases outside allowed_databases, and by default refuses procedures that send mail, call xp_cmdshell or use linked servers.

It is also a CLI and a GitHub Action, and a Claude Code plugin ships a skill teaching the inspect, design cases, capture, change, verify loop. It needs Python 3.11 and an ODBC driver; use a development database because captures briefly hold locks.

## Features

- **Behaviour baselines:** Records result sets, errors and table changes for each parameter case.
- **Automatic noise filtering:** Running each case twice flags values like IDENTITY and NEWID() to ignore.
- **Clear diff reports:** Lists every changed row, value or error compared to the baseline.
- **Rollback safety:** Executions run in a transaction that is always rolled back.
- **Allow-listed databases:** Refuses to connect to databases not listed in allowed_databases.
- **tSQLt export:** Turns a baseline into tSQLt tests for read-only procedures.

## Good for

- Check an AI-edited stored procedure still behaves the same
- Block a pull request that changes procedure behaviour
- Generate characterization tests for an untested procedure
- Find which tables a procedure and its triggers write to

## Install

### Claude Code (Terminal)

```sh
claude mcp add sprocguard --env SPROCGUARD_ODBC='<SPROCGUARD_ODBC>' --env SPROCGUARD_PASSWORD='<SPROCGUARD_PASSWORD>' -- uvx sprocguard
```

### Claude Desktop (claude_desktop_config.json)

```json
{
  "mcpServers": {
    "sprocguard": {
      "command": "uvx",
      "args": [
        "sprocguard"
      ],
      "env": {
        "SPROCGUARD_ODBC": "<SPROCGUARD_ODBC>",
        "SPROCGUARD_PASSWORD": "<SPROCGUARD_PASSWORD>"
      }
    }
  }
}
```

### Cursor (~/.cursor/mcp.json)

```json
{
  "mcpServers": {
    "sprocguard": {
      "command": "uvx",
      "args": [
        "sprocguard"
      ],
      "env": {
        "SPROCGUARD_ODBC": "<SPROCGUARD_ODBC>",
        "SPROCGUARD_PASSWORD": "<SPROCGUARD_PASSWORD>"
      }
    }
  }
}
```

### VS Code (.vscode/mcp.json)

```json
{
  "servers": {
    "sprocguard": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "sprocguard"
      ],
      "env": {
        "SPROCGUARD_ODBC": "<SPROCGUARD_ODBC>",
        "SPROCGUARD_PASSWORD": "<SPROCGUARD_PASSWORD>"
      }
    }
  }
}
```

### Windsurf (~/.codeium/windsurf/mcp_config.json)

```json
{
  "mcpServers": {
    "sprocguard": {
      "command": "uvx",
      "args": [
        "sprocguard"
      ],
      "env": {
        "SPROCGUARD_ODBC": "<SPROCGUARD_ODBC>",
        "SPROCGUARD_PASSWORD": "<SPROCGUARD_PASSWORD>"
      }
    }
  }
}
```

### Other clients (your client's MCP settings (most use this shape))

```json
{
  "mcpServers": {
    "sprocguard": {
      "command": "uvx",
      "args": [
        "sprocguard"
      ],
      "env": {
        "SPROCGUARD_ODBC": "<SPROCGUARD_ODBC>",
        "SPROCGUARD_PASSWORD": "<SPROCGUARD_PASSWORD>"
      }
    }
  }
}
```

## Tools

- `inspect_procedure`: Parameters, tables read and written, related procedures and triggers, and risks.
- `suggest_cases`: Real parameter values from related tables plus edge values.
- `capture_baseline`: Records current behaviour; refuses to overwrite unless asked.
- `verify_procedure`: Re-runs cases and lists every difference.
- `generate_tsqlt_tests`: Turns a baseline into tSQLt tests.
- `list_baselines`: Lists captured baselines.

## FAQ

### Does sprocguard change my data?

No. Every execution runs inside a transaction that is always rolled back, though captures hold locks briefly so a development database is advised.

### What does sprocguard require?

Python 3.11 or newer and Microsoft ODBC Driver 17 or 18 for SQL Server.

### Which procedures are refused?

By default those that send e-mail, run xp_cmdshell, start jobs or use OPENROWSET, OPENQUERY or linked servers.

### How is sprocguard used with agents?

Run sprocguard serve as an MCP server or install the Claude Code plugin that includes an agent skill.

### How do I add sprocguard to Claude Code?

Run this command in your terminal: claude mcp add sprocguard --env SPROCGUARD_ODBC='<SPROCGUARD_ODBC>' --env SPROCGUARD_PASSWORD='<SPROCGUARD_PASSWORD>' -- uvx sprocguard

### What are the best alternatives to sprocguard?

The closest alternatives to sprocguard are Scribase, PrufGate, Guard, GuardLayer and Prober.

## Where this comes from

- Description: written from the project's README.
- Install steps: from the official MCP Registry entry.

## Alternatives

- [Scribase](https://ai-powered.com/mcp/scribase): Scribase is a freemium MCP server for databases.
- [PrufGate](https://ai-powered.com/mcp/prufgate): PrufGate is an MCP server for security.
- [Guard](https://ai-powered.com/mcp/guard): Guard is an open-source MCP server for developer tools.
- [GuardLayer](https://ai-powered.com/mcp/guardlayer): GuardLayer is a free MCP server for security.
- [Prober](https://ai-powered.com/mcp/prober): Prober is a freemium MCP server for developer tools.
- [Vericto: database guardrails for AI agents](https://ai-powered.com/mcp/vericto-database-guardrails-for-ai-agents): Vericto: database guardrails for AI agents is a freemium MCP server for databases.
- [AgentSQL](https://ai-powered.com/mcp/agentsql): AgentSQL is an open-source MCP server for databases.
- [Stet](https://ai-powered.com/mcp/stet): Stet is an open-source MCP server for developer tools.

---
Source: https://ai-powered.com/mcp/sprocguard
