Local AI · Model Context Protocol

Connect a local vector database to MCP

MCP can let an IDE or model client inspect schema, execute SQL, and run local retrieval through a standard tool interface. That convenience creates a direct database trust boundary: “local” does not mean “read-only” or “safe.”

Short answer: use stdio when the client can manage a child process. Use loopback HTTP when MongrelDB Viewer is already open and the client accepts direct JSON-RPC. Never expose Viewer's unauthenticated MCP listener beyond 127.0.0.1.

Two local MCP architectures

TransportDatabase stateUse it whenMain limit
Viewer loopback HTTPShares the GUI's current Direct or Server connectionViewer is open and the client accepts URL-based JSON-RPCNo authentication; loopback only
Viewer stdioChild process opens its own Direct or Server connectionThe IDE or model client manages subprocessesDirect mode cannot share a root already exclusively locked by the GUI

The HTTP route is a direct POST JSON-RPC endpoint. It does not implement full streamable-HTTP sessions or a complete SSE event stream. Clients requiring those details should use stdio or an explicit compatibility bridge.

Use the in-app loopback server

  1. Open MongrelDB Viewer and connect a database.
  2. Open MCP, choose a port, and start the listener.
  3. Copy the displayed http://127.0.0.1:<port>/mcp URL into the model client.
  4. Stop MCP separately when the session is finished.
{
  "mcpServers": {
    "mongreldb-viewer": {
      "url": "http://127.0.0.1:7337/mcp"
    }
  }
}

Viewer binds the public desktop form to 127.0.0.1. Any local process that can reach that port can invoke tools, so host-level trust still matters.

Use stdio for client-managed isolation

{
  "mcpServers": {
    "mongreldb-viewer": {
      "command": "/absolute/path/to/mongreldb-viewer",
      "args": ["--mcp-stdio"],
      "env": {
        "MONGRELDB_VIEWER_PATH": "/absolute/path/to/database-root"
      }
    }
  }
}

For daemon access, set MONGRELDB_VIEWER_SERVER instead. Optional bearer or basic-auth environment variables support the server connection. Do not commit database passwords or tokens to an IDE settings repository.

Exclusive-lock rule: a Direct stdio process and a Direct GUI process cannot own the same MongrelDB root simultaneously. Disconnect one or use mongreldb-server for multi-client access.

What the model can do

The Viewer tool surface includes database overview, table listing and description, SQL execution, semantic search, and related database operations. SQL, Agent, and MCP are not inherently read-only. DDL, DML, REINDEX, and index work can alter the database when the active connection permits it.

Use a disposable fixture first. For sensitive data, connect with a principal whose row, column, and operation permissions match the task. A prompt instruction such as “never write” is not an authorization boundary.

Security checklist

  • Keep in-app HTTP on loopback and behind a trusted OS user session.
  • Prefer a least-privilege server identity for model-driven exploration.
  • Do not place API keys, database tokens, or passphrases in prompts.
  • Review what table samples and tool results a remote model provider receives.
  • Close Viewer to clear the in-memory Agent API key.
  • Back up and test restore before allowing write-capable tools near important data.
  • Use synthetic data when testing a new model client or MCP bridge.

Why this pairs well with a local vector database

Model clients often need more than nearest neighbors. They need schema discovery, exact filters, SQL, text constraints, and provenance. MongrelDB keeps dense ANN, sparse retrieval, substring, equality, and range candidates in one RowId model; Viewer exposes that database context through one tool process.

This is most useful for local RAG, agent memory, developer datasets, and offline inspection. It is not a replacement for an authenticated public MCP gateway or a multi-tenant authorization service.

Implementation used here

MongrelDB Viewer

Free, open source, cross-platform, and able to connect directly or through mongreldb-server.

Wider developer workspace

Mongrel by VisorCraft

Use Mongrel when database work also involves API calls, terminals, files, containers, Kubernetes, or one of 30+ supported engines.

Sources