A Model Context Protocol (MCP) server that provides tools for searching personal notes using vector embeddings, performing basic calculations, and accessing weather information.
This project implements an MCP server that combines multiple tools:
- Note Search: Semantic search through your notes using ChromaDB and HuggingFace embeddings
- Math Operations: Basic arithmetic functions (add, subtract)
- Weather Services: Get weather alerts and forecasts via the National Weather Service API
notes-mcp-server/
├── mcp_server.py # Main MCP server with all tools
├── seeder.py # Script to process and embed documents
├── tools.json # Tool definitions (for external MCP clients)
├── data/ # Directory containing your notes/documents
│ ├── note1.txt
│ └── note2.txt
├── chroma_db/ # ChromaDB vector database (generated)
└── weather/ # Weather service module
├── __init__.py
└── weather_service.py
- Searches through your notes using semantic similarity
- Returns the top 3 most relevant chunks with source information
- Uses HuggingFace embeddings (
all-MiniLM-L6-v2) for vector search
add_numbers(a, b): Add two numberssubtract_numbers(a, b): Subtract two numbers
get_alerts(state): Get active weather alerts for a US stateget_forecast(latitude, longitude): Get 5-day weather forecast for a location
- Python 3.8+
- pip (Python package manager)
-
Clone or navigate to the project directory:
cd notes-mcp-server -
Create a virtual environment (recommended):
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install mcp fastmcp langchain-community langchain-huggingface chromadb httpx
Or install individually:
pip install mcp pip install fastmcp pip install langchain-community pip install langchain-huggingface pip install chromadb pip install httpx
Place your text files (.txt) or PDF files (.pdf) in the data/ directory:
# Example: Copy your notes
cp ~/my-notes/*.txt data/
cp ~/documents/*.pdf data/Run the seeder script to process your documents:
python seeder.pyThis script will:
- Load all
.txtand.pdffiles from thedata/directory - Split them into chunks (1000 characters with 200 character overlap)
- Generate embeddings using HuggingFace's
all-MiniLM-L6-v2model - Store them in ChromaDB at
chroma_db/
Note: The seeder will delete and recreate the database each time it runs. To update your notes, simply add/modify files in data/ and run the seeder again.
Run the main server:
python mcp_server.pyThe server runs using stdio transport, which is compatible with MCP clients like Cursor, Claude Desktop, etc.
-
Loading (
load_documents()):- Scans the
data/folder for.txtand.pdffiles - Uses LangChain loaders to extract text
- Attaches metadata (source file, etc.)
- Scans the
-
Chunking (
chunk_documents()):- Splits documents into smaller chunks (1000 chars, 200 overlap)
- Uses
RecursiveCharacterTextSplitterwith smart separators - Adds chunk IDs to metadata
-
Embedding & Storage (
embed_and_store()):- Generates embeddings using HuggingFace's sentence transformer
- Stores vectors in ChromaDB with persistence
- Database is saved to
chroma_db/directory
When you call search_my_notes(query):
- The query is embedded using the same model
- ChromaDB performs similarity search
- Returns top 3 most relevant chunks with source information
Edit seeder.py to modify chunking parameters:
splitter = RecursiveCharacterTextSplitter(
chunk_size=1000, # Change this
chunk_overlap=200, # Change this
separators=["\n\n", "\n", " ", ""],
)Edit the model name in both seeder.py and mcp_server.py:
# In seeder.py (line 89)
embedding_model = HuggingFaceEmbeddings(
model_name="sentence-transformers/all-MiniLM-L6-v2" # Change this
)
# In mcp_server.py (line 35)
embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2") # Change thisImportant: Use the same model in both files for consistent search results.
Currently supported:
.txtfiles (viaTextLoader).pdffiles (viaPyPDFLoader)
To add more file types, modify load_documents() in seeder.py:
loaders = {
".txt": TextLoader,
".pdf": PyPDFLoader,
".md": MarkdownLoader, # Add new types here
}Add this to your MCP client configuration:
{
"mcpServers": {
"notes-mcp-server": {
"command": "python",
"args": ["/path/to/notes-mcp-server/mcp_server.py"]
}
}
}The tools.json file provides tool definitions for external MCP clients. Note that the weather tools are defined here but not currently integrated into the main server. To use them, you would need to import the weather module in mcp_server.py.
If you see errors about the database not existing:
- Make sure you've run
seeder.pyfirst - Check that
chroma_db/directory exists - Verify files exist in the
data/directory
If you get import errors:
- Ensure all dependencies are installed:
pip install -r requirements.txt(if available) - Activate your virtual environment
- Check Python version:
python --version(should be 3.8+)
If searches return no results:
- Verify documents were processed: check
chroma_db/exists and has files - Re-run
seeder.pyto rebuild the database - Check that your query is relevant to the content in your notes
Weather services use the National Weather Service API (no API key required):
- Ensure you have internet connectivity
- Check that state codes are valid (e.g., "CA", "NY", "TX")
- Verify coordinates are valid (latitude: -90 to 90, longitude: -180 to 180)
To add a new tool to the MCP server:
- Open
mcp_server.py - Add a new function with the
@mcp.tool()decorator:
@mcp.tool()
async def my_new_tool(param: str) -> str:
"""Description of what the tool does."""
# Your implementation
return result- The tool will automatically be available to MCP clients
Test individual components:
# Test seeder
python seeder.py
# Test server (will run until interrupted)
python mcp_server.pymcp_server.py: Main server file that defines all MCP tools and runs the serverseeder.py: Processes documents fromdata/and creates the vector databasetools.json: Tool schema definitions for external MCP clientsweather/weather_service.py: Weather API integration (currently separate module)data/: Directory for your notes and documentschroma_db/: Generated vector database (do not edit manually)
- The vector database (
chroma_db/) is persistent and will be reused between runs - Running
seeder.pywill delete and recreate the database - The embedding model is downloaded automatically on first use
- Weather services require internet connectivity
- The server uses stdio transport for MCP communication
This project appears to be for personal use. Modify as needed for your requirements.
Feel free to extend this project with:
- Additional file type support
- More sophisticated search features
- Additional tools and integrations
- Better error handling and logging