Get the FREE Ultimate OpenClaw Setup Guide →

RAG

Simple RAG implementation from scratch using MCP, focusing on Perception, Memory, Decision and Action

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio cr21-rag-mcp uvx cr21-rag-mcp \
  --env RAG_MCP_ENV="placeholder or describe if needed"

How to use

The cr21-rag-mcp server implements a Retrieval-Augmented Generation (RAG) agent that uses the Model Context Protocol (MCP) to connect to data sources and tooling for ecommerce product search. It follows a four-stage cognitive flow—Perception, Memory, Decision, and Action—allowing the agent to interpret user queries, retrieve relevant context from memory, decide on a course of action, and execute tools via MCP to fetch product information. When a user asks for products, the Perception component extracts intent and attributes (e.g., capacity, product type, activity). The Memory component recalls prior interactions and relevant context to maintain continuity across turns. The Decision stage plans an action or answer, and the Action stage uses MCP-enabled connectors to query product databases, search documents, or external APIs, returning a structured result with product recommendations, links, and attributes.

To use the server, send a user query through an MCP client that targets the cr21-rag-mcp endpoint. The agent will perform a guided sequence: it will normalize the query, identify product attributes (like capacity, activity, and category), retrieve similar past interactions to enrich context, decide which tools to invoke (e.g., search_product_documents, product database queries), and then execute those tools via MCP to assemble a final answer with product suggestions and links. The system is designed to integrate with connectors such as product catalogs, knowledge bases, and external retailer APIs, enabling real-time, context-rich product recommendations.

How to install

Prerequisites:

  • Python/uv framework installed (uvx package manager) or an environment capable of running MCP UV-based servers
  • Access to the internet to fetch dependencies
  • Basic familiarity with MCP workflow and client connections

Step 1: Prepare the environment

  • Create a virtual environment (optional but recommended) python -m venv venv source venv/bin/activate # on Unix/macOS .\venv\Scripts\activate # on Windows

Step 2: Install the MCP server package

  • Using uvx (Python): uvx install cr21-rag-mcp

Step 3: Run the MCP server

  • Start the server (adjust command if your environment differs): uvx run cr21-rag-mcp

Step 4: Verify the server is running

  • Send a test request to the MCP server endpoint (via MCP client) and check for a valid response containing product recommendations and MCP tool invocations.

Notes:

  • If any environment variables are required (credentials, API endpoints), set them in your environment or a .env file and load them before starting the server.
  • If your deployment uses Docker, you can adapt the command to your container runtime (see the mcp_config schema for the expected fields).

Additional notes

Tips and considerations:

  • Ensure product data sources (catalogs, knowledge bases, external APIs) are accessible by the MCP server and properly indexed for fast retrieval.
  • Tune memory and embedding retrieval settings (e.g., FAISS index) to balance recall vs. latency for large catalogs.
  • Common issues include missing connectors or authentication failures; verify that MCP tool hints (e.g., search_product_documents) map to functional tool adapters in your environment.
  • When debugging, inspect Perception outputs and Memory retrieval results to understand how the agent reasons about queries.
  • Environment variables for API keys or service endpoints should be documented and secured; avoid hardcoding credentials in the codebase.

Related MCP Servers

Sponsor this space

Reach thousands of developers