MCP and skills in AI agents: integrating external knowledge bases
published: ⏰ 8A slightly belated article: last year I planned to write about using MCP and skills in AI agents. The main goal is to enable retrieval of data from an external knowledge base for use in AI agents. This is probably no longer relevant, and many aspects are well-known, but better late than never.
Introduction
As stated earlier, the main goal is to retrieve accurate data from an external knowledge base for use in AI agents. The problem with agents, and LLMs in general, is that they contain knowledge as of a specific point in time, but they don’t have access to up-to-date data. All they know is what was in their training datasets. A second, more critical problem is hallucinations, when LLMs produce information that doesn’t exist or doesn’t correspond to reality.
The solution is to use external data sources and integrate them into the agent workflow. This idea isn’t new and has been used for a long time; for example, Context7 for retrieving information on libraries and frameworks.
General interaction scheme
For this example, I’ll use a combination of tekBlueprint.kbase with MCP, a skill, and a CLI agent for coding.
Architecture components:
- AI Agent acts as the central orchestrator. It accepts the user’s task, determines what is needed to solve it, and selects the tools or data required.
- MCP Client is a built-in agent module implementing the MCP protocol. It is responsible for establishing a connection to the MCP Server (API), sending JSON-RPC requests, and receiving responses.
- SKILLS.md is a knowledge base skill. Information loaded into the context “trains” the model to work with a specific knowledge base server. It defines prompts (if any), rules for using MCP tools (Tools), and access to resources (Resources).
- Knowledge Base is an information repository from which the necessary data will be retrieved during agent execution.
- MCP Server (MCP API) is an intermediate layer (gateway) that implements the MCP specification. Provides the agent with a standardized interface: Tools (for performing actions, such as searching) and Resources (for reading data, such as specifications).
- The Internal API processes requests from the MCP API and the agent. For example, it searches for data in the knowledge base or executes calculation logic based on the agent’s request.
- The Databases layer is responsible for long-term storage of the knowledge base and searching within it. It can be organized using a single database type or consist of groups of data sources for different use cases.
Data flow:
- The user asks a question in chat with the agent (AI Agent).
- The agent analyzes the request, activates the skill (SKILLS.md) if available, and understands that the knowledge base needs to be accessed.
- Through the client (MCP Client), the agent sends a request to the server (MCP Server) (e.g., tools/call for searching or resources/read for reading).
- The server (MCP Server) receives the request, authenticates it, and converts it into a request understandable by the internal API (Internal API).
- The Internal API processes the request or requests data from the database (Databases) via REST, gRPC, or a direct SQL/vector query.
- The knowledge base server (Databases) finds relevant documents/facts and returns them back along the Internal API → MCP Server chain.
- The server (MCP Server) packages the result in MCP format and passes it back to the agent (AI Agent).
- The agent (AI Agent) enriches its context with the received data and generates a final response to the user.
This scheme ensures loose coupling: the AI agent does not need to know the internal structure of the database; it only needs to work with the standardized MCP interface. Additionally, the Internal API can be moved to separate microservices if scaling to suit load is required.
Model Context Protocol (MCP)
MCP (Model Context Protocol) is a protocol developed to standardize interactions between LLM and external data sources. MCP allows agents to request data from various sources, hiding all the logic behind interactions with various data sources and business logic within. I believe there are MCP server implementations for all popular development languages. Therefore, it’s not difficult to find examples: here is a list of SDK Model Context Protocol servers, grouped by development language, as well as implementation examples.
If Java is your primary development language, you can use Spring AI. MCP for tekBlueprint.kbase is built on this very framework. It allows for the development of all the basic tools, such as resources, resource templates, utilities, autocompletion, and so on.
It is necessary to consider the architecture and structure of the resources and utilities it will provide.
Tools, Resources, Prompts
The problems of bounded context in LLM and the loss of focus on large contexts require the MCP server to be able to return data in a compact format. This applies both to the format for transferring the resources themselves and to limits on the number of objects when searching for data. For example, as an alternative to JSON, there is the TOON format, which allows for token savings. Standard page/pageSize and filters that the agent can specify at its discretion can be used for limits.
It is also worthwhile to provide detailed descriptions of utilities and parameters in JSON Schema. Although not always the case, LLMs rely on them for tool selection.
Security and Access Control
This is an important point if you plan to work with sensitive data or if this is a public server.
As always, all input data from clients must be validated before calling business logic. It is important to limit the access scope of tools. This applies to access to the file system, databases, and so on. Standard checks should also be used here: request limitation, processing timeouts, and so on.
If the data may contain information accessible only to a limited number of people, then authentication of the agent and user is required before transferring the data. The approach here is similar to a regular API, for example, for a UI. We check access rights and filter only accessible data. For example, obtaining hourly rates by job title might be available only to managers, while empty values would be returned to regular users.
Ideally, running the server in separate processes/containers would reduce the risk of data compromise due to vulnerabilities.
Knowledge Base
Any storage system can be used as a knowledge base, from a simple file system to a full-fledged database. It is important that the data is structured and easily indexed for quick searching and retrieval.
As mentioned above, fuzzy data search is necessary, as agents don’t always know exactly which documents are needed. The process involves gradually narrowing the selection to the required data. Implementation using standard relational databases and SQL can be problematic: additional databases or the inclusion of additional engines for full-text or vector search are required. There are currently a huge number of such database options: Meilisearch, OpenSearch, Qdrant, Chroma, Weaviate, Pinecone, Milvus, and others. Choose one that suits your requirements and workload.
Agents and Skills
An AI agent is an autonomous program (CLI, service, etc.) that makes decisions and takes actions to achieve goals based on external data and requests. In the context of modern large language models (LLM), an AI agent is not just a chatbot, but a system capable of planning, using tools, and iteratively executing tasks.
Skills for AI agents are highly specialized and reusable descriptions of functionality that the agent can invoke to perform specific actions. These are “tools in the agent’s hands,” allowing it to go beyond text generation and interact with the outside world.
For an agent, the primary source of information on how to interact with the MCP is its API schema. When implementing an MCP server, it is important to understand that agents will not always be able to understand how to work with it from a simple description of utilities and resources. Therefore, it is essential to create correct and accurate descriptions for utilities and resources. For example, working with a knowledge base requires a specific process due to the large volume of data and contextual constraints. Consequently, the agent must clearly understand which tools and resources they should use to optimally search it.
One way to explicitly instruct the agent how to work with the knowledge base is to use additional skills that are loaded when the skill is invoked. For example, a skill defines which tools and resources are available, specifies the sequence of operations, as well as when it should be activated and where to use it. Examples of skills can be found on the Agent Skills Marketplace; in just a few months, their number has grown to almost a million.
Potential Issues
When linking agents with MCPs and skills, there were compatibility and operational issues.
Some popular agents don’t fully support the entire MCP specification. For example, OpenCode still can’t work with resources, only with utilities. Therefore, utilities must be written to replicate resource data. RooCode, however, can work with resources and understands when to request them. Therefore, it’s necessary to consider such limitations and create a redundant API if compatibility with a large set of agents is planned.
Another issue is that agents sometimes “lose” the requirement to use a skill or MCP during successive requests. For example, the first request is processed using data from the MCP, while subsequent requests and responses will be based on data or model assumptions without additional database queries.
Implementation specifics of specific agents or API compatibility issues. For example, Spring AI uses a Java SDK with an outdated MCP, while agents use a newer one. This may not be related, but some agents frequently experience connection losses with the MCP server and require reconnection.
Example
Below is a short example of how tekBlueprint.kbase works with the MCP, a skill, and a CLI agent for coding. The data is from 2025 and is not entirely complete, but it’s good enough to understand the process.
Conclusion
Until the fundamental problems of current generative models with data aging and hallucinations are resolved, additional data sources and tools will be needed to support the agent and model when solving the problem. MCP and knowledge bases are quite a convenient and useful tool in such cases.