{"slug": "your-search-tool-should-say-no-building-an-mcp-server-for-an-unreliable-caller", "title": "Your search tool should say no: building an MCP server for an unreliable caller", "summary": "A developer built CameoDB, a Rust search database with a built-in MCP server whose six read-only tools reject malformed queries instead of silently dropping unparseable clauses. When an agent submits a query with an unknown field such as 'platfrom', search_index returns isError: true with an explanation and points the caller to describe_index, rather than returning confident but wrong hits. The server also exposes validate_query, per-field type and tokenizer hints, field projection that cut search-result tokens by 91–96% on one index, and bearer-key or OAuth authentication scoped to allowed indexes.", "body_md": "An agent with a search tool makes typos. It writes `platfrom:hn` instead of `platform:hn`, or it asks for a field that exists in one index and not the one it's querying. What happens next depends on the server. Many search engines drop the clause they can't read and answer the rest. The tool call succeeds, the agent gets a confident list of hits, and nothing tells it the hits answer a different question.\n\nFor a human at a search box that's a minor annoyance, because you look at the results and notice. An agent doesn't notice. It reasons over what came back.\n\nI build [CameoDB](https://github.com/cameodb/cameodb), a search database (full-text, key-value and documents in one Rust binary) with an MCP server built in. This post is about the design choices in that MCP surface, made with that caller in mind.\n\nHere is a real call to `search_index` with the typo from above, on an index of about 2,900 tech-community posts:\n\n```\n{\"index\": \"marketing\", \"query\": \"platfrom:hn AND title:mcp\", \"limit\": 2}\n```\n\nThe response is `isError: true`:\n\n```\nQuery rejected: part of this query could not be interpreted and was dropped,\nso the results would not be the ones asked for.\n  - unknown field 'platfrom' — the clause naming it was dropped, so this\n    result set does not match what the query asked for\n\nRewrite the query and retry. `describe_index` lists the fields this index\nactually has, with the operators each field's type supports.\n```\n\nNo hits. The agent is told what was wrong and which tool shows the real fields. With `platform` spelled right, the same call returns 72 hits.\n\nThe same rule covers a quieter trap: a field that only showed up in later writes, and so was never indexed. A search naming it is refused on the MCP surface rather than answered with nothing.\n\nIf the agent wants to check first, `validate_query` is a tool too. It returns the recognized and unknown fields, the clauses that would be discarded, and for each field its type and how it matches (\"Words in any case, English stemmed: `running` finds `runs`\"), all before anything runs.\n\nAn agent arrives knowing nothing about your data. Whatever it does is bounded by what it can read from `list_indexes` and `describe_index`, so those carry as much as possible:\n\n`description` you write, verbatim. The schema is the only place that says what the data `query_hint` per type naming the operators that work on it, and a `tokenizer_hint` saying how matching behaves.\nThat's also what makes field projection usable. `search_index` takes a `fields` list, and an agent that has read `describe_index` can ask for three fields instead of whole documents. On one of our indexes that cut [search-result tokens by 91–96%](https://dev.to/gorancv/your-agent-doesnt-need-the-whole-document-cutting-search-result-tokens-by-91-96-gjh).\n\nThe surface is six tools: `list_indexes`, `describe_index`, `validate_query`, `search_index`, `search_across_indexes` and `get_catalog_stats`. All six are reads and are annotated `readOnlyHint: true`. Ingestion happens through the HTTP API, outside the agent's reach.\n\nAn MCP client authenticates with the same bearer key as the REST API, and the key's capabilities and `allowed_indexes` apply unchanged. The tool catalogue itself is filtered to what the key may call, so the agent is never offered a tool it would be refused for.\n\nClients that can't set headers (claude.ai, ChatGPT, Claude Desktop connecting by URL) sign in with OAuth instead. The token they receive acts as the user's key with `read` only, on `/mcp` only.\n\nMCP is served on the same HTTP listener as the REST API: `POST /mcp` for Streamable HTTP, plus the older HTTP+SSE transport for clients that haven't moved. There is no separate MCP process to deploy, version and keep in sync with the database. When the schema changes, the tools describe the new schema. A node whose callers don't need MCP turns it off with `enabled = false` under `[mcp]`.\n\nConnecting Claude Code to a local node:\n\n```\nclaude mcp add --transport http cameodb http://localhost:9480/mcp\n```\n\nSetup for Claude Desktop, Cursor, Devin and the MCP Inspector is in the [MCP client guide](https://github.com/cameodb/cameodb/blob/main/crates/mcp/README.md).\n\nTeaching has a price. I measured the tool catalogue the server returns from `tools/list`: about 27 KB, roughly 6,800 tokens, loaded once per session. Most of it is `search_index` (16 KB), because its description carries the query syntax reference: phrases, ranges, regex, `IN` lists and per-type operators. The alternative is an agent that guesses the syntax and retries, and every failed round trip also costs tokens and time. I'd still like that number smaller, and it's the next thing I'm looking at.\n\nCameoDB is a single binary: [downloads](https://cameodb.com/downloads.html), source and docs on [GitHub](https://github.com/cameodb/cameodb). The operator side of MCP (mounting, securing, shaping an index for agents) is in [docs/MCP.md](https://github.com/cameodb/cameodb/blob/main/docs/MCP.md).\n\nI'd like to hear how your agents fail with search tools. Silent wrong answers, retries, syntax guesses: what have you seen?", "url": "https://wpnews.pro/news/your-search-tool-should-say-no-building-an-mcp-server-for-an-unreliable-caller", "canonical_source": "https://dev.to/gorancv/your-search-tool-should-say-no-building-an-mcp-server-for-an-unreliable-caller-1co9", "published_at": "2026-12-01 22:07:30+00:00", "updated_at": "2026-12-01 22:13:32.883363+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "developer-tools", "large-language-models"], "entities": ["CameoDB", "Claude Code", "Claude Desktop", "ChatGPT", "claude.ai", "MCP"], "also_reported_by": [], "takeaway": "Rejecting a query with an unknown field (isError: true plus a pointer to describe_index) instead of silently dropping the clause prevents agents from reasoning over results that answer a different question; field projection cut search-result tokens by 91–96% on one index.", "recommendation": {"advice": "Make search tools fail loudly on unparseable clauses and expose schema and validation tools so agents can rewrite queries before running them.", "playbook": "agent-architecture", "playbook_url": "https://wpnews.pro/playbooks/agent-architecture"}, "alternates": {"html": "https://wpnews.pro/news/your-search-tool-should-say-no-building-an-mcp-server-for-an-unreliable-caller", "markdown": "https://wpnews.pro/news/your-search-tool-should-say-no-building-an-mcp-server-for-an-unreliable-caller.md", "text": "https://wpnews.pro/news/your-search-tool-should-say-no-building-an-mcp-server-for-an-unreliable-caller.txt", "jsonld": "https://wpnews.pro/news/your-search-tool-should-say-no-building-an-mcp-server-for-an-unreliable-caller.jsonld"}}