This guide covers advanced configuration options for NetContextServer to help you customize and optimize its behavior for your specific needs.
Required for semantic search functionality:
# Azure OpenAI Settings
AZURE_OPENAI_ENDPOINT=your_azure_openai_endpoint
AZURE_OPENAI_API_KEY=your_azure_openai_keyThe base directory is a critical security feature that defines the root of your workspace. All file operations are restricted to this directory and its subdirectories.
You can set the base directory in several ways:
- Command Line:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory "D:\YourProject"- Environment Variable (optional):
NETCONTEXT_BASE_DIR=D:\YourProject- Set to your solution or project root
- Ensure it contains all necessary source files
- Avoid setting to system directories or root paths
- Use absolute paths for reliability
NetContextServer uses ignore patterns to protect sensitive files and optimize performance.
These patterns are always active and cannot be disabled:
*.env
appsettings.*.json
*.pfx
*.key
*.pem
*password*
*secret*
Add your own patterns for project-specific needs:
# Add patterns
dotnet run --project src/NetContextClient/NetContextClient.csproj -- add-ignore-patterns --patterns "*.generated.cs" "bin/*" "obj/*"
# View current patterns
dotnet run --project src/NetContextClient/NetContextClient.csproj -- get-ignore-patternsPatterns are stored in ignore_patterns.json. Location can be found using:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- get-state-file-location-
Size Limits
- Large files are truncated to prevent memory issues
- Default limit: 1MB per file
- Binary files are blocked
-
Path Validation
- All file paths must be within base directory
- Symbolic links are resolved and validated
- Parent directory traversal (
..) is blocked
Text search is configured for:
- Case-sensitive matching
- Regular expression support
- Line number reporting
- Context lines around matches
Semantic search can be customized with:
- Results Count
# Customize number of results
dotnet run --project src/NetContextClient/NetContextClient.csproj -- semantic-search --query "error handling" --top 10- Index Management
- Files are automatically indexed on first search
- Index is maintained in memory for performance
- Reindexing occurs when files change
-
Excluded Directories
binandobjdirectories are skipped by default- Add custom directories to ignore for faster scanning
-
File Type Filtering
- Focus on relevant file types
- Add ignore patterns for non-code files
-
File Content Caching
- Recently accessed files are cached
- Large files are read in chunks
-
Search Index
- Semantic search index is optimized for speed
- Index is updated incrementally
- MCP Server Configuration
{
"command": "dotnet",
"args": ["run", "--project", "path/to/NetContextServer/src/NetContextServer/NetContextServer.csproj"]
}- Recommended Settings
- Keep server running for better performance
- Configure in workspace settings for project-specific setup
For debugging MCP communication:
- Install CursorMCPMonitor
- Configure logging level
- Monitor real-time interactions
Available log levels:
- ERROR: Critical issues
- WARN: Important warnings
- INFO: General operation info
- DEBUG: Detailed debugging info
- Server status
- Connection details
- Operation timing
- Error traces
-
Project Structure
- Set base directory at solution root
- Use consistent file organization
- Follow standard .NET project layout
-
Security
- Review ignore patterns regularly
- Keep sensitive files outside source tree
- Use environment variables for secrets
-
Performance
- Optimize ignore patterns
- Clean up unused files
- Monitor memory usage
-
Integration
- Test configuration changes
- Verify file access patterns
- Monitor error logs
-
Access Denied
- Verify base directory setting
- Check file permissions
- Review ignore patterns
-
Search Not Working
- Verify Azure OpenAI credentials
- Check file indexing status
- Review search patterns
-
Performance Issues
- Optimize ignore patterns
- Clean up temporary files
- Review large file handling