Knowledge Base MCP Server
This is a knowledge base server that allows you to upload files, search them using semantic search, and ask questions about them using a LangChain agent.
Features
- File Management: Add, list, and read files in the knowledge base.
- Semantic Search: Search for documents using semantic similarity.
- LangChain Agent: Ask questions about the documents in the knowledge base.
Setup
-
Install dependencies:
bash pip install -r requirements.txt -
Set Hugging Face API Token:
To use the LangChain agent, you need to set your Hugging Face API token as an environment variable:bash export HUGGINGFACEHUB_API_TOKEN="your-token-here" -
Run the server:
bash python app.py
The server will be running athttp://localhost:8000.
API
Files
POST /files/: Upload a file.- Form Data:
file -
Example:
bash curl -X POST -F "file=@/path/to/your/file.txt" http://localhost:8000/files/ -
GET /files/: List all files. -
Example:
bash curl http://localhost:8000/files/ -
GET /files/: Read a file. - Example:
bash curl http://localhost:8000/files/your-file.txt
Search
POST /index/: Re-index all documents.-
Example:
bash curl -X POST http://localhost:8000/index/ -
POST /search/: Search for documents. - Body:
{"query": "your search query"} - Example:
bash curl -X POST -H "Content-Type: application/json" -d '{"query": "your search query"}' http://localhost:8000/search/
Agent
POST /agent/: Ask a question to the agent.- Body:
{"query": "your question"} - Example:
bash curl -X POST -H "Content-Type: application/json" -d '{"query": "your question"}' http://localhost:8000/agent/