Content
# dotnet-context-mcp
[](https://github.com/sayinbrahim/dotnet-context-mcp/actions)
[](https://opensource.org/licenses/MIT)
[](https://dotnet.microsoft.com/download/dotnet/8.0)
[](https://nodejs.org)
[](https://www.npmjs.com/package/dotnet-context-mcp)
[](https://www.npmjs.com/package/dotnet-context-mcp)
Bring deep .NET solution context to Claude Code via Roslyn-powered MCP tools.
> **Status**: v0.1.0 published to npm. 4 tools working end-to-end. Looking for early adopters and feedback. PRs welcome.
## What it does
When Claude Code works on .NET projects, it reads files one at a time and infers structure. For larger solutions, this is slow and lossy.
This MCP server gives Claude **structured, Roslyn-backed access** to solution-level information. Questions like "what DbContexts exist", "show me entities in OrderContext", or "list migrations for ApplicationDbContext" become single tool calls instead of multi-file searches.
## Architecture
Two-layer bridge MCP design:
- **TypeScript MCP layer** (~300 lines): Handles MCP protocol, spawns subprocess, returns structured responses
- **.NET CLI layer** (~600 lines C#): Uses Roslyn Workspace API to load solutions and analyze code symbolically
```
Claude Code (MCP client)
│ stdio
▼
TypeScript MCP server ← src/index.ts (Node.js + @modelcontextprotocol/sdk)
│ child_process spawn + JSON on stdout
▼
.NET CLI bridge ← cli/DotnetContextMcp.Cli/ (Roslyn workspace)
```
## Available tools
### `echo`
Test tool to verify MCP connection. Echoes input back to the caller.
### `list_dbcontexts`
Lists all EF Core DbContext classes in a solution.
- **Input**: `solutionPath` (absolute .sln path)
- **Output**: DbContext name, namespace, project, file path
- Filters out abstract DbContexts automatically
- Skips projects without EF Core reference
### `list_entities`
Lists EF Core entities (`DbSet<T>` properties) across all DbContexts.
- **Input**: `solutionPath`, optional `dbContextName` filter
- **Output**: Entity name, namespace, file path, owning DbSet property name
### `list_migrations`
Lists EF Core migrations organized by DbContext.
- **Input**: `solutionPath`, optional `dbContextName` filter
- **Output**: Migration ID, name, ISO 8601 timestamp, file path
- Migrations sorted by timestamp ASC
- Multi-DbContext subfolder layout supported (e.g., `Migrations/SecondDb/`)
- Stats: earliest/latest migration date, total counts
## Platform support
| Platform | RID | Status |
|---|---|---|
| Windows x64 | `win-x64` | Tested |
| Linux x64 | `linux-x64` | Binary built, untested in production |
| macOS x64 (Intel) | `osx-x64` | Binary built, untested in production |
| macOS ARM64 (Apple Silicon) | `osx-arm64` | Binary built, untested in production |
**Current limitation:** `Microsoft.Build.Locator` requires a .NET 8 SDK to be installed on the target machine to locate MSBuild. Truly hermetic operation (no SDK required) is deferred to a future phase.
## Installation
### Quick install (recommended)
```bash
claude mcp add dotnet-context-mcp -s user -- npx -y dotnet-context-mcp@latest
```
The `-s user` flag makes this MCP server available globally across all your projects. For project-specific install, omit the flag.
Restart Claude Code (`/exit`, then `claude`) to load the new MCP server.
Verify the server is connected:
```bash
claude mcp list
# Should show: dotnet-context-mcp ✔ Connected
```
The first tool call may take 5-15 seconds (npm fetches the package and downloads the platform-specific binary). Subsequent calls are 3-4 seconds.
### Platform support
Pre-built binaries are automatically downloaded for:
- Windows x64
- Linux x64
- macOS Intel (x64)
- macOS Apple Silicon (arm64)
### Requirements
- Node.js 18+
- Claude Code 2.x
- .NET 8 SDK installed on your machine (required for Roslyn's MSBuildLocator)
- `tar` command (built-in on macOS/Linux; available on Windows 10+)
### From source (developers)
```bash
git clone https://github.com/sayinbrahim/dotnet-context-mcp.git
cd dotnet-context-mcp
npm install
npm run build:all # TypeScript + Windows binary
claude mcp add dotnet-context-mcp -- node /absolute/path/to/build/index.js
```
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup details.
## Usage examples
### Discovering DbContexts
> **You**: What DbContexts exist in my solution at C:\src\MyApp\MyApp.sln?
>
> **Claude**: [calls list_dbcontexts] Found 2 DbContexts: ApplicationDbContext (MyApp.Data, 3 entities) and AuditDbContext (MyApp.Audit, 1 entity).
### Exploring entities
> **You**: Show me the entities in ApplicationDbContext.
>
> **Claude**: [calls list_entities with filter] ApplicationDbContext manages 3 entities: User, Order, Product. All in MyApp.Data.Entities namespace.
### Reviewing migrations
> **You**: What's the migration history for ApplicationDbContext?
>
> **Claude**: [calls list_migrations] 5 migrations:
> 1. 20240115_InitialCreate (2024-01-15)
> 2. 20240201_AddOrderTotal (2024-02-01)
> 3. ...
## Known limitations
- **Cold start**: First call takes 3–4 seconds (self-contained binary warm-up). Previously 15–20s with `dotnet run`.
- **.NET SDK required**: `MSBuildLocator` must find a .NET 8 SDK on the target machine. Hermetic operation is a future phase.
- **.NET 10 .slnx format**: MSBuildWorkspace requires classic `.sln`. `.slnx` (.NET 10 XML format) is not yet supported.
- **Non-ASCII paths**: Solution paths with non-ASCII characters may fail. Use ASCII-only paths for now.
## Roadmap
### Done
- [x] Phase 1–5: MCP scaffold, Roslyn integration, list_dbcontexts
- [x] Phase 6: list_entities with optional filtering
- [x] Phase 7: list_migrations with metadata extraction
- [x] Phase 12.1–12.3: Self-contained binary publish (5-6x cold-start improvement, 4 platforms)
- [x] Phase 13: Published as npm package (`npx dotnet-context-mcp`) — v0.1.0 live on npm
### Next
- [ ] Phase 8: analyze_migration (single migration detail with operations)
- [ ] Phase 9: find_relationships (entity navigation properties)
- [ ] Phase 10: find_dbcontext_dependencies (DI graph)
- [ ] Phase 11: analyze_solution_health (overall report)
- [ ] Phase 12.4: Hermetic binary (no .NET SDK required on target)
- [ ] Phase 14: Documentation site
- [ ] Phase 15: VS Code extension installer
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup, testing, and PR guidelines.
## Support
- [GitHub Issues](https://github.com/sayinbrahim/dotnet-context-mcp/issues) for bugs
- [Discussions](https://github.com/sayinbrahim/dotnet-context-mcp/discussions) for questions
## License
MIT — see [LICENSE](LICENSE) for details.
## Author
Built by [Halil İbrahim Sayın](https://github.com/sayinbrahim) — Senior .NET Developer at Enerjisa, Ankara.
Contact: [LinkedIn](https://www.linkedin.com/in/halil-ibrahim-say%C4%B1n-0a8760115/)