valv MCP server
Commit Oct 2, 2026Allows coding agents to query SQL and NoSQL databases safely using read-only tools and policy-based access control.
Also known as valv-dev/valv, mcp, @valv/mcp
- Stars
- 5
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- 0.6.2
- Last commit
- Oct 2, 2026
- License
- MIT
What is valv MCP?
valv allows coding agents to query SQL and NoSQL databases safely using read-only tools and policy-based access control.
Summary generated from the project's README
About valv MCP server
Querying live databases through coding agents without exposing raw SQL or risking data modification is what valv enables. Developers can connect this server to PostgreSQL, MySQL, SQLite, CockroachDB, ClickHouse, or MongoDB using a connection string. It functions as a read-only bridge that introspects your schema and provides four specific tools: list_resources, search_resources, describe_resource, and query.
Setup is handled via npx or manual configuration in files like .mcp.json for clients such as Claude Desktop, Claude Code, Cursor, or Codex. You can control access through environment variables like VALV_TABLES to allow-list specific tables or VALV_EXCLUDE to deny-list them. For more granular security, a policy file can hide specific columns or restrict row access based on a provided JSON context. This ensures the model only interacts with the data you explicitly permit while preventing it from ever seeing or executing raw SQL commands.
What you can do with it
- 1Secure database schema explorationAsk an AI agent to discover the structure and available tables within a production database.
- 2Restricted data retrievalInstruct an agent to fetch specific records while ensuring sensitive columns remain hidden from the model.
- 3Automated data reportingHave a coding agent transform database query results into interactive HTML charts and reports.
- 4Multi-tenant data isolationUse policy files to ensure an agent only accesses data belonging to a specific tenant or user.
Written from the project's README. Every use case is checked against a quote from it.
How to install valv MCP
Formats verified 10 Nov 2026Install valv MCP in Claude Code
$ claude mcp add --env DATABASE_URL=<YOUR_DATABASE_URL> mcp -- npx -y @valv/mcpInstall valv MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@valv/mcp"
],
"env": {
"DATABASE_URL": "<YOUR_DATABASE_URL>"
}
}
}
}Install valv MCP in VS Code
.vscode/mcp.json
{
"servers": {
"mcp": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"@valv/mcp"
],
"env": {
"DATABASE_URL": "<YOUR_DATABASE_URL>"
}
}
}
}Install valv MCP in Claude Desktop
claude_desktop_config.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@valv/mcp"
],
"env": {
"DATABASE_URL": "<YOUR_DATABASE_URL>"
}
}
}
}Install valv MCP in Codex
~/.codex/config.toml
[mcp_servers.mcp] command = "npx" args = ["-y", "@valv/mcp"] [mcp_servers.mcp.env] DATABASE_URL = "<YOUR_DATABASE_URL>"
Install valv MCP in Gemini CLI
~/.gemini/settings.json
{
"mcpServers": {
"mcp": {
"command": "npx",
"args": [
"-y",
"@valv/mcp"
],
"env": {
"DATABASE_URL": "<YOUR_DATABASE_URL>"
}
}
}
}Configuration
DATABASE_URLRequiredSecretDatabase connection string. PostgreSQL, MySQL, SQLite, CockroachDB, or a ClickHouse HTTP URL.
VALV_CONTEXTJSON context object the policy reads, e.g. {"tenant":{"id":"acme"}}.
VALV_DATABASEDatabase name. Required for ClickHouse, whose URL does not carry one.
VALV_EXCLUDEComma-separated deny-list of tables, applied after the allow-list.
VALV_HTTP_PORTServe over Streamable HTTP on this port instead of stdio.
VALV_POLICY_FILEPath to a policy module that takes full control of access. Without it, the server is read-only across all tables.
VALV_PROVIDERDatasource provider: postgresql, mysql, sqlite, or clickhouse. Inferred from DATABASE_URL when omitted.
VALV_TABLESComma-separated allow-list of tables. When set, only these are exposed to the agent.
| Name | Description | |
|---|---|---|
| DATABASE_URL | Database connection string. PostgreSQL, MySQL, SQLite, CockroachDB, or a ClickHouse HTTP URL. | RequiredSecret |
| VALV_CONTEXT | JSON context object the policy reads, e.g. {"tenant":{"id":"acme"}}. | |
| VALV_DATABASE | Database name. Required for ClickHouse, whose URL does not carry one. | |
| VALV_EXCLUDE | Comma-separated deny-list of tables, applied after the allow-list. | |
| VALV_HTTP_PORT | Serve over Streamable HTTP on this port instead of stdio. | |
| VALV_POLICY_FILE | Path to a policy module that takes full control of access. Without it, the server is read-only across all tables. | |
| VALV_PROVIDER | Datasource provider: postgresql, mysql, sqlite, or clickhouse. Inferred from DATABASE_URL when omitted. | |
| VALV_TABLES | Comma-separated allow-list of tables. When set, only these are exposed to the agent. |
README
View on GitHub@valv/mcp
Point it at a database URL. Your agent queries it safely. No SQL, no code.
A zero-config MCP server built on valv. Give it a connection string and it introspects your live schema, serves four tools (list_resources, search_resources, describe_resource, query) read-only by default, and enforces your policies — no SQL ever reaches the model, and it can only read what you allow.
Works with PostgreSQL, MySQL, SQLite, CockroachDB, ClickHouse, and MongoDB.
Guided setup
The fastest way in — it probes your database, lets you choose access, and writes the config:
npx @valv/mcp init
It takes either a connection string or individual fields (host, port, user, password, database), confirms the dialect, connects and shows your tables, then offers read-only / pick-tables / a policy-file stub. It then merges the server entry into the client of your choice — Claude Code, Claude Desktop, Cursor, or Codex — at project or global scope, leaving any existing config in place. Lastly it offers to install the valv skill, which teaches the agent how to query valv and turn results into interactive chart-report HTML files — as a skill for Claude Code (.claude/skills), Codex (.agents/skills), or Cursor (.cursor/skills), at project or global scope. Finally it can copy a kickstart prompt to your clipboard — paste it into your agent to explore the schema (seeding .valv/notes.md for future queries) and generate a single interactive valv-map.html overview of the database.
Manual setup
Add it to your .mcp.json (or Claude Desktop config):
{
"mcpServers": {
"db": {
"command": "npx",
"args": ["-y", "@valv/mcp"],
"env": { "DATABASE_URL": "postgresql://user:pass@localhost:5432/mydb" }
}
}
}
For ClickHouse, use its HTTP URL and a database name:
"env": { "DATABASE_URL": "http://localhost:8123", "VALV_DATABASE": "analytics" }
For MongoDB, use a standard connection string. Set VALV_DATABASE when the
URL does not select a database:
"env": { "DATABASE_URL": "mongodb://localhost:27017", "VALV_DATABASE": "analytics" }
Configuration
All via environment variables:
| Variable | Description |
|---|---|
DATABASE_URL |
Connection string (required; or pass as the first CLI arg). |
VALV_PROVIDER |
postgresql | mysql | sqlite | mongodb | clickhouse. Inferred from the URL when omitted. |
VALV_DATABASE |
Database name for ClickHouse or MongoDB. |
VALV_TABLES |
Comma-separated allow-list — only these tables are exposed. |
VALV_EXCLUDE |
Comma-separated deny-list, applied after the allow-list. |
VALV_POLICY_FILE |
Path to a policy module (below) for tenant scoping / hidden fields. |
VALV_CONTEXT |
JSON context the policy reads (e.g. {"tenant":{"id":"acme"}}). |
VALV_HTTP_PORT |
Serve over Streamable HTTP on this port instead of stdio. |
Policy file
Without one, access is read-only across all tables. To restrict what the agent can see — which tables, which columns — point VALV_POLICY_FILE at a module that receives the configured valv instance:
// valv.policy.cjs
module.exports = (valv) => {
valv.policy("orders", () => ({
read: true, // allow reads (or { column: value } to filter rows)
fields: { deny: ["internal_notes"] }, // hide columns from the agent
}))
// Tables without a policy are denied (deny-all).
}
Need per-request row scoping by tenant/user? That belongs in the app-controlled path, where your code supplies real identity per request — use @valv/mcp-sdk (or pass a fixed VALV_CONTEXT and read it in the policy here).
License
MIT
valv MCP questions
How do I add valv MCP to Claude Code?
Run claude mcp add --env DATABASE_URL=<YOUR_DATABASE_URL> mcp -- npx -y @valv/mcp in your terminal. Add --scope user to make it available in every project.
How do I add valv MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.
Which databases are supported?
The server works with PostgreSQL, MySQL, SQLite, CockroachDB, ClickHouse, and MongoDB.
Is the database access read-only?
Yes, the server provides tools that are read-only by default to ensure safety.
How can I restrict which tables or columns an agent can see?
You can use a policy file to define specific access rules, such as allowing reads on certain tables or denying specific columns.
Can I use this with MongoDB?
Yes, you can use a standard connection string for MongoDB and set the VALV_DATABASE variable if the URL does not select a database.