This guide explains how the context-aware version keeps project knowledge separate and provides relevant context based on your current working directory.
The context-aware server automatically:
- Detects your current project based on project markers (.git, package.json, etc.)
- Scopes searches to the current project by default
- Indexes files into project-specific collections
- Maintains clear boundaries between different projects
# Install globally with context awareness
cd ~/mcp-servers/qdrant-rag
./install_global.shThis automatically configures Claude Code with context awareness enabled.
When you run a command, the server:
- Checks your current working directory
- Looks for project markers going up the directory tree:
.gitdirectorypackage.jsonpyproject.tomlCargo.tomlgo.modpom.xml.project
- Uses the project root directory name as the project identifier
- Creates project-specific collections:
project_<name>_codeandproject_<name>_config
cd ~/projects/my-react-app
# Claude CLI with MCP server
# This indexes only into my-react-app collections
index_directory .
# This searches ONLY in my-react-app by default
search "useState hook implementation"
# Returns: Results only from my-react-app projectcd ~/projects/my-api-backend
# Claude CLI continues...
# Now indexing goes to my-api-backend collections
index_code src/auth.py
# Searches are scoped to my-api-backend
search "authentication middleware"
# Returns: Results only from my-api-backend project# Still in my-api-backend directory
# Search across all projects for a pattern
search "JWT implementation" cross_project=true
# Returns: Results from all indexed projects| Command | Behavior | Example |
|---|---|---|
index_code |
Indexes to current project | index_code src/main.py |
index_directory |
Indexes to current project | index_directory . |
search |
Searches current project only | search "error handling" |
search_code |
Searches current project code | search_code "async function" |
| Command | Parameter | Example |
|---|---|---|
search |
cross_project=true |
search "design pattern" cross_project=true |
search_code |
cross_project=true |
search_code "logger" cross_project=true |
index_code |
force_global=true |
index_code ~/scripts/util.py force_global=true |
| Command | Purpose | Example |
|---|---|---|
get_context |
Show current project info | get_context |
switch_project |
Change project context | switch_project ~/projects/other-app |
# Working on user service
cd ~/projects/microservices/user-service
# Index the service
index_directory .
# Search within user service only
search "user validation"
# Need to check how auth service does it?
search "token validation" cross_project=true
# Switch to auth service
switch_project ~/projects/microservices/auth-service
# Now searches default to auth service
search "token generation"# Morning: Working on React frontend
cd ~/projects/app-frontend
index_directory . patterns=["*.js", "*.jsx", "*.css"]
search "form submission" # Only frontend results
# Afternoon: Switch to backend
cd ~/projects/app-backend
index_directory . patterns=["*.py", "*.yml"]
search "form handler" # Only backend results
# Need to see the full flow?
search "form data flow" cross_project=true# Working on main library
cd ~/projects/my-awesome-lib
index_directory src
search "public API" # Only library code
# Checking example usage
cd ~/projects/my-awesome-lib/examples
index_directory .
search "import MyLib" # Only example code
# See all usages across library and examples
cd ~/projects/my-awesome-lib
search "MyLib usage" cross_project=true- Search results are relevant to your current task
- No confusion from similar code in other projects
- Faster, more focused results
- Client A's code doesn't appear when working on Client B
- Personal projects stay separate from work projects
- Experimental code doesn't pollute production searches
- Claude understands your current project context
- Suggestions are relevant to the codebase you're working on
- No accidental mixing of different project patterns
- Cross-project search for finding patterns
- Global search for utility functions
- Easy project switching for multi-project work
The server recognizes these files/directories as project roots:
.git- Git repositoriespackage.json- Node.js projectspyproject.toml- Python projectsCargo.toml- Rust projectsgo.mod- Go projectspom.xml- Java/Maven projects.project- Generic project marker
These are automatically excluded from indexing:
.git/,__pycache__/,node_modules/.venv/,venv/,env/build/,dist/,.cache/,tmp/
If get_context shows no project:
- Check if you have a project marker in parent directories
- Create a
.projectfile in your project root - Use
force_global=truefor standalone scripts
If files are going to the wrong project:
- Check
get_contextto see current detection - Ensure you're in the right directory
- Consider adding a project marker closer to your files
If project structure changed:
- Clear the old project:
clear_project "old_name" - Re-index from the new location
-
Start Each Session with Context Check
get_context -
Index at Project Start
index_directory . -
Use Project Defaults
- Let the server handle project detection
- Only use
cross_project=truewhen needed
-
Organize Projects Clearly
- Keep projects in separate directories
- Use standard project markers
- Avoid nested projects
This context-aware approach ensures Claude Code always has the right context for your current work!