local-only server
The server can only run on the client’s local machine because it depends on local resources.
Integrations
Provides deep codebase understanding for .NET projects, including semantic code search, project structure navigation, and test coverage analysis.
Enables package analysis for NuGet dependencies, including visualization of transitive dependencies, update recommendations, and security issue identification.
Leverages Azure OpenAI for semantic code search capabilities, finding code based on meaning rather than exact text matches.
NetContextServer
🔍 Supercharge Your AI Coding Assistant with Deep .NET Codebase Understanding
NetContextServer empowers AI coding assistants like VS Code 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.
✨ Key Features
- 🧠 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
- 🚀 VS Code Integration: Seamless setup with VS Code 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
- 📊 Test Coverage Analysis: Deep insights into your test coverage
- 🎯 Multi-Format Support: Parse coverage data from Coverlet, LCOV, and Cobertura XML
- 📈 Detailed Reports: File-level coverage percentages and uncovered line tracking
- 🔄 Branch Coverage: Track method-level branch coverage where available
- 💡 Smart Recommendations: Get suggestions for improving test coverage
- ⚡ Fast & Efficient: Quick indexing and response times for large codebases
🚀 Quick Start
- Clone & Build:
- Set Up (optional, for semantic search):
- Start Using:
👉 Read our Getting Started Guide for detailed setup instructions and best practices.
🔌 Integration with VS Code
- Open Visual Studio Code
- Press
Ctrl + Shift + P
(orCmd + Shift + P
on macOS) - Type "Configure MCP Server"
- Enter:
Now VS Code 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?"
- "Help me think through the authentication system design"
- "Document my reasoning about this architectural decision"
- "Analyze test coverage for MyService.cs"
- "Show me uncovered lines in the authentication module"
- "What's the overall test coverage percentage?"
- "Which files have the lowest test coverage?"
📚 Documentation
- 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
Features
- 📁 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
- 📊 Coverage Analysis: Parse and analyze test coverage data
- 📈 Coverage Reports: Support for Coverlet JSON, LCOV, and Cobertura XML formats
- 🎯 Line Coverage: Track which lines are covered by tests
- 🌳 Branch Coverage: Monitor method-level branch coverage
- 💡 Recommendations: Get actionable suggestions to improve coverage
- 💭 Structured Thinking: Document and validate reasoning about complex operations
- 🧩 AI-Optimized Reasoning: Based on Anthropic's research on improving LLM problem-solving
- 📋 Task Planning: Break down complex problems into manageable steps
- ✅ Policy Compliance: Verify solutions against project guidelines
- 🔄 Tool Output Analysis: Process results from other tools before taking next actions
- 📝 Decision Documentation: Maintain audit trails of architectural choices
Building from Source
- Clone the repository:
- Build the solution:
- Run the tests (optional):
Running Commands
Use the client to interact with your codebase:
Environment Setup
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
Usage
Basic Commands
- Set Base Directory:
- Get Base Directory:
- Get Version Information:
- List Projects:
- List Source Files:
- Analyze Packages:
Example output:
- Analyze Test Coverage:
Example coverage analysis output:
Search Commands
- Text Search:
- Semantic Search:
The 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
Pattern Management
- Add Ignore Patterns:
- View Current Patterns:
- Remove Specific Patterns:
- Clear User Patterns:
- View State File Location:
Default Ignore Patterns
The 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
Security Features
- 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
Example Workflow
- Set the base directory for your project:
- Check server version and configuration:
- Set up custom ignore patterns:
- List all projects:
- Analyze your project's package dependencies:
- Search for authentication-related code:
Integration with AI Coding Tools
NetContextServer implements the Model Context Protocol (MCP), allowing seamless integration with AI coding assistants that support this protocol, such as:
- VS Code: 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 VS Code:
- Configure VS Code 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 the Model Context Protocol Inspector, a visual testing tool that helps you inspect and validate communications between MCP clients and servers. Visit the inspector documentation to learn more about its features and capabilities.
The NetContextServer enables AI collaborators to request specific information about your codebase, making the AI's suggestions more relevant and accurate to your specific project structure and coding patterns.
Error Handling
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
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
This server cannot be installed
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.