Can ClickHouse MCP be locked down to read-only access for AI agents?
The managed Cloud remote server is read-only by documented design: ClickHouse's docs say every tool on it is annotated readOnlyHint true and that no tool can modify data or alter service configuration. The open-source mcp-clickhouse server is read-only by default, since its run_query tool runs with CLICKHOUSE_ALLOW_WRITE_ACCESS=false, but writes can be switched on explicitly, so read-only status there is a configuration fact you must verify, not a guarantee. Whether a given setup is actually read-only depends on three things: which server is chosen, what key or credential it runs with, and whether the cluster is self-hosted or in ClickHouse Cloud.
The credential matters as much as the server. For API-key access to the remote server, ClickHouse's docs say access is scoped by the key's roles, permissions and expiration, and advise a dedicated least-privilege key injected through a secret-management system. Treat that as the control that limits damage: an over-privileged key can read sensitive tables even when the tool layer is read-only, and a shared key makes audit attribution weak. For the open-source server, confirm that the database user behind it has only SELECT-level grants on the databases and tables the agent needs, because the server's own read-only flag does not replace database permissions.
Before approving, ask the owning team to confirm four things in writing: the exact server and version in use, that CLICKHOUSE_ALLOW_WRITE_ACCESS is unset or false in every deployed configuration, which key or database user is used and its grants and expiry, and whether HTTP or SSE transport is used with authentication enabled, since the README says authentication is required by default for those transports but not for stdio. Then test the lockdown directly: attempt an INSERT, ALTER or DROP through the agent and confirm it is refused. Note that the Cloud remote server's read-only design covers its own tools, so a separate test is still needed for any other MCP server connected to the same agent.
ClickHouse MCP security controls by server
This table compares the ClickHouse Cloud remote MCP server with the open-source mcp-clickhouse server on read-only behavior, write enablement, transport, default authentication, supported services and key scoping. Read each row as a control to confirm in your own environment, and treat any cell marked as a confirmation item as an open question for the vendor before approval. The main takeaway is that the two servers differ in where they run and how they are locked down, so the same review does not apply to both.
| Control | Cloud remote MCP server | Open-source mcp-clickhouse server |
|---|---|---|
| Read-only behavior | All tools are documented as read-only and annotated readOnlyHint true | run_query runs in read-only mode by default |
| Write enablement | No tool can modify data or service configuration, per ClickHouse docs | Writes are off by default (CLICKHOUSE_ALLOW_WRITE_ACCESS=false) and must be enabled explicitly |
| Transport | Streamable HTTP at the managed remote endpoint | Local stdio by default; HTTP or SSE transport also available |
| Authentication default | API key access, scoped by the key's roles, permissions and expiration | stdio needs no authentication; HTTP and SSE require authentication by default |
| Supported services | ClickHouse Cloud and Managed Postgres services | Any ClickHouse instance, self-hosted or Cloud |
| Key scoping | Use a dedicated least-privilege key, injected through a secret manager | Confirm the database user and its grants used by the server; no key model is documented in the supplied facts |
| Tool surface | Lists databases and tables, inspects schemas, runs scoped SELECT queries, plus service, backup, ClickPipes, billing and Postgres monitoring tools | Central tool is run_query; confirm the full tool list in the current release before approval |
| Who runs and patches it | ClickHouse operates the server | Your team runs it; confirm the version pinned and the update process |
What each ClickHouse MCP server can read and change
The remote server in ClickHouse Cloud is documented as read-only end to end. ClickHouse's docs say every tool is annotated with readOnlyHint true and that no tool can modify data or alter service configuration. The tools cover listing databases and tables, inspecting schemas, and running scoped read-only SELECT queries. Other tools return service details, backup information, ClickPipes status, billing data and Postgres monitoring output. A reviewer should still confirm the exact tool list against the remote MCP documentation for the edition in use, because tool sets change, and should treat the read exposure as real: schemas, billing and service metadata can reveal sensitive business information even without writes.
The open-source server is a different risk profile. Its run_query tool executes SQL against the cluster it is pointed at, so what it can do depends on two things: the database account in the connection settings and the write flag. The README states that the server runs in read-only mode by default through CLICKHOUSE_ALLOW_WRITE_ACCESS=false, but writes can be enabled explicitly. Confirm in each deployment that this variable is unset or false, and that the account used has only the grants it needs. A broad administrative account turns a read-only default into a weak control, because the agent can still submit any SQL the account allows.
Before approving either server, ask the platform team three questions. Which database role or API key does the agent use, and can it reach tables holding regulated data? Is the write flag set anywhere, including in copies of the configuration used by developers? And who can change either setting? The remote server limits access through the roles, permissions and expiration of the API key, so a dedicated least-privilege key injected through a secret manager is the baseline. For the open-source server, a read-only database user with no write grants is the control that holds even if the flag is changed.
Where permissions are enforced for each ClickHouse MCP path
The remote path starts when an agent calls the Streamable HTTP endpoint with an API key, and ClickHouse Cloud checks the key's roles, permissions and expiration before any tool runs. The local path starts when an agent launches the stdio server, which connects to the cluster with a database user, so the write flag and the database user's grants decide what SQL can change. Check the key's scope and expiry, confirm that writes stay disabled, and confirm that HTTP or SSE transport requires authentication on any open-source deployment.
Enforcement points for the remote Cloud server and the local open-source server.
Decisions that set ClickHouse MCP risk
Most of the risk in a ClickHouse MCP setup comes from a few early choices: which server to use, which credentials it runs with, whether writes are switched on, and how the connection is transported and secured. Each card below names one of these decisions, what it changes, and what a reviewer should confirm before approving the connection.
Choosing the server
ClickHouse publishes two servers with different trust profiles. The managed remote server runs in ClickHouse Cloud over Streamable HTTP, and its tools are documented as read-only. The open-source mcp-clickhouse server runs locally over stdio by default and works with any ClickHouse instance, including self-hosted ones. Community forks of mcp-clickhouse are not ClickHouse's official server. Reviewers should confirm which server is in use, where its code came from, and whether its version is pinned and tracked.
Remote MCP docsAPI key roles and expiration
For the remote server, access is scoped by the API key's roles, permissions and expiration. A key with broader database rights exposes more data to every agent that holds it. Reviewers should confirm that each key is dedicated to the MCP connection, grants only the databases and tables the agent needs, has a defined expiration, and is rotated on a schedule the security team has approved. Ask who can create keys and whether key use is attributed to a named owner.
Remote MCP docsDatabase user behind the open-source server
The open-source server connects to ClickHouse as a database user, and every query runs with that user's grants. Read-only mode in the server does not replace database-level restrictions. Reviewers should confirm that the user holds only SELECT on the approved databases, has no grants for DDL, INSERT, ALTER or user management, and is separate from administrative and application accounts. Ask how the user's grants are reviewed after the server is first set up.
Server READMEThe CLICKHOUSE_ALLOW_WRITE_ACCESS setting
In the open-source server, the run_query tool is read-only by default because CLICKHOUSE_ALLOW_WRITE_ACCESS is set to false. Writes can be enabled by setting that variable explicitly. Any change to it should be treated as a security-relevant change that needs approval. Reviewers should confirm the value in each deployed configuration, check that it is not set in shared templates or developer dotfiles, and make sure a database-level read-only grant still applies even when the flag is false.
Server READMETransport for the open-source server
The open-source server supports stdio, HTTP and SSE transports. The README states that authentication is required by default for HTTP and SSE, while the default stdio transport does not require authentication. A stdio server runs under the local user's account and is reachable only by that process, while an HTTP or SSE server can be reached over the network. Reviewers should confirm which transport is used, that HTTP or SSE endpoints are not exposed beyond the approved network, and that authentication has not been turned off.
Server READMEWhere secrets are injected
Database credentials and API keys should reach the server from a secret-management system at runtime, not from files in a repository, shared configuration or a developer's shell history. ClickHouse advises a dedicated least-privilege key injected through a secret manager. Reviewers should confirm where the credential is stored, who can read it, whether it appears in logs or agent transcripts, and how it is revoked when a developer leaves or a laptop is lost.
Remote MCP docsHow the lockdown differs by deployment
ClickHouse runs the remote MCP server for ClickHouse Cloud and Managed Postgres services, and external agents connect to it over Streamable HTTP at the endpoint documented by ClickHouse. The vendor's documentation states that every tool on this server is read-only, annotated with a read-only hint, and that no tool can modify data or change service configuration. Access is governed by the API key you issue, so the key's roles, permissions and expiration define what an agent can reach.
- Read-only by design: The vendor states that no tool modifies data or service settings, so write controls are not a setting you turn on or off.
- Key scope: Confirm the roles and permissions attached to the key, since they determine which services and schemas the agent can query.
- Key expiration: Set and record an expiration date for every key used by an agent.
- Secret storage: The documentation advises a dedicated least-privilege key injected through a secret-management system, not pasted into client configuration files.
- Extra tools: Check whether the backup, ClickPipes, billing and Postgres monitoring tools are visible to your agents and whether you need them.
Before approving this path, verify the key's scope in the Cloud console against the exact services you intend to expose.
The open-source mcp-clickhouse server runs on the user's machine and talks to the agent over local stdio, so it works against any ClickHouse instance, self-hosted or Cloud. The README states that the default stdio transport does not require authentication. Control therefore comes from the database credentials in the server's environment and from the write setting, not from a server login.
- Read-only default: The
run_querytool runs in read-only mode unlessCLICKHOUSE_ALLOW_WRITE_ACCESSis set to true. - No server authentication: Anyone who can start the process on a workstation can use whatever database user is configured, so the process itself is the trust boundary.
- Database user: Create a dedicated ClickHouse user with read-only grants on the required databases, and do not reuse administrator credentials.
- Write flag: Confirm that
CLICKHOUSE_ALLOW_WRITE_ACCESSis absent or false in every client configuration staff use. - Provenance: Use the ClickHouse-maintained repository, since other mcp-clickhouse repositories on GitHub are community forks.
On each workstation, check the effective environment variables and the database user's grants, because a local configuration can override the read-only default.
When the open-source server runs with HTTP or SSE transport, its README says authentication is required by default. The server is then reachable over the network, so it becomes a shared service with its own access boundary, and the controls that matter are the authentication layer, the network path and the database user behind it. The default stopped being safe for a stdio setup as soon as the server listens on a port.
- Authentication default: Confirm the server has not been started with authentication disabled and that the expected auth mode is active.
- Network exposure: Restrict who can reach the listening port with network policy, and avoid public exposure.
- Shared database user: One service account often serves many agents, so per-user attribution is weaker than in the Cloud key model unless you add it.
- Write mode: Verify that write access stays off on any shared instance unless a documented change approves it.
- Logging: Confirm where request and query logs are kept, since a shared endpoint must be auditable.
For this deployment, verify the authentication settings, the listening address and the database grants together, because each one can defeat the others.
Where ClickHouse MCP leaves gaps reviewers must cover
Read-only defaults reduce what an agent can change, but they do not decide what it can see. The gaps below sit in data exposure, database privileges, fork provenance and audit detail, and each one needs a control that sits outside the MCP server itself. Reviewers should confirm every control in their own environment before approving a connection.
Read-only tools still expose table data
The Cloud remote server's tools are annotated read-only, so they cannot modify data or service configuration. Read access is still broad, though. Any key that is allowed to connect can list databases and tables, inspect schemas and run scoped SELECT queries, which can reach sensitive columns such as personal or payment fields. Confirm which tables and columns the key's role can reach, and restrict them with least-privilege database users, column-level grants or row policies before connecting an agent.
Remote MCP docsBroad grants behind open-source queries
The open-source server's run_query tool executes SQL on the cluster, and read-only mode is the default only for writes. Whatever the connecting database user can read is what the agent can read, so a user with broad grants gives the agent broad access. Create a dedicated user for the server with SELECT limited to named databases, and keep write access disabled. Review the configuration whenever writes are enabled, since that switch is explicit in the README.
Server READMEUnverified community forks
The official open-source server is published by ClickHouse under Apache-2.0. Other mcp-clickhouse repositories on GitHub are community forks, and they are not ClickHouse's official server. A fork can change how queries are run, what is logged or where credentials are sent. Pin the official repository as the only approved source, verify the publisher before installing any package, and require a review of code changes before a fork is used anywhere near production data.
Key and credential handling
Remote server access uses API keys scoped by roles, permissions and expiration. ClickHouse advises a dedicated least-privilege key injected through a secret-management system. In practice, keys are often shared in config files or chat tools. Ask who issues each key, set expiration dates that match the approved use, store keys in a secret manager, and rotate them on a schedule and when staff leave. Confirm that a leaked key can be revoked without disrupting other agents.
Network reach of HTTP-based servers
The open-source server requires authentication by default when it runs over HTTP or SSE, while the default stdio transport does not. Reviewers should not assume that a local stdio process is safe to run on a shared host, because it inherits the user's database connection. For any HTTP deployment, limit which networks can reach the server and which clients can connect to the remote endpoint, and confirm that the server cannot be reached from outside the approved network.
Limited audit detail for agent queries
Agent queries run under a shared key or database user, which can make them hard to attribute to a person or session. The documentation reviewed here does not set out how much query detail the remote server records or how long it keeps it. Ask ClickHouse what query logs exist for MCP-initiated queries, whether they identify the key, and how long they are retained. Where the logs are thin, use a separate database user per agent so that query logs tie each action to an identity.
Order of work to lock down ClickHouse MCP
This sequence takes an organization from choosing between the managed and open-source ClickHouse MCP servers to a verified configuration where the agent sees only the data it needs and cannot change anything. Each step ends with a check that the security owner can record as evidence.
Choose the server before anything else
The security owner and the data owner decide whether the agent will use the remote server that ClickHouse manages on Cloud or the open-source mcp-clickhouse server that runs in the organization's own environment. The choice sets the transport, the authentication model and who controls the server's configuration. Record the decision with the reason, the ClickHouse services in scope and the named owner. The step is done when every in-scope service is assigned to one server and no community fork is in the plan.
Create a dedicated least-privilege credential
The platform team creates a separate API key for the remote server or a separate database user for the open-source server, rather than reusing a personal or administrative credential. For the remote server, confirm that the key's roles, permissions and expiration are set to the minimum the use case needs, as ClickHouse's documentation describes. The step is done when the credential is listed with its scope, owner and expiry date, and an administrator review confirms no broader role was attached.
Confirm write access is disabled
On the open-source server, check that the write setting is off, which is the default, and that no deployment file, environment variable or wrapper script turns it on. On the remote server, confirm from ClickHouse's documentation that its tools are read-only and that the agent's credential has no role that could change data or service configuration. The step is done when a reviewer has checked the effective configuration of the running server, not only the template, and recorded the result.
Set authentication for HTTP or SSE transport
If the open-source server runs over HTTP or SSE, confirm that authentication is required and that the server is not reachable from networks beyond the agent's host or the approved network segment. The open-source README states that authentication is required by default for these transports, but the default stdio transport does not require it, so the team must verify which transport is actually running. The step is done when an unauthenticated request is refused and the network path is documented.
Inject secrets through a secret manager
The platform team moves the ClickHouse credential out of configuration files, shell history and agent client settings and into the organization's secret-management system, which then supplies it to the server at start-up. Check that developers' machines do not keep a copy and that the secret rotates on a schedule the security owner sets. The step is done when a search of repositories and developer workstations finds no plaintext credential and the secret manager's access log shows which service reads it.
Restrict which tables the agent can see
The data owner and the database administrator limit the agent's view to the databases and tables approved for the use case, using the permissions on the credential or user. Remember that listing tools can reveal schema names, so confirm that restricted tables are also hidden from schema inspection, not only from SELECT. The step is done when a test with the agent's credential lists only the approved objects and a query against a restricted table is denied.
Verify each control with a test query
The security reviewer runs a set of approved test queries with the agent's credential: one read against an allowed table, one attempt to read a restricted table, one attempted write, and one attempt to call a service-level function. Each result should match the expected outcome, and the reviewer records the query, the time and the response. The step is done when every expected result is recorded, failures are fixed and the test is repeated after any change to the server, key or permissions.
Evidence a security reviewer asks for
This table lists the artifacts a reviewer should request before approving ClickHouse MCP access, and where each one is read from. Use it as a checklist: for the Cloud remote server, most evidence comes from the API key and service settings in ClickHouse Cloud, while for the open-source server it comes from your configuration files, the database user grants and your own query logs. A missing artifact is a reason to pause approval.
| Evidence | What it shows | Where it comes from |
|---|---|---|
| API key roles and expiry | Which roles the key holds, what it may access and when it stops working | Key settings in ClickHouse Cloud for the remote server key, confirmed by the key's roles and expiration fields |
| Database user grants | Which databases, tables and statements the agent's database user can run, independent of the MCP layer | SHOW GRANTS output for the MCP database user on the cluster, checked against the least-privilege intent |
| Write flag value | Whether the open-source server can execute writes (CLICKHOUSE_ALLOW_WRITE_ACCESS) | The environment or config file that starts the open-source server, recorded from the running deployment |
| Transport and authentication setting | Whether the server runs over local stdio or HTTP or SSE, and whether authentication is enforced | Launch configuration of the open-source server; for the Cloud server, the Streamable HTTP endpoint and key-based access in use |
| Server fork and version | Which repository and release is running, so you know whether it is ClickHouse's official server or a community fork | Package or container image tag and source repository recorded in your deployment inventory |
| Tool list exposed to the client | Which tools the agent can call, including whether any tool is marked as modifying data | The tools list returned by the MCP server at connection time, and the readOnlyHint annotations for Cloud tools |
| Agent query logs | What SQL the agent ran, when, under which identity and with what result size | ClickHouse query log on the cluster, filtered by the MCP user, plus client-side logs kept by the AI tool |
| Secret storage record | Where the key or password is held and who can read it | Secret manager entry and its access policy, not the client configuration file |
Questions buyers ask about ClickHouse MCP security
Can the ClickHouse remote MCP server write or change data?
No, according to ClickHouse's documentation, every tool on the Cloud remote MCP server is read-only, each tool is annotated with readOnlyHint set to true, and no tool can modify data or alter service configuration. The remote server can list databases and tables, inspect schemas and run scoped read-only SELECT queries, and it also exposes tools for service details, backups, ClickPipes, billing and Postgres monitoring. Read-only does not mean low risk, though. A SELECT can still expose sensitive rows, so confirm which tables and databases the key can reach and which of the other tools your teams are allowed to use. Check the current tool list on the ClickHouse remote MCP documentation before approval.
Is the open-source ClickHouse MCP server safe by default?
It is read-only by default, but its safety depends on how it is run. The run_query tool executes SQL on your cluster and runs in read-only mode unless CLICKHOUSE_ALLOW_WRITE_ACCESS is set to true, which is the setting to verify in every deployment. The README also states that with HTTP or SSE transport, authentication is required by default, while the default stdio transport does not require authentication. That means a local stdio process runs with whatever database credentials it was given, so treat those credentials as the real boundary. Review the mcp-clickhouse README and confirm the write flag, transport and credentials in each environment, not only in a reference configuration.
Is a community fork of mcp-clickhouse acceptable for staff use?
Only after a separate review, because community forks are not ClickHouse's official server and their code, defaults and maintenance can differ from the ClickHouse/mcp-clickhouse repository. The official open-source server is published under the Apache-2.0 license, and the Docker MCP Catalog lists an Official ClickHouse server authored by ClickHouse with 3 tools and a requirement for secrets. Before approving a fork, compare its read-only default, write flag, transport authentication and dependencies against the official repository, and confirm who maintains it and how updates are released. Prefer pinning the official repository or the managed remote server where your requirements allow it.
What does a dedicated least-privilege API key change?
A dedicated key limits what an agent can reach, which is the main control ClickHouse documents for the remote server. For API-key access, ClickHouse says access is scoped by the key's roles, permissions and expiration, and advises a dedicated least-privilege key injected through a secret-management system. In practice, this means one key per agent or team, granted only the databases and tables it needs, with a short expiration and rotation. A shared personal key or an admin key removes that boundary, and makers may not notice the scope they have. Ask ClickHouse to confirm exactly which role and permission options are available for your service tier before you write the access policy.
Can our own team configure ClickHouse MCP security without outside help?
Often yes for a single read-only deployment, but the work is more than changing one flag. The team must confirm the write setting on the open-source server, choose the transport and its authentication, issue scoped keys, store them in a secret manager, and decide which tables an agent may query. Teams with strong ClickHouse administration and security review skills can do this internally. Outside help becomes useful when several clients, environments or sensitive datasets are involved, or when you need evidence that the setup was tested. DeployOpen tests AI agent and MCP setups, including tool and file permissions, data exposure and credential handling, and delivers a findings report with fixes and a retest, under a fixed-scope written agreement.
What drives the effort to lock down ClickHouse MCP?
The main drivers are how many services and clients are involved, how sensitive the queried data is, and whether you use the managed remote server, the open-source server or both. Each open-source deployment needs its write flag, transport and credentials checked, while the remote server needs its keys, roles and expiration set and the enabled tools reviewed. Effort rises with more databases, more agents, custom forks and any requirement to show evidence to auditors. No duration or price is given here because none is supplied. Ask ClickHouse and your implementation partner for a written scope that lists each server, each key and each environment to be reviewed.
Where should we confirm current ClickHouse MCP permissions?
Confirm them in the vendor documentation and in your own service settings at the time of approval, because tool lists and defaults can change. Start with ClickHouse's remote MCP documentation for the managed server's tools, read-only annotations and key guidance. For the open-source server, check the repository README for the write flag, transport authentication and supported configuration. Then verify in your own environment by listing the tools a test client receives and attempting a write with a scoped key. Record the results so your security reviewers can repeat the check after upgrades.
How DeployOpen tests and locks down ClickHouse MCP for your team
DeployOpen plans, implements, hardens and tests self-hosted platforms inside the client's own infrastructure, and runs security testing that includes AI systems and agents. For ClickHouse MCP security, that means checking which server is in use, what its tools can read and change, and how its credentials and permissions are set before staff connect an AI client.
How we scope
- Confirm which server is in use: the managed remote server in ClickHouse Cloud or the open-source mcp-clickhouse server
- Inventory the tools exposed, the services and databases reachable, and any write access that must stay disabled
- Agree the written scope, deliverables and timeline with you before any testing begins, as engagements are fixed-scope
How we build
- Configure a dedicated least-privilege key or database user, injected through your secret-management system rather than shared credentials
- Keep the open-source server in read-only mode and confirm the write setting is off, or document an approved exception
- Set authentication for HTTP or SSE transports so the default protection is not relied on by accident
How we hand over
- Deliver a findings report covering prompt injection, tool permissions, data exposure and credential handling for ClickHouse MCP
- Provide fixes, configuration evidence and a retest so your security team can confirm each control works
- Document the final lockdown settings and the logs and records your reviewers should keep for ongoing review
How we support
- Ongoing support, upgrades and continuous testing are available as retainers as the server and your tool list change
- Re-test after ClickHouse or the community server releases changes that affect tools, transports or authentication
- Prepare the evidence your compliance and security reviewers ask for, such as configuration records and test results

