NetContext Code Intelligence
STDIOEmpowers AI coding assistants to deeply understand .NET codebase through Model Context Protocol.
Empowers AI coding assistants to deeply understand .NET codebase through Model Context Protocol.
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.
git clone https://github.com/willibrandon/NetContextServer.git cd NetContextServer dotnet build
# Set Azure OpenAI credentials in environment: AZURE_OPENAI_ENDPOINT=your_endpoint AZURE_OPENAI_API_KEY=your_key
# 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.
Ctrl + Shift + P
(or Cmd + Shift + P
on macOS){ "command": "dotnet", "args": ["run", "--project", "path/to/NetContextServer/src/NetContextServer/NetContextServer.csproj"] }
Now VS Code can understand your codebase! Try asking it questions like:
git clone https://github.com/willibrandon/NetContextServer.git cd NetContextServer
dotnet build
dotnet test
Use 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 keydotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory "D:\YourProject"
dotnet run --project src/NetContextClient/NetContextClient.csproj -- get-base-dir
dotnet run --project src/NetContextClient/NetContextClient.csproj -- version
dotnet run --project src/NetContextClient/NetContextClient.csproj -- list-projects-in-dir --directory "D:\YourProject\src"
dotnet run --project src/NetContextClient/NetContextClient.csproj -- list-source-files --project-dir "D:\YourProject\src\YourProject"
# 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-packages
Example 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
# Set your base directory first dotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory "path/to/your/project" # Analyze coverage from a Coverlet JSON report dotnet run --project src/NetContextClient/NetContextClient.csproj -- coverage-analysis --report-path "TestResults/coverage.json" # Get a coverage summary dotnet run --project src/NetContextClient/NetContextClient.csproj -- coverage-summary --report-path "TestResults/coverage.json"
Example coverage analysis output:
[{ "filePath": "src/MyProject/Services/UserService.cs", "coveragePercentage": 85.3, "uncoveredLines": [42, 43, 88], "branchCoverage": { "ValidateUser()": 75.0, "GetUserById()": 100.0 }, "recommendation": "Consider adding tests for the user validation error paths" } ]
dotnet run --project src/NetContextClient/NetContextClient.csproj -- search-code --text "authentication"
# 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 10
The semantic search feature:
dotnet run --project src/NetContextClient/NetContextClient.csproj -- add-ignore-patterns --patterns "*.txt" "*.log"
dotnet run --project src/NetContextClient/NetContextClient.csproj -- get-ignore-patterns
dotnet run --project src/NetContextClient/NetContextClient.csproj -- remove-ignore-patterns --patterns "*.txt"
dotnet run --project src/NetContextClient/NetContextClient.csproj -- clear-ignore-patterns
dotnet run --project src/NetContextClient/NetContextClient.csproj -- get-state-file-location
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 namedotnet run --project src/NetContextClient/NetContextClient.csproj -- set-base-dir --directory "D:\Projects\MyApp"
dotnet run --project src/NetContextClient/NetContextClient.csproj -- version
dotnet run --project src/NetContextClient/NetContextClient.csproj -- add-ignore-patterns --patterns "*.generated.cs" "*.designer.cs"
dotnet run --project src/NetContextClient/NetContextClient.csproj -- list-projects-in-dir --directory "D:\Projects\MyApp\src"
dotnet run --project src/NetContextClient/NetContextClient.csproj -- analyze-packages
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:
To use with VS Code:
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.
The server provides clear error messages for common scenarios:
This project is licensed under the MIT License - see the LICENSE file for details.