Repository navigation
v4.21.0
[4.21.0] - 2026-10-30
MCP Proxy mode: an agent runs SQL through Vericto, and what is checked is what
runs. vericto-proxy mcp is an MCP server in the same binary and image. An AI agent
(Claude Code, Cursor, Codex, any MCP client) gets execute_sql and no database
credential: every statement is evaluated against the workspace's rules, masks,
allowlists and business policies, and the server runs exactly the bytes it evaluated
(or the policy's own rewrite) on PostgreSQL, read-only, with row, size and time caps.
This is milestone M1 of the design "MCP execution modes" (vericto-fmw
docs/design/mcp-proxy-mode.md, revision 3.1), the read tier only. The TCP proxy
answers every statement exactly as in 4.20.0. See docs/MCP.md.
Added
vericto-proxy mcp(src/mcp/), over stdio (the default; stdout carries
JSON-RPC only and every log line goes to stderr; the process exits when stdin
closes) or stateless Streamable HTTP (--transport http,POST /mcp,127.0.0.1:8808
by default). One PostgreSQL database per process; the TCP listener is off in this
mode. EveryVERICTO_MCP_*setting is also a flag (vericto-proxy mcp --help).execute_sql, the exact-text guarantee (design §7). One statement per call (a
second one, a NUL byte, an empty or oversized statement, orparamsthat do not match
$1…$nisINVALID_INPUTbefore evaluation); evaluation under one snapshot with the
MCP identity as the principal; the evaluator's bytes, or its mask /LIMITrewrite,
sent as one unnamedParsewith the values inBind, inside
BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLYwithSET LOCAL
timeouts and pinned settings, ending inROLLBACKevery time. The PostgreSQL client is
the low-levelpostgres-protocolcrate on the proxy's ownconnect_upstream(TLS
verify-fullby default for any host that is not loopback; SCRAM-SHA-256; MD5 only with
VERICTO_MCP_ALLOW_MD5; no driver-issued catalog lookups). The only SQL of its own is
insrc/mcp/control.rs, with a test that fails if SQL appears anywhere else.- The read tier, enforced twice (§8.4, §9.1): the statement class from the parse
tree (reads only; a data-modifyingWITHanywhere raises the tier; a statement the
parser cannot read is refused whatever the parse-error policy), a denylist of
side-effect functions found anywhere in the tree (pg_terminate_backend,
set_config,dblink*,lo_*,query_to_xml*,table_to_xml*,nextval…), and the
READ ONLYtransaction. Above read:TIER_NOT_ENABLED; never-run statements (SET,
COPY,DO…):INVALID_INPUT. - Bounded results (§8): rows (200, cap 1000; fetched with
Execute{max_rows+1}),
serialized bytes (256 KiB, cap 1 MiB), bytes per value (8 KiB, cap 64 KiB), statement
time (15 s, cap 60 s), lock wait (2 s), each cut said intruncated, the text and a
refine_querynext step; values converted by type (int8/numericas exact strings,
JSON as JSON, arrays as arrays,byteaas base64 with its length). A connection that
broke or is not idle after a call is never reused (VERICTO_MCP_POOL_SIZE, default 4). - Database errors sanitized (
VERICTO_MCP_RESULT_DETAIL=sanitized, §15 T5):
DETAIL,HINT,WHERE,CONTEXTdropped and quoted values redacted for SQLSTATE
classes 21, 22, 23 and P0, so a cast cannot print a masked value. describe_schema(tables, columns, keys from fixed catalog queries; masked and
blocked columns marked; filtered by an enforced allowlist), a localcheck_sql
(the hosted tool's answer, evaluated here, no CI checks spent, events
execution_status: dry_run),whoamiwith theexecutionblock, and, with the
control-plane link,list_rules/show_rulefrom the signed bundle.- The contract shared with the control plane in
tests/mcp-contract/(vendored from
vericto-fmw PR #543; this repository is its home from now on, design §6.9): input,
output, the 42 outcomes and their exact next steps, error codes,whoami.execution,
ingest events and the sync section, all asserted bysrc/mcp/protocol_tests.rs. - Signed rule sync in mcp mode (§7.5, §11.2): every bundle must carry a valid
signature whateverVERICTO_POLICY_RULESsays (it defaults toenforcethere;offis
refused); the sync sendsX-Vericto-Proxy-Mode: mcpand polls every 30 s by default;
execute_sqlanswersNOT_READYuntil a signed bundle (or the verified rules cache)
is in force (VERICTO_MCP_REQUIRE_CONTROL_PLANE). The bundle'smcpsection (tiers,
limits that can only lower this process's, the key's own kill-switch block, and the
agent keys by SHA-256) is read fail-safe. - HTTP authentication and guards (§5.4):
Host/Originvalidated before
authentication (VERICTO_MCP_ALLOWED_HOSTS,VERICTO_MCP_ALLOWED_ORIGINS), a bearer
token mandatory also on loopback (the bundle's agent keys, or
VERICTO_MCP_AUTH_TOKENS_FILE), TLS (PROXY_TLS_MODE=require) or
VERICTO_MCP_ALLOW_PLAINTEXT_HTTPfor a non-loopback listener, a bounded body and a
header read timeout. The kill switch applies by key, by database user and to the
workspace, and cancels a statement already running. - Credentials (§12.1):
VERICTO_MCP_DATABASE_URL_FILE(preferred),
VERICTO_MCP_DATABASE_URL(warned about) orUPSTREAM_*;--database-urlis refused;
the password never prints. At startup, and inwhoami, the server warns
(agent_environment_has_db_credentials) when its environment also exposes a database
credential (DATABASE_URL*,PGPASSWORD,POSTGRES_URL*,SUPABASE_DB_*,NEON_*,
~/.pgpass, a secret file other users can read). - Telemetry (§14): one event per call, refused ones included,
source: mcp_proxy,
withexecution_status,tier,rows_returned,bytes_returned,truncated,
sqlstate,execution_ms,mcp_client_name/version,statement_sha256and, over
HTTP,api_key_id; counts and hashes only, never a result value. Input refused before
evaluation isstatus: INVALIDwith its hash. An ingest that refuses the new source is
sent the same events assource: mcp(once detected, for the life of the process). - A principal signal
mcp_credential(strong) in theprincipalssection, matched by
the key an MCP call presents; a TCP session never has one. - Try it without an account: the local mode. With none of
VERICTO_API_URL,
VERICTO_API_KEYandVERICTO_DATABASE_IDset,vericto-proxy mcpstarts on the
built-in ruleset the TCP proxy runs standalone, read tier only, with every safety of a
linked server (exact text, read-only twice, limits, sanitized errors, TLS
verify-full), and sends nothing anywhere (no event, heartbeat or sync). The startup
log says so (mode=local);whoamireportscontrol_plane.mode: "none",
control_plane.ruleset: "built-in"andcontrol_plane.reporting: false(new fields,
alsoruleset: "signed_bundle","rules_cache", or"none"whileNOT_READYwhen
linked;whoami-execution.jsongainsproxy_unlinked_control_planeand
control_plane_values); the server instructions andwhoamisay once that an account
adds custom rules, business policies, sensitive-column masking, audit and the
dashboard. There is no dashboard kill switch in this mode.docs/MCP.mdstarts with a
quick start without an account (Claude Code, Cursor, Codex; Docker or a source build),
then "Connect to Vericto".
Security
-
A configured control plane is never replaced by the built-in rules in
mcpmode.
VERICTO_API_KEYlinks the server (VERICTO_DATABASE_IDoptional, as on the TCP
path); it then answersNOT_READYuntil a signed bundle or the verified rules cache is
in force, also when the control plane is unreachable or a bundle fails the signature
check.VERICTO_API_URLorVERICTO_DATABASE_IDwithout a key, a key with an empty
VERICTO_API_URL, andVERICTO_MCP_REQUIRE_CONTROL_PLANE=truewithout a key are
startup errors (the TCP proxy keeps its behaviour: it runs standalone). -
HTTP without a control plane needs bearer tokens:
--transport httpin the local
mode does not start unlessVERICTO_MCP_AUTH_TOKENS_FILElists at least one token
(before, it started and refused every request). -
Parsing on a large stack. In
mcpmode every parse of agent text runs on a thread
with a large stack (reserved, committed as touched), at most 8 at a time, and
statements are limited to 64 KiB by default (at most 1 MiB), so a deeply nested
statement cannot exhaust a worker's stack. -
TCP proxy: evaluation of very large statements runs on threads with enough
stack. A statement overVERICTO_INLINE_EVAL_MAX_BYTESis evaluated on a thread
of its own whose stack is sized from the statement's length (reserved address space,
committed only as a deep parse touches it), two per CPU at a time, at least 8,
instead of on the blocking pool's 2 MiB threads; the async runtime's threads get an
8 MiB stack. Verdicts are unchanged. A statement that could not be given a thread is
not forwarded and its session ends.
Changed
TelemetryEventgains optional MCP fields (omitted on every TCP event, so a TCP
event's JSON is what 4.20.0 sent); the principal map, the rule sync and the telemetry
reporter gain the hooksmcpmode uses, each a no-op on the TCP path.VERICTO_INLINE_EVAL_MAX_BYTESis at most 4096: a larger value is used as 4096, with a
warning (a statement evaluated inline uses the worker's stack). The default (1024) is
unchanged.
Dependencies
postgres-protocol0.6 (MIT OR Apache-2.0; already in the tree as a dependency of the
tokio-postgresdev-dependency), and the server half ofhyper1 withhyper-util
andhttp-body-util(MIT; already compiled in as reqwest's client). Newly shipped
transitive crates are MIT, Apache-2.0 or Unicode-3.0 licensed (cargo-deny passes; the
image's THIRD_PARTY_LICENSES lists them).proptest1 (MIT OR Apache-2.0) as a
dev-dependency.
Image: vericto/vericto-proxy:4.21.0@sha256:7cca34697f61cf2baadb85a963520813ef108f10ad379906ffffb60b860c3bfd (Docker Hub and GHCR).