Build a RAG chatbot for website content you host, served as an MCP tool
A RAG chatbot for website content costs about $0.05 to embed 3,000 pages once at November 2026 list prices. Keep the index on your server, serve retrieval as an MCP tool, and let the visitor's own AI write and cite the answer.
Published on
A RAG chatbot for website content costs about $0.05 to embed 3,000 pages once with text-embedding-3-small at November 2026 list prices, and the site pays nothing per answer when the visitor's own AI writes the reply. Hosted RAG chatbots charge a site $49 to $499 a month for the same job on their plans published in September 2026. This guide keeps the index on your server and exposes retrieval as a search tool on your site's MCP server. The visitor's model calls that tool, reads the passages and answers with a link to the page. You pay for embeddings and hosting. The visitor's account pays for the answer. Each step below carries the figure it rests on: passage size, hit counts, rerank depth, schema limits and the dated prices of the hosted vendors.
Key takeaways:
- Embedding 3,000 pages at about 800 tokens each takes 2.4 million tokens, or $0.048 on text-embedding-3-small at $0.02 per million tokens (November 2026 list price).
- Contextual embeddings combined with BM25 cut the top 20 retrieval failure rate from 5.7% to 2.9%, a 49% drop, in a 2024 benchmark; adding a reranker raised the drop to 67%.
- The MCP tools specification of 25 November 2025 requires servers to validate all tool inputs, rate limit tool invocations and sanitize tool outputs.
- Only 3 of 12 hosted RAG chatbots reviewed in October 2026 state plainly that the visitor sees a source on every answer.
What a RAG chatbot for website pages does
RAG (retrieval augmented generation) means the bot searches your content first, then writes its reply from the passages it found. The guides that rank for this query describe one pipeline: crawl, chunk, embed, store in a vector database, retrieve, then answer through a widget. In that pipeline the site pays for every embedding and every answer, because the generation model runs on the site's API key.
This page moves one boundary. The index and the search stay on your server. The answer moves to the visitor's own AI account, which calls your search as an MCP tool. Your site runs no generation model at all.
The AI Connect RAG chatbot Agent Skill (version 0.2.0, read on 22 November 2026) is built on that split. It has three parts: an index of passages, an MCP server that serves search_site and read_page on the site's own origin, and a chat module in the page. Each question costs the site one in memory search.
A 3,000 page documentation or media site sits past the threshold where that Skill adds embeddings. Keyword search alone covers a site of a few hundred pages, because the visitor's model rewrites its query and searches again when a search returns nothing. Thousands of pages, questions in a language the pages are not written in, and searches that miss in the logs are the three cases where the Skill adds vectors next to BM25. If you have not wired a chat yet, start with how to add an AI chatbot to your website with no API key on your server.
Who pays what on a 3,000 page site
The split below uses OpenAI list prices read on 22 November 2026 and four stated assumptions: 800 tokens per page, 20 tokens per visitor query, 10,000 questions a month, and 3,000 input plus 300 output tokens per answer.
| Cost line | Who pays | Basis | Amount |
|---|---|---|---|
| Embed 3,000 pages once, text-embedding-3-small | Your site | 2.4 million tokens at $0.02 per million | $0.048 |
| Embed 3,000 pages once, text-embedding-3-large | Your site | 2.4 million tokens at $0.13 per million | $0.312 |
| Embed 10,000 visitor queries a month | Your site | 200,000 tokens at $0.02 per million | $0.004 a month |
| Write 10,000 answers a month on gpt-5-mini | The visitor's AI account | $0.25 per million input and $2.00 per million output tokens | $13.50 a month at API list price |
| Store the vectors | Your site | 12,000 passages of 1,536 dimensions at 4 bytes each | 73.7 MB on your database |
One answer at that size is worth $0.00135 at gpt-5-mini API prices. On the visitor's subscription it counts against their plan's usage limits instead of a per token bill. The MCP server runs on the host that already serves your site, so its cost is your existing hosting.
Hosted RAG chatbot for website plans, with their dated prices
The hosted market prices by query, credit or page count. These figures come from each vendor's own pages as read on 12 September 2026. CustomGPT.ai Standard costs $99 a month for 1,000 queries, and Premium costs $499 a month for 5,000 queries. DocsBot AI Personal costs $49 a month for 5,000 credits and 5,000 source pages; Business costs $499 for 100,000 pages. Wonderchat Basic costs $124 a month billed yearly with 1,000 web pages, and Scale costs $417 a month with 2,500 pages, which is short of a 3,000 page site. Fin bills $0.99 per outcome, read on 3 October 2026.
OpenAI is winding down Agent Builder: from 30 November 2026 it leaves the OpenAI platform, while ChatKit stays available. A team that assembled its RAG chatbot in Agent Builder has to move its workflow off it by that date. The full price comparison sits in AI chatbot pricing compared by who pays for each answer.
Crawl and chunk a few thousand pages
Clean extraction decides answer quality before any model runs. In its January 2026 write-up, the SAM Solutions team describes a first version that embedded entire pages with their HTML and tags; the chatbot answered from navigation menus and repeated blocks. Its second version pulled content through site APIs, cleaned it, split it into chunks and embedded only those chunks.
Read the URLs from /sitemap.xml. Keep the main content of each page as text, drop the header, footer, cookie banner and navigation, and skip every page marked noindex. Exclude private paths such as /account and /admin at build time. When your content lives in Markdown, MDX or a headless CMS, read it from that source as a list of { url, title, text } objects with # headings left in the text.
Cut each page into passages under its headings. The Skill's index starts a new passage at each heading, and before any paragraph that would push the current passage past 1,200 characters, so no passage straddles two sections. Each passage keeps four fields: url, title, heading and text. The url field becomes the citation later. The index counts title and heading words twice, which favours a passage whose heading names the term the visitor asked about.
SAM Solutions tested a sentence window of 3 sentences, shifted by one sentence, with neighbouring windows merged when their embeddings were close. It settled on a semantic slicer library. Heading bounded passages of about 1,200 characters need no model at build time and sit far below the 8,192 token input limit of OpenAI's current embedding models.
Embed the passages and store the vectors on your server
Embeddings are vectors of numbers that place passages with similar meaning close together. text-embedding-3-small returns 1,536 dimensions and scores 62.3% on the MTEB benchmark; text-embedding-3-large returns 3,072 dimensions and scores 64.6%. OpenAI counts 62,500 pages per dollar for the small model and 9,615 for the large one, at about 800 tokens per page.
For 3,000 pages the small model costs $0.048 and the large one $0.312. Both models accept a dimensions parameter that shortens the vector, which cuts storage proportionally. At 1,536 dimensions, 12,000 passages take 73.7 MB as 4 byte floats.
Store the vectors next to your content. The Skill names pgvector (the vector extension for PostgreSQL) and Qdrant (an open source vector database) for this step. A site already running PostgreSQL adds one extension and one table. Keep the BM25 index as a JSON file committed with the site, as the Skill does, and keep the vectors in the database.
Rebuild both when the content changes. SAM Solutions re-indexed every few hours at first, up to twice a day, with a frequency configurable down to every 15 minutes. A build step in your deploy pipeline re-embeds only the passages whose text changed, so a 20 page update costs a fraction of a cent.
Embeddings run on your key. They are the one model cost your site carries in this design.
Expose retrieval as a search tool on your MCP server
The MCP specification of 25 November 2025 defines the contract for the tool. A client sends tools/list to discover tools and tools/call to run one. Each tool has a name, a description and an inputSchema, which MUST be a valid JSON Schema object and follows draft 2020-12 when no $schema field is present. Tool names SHOULD be 1 to 128 characters of ASCII letters, digits, underscore, hyphen and dot.
A search tool for 3,000 pages looks like this:
{
"name": "search_site",
"title": "Search this site",
"description": "Search the published pages of this site. Returns at most 8 passages, each with its page url, title and heading. Link the url of every passage you use. An empty list means no page covers the question.",
"inputSchema": {
"type": "object",
"properties": {
"query": { "type": "string", "maxLength": 200, "description": "Words to search for, in the language of the pages" },
"limit": { "type": "integer", "minimum": 1, "maximum": 8 }
},
"required": ["query"],
"additionalProperties": false
},
"annotations": { "readOnlyHint": true, "openWorldHint": false }
}Return the passages as JSON inside a text content block. The TensorPass McpToolSource client joins the text parts of a result and drops other content types. If you also send structuredContent, the specification asks for the same JSON serialized in a text block for backward compatibility. A page lookup that finds nothing returns a result with isError: true and a short reason; the SDK hands it to the model as Tool error: followed by that text.
Serve the server under your own domain at a path such as /api/mcp, which removes any CORS setup. A stateless server answers POST only and returns 405 to GET. The TensorPass MCP tools guide treats that 405 in your logs as expected behaviour. Its worked example limits each visitor address to 60 requests a minute.
The Skill's route sets three more caps. It refuses a request body over 16 KB, which needs @modelcontextprotocol/sdk 1.31 or later. Each search returns at most 8 passages of 700 characters. Its read_page tool returns at most 6,000 characters and refuses any path outside the index.
Hybrid retrieval: BM25 and dense hits, merged then reranked
BM25 is a lexical ranking function that scores a passage by how often the query terms appear in it, how rare those terms are across the index, and how long the passage is. The Skill's implementation uses the standard parameters k1 = 1.2 and b = 0.75. Dense search embeds the query and returns the passages whose vectors sit closest. Each method misses what the other catches: BM25 finds exact product names, error codes and prices, and dense search finds a paraphrase that shares no word with the page.
The SAM Solutions engine, described in January 2026, runs retrieval twice for each question. An LLM first expanded the visitor's question into an enriched query. The system then took 15 vector hits from the enriched query and 10 from the original one, reranked those 25 candidates with BM25, and passed the top 5 to the model. The team reported tighter answers and fewer irrelevant citations after adding those two steps. A benchmark published in September 2024 measured the same direction with numbers: contextual embeddings alone cut the top 20 retrieval failure rate by 35%, from 5.7% to 3.7%. Adding contextual BM25 brought the cut to 49%, at 2.9%, and a reranker on top brought it to 67%. On a 3,000 page site, a keyword index plus vectors is the configuration those figures support. The cost of the second index is $0.048 of embeddings and 73.7 MB of storage.
The Skill merges the two rankings with reciprocal rank fusion (RRF), which scores each passage by the sum of 1 / (k + rank) across the rankings, with k = 60. In the 2009 experiments on TREC collections that introduced it, RRF beat Condorcet fusion, CombMNZ and the best single system by 4% to 5% on average. RRF needs no score calibration between BM25 and cosine similarity, which is why it fits behind one search_site tool.
Our working setting for 3,000 pages is 20 BM25 hits and 20 dense hits fused with RRF at k = 60, then the top 8 passages returned to the model. That stays inside the Skill's cap of 8 passages of 700 characters.
Let the visitor's AI write the answer and cite the page
The answer runs in the visitor's browser on the visitor's model. In AI Connect, useAiChat in React, or runConversation without it, lists your tools and sends the conversation and the tool definitions to the visitor's model through AI Wallet. When the model asks for tools, the SDK calls them in the order requested and adds each result as a tool message. It repeats until the model answers without tool calls.
The default loop runs 6 steps, and the maxSteps option changes it. The last step offers no tools, so the model has to conclude. The loop runs only tools it offered at that step: a call to a name outside your catalog gets a Tool error: result and your server receives nothing.
Citations come from the passage fields. Each search result carries its url, and the system prompt asks the model to link every page it uses by its path. The Skill's answer guard lets links to hosts listed in allowedLinkHosts through and stops any other link. A visitor reads the claim and the page that backs it in the same reply.
Hosted vendors vary on this point. Of the 12 hosted RAG chatbots reviewed in October 2026, 3 state plainly that the visitor sees a source on every answer. With a page path on every passage, citation becomes a property of your tool output.
Keep each result short. Every passage you return counts against the visitor's plan, and 8 passages of 700 characters add about 5,600 characters to the conversation per search.
Keep retrieved text from giving orders
Any page in your index is text the visitor's model will read, and text a model reads acts on its behaviour. The OWASP Top 10 for LLM applications, 2025 edition, lists prompt injection as risk LLM01. It names indirect prompt injection, where instructions arrive through websites or files the model ingests, and states that RAG does not fully mitigate it. Its Scenario 4 describes an attacker modifying a document in a repository that a RAG application retrieves from.
Kai Greshake and five co-authors described the mechanism in February 2023: "LLM-Integrated Applications blur the line between data and instructions." Their attacks injected prompts "into data likely to be retrieved" and worked against Bing's GPT-4 powered chat.
Five controls apply to a site search tool:
- Index only what you publish. The chat repeats any passage it finds, so drafts, comments and user submissions stay out of the index.
- Wrap tool results in envelopes. The Skill draws a salt for each conversation and closes the instructions and every tool result in envelopes marked with it, so the model separates your policy from page text. OWASP lists segregating untrusted content as mitigation 6.
- Filter the answer as it streams. The Skill's chat checks each question and each answer, blocks links outside
allowedLinkHosts, and blocks the internal names listed indenyPatterns. - Validate on the server. The MCP specification requires servers to validate inputs, rate limit invocations and sanitize outputs; clients SHOULD validate tool results before passing them to the model.
- Pen test before launch. The Skill's hardening companion runs a unit pass, an MCP pass and a model pass, and all three pass before the chat goes public.
These guards reduce the risk; none of them removes it. Our measured test of our own chat is in AI chatbot security for a public website.
Ship a RAG chatbot for website pages with the Agent Skill
The aiconnect-rag-chatbot skill in the TensorPass GitHub repository turns the design above into files for a Next.js App Router site. A coding agent reads the skill and applies it to your repository. The steps, in order:
- Set up AI Connect. Install the packages, create one AiConnect client and wrap the app in
AiConnectProvider, as theaiconnect-integrateskill describes. - Install the hardening skill. The chat uses the policy, the rate limiter and the pen test of
aiconnect-hardening. - Copy the five templates.
siteIndex.mjs,collectPages.mjs,build-index.mjs,mcp-route.tsandSiteChat.tsxgo to their target folders. - Write the policy. In
lib/ai/chatPolicy.mjs, ask the model to callsearch_sitebefore answering, to link each page it uses by its path, and to point to the contact page when nothing matches. Add 3 to 5 sample questions. - Build the index. Run
scripts/build-index.mjsagainst your local origin, commitdata/site-index.json, and rerun it when the content changes. - Add embeddings for 3,000 pages. Embed passages at build time and queries at search time, store the vectors in pgvector or Qdrant, and fuse with BM25 by RRF behind the same
search_sitetool. - Render the chat and test it. Mount the
SiteChatcomponent once in the root layout, then run the three pen test passes.
A quick check before launch: a tools/call request for search_site with the query "delivery" returns passages with their paths, and a query with no match returns [].
FAQ: RAG chatbot questions from developers
Do I need embeddings for a site of 3,000 pages?
Yes, at that size. The AI Connect RAG chatbot Skill runs on BM25 alone for a site of a few hundred pages, because the visitor's model rewrites a failed query and searches again. It adds embeddings for thousands of pages, for questions asked in a language the pages are not written in, and when logs show missed searches. For 3,000 pages, embedding costs $0.048 once on text-embedding-3-small at November 2026 prices, and the vectors merge with BM25 through reciprocal rank fusion.
What does a RAG chatbot for website content cost the site each month?
The site pays for query embeddings, storage and hosting. At 10,000 questions a month of 20 tokens each, query embeddings cost $0.004 on text-embedding-3-small at November 2026 list prices. The vectors for 12,000 passages take 73.7 MB. The answers run on the visitor's AI account: at gpt-5-mini API prices, 10,000 answers of 3,000 input and 300 output tokens are worth $13.50. The MCP server runs on the host that already serves your site.
Can the visitor's AI read pages I did not index?
No. The model only sees what your tools return. In the AI Connect Skill, search_site reads the index built from your sitemap, minus pages marked noindex and the paths you exclude. The read_page tool returns at most 6,000 characters of a page in the index and refuses any other path. The MCP specification requires the server to validate every tool input, so a request for /admin fails on your side before any text leaves the server.
How often should I rebuild the index?
Rebuild on every content deploy. The SAM Solutions website chatbot, described in January 2026, re-indexed every few hours at first, up to twice a day, with a setting that goes down to every 15 minutes. A deploy step that re-embeds only changed passages keeps the cost low: at $0.02 per million tokens, re-embedding 20 changed pages of 800 tokens costs $0.00032. The BM25 index is a JSON file you commit, so it rebuilds in seconds with no model call.
Which vector database fits a self-hosted index?
The AI Connect RAG chatbot Skill names pgvector and Qdrant. pgvector adds vector columns and similarity search to PostgreSQL, so a site already on PostgreSQL adds one extension and one table. Qdrant is an open source vector database you run as its own service. At 12,000 passages of 1,536 dimensions the vectors take 73.7 MB, which fits in memory on a small server. Shortening the vectors through the dimensions parameter cuts that figure proportionally.
How TensorPass helps you run it
We build AI Connect so your site's chat runs on the visitor's own AI. Three parts apply to a RAG chatbot.
Free components. The AI Connect SDK, the WordPress plugin, the Shopify app, the Agent Skills, the MCP servers, AI Wallet and the site key are free. The SDK is open source under Apache 2.0 on GitHub. Its four packages are on npm under the @tensorpass scope since 16 November 2026, and npm provenance ties each package to the commit and the workflow that built it.
AI Wallet for your visitors. AI Wallet runs in Chrome, Edge, Brave and Opera on a computer, from the Chrome Web Store, and in Firefox from Firefox Add-ons. A visitor with no AI account subscribes to the TensorPass plan at US$5 (Light), US$20 (Pro) or US$50 (Max) a month, paid by the visitor.
Done for you. We make a site AI native in under 24 hours. The service is priced on quote, at [email protected].
Start with the MCP tools guide: it is the contract your search_site tool follows.
Next step: index your sitemap and query it from curl
Build the BM25 index from your sitemap first and check that a word from a known page appears in the JSON file. Serve search_site at /api/mcp, call it once with curl, and confirm it returns passages with their paths. Add embeddings and RRF once the keyword index answers. For the wider install routes, read an AI chatbot for your website that runs on the visitor's own AI.
Your RAG chatbot for website content then costs your site $0.048 of embeddings for 3,000 pages, plus the host it already runs on, and each answer runs on the visitor's account with a link to the page it came from.
Also worth reading:
- Add an AI chatbot to your website with no API key on your server
- An AI chatbot for your website that runs on the visitor's own AI
- AI chatbot pricing compared by who pays for each answer
- AI chatbot security for a public website
Sources:
- How We Built a Production-Grade RAG Engine for a Website AI Chatbot: SAM Solutions, 16 January 2026
- What is the best RAG chatbot for your website or documents?: Stewie, 9 October 2026
- Expose your tools over MCP: TensorPass docs, read 22 November 2026
- Tools, Model Context Protocol specification 2025-11-25: Model Context Protocol, 25 November 2025
- aiconnect-rag-chatbot SKILL.md and siteIndex.mjs, version 0.2.0: TensorPass on GitHub, read 22 November 2026
- Changelog: TensorPass docs, read 22 November 2026
- API pricing: OpenAI, read 22 November 2026
- Vector embeddings guide: OpenAI, read 22 November 2026
- Introducing Contextual Retrieval: Anthropic, 19 September 2024
- LLM01:2025 Prompt Injection: OWASP GenAI Security Project, 2025 edition
- Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods: G. V. Cormack, C. L. A. Clarke and S. Büttcher, SIGIR 2009
- Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection: Kai Greshake et al., arXiv, 23 February 2023
Questions
- Do I need embeddings for a site of 3,000 pages?
- Yes, at that size. The AI Connect RAG chatbot Skill runs on BM25 alone for a site of a few hundred pages, because the visitor's model rewrites a failed query and searches again. It adds embeddings for thousands of pages, for questions asked in a language the pages are not written in, and when logs show missed searches. For 3,000 pages, embedding costs $0.048 once on text-embedding-3-small at November 2026 prices, and the vectors merge with BM25 through reciprocal rank fusion.
- What does a RAG chatbot for website content cost the site each month?
- The site pays for query embeddings, storage and hosting. At 10,000 questions a month of 20 tokens each, query embeddings cost $0.004 on text-embedding-3-small at November 2026 list prices. The vectors for 12,000 passages take 73.7 MB. The answers run on the visitor's AI account: at gpt-5-mini API prices, 10,000 answers of 3,000 input and 300 output tokens are worth $13.50. The MCP server runs on the host that already serves your site.
- Can the visitor's AI read pages I did not index?
- No. The model only sees what your tools return. In the AI Connect Skill, search_site reads the index built from your sitemap, minus pages marked noindex and the paths you exclude. The read_page tool returns at most 6,000 characters of a page in the index and refuses any other path. The MCP specification requires the server to validate every tool input, so a request for /admin fails on your side before any text leaves the server.
- How often should I rebuild the index?
- Rebuild on every content deploy. The SAM Solutions website chatbot, described in January 2026, re-indexed every few hours at first, up to twice a day, with a setting that goes down to every 15 minutes. A deploy step that re-embeds only changed passages keeps the cost low: at $0.02 per million tokens, re-embedding 20 changed pages of 800 tokens costs $0.00032. The BM25 index is a JSON file you commit, so it rebuilds in seconds with no model call.
- Which vector database fits a self-hosted index?
- The AI Connect RAG chatbot Skill names pgvector and Qdrant. pgvector adds vector columns and similarity search to PostgreSQL, so a site already on PostgreSQL adds one extension and one table. Qdrant is an open source vector database you run as its own service. At 12,000 passages of 1,536 dimensions the vectors take 73.7 MB, which fits in memory on a small server. Shortening the vectors through the dimensions parameter cuts that figure proportionally.