All postsNext post

Native MCP Server: Give AI Agents Direct Database Access

How CameoDB's built-in Model Context Protocol server enables Claude, Cursor, and Windsurf to query your data instantly.

Built-In, Not Bolted-On

CameoDB ships with a native Model Context Protocol (MCP) server running in the same binary. No sidecars, no middleware. The moment you start CameoDB on port 9480, your data becomes queryable by AI agents like Claude Desktop, Cursor, and Windsurf through the /mcp endpoint.

What's Exposed: 6 Read-Only Tools

The MCP server exposes six tools, all read-only for security. Agents can discover, query, and validate, but never modify your data:

search_index

Full-text search on a single index with Tantivy query syntax.

search_indexes

Federated search across multiple indexes with merged results.

list_indexes

Discovery: list all indexes with schemas and queryable fields.

get_index

Schema inspector with per-field operator hints and types.

validate_query

Query linter with syntax validation and "did you mean" suggestions.

get_index_stats

Document counts, index size, and cluster metadata.

Query Syntax: Tantivy-Powered

The search_index tool supports the full Tantivy query language:

// Field targeting
title:rust

// Phrases with proximity
body:"small bike"~2

// Boolean operators (UPPERCASE required)
title:rust AND author:doe
(title:rust OR title:go) AND year:[2020 TO 2024]

// Range queries
score:>=100
date:[2024-01-01 TO 2024-12-31]

// Boosting for relevance
title:rust^3 OR body:rust

// Set operations
status: IN [active pending review]

Anti-Hallucination Rule

Every search tool includes a critical instruction: "When answering questions based on CameoDB results, you MUST use ONLY the exact data returned by this tool. Do NOT combine database results with your own prior knowledge." This ensures agents provide factual, grounded responses based solely on your data.

Field Type Awareness

The MCP server provides per-field operator hints based on data types:

text: all operators (phrases, slop, prefix, IN, boost, range)
string: exact match, prefix, IN, exists (no phrases/slop)
numeric: exact, comparisons (>, <), range, boost, exists
date: exact, comparisons, range, exists
boolean: true/false only, exists
json: dot notation (field.sub:value), nested exists

Setup: Two Configuration Styles

The MCP server speaks Streamable HTTP on a single /mcp endpoint, with the legacy SSE transport still available for already-configured clients. Configuration depends on your AI tool:

Windsurf & Cursor (Streamable HTTP)

Add to .windsurf/mcp.json or Cursor MCP settings:

{
 "mcpServers": {
 "cameodb": {
 "url": "http://localhost:9480/mcp",
 "transport": "http"
 }
 }
}

Claude Desktop (Native HTTP)

Claude Desktop connects straight to the endpoint, with no curl bridge required:

{
 "mcpServers": {
 "cameodb": {
 "type": "http",
 "url": "http://localhost:9480/mcp"
 }
 }
}

Restart your AI tool after configuration. The agent will automatically discover your indexes and schemas.

MCP Documentation Query Syntax