# QueryShield MCP server

> Provides a secure SQL proxy and credential vault that allows AI agents to query databases using natural language with AST-level safety and row-level security.

- Repository: https://github.com/bch1212/queryshield
- Page: https://hostedmcp.org/servers/bch1212/queryshield
- Transport: stdio
- Stars: 1
- License: MIT
- Latest version: 1.0.1

## Install

### Claude Code

```sh
claude mcp add --env 'QUERYSHIELD_API_KEY=<YOUR_QUERYSHIELD_API_KEY>' queryshield -- uvx queryshield-mcp
```

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

```json
{
  "mcpServers": {
    "queryshield": {
      "command": "uvx",
      "args": [
        "queryshield-mcp"
      ],
      "env": {
        "QUERYSHIELD_API_KEY": "<YOUR_QUERYSHIELD_API_KEY>"
      }
    }
  }
}
```

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

```json
{
  "servers": {
    "queryshield": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "queryshield-mcp"
      ],
      "env": {
        "QUERYSHIELD_API_KEY": "<YOUR_QUERYSHIELD_API_KEY>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"queryshield","type":"stdio","command":"uvx","args":["queryshield-mcp"],"env":{"QUERYSHIELD_API_KEY":"<YOUR_QUERYSHIELD_API_KEY>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "queryshield": {
      "command": "uvx",
      "args": [
        "queryshield-mcp"
      ],
      "env": {
        "QUERYSHIELD_API_KEY": "<YOUR_QUERYSHIELD_API_KEY>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add queryshield --env 'QUERYSHIELD_API_KEY=<YOUR_QUERYSHIELD_API_KEY>' -- uvx queryshield-mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.queryshield]
command = "uvx"
args = ["queryshield-mcp"]

[mcp_servers.queryshield.env]
QUERYSHIELD_API_KEY = "<YOUR_QUERYSHIELD_API_KEY>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'QUERYSHIELD_API_KEY=<YOUR_QUERYSHIELD_API_KEY>' queryshield uvx -- queryshield-mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "queryshield": {
      "command": "uvx",
      "args": [
        "queryshield-mcp"
      ],
      "env": {
        "QUERYSHIELD_API_KEY": "<YOUR_QUERYSHIELD_API_KEY>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `QUERYSHIELD_API_KEY` | yes | yes | Agent API key issued by QueryShield. |
| `QUERYSHIELD_BASE_URL` | no | no | Override the default endpoint. |

## FAQ

### How does QueryShield prevent malicious SQL commands?

It validates every query at the AST level, allowing only SELECT statements, preventing stacked statements, and using a function deny-list.

### Can agents access data they aren't supposed to see?

No, the system applies per-agent row-level security through schema/table whitelists and automatic WHERE clause injection.

### Does the audit log contain sensitive database rows?

No, the audit log only stores metadata and never contains actual row contents.

### What tools are exposed via MCP?

Exposed tools include natural-language database querying, SQL querying, listing and retrieving permitted credentials, and accessing the audit log.
