
Security News
Happy Birthday, Shai-Hulud
It has been one year since Shai-Hulud made its first appearance on npm.
@valv/mcp-sdk
Advanced tools
Library to turn your app's database into an MCP server for coding agents (Claude Code) — adapter-agnostic, row-level security, zero SQL
Expose a valv instance as an MCP server, so coding agents like Claude Code can connect to your database — with the same row-level security, field masking, and zero-SQL safety valv gives in-process.
It's a thin, adapter-agnostic wrapper: works with any configured Valv
instance, whether backed by @valv/prisma or @valv/clickhouse. Tool
definitions and execution both run through valv's policy engine, so every call
the agent makes is governed by your policies.
Just want to point an agent at a database with no code? Use
@valv/mcp— give it aDATABASE_URLand it introspects the live schema and serves it read-only. This package (@valv/mcp-sdk) is for when you want to define the adapter and policies yourself.
npm install @valv/mcp-sdk @valv/core
# plus your adapter, e.g. @valv/prisma + @prisma/client
# plus `express` only if you use the HTTP transport
Write a small entry script that builds your valv instance (adapter + policies),
then start the server. The agent gets the consolidated tool set by default —
a small fixed verb set (list_resources, describe_resource, query, get,
create, update, delete, aggregate) it uses to discover your schema at
runtime.
// mcp.ts
import { PrismaClient } from "@prisma/client"
import { createValv } from "@valv/prisma"
import { startStdioServer } from "@valv/mcp-sdk"
const prisma = new PrismaClient()
const valv = createValv(prisma, { defaultPolicy: "deny-all" })
valv.policy("order", (ctx) => ({
read: { tenant_id: ctx.tenant.id },
write: { tenant_id: ctx.tenant.id },
delete: false,
}))
await startStdioServer(valv, {
// Resolved per request — source identity however you like (env, file, …).
context: () => ({
user: { id: process.env.VALV_USER_ID ?? "agent", role: process.env.VALV_ROLE ?? "support" },
tenant: { id: process.env.VALV_TENANT ?? "tenant-alpha" },
}),
})
Add it to your .mcp.json (run the TS entry with tsx):
{
"mcpServers": {
"valv": {
"command": "npx",
"args": ["tsx", "mcp.ts"],
"env": {
"DATABASE_URL": "postgres://…",
"VALV_ROLE": "support",
"VALV_TENANT": "tenant-alpha"
}
}
}
}
context accepts a fixed value or a () => ctx | Promise<ctx> resolver
called on every request, so policy is always evaluated against fresh context.
This is the hook for sourcing identity from env vars (as above) — or, over HTTP,
from a verified request.
startStdioServer)What Claude Code and most local MCP clients launch. No networking.
startHttpServer)For remote / shared deployments. Requires the optional peer dependency express.
A fresh server is created per request (stateless), so the context resolver runs
on every call. Deploy behind your own authentication — the context resolver
is the natural place to map a verified caller to a valv policy context.
import { startHttpServer } from "@valv/mcp-sdk"
await startHttpServer(valv, {
context: () => ({ user: { id: "agent", role: "support" }, tenant: { id: "tenant-alpha" } }),
port: 3000, // POST /mcp
})
createMcpServer(valv, options) returns a transport-agnostic MCP Server
you can connect to any transport yourself.
| Export | Description |
|---|---|
createMcpServer(valv, options) | Build a transport-agnostic MCP Server. |
startStdioServer(valv, options) | Build + connect over stdio. |
startHttpServer(valv, options) | Build + serve over Streamable HTTP (needs express). |
ValvMcpOptions | context, mode ("consolidated" | "per-resource"), toolOptions, serverInfo. |
See examples/ecommerce/mcp.ts for a full,
policy-rich example.
MIT
FAQs
Library to turn your app's database into an MCP server for coding agents (Claude Code) — adapter-agnostic, row-level security, zero SQL
The npm package @valv/mcp-sdk receives a total of 15 weekly downloads. As such, @valv/mcp-sdk popularity was classified as not popular.
We found that @valv/mcp-sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.

Security News
It has been one year since Shai-Hulud made its first appearance on npm.

Research
/Security News
Operators behind PolinRider used a compromised GitHub account to plant malware in four development versions of a Packagist package with 700,000+ downloads.

Security News
GitHub Actions now supports cache-mode, a least-privilege control on the Actions cache aimed at the cache poisoning technique behind recent compromises.