HR Policy Chatbot MCP server

Enables HR departments to provide workplace policy information through a RAG-based chatbot that indexes, retrieves, and generates answers from PDF documentation with email sending capabilities.
Back to servers
Provider
ImVirtue
Release date
Apr 14, 2025
Language
Python
Stats
4 stars

This MCP server implementation creates a RAG-based chatbot designed to retrieve and answer questions from PDF documents. It integrates OpenAI models with LangChain utilities through the Model Context Protocol (MCP) server to provide relevant information from uploaded documents.

Installation and Setup

Prerequisites

  • Python 3.7+
  • OpenAI API key

Installation Steps

  1. Clone the repository and navigate to the project directory:
git clone https://github.com/username/rag-chatbot-mcp-server.git
cd rag-chatbot-mcp-server
  1. Install the required dependencies:
pip install -r requirements.txt
  1. Set up your OpenAI API key as an environment variable:
export OPENAI_API_KEY="your-api-key-here"

Usage

Starting the Application

Run the Streamlit application with:

streamlit run app.py

Using the Chatbot

  1. Upload PDF Documents:

    • Use the upload interface to select and upload your PDF files
    • The system will automatically parse and index the document content
  2. Ask Questions:

    • Type your question in the input field
    • The chatbot will retrieve relevant information from the uploaded PDFs
    • Responses are generated based on the document content

How It Works

The application follows these steps when processing queries:

  1. Your uploaded PDF is parsed using PDFPlumberLoader
  2. Text is split into manageable chunks with RecursiveCharacterTextSplitter
  3. Chunks are indexed in a vector store with embeddings from OpenAIEmbeddings
  4. When you ask a question, the system:
    • Performs a similarity search to find relevant document chunks
    • Combines your question with retrieved context in a prompt
    • Generates a comprehensive answer using GPT-4

Advanced Configuration

Customizing Chunking Parameters

You can adjust how documents are chunked for better retrieval:

text_splitter = RecursiveCharacterTextSplitter(
    chunk_size=1000,  # Adjust based on your document complexity
    chunk_overlap=200,  # Increase for better context preservation
    length_function=len,
)

Modifying the Vector Search

To change how many document chunks are retrieved:

docs = docsearch.similarity_search(query, k=4)  # Adjust k for more/fewer results

Changing the LLM Model

To use a different OpenAI model:

llm = ChatOpenAI(
    model_name="gpt-4",  # Change to gpt-3.5-turbo for faster/cheaper responses
    temperature=0.2,
)

Troubleshooting

  • Empty Responses: Ensure your PDF has extractable text and not just images
  • Irrelevant Answers: Try adjusting the number of chunks retrieved or the chunk size
  • API Errors: Verify your OpenAI API key is set correctly and has sufficient quota

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later