{"slug": "ai-agent-access-control-read-only-search-with-manticore", "title": "AI Agent Access Control: Read-Only Search with Manticore", "summary": "A reproducible lab published by Manticore Search shows that connecting the official Manticore MCP server (commit c835b5c, package version 0.1.2) to a database account granted only `read` on the `agent_docs` table blocks tested INSERT, UPDATE, DELETE, DROP and TRUNCATE requests and denies access to the `private_docs` table, while the same read grant still exposes other tenants' rows within `agent_docs`. The lab runs on Manticore 29.9.0 with FastMCP 4.1.4 and the `manticoresearch` 11.2.0 client, tests reads and attempted writes through both MCP and direct HTTP, and repeats the checks after a restart, ending with \"PASS: reads allowed; mutations denied; data and schema unchanged.\" The result matters because it separates three access-control layers — an MCP query guard that does not enforce read-only SQL, a database grant that does not isolate tenants, and an agent host's tool allowlist that does not change database permissions — and shows the database grant alone leaves cross-tenant rows visible.", "body_md": "An agent answering questions from documentation needs search access, not permission to edit data. This example connects the official Manticore MCP server with a database account that can read one table, then tests what that account can and cannot do.\n\nWe run reads and attempted writes through MCP and direct HTTP, compare the data and schema before and after, and repeat the checks after a restart. The read grant also exposes other tenants' rows in the same table.\n\nA small test client sends the MCP requests. You don't need a live LLM or model credentials to reproduce the results.\n\n## The Access Boundary\n\nIf you've followed our [MCP introduction](https://manticoresearch.com/blog/mcp-manticore-server/)\nor [authentication guide](https://manticoresearch.com/blog/how-to-secure-manticore-search-with-authentication-authorization/)\n, this lab shows how to use them together with a restricted account.\n\nThe lab uses two tables:\n\n- `agent_docs` : three documentation records, one belonging to a second tenant.\n- `private_docs` : an internal runbook that the agent cannot read.\n\nThe MCP server connects with a user that has one grant:\n\n```\nCREATE USER 'agent_docs' IDENTIFIED BY 'DemoReader05!';\nGRANT read ON 'agent_docs' TO 'agent_docs';\n```\n\nThe administrator creates the tables and the read-only user. Only the restricted credentials reach the MCP process; the password shown here is for this disposable lab. Manticore's [authentication and authorization reference](https://manual.manticoresearch.com/Security/Authentication_and_authorization)\nexplains its action and target permissions.\n\nAI agent access control here has three layers worth keeping separate:\n\n| Control | What It Does | Limit | \n|---|---|---|\n| MCP query guard | Blocks the tested INSERT, UPDATE, DELETE, DROP and TRUNCATE requests | Does not enforce read-only SQL | \n| Database grant | Allows reads on `agent_docs` ; denies the tested writes and access to`private_docs` | Does not isolate tenants within `agent_docs` | \n| Tool selection in an agent host | Limits which tools the agent sees | Does not change database permissions | \n\nThis lab tests the MCP guard and the database grant, not the agent host's tool allowlist.\n\n## A Reproducible Lab\n\n[Download the runnable example](https://manticoresearch.com/downloads/agent-read-only-search.tar.gz)\n. It contains Compose files, the unmodified official MCP source and license, pinned Python packages, a protocol test client (`check.py`), and checksums.\n\nThe example uses [Manticore 29.9.0](https://github.com/manticoresoftware/manticoresearch/releases/tag/release-29.9.0)\n, pinned to this image digest:\n\n```\nmanticoresearch/manticore:29.9.0@sha256:461b419739a2bbbffb4be0b32db26c41d7b435bf7fd1fce95b414ca5ccbb3775\n```\n\nThe engine reported `29.9.0 58e88d5ab@26091108`. We used official MCP [commit c835b5c](https://github.com/manticoresoftware/mcp-manticore/tree/c835b5c5bd8d50f6ee76969d5c277967660501aa)\n(package version `0.1.2`), FastMCP `4.1.4`, and `manticoresearch` `11.2.0`. Retest if you upgrade any of them.\n\nThe tested platform is Linux amd64. You'll also need Docker Engine with Compose v2, Bash, Python 3, [uv](https://docs.astral.sh/uv/)\n, `tar`, and `sha256sum`. The first run may download an image, Python 3.12, and packages. No embedding model or API key is needed.\n\nThe Compose project is `manticore-article05`. The runner checks for existing project resources and a free port. The database binds to `127.0.0.1:39508` and has a one-CPU, 1-GiB limit; Python and downloads use additional host resources. Run only one copy at a time.\n\nDownload the archive and its [checksum file](https://manticoresearch.com/downloads/agent-read-only-search.tar.gz.sha256)\n, then run:\n\n```\nsha256sum -c agent-read-only-search.tar.gz.sha256\nmkdir agent-search-lab\ntar -xzf agent-read-only-search.tar.gz -C agent-search-lab\ncd agent-search-lab\nsha256sum -c SHA256SUMS\n./run.sh > run.log 2>&1\ntail -1 run.log\n```\n\nThe last line should be:\n\n```\nPASS: reads allowed; mutations denied; data and schema unchanged\n```\n\nWe verified the archive from a fresh extraction and a new database volume. The runner refuses to reuse a lab volume. The checksums cover downloaded files, not external package repositories.\n\n## Retrieval Through the Official MCP Server\n\nThe runner sets `auth = 1` and starts a standalone RT node. It bootstraps the administrator as the container's `manticore` OS user so the daemon can read its private auth store. The administrator then loads the fixtures and creates the restricted user.\n\nNext, the MCP process starts over stdio with:\n\n```\nMANTICORE_HOST=127.0.0.1\nMANTICORE_PORT=39508\nMANTICORE_USER=agent_docs\nMANTICORE_PASSWORD=DemoReader05!\nMANTICORE_ALLOW_WRITE_ACCESS=false\nMANTICORE_ALLOW_DROP=false\nMANTICORE_MCP_TRANSPORT=stdio\n```\n\nIn your agent host, launch `mcp-manticore` with these settings. Stdio does not open an MCP listening port. Remote MCP connections need separate transport and authentication controls; HTTP/SSE transport is not tested here.\n\nThe `tools/list` response contains five tools:\n\n```\nrun_query\nlist_tables\ndescribe_table\nlist_documentation\nget_documentation\n```\n\nThis version calls the SQL tool `run_query`, not the `execute_query` name used in our introductory post. The tests use the database tools, not the documentation tools.\n\nStart by listing tables, inspecting a schema, and running a query. Here, `list_tables` showed `agent_docs` but not `private_docs`. `describe_table` returned the `agent_docs` schema and denied access to `private_docs`. It builds `DESCRIBE <table_name>` without going through the `run_query` guard, so database permissions matter here too.\n\nWe also tried crafted table names outside `check.py`, with the MCP write flags both on and off. Names such as `agent_docs; DROP TABLE agent_docs` and `private_docs; DESCRIBE agent_docs` produced `P01: syntax error` (HTTP 500), without changing the database. An unterminated comment in `agent_docs /* ; DROP TABLE agent_docs` was treated as `DESCRIBE agent_docs`; `private_docs` alone returned 403. The syntax errors came from Manticore's parser, not from MCP name validation: `describe_table` does not validate that argument.\n\nHere is the retrieval request:\n\n```\n{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 3,\n  \"method\": \"tools/call\",\n  \"params\": {\n    \"name\": \"run_query\",\n    \"arguments\": {\n      \"query\": \"SELECT id,title,body FROM agent_docs WHERE MATCH('retry') AND tenant_id=1 LIMIT 3\"\n    }\n  }\n}\n```\n\nThe response contained record `1`, titled `Timeouts`, with this body:\n\n```\nSet a request timeout and retry transient failures.\n```\n\nThe test checks the embedded SQL response for exactly that record. In this fixture, `retry` does not also match `retries`. This is a retrieval example, not a relevance benchmark.\n\nWatch the response format: this MCP version wraps SQL data in `columns`/` rows`. Its outer `total` is `1` for the response envelope, not necessarily the number of matching documents. The raw response is in `results.jsonl`; read the embedded SQL `data` for the actual matches.\n\n## Mutation Tests That Reach the Database\n\nAn MCP error alone doesn't tell you whether the guard or the database stopped a write. The runner tries three paths:\n\n1. Default MCP, with both write flags `false` .\n2. A new MCP process with both flags `true` , still using`agent_docs` .\n3. Direct HTTP SQL with the same restricted credentials, bypassing MCP.\n\nEach path tries these statements:\n\n```\nINSERT INTO agent_docs(id,title,body,tenant_id) VALUES (99,'bad','bad',1);\nUPDATE agent_docs SET tenant_id=99 WHERE id=1;\nDELETE FROM agent_docs WHERE id=1;\nCREATE TABLE forbidden_table(body text);\nALTER TABLE agent_docs ADD COLUMN injected integer;\nDROP TABLE agent_docs;\nTRUNCATE TABLE agent_docs;\nCREATE USER 'intruder' IDENTIFIED BY 'demo';\n```\n\nThe table shows which layer blocked each request. `DB 403` means Manticore denied it. A dash means that combination was not tested:\n\n| Request | Default MCP | Flags On | HTTP | \n|---|---|---|---|\n| INSERT, UPDATE, DELETE | Guard rejects | DB 403 | DB 403 | \n| DROP, TRUNCATE | Guard rejects | DB 403 | DB 403 | \n| CREATE TABLE, ALTER TABLE | DB 403 | DB 403 | DB 403 | \n| CREATE USER | DB 403 | DB 403 | DB 403 | \n| SELECT from `private_docs` | DB 403 | — | DB 403 | \n| Request without credentials | — | — | HTTP 401 | \n\nFor example, the write-enabled MCP call returned `isError: true` and this database response (headers omitted):\n\n```\n(403)\nReason: Forbidden\nHTTP response body: {\"error\":\"Permission denied for user 'agent_docs'\"}\n```\n\nThe MCP guard is not complete SQL authorization. We proved this with a separate administrator-only control: with both write flags `false`, `run_query` successfully executed `CREATE TABLE guard_probe(body text)`. An independent administrator query confirmed the table, which we then removed. The pinned [guard code](https://github.com/manticoresoftware/mcp-manticore/blob/c835b5c5bd8d50f6ee76969d5c277967660501aa/mcp_manticore/mcp_server.py)\nblocks some mutation patterns, not every schema operation.\n\nThe guard can also reject harmless reads. In a separate check outside `check.py`, the restricted MCP account got a write-operation error for `SELECT id,title FROM agent_docs WHERE MATCH('update')`, for a `MATCH('\"delete from\"')` search, and for a query containing `/* update */`. None writes data, but the guard scans the whole SQL text for mutation words. The database grant is what prevents writes when the guard misses them.\n\n**Never give an agent administrator credentials and rely on MCP write flags alone.** The normal MCP process uses the restricted account; the same `CREATE TABLE` request was denied under that account.\n\n## Verification Beyond Error Messages\n\nBefore and after the attempted writes, a separate administrator connection compares:\n\n- the full table list;\n- the `agent_docs` schema;\n- every field in both tables, ordered by ID;\n- the user list.\n\nNothing changed: record `99`, the injected column, forbidden table, and `intruder` user were absent, and the original data remained intact. The temporary administrator-only test table was removed too.\n\nAfter restarting Manticore with the data volume intact, the snapshots still matched, direct writes were still denied, and MCP retrieval and denial checks passed again. This verifies the standalone setup, not a distributed cluster; see the [authentication rollout checklist](https://manticoresearch.com/blog/manticore-auth-migration-hardening-checklist/)\nfor that.\n\n## Read-Only Access Still Exposes Data\n\nThe retrieval query uses `tenant_id=1`, but the agent controls the SQL. Remove that filter:\n\n```\nSELECT id,tenant_id,title FROM agent_docs ORDER BY id ASC;\n```\n\nThe query returns tenant two's record. The read grant covers the whole table, and a prompt saying 'only query tenant one' cannot change that.\n\nIf the agent must not see another tenant's rows, don't give it arbitrary SQL access to a shared table. Use a separate table with a narrow grant, or an application-owned tool that takes tenant identity from trusted caller context and fixes the query scope. Both approaches need isolation tests. This example implements neither row-level authorization nor such an adapter; the `private_docs` test checks only the separate-table boundary.\n\nRead-only access still leaves other AI agent security risks:\n\n- **Resource use:** costly reads can consume CPU or return large amounts of permitted data. The example has a query limit and container resource caps, but no per-agent rate limit or load test.\n- **Host privileges:** an agent with Docker access, the administrator password, or database-volume access can bypass these restrictions. Keep all three out of its runtime.\n- **Untrusted content:** a document may contain instructions that steer an agent toward other tools or disclosing readable data. Database permissions do not stop prompt injection.\n\nThis lab uses HTTP on loopback. For networked deployments, protect credentials in transit and control access to the MCP server. The lab password is not meant for production.\n\n## Cleanup\n\nCheck `results.jsonl`, `run.log`, and `mcp-*.log` for the requests and responses, then remove the lab's containers, network, data volume, and auth store:\n\n```\n./cleanup.sh\n```\n\nImages, Python caches, the virtual environment, and logs remain. Unpack the archive again for a clean rerun.\n\nThe official MCP server could read the documentation, and Manticore denied all eight tested mutations under the restricted account. The lesson is in the boundary: MCP's guard helps, but the database grant stops writes. And a read grant on a shared table still exposes other tenants' rows.", "url": "https://wpnews.pro/news/ai-agent-access-control-read-only-search-with-manticore", "canonical_source": "https://manticoresearch.com/blog/agent-read-only-search/", "published_at": "2026-11-19 00:00:00+00:00", "updated_at": "2026-11-26 04:15:15.291539+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools", "agent-protocols", "ai-policy"], "entities": ["Manticore Search", "Manticore MCP server", "FastMCP", "manticoresearch", "Manticore 29.9.0", "Docker"], "also_reported_by": [], "takeaway": "Granting the MCP server's database user only `read` on one table blocked the tested INSERT, UPDATE, DELETE, DROP and TRUNCATE requests and access to `private_docs`, but did not isolate tenants — the grant still exposed other tenants' rows in `agent_docs`.", "recommendation": {"advice": "Give the MCP server a database user with a single `read` grant on the needed table, then test reads and attempted writes over both MCP and direct HTTP and re-check after restart; add row-level tenant filtering, since the grant alone exposed other tenants' rows.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/ai-agent-access-control-read-only-search-with-manticore", "markdown": "https://wpnews.pro/news/ai-agent-access-control-read-only-search-with-manticore.md", "text": "https://wpnews.pro/news/ai-agent-access-control-read-only-search-with-manticore.txt", "jsonld": "https://wpnews.pro/news/ai-agent-access-control-read-only-search-with-manticore.jsonld"}}