NetContextServer empowers AI coding assistants like Cursor AI to deeply understand your .NET codebase through the Model Context Protocol (MCP). This means more accurate code suggestions, better answers to your questions, and a more productive coding experience.
- 🧠 Semantic Code Search: Find code by describing what you're looking for in natural language
- 🔍 Intelligent Navigation: Help AI tools understand your project structure and dependencies
- 🛡️ Built-in Security: Safe file access with automatic protection of sensitive data
- 🚀 Cursor AI Integration: Seamless setup with Cursor AI for enhanced coding assistance
- 📦 Package Analysis: Understand your dependencies and get update recommendations
- 🔍 Deep Dependency Visualization: See transitive dependencies with interactive, color-coded graphs
- 🧩 Smart Grouping: Visually group related packages for easier navigation
- 📊 Update Recommendations: Identify outdated packages and security issues
- ⚡ Fast & Efficient: Quick indexing and response times for large codebases
- Clone & Build:
git clone https://github.com/willibrandon/NetContextServer.git
cd NetContextServer
dotnet build- Set Up (optional, for semantic search):
# Set Azure OpenAI credentials in environment:
AZURE_OPENAI_ENDPOINT=your_endpoint
AZURE_OPENAI_API_KEY=your_key- Start Using:
# Point to your project
dotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory "path/to/your/project"
# Try semantic search
dotnet run --project src/NetContextClient/NetContextClient.csproj -- semantic-search --query "find authentication logic"👉 Read our Getting Started Guide for detailed setup instructions and best practices.
- Open Cursor AI
- Press
Cmd/Ctrl + Shift + P - Type "Configure MCP Server"
- Enter:
{
"command": "dotnet",
"args": ["run", "--project", "path/to/NetContextServer/src/NetContextServer/NetContextServer.csproj"]
}Now Cursor AI can understand your codebase! Try asking it questions like:
- "List all .NET source files in this project directory"
- "Search for exact text matches in the code files"
- "Analyze NuGet packages in all projects"
- "Get the current list of ignore patterns"
- "Add these ignore patterns: .generated.cs, bin/"
- "List all .csproj files in this directory"
- "Show me the contents of this file"
- "What's the current base directory for file operations?"
- Getting Started Guide - Quick setup and first steps
- Tool Reference - Detailed tool documentation
- Configuration Guide - Advanced configuration options
- Integration Examples - Using with different AI tools
- Contributing Guide - How to help improve NetContextServer
- 📁 Project & File Listing: List all projects and source files in your solution
- 🔍 Code Search: Search through your codebase for specific patterns or text
- 🧠 Semantic Search: Find code based on meaning, not just exact text matches
- 📖 File Content Access: Read source files with safety checks and size limits
- 🛡️ Security: Built-in safeguards for sensitive files and directory access
- 🎯 Pattern Management: Flexible ignore patterns for controlling file access
- Clone the repository:
git clone https://github.com/willibrandon/NetContextServer.git
cd NetContextServer- Build the solution:
dotnet build- Run the tests (optional):
dotnet testUse the client to interact with your codebase:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- <command> [options]For semantic search functionality, you need to set up the following environment variables:
AZURE_OPENAI_ENDPOINT: Your Azure OpenAI endpoint URLAZURE_OPENAI_API_KEY: Your Azure OpenAI API key
- Set Base Directory:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory "D:\YourProject"- Get Base Directory:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- get-base-dir- List Projects:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- list-projects-in-dir --directory "D:\YourProject\src"- List Source Files:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- list-source-files --project-dir "D:\YourProject\src\YourProject"- Analyze Packages:
# Set your base directory first
dotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory "path/to/your/project"
# Run the package analysis
dotnet run --project src/NetContextClient/NetContextClient.csproj -- analyze-packagesExample output:
Project: MyProject.csproj
Found 2 package(s):
- ✅ Newtonsoft.Json (13.0.1)
Used in 5 location(s)
Dependencies:
└─ Newtonsoft.Json
└─ System.*
└─ System.ComponentModel
- 🔄 Microsoft.Extensions.DependencyInjection (5.0.2 → 6.0.1)
Update available: 6.0.1
Dependencies:
└─ Microsoft.Extensions.DependencyInjection
└─ Microsoft.*
└─ Microsoft.Extensions.DependencyInjection.Abstractions
- Text Search:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- search-code --text "authentication"- Semantic Search:
# Search with default number of results (5)
dotnet run --project src/NetContextClient/NetContextClient.csproj -- semantic-search --query "handle user authentication"
# Search with custom number of results
dotnet run --project src/NetContextClient/NetContextClient.csproj -- semantic-search --query "database connection string" --top 10The semantic search feature:
- Uses embeddings to find code based on meaning
- Returns code snippets ranked by relevance
- Shows line numbers and similarity scores
- Automatically indexes your code on first search
- Add Ignore Patterns:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- add-ignore-patterns --patterns "*.txt" "*.log"- View Current Patterns:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- get-ignore-patterns- Remove Specific Patterns:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- remove-ignore-patterns --patterns "*.txt"- Clear User Patterns:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- clear-ignore-patterns- View State File Location:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- get-state-file-locationThe following patterns are ignored by default to protect sensitive information:
*.env- Environment filesappsettings.*.json- Application settings*.pfx- Certificate files*.key- Key files*.pem- PEM files*password*- Files containing "password" in the name*secret*- Files containing "secret" in the name
- Path Safety: Files can only be accessed within the specified base directory
- Pattern Validation: Ignore patterns are validated for proper syntax
- Size Limits: Large file contents are truncated to prevent memory issues
- Sensitive File Protection: Built-in patterns protect common sensitive files
- Set the base directory for your project:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory "D:\Projects\MyApp"- Set up custom ignore patterns:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- add-ignore-patterns --patterns "*.generated.cs" "*.designer.cs"- List all projects:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- list-projects-in-dir --directory "D:\Projects\MyApp\src"- Analyze your project's package dependencies:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- analyze-packages- Search for authentication-related code:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- semantic-search --query "user authentication and authorization logic"NetContextServer implements the Model Context Protocol (MCP), allowing seamless integration with AI coding assistants that support this protocol, such as:
- Cursor AI: Provides your AI assistant with full context of your codebase for more accurate code generation and assistance
- Other MCP-compatible tools: Any tool that implements the Model Context Protocol can connect to NetContextServer
To use with Cursor AI:
- Configure Cursor AI to use the NetContextServer as its MCP provider
- Enjoy enhanced code assistance with full codebase context
For testing and debugging MCP interactions, you can use CursorMCPMonitor, a real-time monitoring tool that helps track and analyze communications between MCP clients and servers.
The Model Context Protocol enables AI tools to request specific information about your codebase, making the AI's suggestions more relevant and accurate to your specific project structure and coding patterns.
The server provides clear error messages for common scenarios:
- Directory not found
- Access denied (outside base directory)
- Invalid patterns
- File size limits exceeded
- Restricted file types
- Missing environment variables for semantic search
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
