Choose GROQ mode when your content is structured and the schema makes the right records and fields clear. Choose Knowledge Base mode when useful answers are spread across prose and multiple sources that benefit from being assembled into an index before a conversation. Neither option makes an AI agent incapable of guessing: reliable answers also depend on the source material, access rules, tool use, and explicit instructions for what to do when information is missing.
What Sanity Context does—and what it does not
Sanity Context is a hosted, read-only Model Context Protocol (MCP) server. It gives an external, MCP-capable agent access to configured Sanity content; the application builder supplies the agent harness and model. Context does not run the agent loop or write changes back to dataset documents. Sanity describes the service as providing “structured, read-only access to your content” in its Sanity Context documentation, last updated September 30, 2026.
As an Amazon Associate I earn from qualifying purchases.
The practical distinction is retrieval: GROQ mode queries a dataset when the agent asks, while Knowledge Base mode retrieves from material prepared and indexed ahead of the question. The former suits well-modelled records; the latter suits information that is harder to locate by querying individual fields.
Free tools Windows power users keep installed
One-click scans. No signup required.
GROQ mode or Knowledge Base mode?
| Decision | GROQ mode | Knowledge Base mode |
|---|---|---|
| Best fit | Structured, consistent content whose schema identifies useful fields and relationships. | Answers distributed across prose, websites, files, or other selected sources. |
| When retrieval happens | The agent queries the dataset at request time. | Selected content is prepared into an index before the conversation. |
| How the agent navigates | Explores the schema, queries with GROQ, and can read large array or Portable Text fields. | Uses an outline to navigate and retrieve prepared entries. |
| Key setup consideration | Requires project content and a deployed schema; Sanity documents Studio 5.1.0 or later for server-side schema support. | Requires an enabled opt-in beta and a Knowledge Base the token can read. |
| Ongoing care | Keep the schema and source records useful for the questions the agent needs to answer. | Keep sources and the generated index current, and review conflicts or build issues. |
These distinctions follow Sanity’s retrieval-mode guidance and Knowledge Base documentation, last updated September 18, 2026. Sanity says to use GROQ when content is structured and consistent and its schema tells the agent where to look. For example, a request such as “Size L latex gloves, under $200 a pallet” is a natural fit if the dataset consistently stores size, product, and price in queryable fields.
#1 Best Overall
Choose GROQ when records answer the question
Use GROQ when the content is already represented as records with dependable fields and relationships. An agent can discover the schema and retrieve matching records at question time, which is useful when the answer depends on filtering or following structured relationships. This approach depends on the schema and content being deployed and suitable for those queries.
Choose a Knowledge Base when meaning is spread across prose
Use a Knowledge Base when an answer may be scattered across documents or other selected sources rather than stored in predictable fields. A build reads the chosen material, resolves conflicts, and produces entries for retrieval. Its purpose influences the outline and which entries are treated as central, so the Knowledge Base should be designed around the information the agent is expected to find.
Knowledge Bases are an opt-in beta, not a generally available feature. Sanity warns that beta features and limits may change before general availability; confirm current availability and limits in its Knowledge Base documentation.
How a Context connection works
- Configure a Context MCP in the Sanity Dashboard. Choose the sources available to the agent and, where appropriate, add instructions or a GROQ filter.
- Connect an MCP-capable agent harness. The builder supplies this harness and the model; Sanity names Vercel AI SDK as one example in its Context overview.
- Authorize the connection with an organization API token. Sanity documents Context Viewer as the least-privilege permission that works, says project tokens are refused, and advises keeping the token server-side. See Content access and security.
- Let the agent orient itself. Initial context can provide a compressed schema overview in GROQ mode or an outline in Knowledge Base mode.
- Retrieve relevant material. GROQ mode offers schema exploration, querying, and reading large fields; Knowledge Base mode lets the agent read entries from its prepared index. The Context MCP tools reference describes the available tools.
- Present results in the application. Decide how retrieved material should appear to users. Sanity’s patterns and best practices recommend rendering structured results in application components when that serves users better than having the model re-narrate everything.
Set access boundaries before relying on prompts
Configure the connection so the agent can read only the sources it needs. In GROQ mode, use the server-side filter as an access boundary; a prompt asking the model to avoid certain data is not a substitute for limiting what the connection can serve. Store the organization token on the server, not in client-side code. Sanity’s security documentation covers token permissions and content access.
For GROQ mode, Sanity documents Sanity Studio 5.1.0 or later for server-side schema support and requires a deployed schema for the project and dataset. Check the Context MCP reference for the current setup details. For Knowledge Base mode, the organization must have the beta enabled and the token must be able to read at least one Knowledge Base.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.How to reduce guessing when sources are silent
Retrieval does not guarantee accuracy or prevent unsupported output. A model can still misread retrieved content, use tools incorrectly, or answer beyond what the sources establish. Configure both the accessible content and the agent’s behavior:
Rank #3
- Define the audience, tone, and subject boundaries.
- Tell the agent what to do when it cannot find an answer: say the information is unavailable rather than infer it.
- Give users a useful next step, such as contacting the relevant support team.
- Use server-side source selection and filters to enforce which content is available.
- Keep the underlying records or indexed sources current and fit for the questions asked.
Sanity’s production guidance recommends specifying audience, tone, boundaries, and behavior for unanswered questions. Its example pattern is to limit answers to product documentation and direct other questions to support. Treat that as an instruction to pair with access controls, not as proof that the agent will never make an unsupported claim.
Choose based on the shape of your content
If a question can be answered by finding and filtering well-defined records, start with GROQ. If the answer must be assembled from prose and varied sources, a Knowledge Base may be a better retrieval model, provided the beta is available to your organization. In either case, restrict the content the agent can access, tell it how to handle missing information, and decide how retrieved results should be presented to users.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




