Creating an agent leveraging documentation
In this example, we're going to crawl a documentation website, store the content in a vector database and leverage it to anwser questions about it.
Create the vector database
We're going to use the doc2vec project to crawl the MCP documentation website and store the content in a sqlite-vec database.
Clone the doc2vec
repo:
git clone https://github.com/kagent-dev/doc2vec.git
Install the dependencies:
cd doc2vecnpm install
Update the configuration file to crawl the MCP documentation sqlite:
cat <<EOF > config.yamlsources:- type: websiteproduct_name: 'mcp'version: 'latest'url: 'https://modelcontextprotocol.io/'max_size: 1048576database_config:type: 'sqlite'params:db_path: './mcp.db'EOF
Launch the process:
npm start
It will take several minutes to complete.
Create an MCP server to use the MCP documentation database
Now that we have the database, we can create an MCP server to leverage it.
The goal is to deploy it on Kubernetes to allow our agent to use it.
To simplify the process, we're going to store the database in the Docker image.
Let's build and push the Docker image:
cd mcpcp ../mcp.db .docker build -t <your docker repository> .docker push <your docker repository> .
Deploy the MCP server
Create a Secret for the OpenAI API Key which is going to be used to create the embeddings:
kubectl create secret generic mcp-secrets \--from-literal=OPENAI_API_KEY=<your_openai_api_key>
Create a ConfigMap for the Database Configuration:
kubectl create configmap mcp-config \--from-literal=SQLITE_DB_DIR=/data \--from-literal=PORT=3001
Create a file named deployment.yaml
:
apiVersion: apps/v1kind: Deploymentmetadata:name: mcp-sqlite-veclabels:app: mcp-sqlite-vecspec:replicas: 1selector:matchLabels:app: mcp-sqlite-vectemplate:metadata:labels:app: mcp-sqlite-vecspec:containers:- name: mcp-sqlite-vecimage: <your docker repository>imagePullPolicy: Alwaysports:- containerPort: 3001env:- name: OPENAI_API_KEYvalueFrom:secretKeyRef:name: mcp-secretskey: OPENAI_API_KEY- name: SQLITE_DB_DIRvalueFrom:configMapKeyRef:name: mcp-configkey: SQLITE_DB_DIR- name: PORTvalueFrom:configMapKeyRef:name: mcp-configkey: PORT
Apply it:
kubectl apply -f deployment.yaml
Create a file named service.yaml
:
apiVersion: v1kind: Servicemetadata:name: mcp-sqlite-vecspec:selector:app: mcp-sqlite-vecports:- port: 3001targetPort: 3001type: ClusterIP
Apply it:
kubectl apply -f service.yaml
Use the MCP server in kagent
In the kagent UI, click on Tools
and then on Manage tool servers
.

Click on Add Server
.
Call it sqlite-vec
.
Select URL
and use http://mcp-sqlite-vec.default:3001/sse
.

Click on Add Server
.
After refreshing the page, you should see the query-documentation
tool being discovered.

Create the MCP agent
Click on New Agent
Use the following information:
- Agent Name: mcp-agent
- Description: The MCP agent is answering questions about MCP, using the MCP documentation
- Agent Instructions: Use your tool to answer any question about the Model Context Protocol (MCP). Use
mcp
for the product andlatest
for the version.
Click on Add Tools
.
Select the query-documentation
tool.

Congratulations, the agent is ready !
Use the MCP agent
Click on the agent and ask a question.
For example, How can you build an MCP server using sse ?

As you can see, the agent has used the query-documentation
tool to answer the question.