An AI-powered frontend documentation agent that answers development questions using real documentation retrieved through Sanity Context MCP.
Instead of relying only on the model's pretrained knowledge, DevDocs Agent can query a curated documentation Knowledge Base and use the retrieved content as context before generating an answer.
π Live Demo: https://devdocs-agent.vercel.app/
DevDocs Agent is a small AI agent designed to answer practical frontend development questions using a curated documentation source.
You can ask questions such as:
- When should I use
useEffectvsuseLayoutEffect? - What does a particular React API do?
- Should this logic run on the server or the client?
- How does a browser API work?
- What approach should I use for a particular frontend problem?
The agent retrieves relevant documentation from Sanity and uses that information to construct its response.
The final answer is rendered as Markdown, and the documentation sources used by the agent are displayed below the answer.
The goal is simple:
Ask a frontend development question and get an answer grounded in actual documentation rather than relying only on the model's internal knowledge.
π Live Application: https://devdocs-agent.vercel.app/
The application provides a minimal interface:
- Ask a frontend development question.
- The agent decides whether it needs information from the connected documentation.
- Sanity Context MCP retrieves relevant content.
- Gemini uses the retrieved content to generate the answer.
- The answer is streamed to the browser.
- The documentation sources are displayed alongside the response.
The application uses an agentic tool-calling workflow.
Instead of sending a question directly to Gemini and accepting whatever it knows, the model has access to a Sanity Context MCP endpoint.
A simplified version of the architecture looks like this:
User
β
β Question
βΌ
βββββββββββββββββββ
β Groq Agent β
ββββββββββ¬βββββββββ
β
β MCP tool call
βΌ
βββββββββββββββββββ
β Sanity Context β
β MCP β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Sanity Knowledgeβ
β Base β
ββββββββββ¬βββββββββ
β
β Relevant documentation
βΌ
βββββββββββββββββββ
β Groq Agent β
β β
β Reason + Answer β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Next.js Server β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Frontend β
β β
β Answer + Sourcesβ
βββββββββββββββββββ
The important part is that the model is not directly connected to the browser or to the Sanity credentials.
The interaction happens on the server.
Large language models already contain a large amount of knowledge about popular frameworks, APIs, and web technologies.
However, relying entirely on pretrained knowledge creates some practical problems:
- Documentation changes over time.
- APIs evolve.
- Framework behavior can change between versions.
- A model can produce an answer that sounds convincing but does not match the documentation you want your application to follow.
- There is no guarantee that the model's internal knowledge represents the exact documentation source you care about.
This is where Sanity Context MCP becomes useful.
Instead of building the application around:
User
β
LLM
β
Answer
the project uses:
User
β
LLM Agent
β
Sanity Context MCP
β
Knowledge Base
β
Relevant Documentation
β
LLM
β
Grounded Answer
Sanity provides the knowledge layer while Groq (openai-model) provides the reasoning and generation.
Not by retraining the model.
Groq(openai-model) is still the same underlying model.
Sanity provides additional, application-controlled context at inference time.
That means the model can access information that has been deliberately selected and structured for the application instead of depending entirely on what it learned during training.
This is useful when you want the model to answer according to a specific documentation source.
The distinction is:
Model knowledge
+
Retrieved application context
=
Generated answer
The project is therefore less about making the model itself more capable and more about giving the model access to the right knowledge at the right time.
I created a Sanity Knowledge Base containing curated frontend documentation.
The documentation focus is:
- React
- Next.js
The documentation is connected to Sanity Context, which exposes the Knowledge Base through an MCP endpoint.
The Next.js server creates an MCP client and exposes the available Sanity tools to Groq(openai-model).
The relevant flow is:
Next.js API Route
β
βΌ
createSanityMCPClient()
β
βΌ
Sanity Context MCP Endpoint
β
βΌ
MCP Tools
β
βΌ
Groq(openai-model) Agent
The agent is instructed to use the connected Sanity documentation whenever the question can be answered from the available content.
The system prompt also tells the agent to treat the Sanity content as the source of truth and not invent documentation.
The Sanity Context MCP endpoint currently exposes tools including:
initial_contextknowledge_base_read
The agent can decide when to use these tools during generation.
For example, when asking about React effect hooks, the agent can retrieve the relevant documentation from the Knowledge Base before producing its final answer.
This gives the model a tool-based way of accessing external knowledge rather than requiring the application to manually fetch and inject every document into every prompt.
Suppose the user asks:
What is
useEffectand when should I use it?
The request reaches the server.
The server creates the Sanity MCP client and obtains the available tools.
Groq(openai-model) receives the question together with those tools.
The agent can then call the Sanity tools to retrieve relevant documentation.
The retrieved content contains the actual documentation information as well as source information.
Groq(openai-model) uses the retrieved content to construct the final response.
The resulting answer is streamed back to the browser.
The application also extracts the documentation sources from the MCP tool results and displays them underneath the answer.
The result is:
Question
β
Agent reasoning
β
Sanity MCP tool call
β
Relevant documentation
β
Agent reasoning
β
Markdown answer
β
Sources
One of the useful parts of the MCP response is that the retrieved documentation contains source information.
The application extracts the source title and URL from the tool results.
For example:
[
{
"title": "useLayoutEffect β React β Web",
"url": "https://react.dev/reference/react/useLayoutEffect"
},
{
"title": "useInsertionEffect β React β Web",
"url": "https://react.dev/reference/react/useInsertionEffect"
},
{
"title": "useSyncExternalStore β React β Web",
"url": "https://react.dev/reference/react/useSyncExternalStore"
},
{
"title": "useEffectEvent β React β Web",
"url": "https://react.dev/reference/react/useEffectEvent"
}
]These are then displayed in the UI.
This makes the response more inspectable:
Answer
ββββββββββββββββββββββββββββ
useEffect is used to synchronize
a component with an external system...
Sources
ββββββββββββββββββββββββββββ
β’ useLayoutEffect β React β Web
β’ useInsertionEffect β React β Web
β’ useSyncExternalStore β React β Web
β’ useEffectEvent β React β Web
The model is still generating the answer, but the user can see the documentation sources that informed the response.
Groq(openai-model) returns Markdown.
Instead of displaying the raw Markdown directly, the frontend uses react-markdown to render it into a readable documentation-style interface.
For example, the model can return:
### Syntax
```javascript
useEffect(setup, dependencies?)
```
- `setup`: Your effect logic.
- `dependencies`: Reactive values used by the effect.The frontend renders this as actual headings, lists, inline code, and code blocks.
This keeps the agent implementation simple while still producing a readable UI.
The answer is streamed from the server rather than waiting for the entire generation to finish.
The flow is:
Groq(openai-model) generates token/chunk
β
Next.js server
β
HTTP stream
β
Chat.tsx
β
Answer component
This means the user can start reading the answer while the model is still generating it.
After the answer finishes, the application also sends the extracted source metadata through the same response stream.
The frontend separates the answer from the source metadata and passes the sources to the Sources component.
Frontend
- Next.js
- React
- TypeScript
- Tailwind CSS
- React Markdown
AI
- Groq(openai-model)
- Vercel AI SDK
Knowledge Layer
- Sanity
- Sanity Context
- Model Context Protocol (MCP)
Deployment
- Vercel
src/
βββ app/
β βββ api/
β β βββ chat/
β β βββ route.ts
β β
β βββ components/
β β βββ Answer.tsx
β β βββ Chat.tsx
β β βββ QuestionInput.tsx
β β βββ Sources.tsx
β β
β βββ page.tsx
β βββ layout.tsx
β
βββ lib/
βββ extract-sources.ts
βββ sanity-mcp.ts
sanity-mcp.tsβ Creates the server-side connection to the Sanity Context MCP endpoint.route.tsβ Runs the Groq(openai-model) agent and exposes the Sanity MCP tools to the model.extract-sources.tsβ Extracts source titles and URLs from the Sanity MCP tool results.Chat.tsxβ Handles the user question, communicates with the API, processes the streamed response, and passes the extracted sources to the UI.Answer.tsxβ Renders the agent response usingreact-markdown.Sources.tsxβ Displays the documentation sources returned by the Sanity Knowledge Base.
Create a .env.local file containing:
SANITY_CONTEXT_MCP_URL=your_sanity_context_mcp_endpoint
SANITY_ORGANIZATION_TOKEN=your_sanity_organization_token
GROQ_API_KEY=your_groq_model_api_keyThese credentials are intentionally kept on the server.
The Sanity organization token is used by the server-side MCP client and is never exposed to the browser.
Do not commit .env.local to the repository.
Clone the repository:
git clone https://github.com/Adhithyan2004/devdocs-agent
cd devdocs-agentInstall dependencies:
npm installCreate .env.local and add the required environment variables.
Start the development server:
npm run devOpen:
http://localhost:3000
The main idea behind this project is separating reasoning from knowledge.
Groq(openai-model) handles:
- Reasoning
- Tool selection
- Answer generation
- Natural language explanation
Sanity handles:
- Structured documentation
- Curated knowledge
- Content management
- Documentation context
MCP handles the connection between the agent and the knowledge layer.
This separation means the documentation can evolve independently from the model.
If the documentation changes, the Knowledge Base can be updated without retraining Gemini.
The architecture therefore looks like:
ββββββββββββββββββββββ
βGroq(openai-model) β
β β
β Reasoning + Agent β
βββββββββββ¬βββββββββββ
β
β MCP
βΌ
ββββββββββββββββββββββ
β Sanity β
β β
β Knowledge + Contentβ
ββββββββββββββββββββββ
The biggest takeaway from this project was that an AI application does not necessarily need to make the model itself bigger or more complex.
A relatively small model can become much more useful for a specific task when it has access to the right external context.
The interesting engineering problem becomes:
How do I give the model the right information at the right time in a controlled way?
Sanity Context MCP provides one way of solving that problem.
It also changes the role of the application from simply being:
Chat UI + LLM
to:
UI
+
Agent
+
Tools
+
Knowledge
+
Grounding
That was the main reason I wanted to build this project.
This is intentionally a small MVP.
It currently does not include:
- User authentication
- Conversation history
- Persistent chat sessions
- User-uploaded documentation
- A custom vector database
- Fine-tuning
- Multiple agents
- Exhaustive coverage of every frontend framework
- Advanced evaluation or automated groundedness scoring
The goal was not to build a complete documentation platform.
The goal was to build a small but real agent that can query real external content and use that content during generation.
Some things I'd like to explore next:
- Expand the curated Knowledge Base
- Add more frontend ecosystems
- Improve source extraction and citation handling
- Let users inspect the retrieved documentation
- Add conversation history
- Add automated evaluation questions
- Compare answers with and without retrieved context
- Measure retrieval quality and groundedness
- Add richer MCP tool usage
- Add more sophisticated retrieval and ranking
π https://devdocs-agent.vercel.app/
Try asking:
What is
useEffectand when should I use it?
or:
What is the difference between
useEffectanduseLayoutEffect?
This project was built for the DEV X Sanity Challenge.
The challenge gave me an opportunity to explore what happens when an AI agent is connected to a real, curated knowledge source instead of relying entirely on its pretrained knowledge.
The final architecture is intentionally small:
User
β
Next.js
β
Groq(openai-model) Agent
β
Sanity Context MCP
β
Sanity Knowledge Base
β
Gemini
β
Markdown Answer + Sources
π Live: https://devdocs-agent.vercel.app/