How MCP Toolbox turns agent text into ClickHouse vectors
Google's MCP Toolbox for Databases can declare a Gemini embedding model in YAML and mark tool parameters as `embeddedBy`, so agents send plain text and Toolbox embeds it and binds the vector into ClickHouse SQL for ingestion and cosine-distance search. Tested against Toolbox 1.9.0 and ClickHouse Cloud 26.4.1, the walkthrough covers installation, prebuilt ClickHouse tools, an HNSW vector_similarity table, and curated insert/search tools. Several implementation details turned up in testing: vectors are interpolated client-side by clickhouse-go rather than server-side bound, which still escapes injection attempts but bloats query_log. Gemini embeddings at 768 dimensions are not unit-normalized, so cosine distance should be used consistently. Gemini is the only supported embedding provider, and the `dimension` field sets the model's output size, so it must match the index width.
Related posts
- Integrating with ClickHouse MCP
ClickHouse mediumAdept
The open-source mcp-clickhouse server can be wired into five Python agent frameworks: Agno, DSPy, LangChain, LlamaIndex and PydanticAI. Each example uses uv to launch the server over stdio, points it at the public ClickHouse SQL Playground, and uses Anthropic Claude models. The frameworks differ mainly in ceremony. PydanticAI and Agno take the server directly, while DSPy needs a Signature class and manual conversion of MCP tools. LlamaIndex's default max_function_calls of 5 was too low to answer questions and had to be raised to 10. ClickHouse also plans a remote MCP server built into ClickHouse Cloud.
- AI Functions in ClickHouse: Upgrade your SQL to the AI age
ClickHouse mediumAdept
ClickHouse's beta AI Functions call LLM and embedding providers directly from SQL. They include aiClassify, aiExtract, aiGenerate, aiTranslate, aiFilter, aiRedact, aiEmbed and aiSimilarity, added across releases 26.4 to 26.8, and they make one HTTP request per row (batched for embeddings) and return native ClickHouse values. Setup on OSS uses named collections for credentials and works with any OpenAI-compatible endpoint, including local models via Ollama. Examples on the Hacker News dataset show classification, LLM predicates in WHERE, summarization, translation and an in-database RAG pipeline built on materialized-view embeddings and vector indexes. Per-query quotas on API calls and input/output tokens cap spend: call limits are exact, token limits can overshoot by one in-flight request per thread, a soft-stop mode returns partial results, and actual usage is visible in system.query_log ProfileEvents.
- Vector Search with ClickHouse - Part 2
ClickHouse mediumAdept
ClickHouse can serve as a vector store by keeping embeddings in Array(Float32) columns and computing distance functions in SQL. The walkthrough uses the 2.2-billion-row English LAION dataset of CLIP ViT-L/14 image and caption embeddings, covering schema design, loading from S3 Parquet, compression, and exact linear-scan search combined with metadata filtering and aggregation. It also covers the experimental Annoy ANN index, UDFs for generating query vectors, and codec tuning. ClickHouse fits best when vector matching needs SQL filtering, joins or aggregation over datasets too large for memory. Dedicated vector databases or in-memory indexes suit small, very high-QPS workloads better.
- Tracing OpenAI agents with ClickStack
ClickHouse mediumAdept
OpenAI's agents SDK has built-in tracing that can be redirected from OpenAI's hosted product to a custom TracingExporter. Spans can then be written into ClickHouse and explored in HyperDX as part of ClickStack. The worked example uses a gpt-5-mini agent that queries the ClickHouse SQL Playground through the ClickHouse MCP Server. The exporter is attached via a BatchTraceProcessor, adds the missing model name to response spans, and inserts rows into a JSON-typed ClickHouse table. The traces show tool calls, failed SQL attempts and LLM responses, which helps when comparing how different models handle ambiguous instructions.
- Storing OpenAI embeddings in Postgres with pgvector
Supabase mediumAdeptpgvector adds a vector data type and distance operators (Euclidean <->, negative inner product <#>, cosine <=>) to Postgres, so OpenAI text-embedding-ada-002 embeddings (1536 dimensions) can be stored and queried for similarity directly in the database. The walkthrough creates a documents table, a match_documents SQL function that filters by a cosine-similarity threshold, and an IVFFlat index sized at roughly 4 * sqrt(rows) lists. It then generates embeddings in JavaScript and builds Deno Edge Functions for semantic search and for retrieval-augmented answers with text-davinci-003, keeping injected context under about 1500 tokens to fit the 4000-token limit.