NetContextServer
A .NET implementation of the Model Context Protocol enabling AI assistants to explore and understand .NET codebases.
claude mcp add --transport stdio willibrandon-netcontextserver dotnet run --project src/NetContextServer/NetContextServer.csproj \ --env AZURE_OPENAI_API_KEY="Your Azure OpenAI API key (optional for semantic search)" \ --env AZURE_OPENAI_ENDPOINT="Your Azure OpenAI endpoint (optional for semantic search)"
How to use
NetContextServer is a MCP-compliant service that helps AI coding assistants understand and navigate a .NET codebase more effectively. It provides semantic code search, intelligent project navigation, package analysis, test coverage insights, and safe file access controls. When paired with an editor like VS Code, it enables your AI tools to reason about your solution, dependencies, and tests in a structured way, improving the relevance and accuracy of code suggestions and questions answered about the project. You can invoke its capabilities through the MCP tooling, or via the VS Code integration example in the repository, which demonstrates launching the server with the correct dotnet command and arguments.
To use the server from your editor or tooling, ensure the MCP client points to the NetContextServer instance. Typical interactions include semantic searching across your codebase, listing projects and files, analyzing NuGet packages and their dependencies, and querying test coverage information. The server also supports configured ignore patterns and structured thinking capabilities to help document decisions and reasoning about architectural choices.
How to install
Prerequisites
- .NET SDK (recommended latest LTS) installed on your machine
- Git
- Access to the NetContextServer repository (clone the repo if you haven’t already)
Installation steps
- Clone the repository (if not already done)
git clone https://github.com/willibrandon/NetContextServer.git
cd NetContextServer
- Build the solution (optional but recommended to verify the server compiles)
dotnet build
- Run the server locally (example using the MCP-compatible server command)
# From the project root, or as configured in MCP
dotnet run --project src/NetContextServer/NetContextServer.csproj
- (Optional) Configure environment variables for semantic search (Azure OpenAI example shown in README)
export AZURE_OPENAI_ENDPOINT=your_endpoint
export AZURE_OPENAI_API_KEY=your_key
- Verify MCP client configuration points to the running server (example in VS Code integration):
{
"command": "dotnet",
"args": ["run", "--project", "path/to/NetContextServer/src/NetContextServer/NetContextServer.csproj"]
}
Prerequisites recap: ensure you have a working .NET environment, Git, and network access to fetch dependencies during build and run.
Additional notes
Tips and common considerations:
- The NetContextServer integrates with MCP to expose tools for semantic code search, intelligent navigation, and package/test analysis. Ensure the server is reachable by your MCP client configuration (the example path in the README is a good reference).
- If you plan to use semantic search, providing Azure OpenAI credentials is recommended, but optional—your setup can function with other data sources if configured accordingly.
- You can customize ignore patterns to control which files the server will index or expose to the AI tooling.
- When running locally, keep the .NET process running in the foreground or use a process manager for production-like reliability.
- If you encounter path issues, adjust the --project path to match your local clone layout (the example uses src/NetContextServer/NetContextServer.csproj).
- For editor integration, follow the VS Code snippet in the README to wire up the MCP server with the correct command and arguments.
- Regularly update from the upstream repository to keep dependencies and MCP integration up to date.
Related MCP Servers
mssql
MSSQL Server MCP implementation written in C#
McpDotNet.Extensions.SemanticKernel
Microsoft SemanticKernel integration for the Model Context Protocol (MCP). Enables seamless use of MCP tools as AI functions.
DatabaseMcpServer
MCP server from ttcc666/DatabaseMcpServer
mcp-dataverse
MCP Server for querying Dataverse using SQL
xperience-community
ASP.NET Core MCP server for Xperience by Kentico projects
console-to-http
Example of converting a stdio MCP server to HTTP using ModelContextProtocol.AspNetCore