# Coa Codenav Mcp

> MCP server leveraging Roslyn code analysis and refactoring tools

- **Type:** MCP server
- **Install:** `agentstack add mcp-anortham-coa-codenav-mcp`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [anortham](https://agentstack.voostack.com/s/anortham)
- **Installs:** 0
- **Category:** [Integrations](https://agentstack.voostack.com/c/integrations)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [anortham](https://github.com/anortham)
- **Source:** https://github.com/anortham/coa-codenav-mcp

## Install

```sh
agentstack add mcp-anortham-coa-codenav-mcp
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# COA CodeNav MCP Server

A powerful MCP (Model Context Protocol) server providing comprehensive **C# and TypeScript** code analysis and navigation tools for AI assistants. Built on Microsoft's Roslyn compiler platform and TypeScript Server Protocol, it brings Visual Studio's IntelliSense and advanced code navigation capabilities to AI, enabling deep understanding and manipulation of codebases.

## 🚀 Features

### Auto-Loading System ⚡
- **Zero Configuration** - Solutions and TypeScript projects load automatically at startup
- **Multi-Language Support** - Simultaneous C# and TypeScript workspace initialization
- **Smart Discovery** - Automatically finds .sln, .csproj, and tsconfig.json files
- **Background Loading** - Non-blocking startup with parallel workspace preparation
- **Graceful Fallbacks** - Falls back to manual loading if auto-detection fails

### C# Analysis (Roslyn)
- **Complete C# Code Analysis** - Full Roslyn compiler integration for accurate code understanding
- **31 Powerful Tools** - Comprehensive suite covering navigation, analysis, refactoring, and code generation
- **Advanced Refactoring** - Extract methods/interfaces, inline code, move types, rename symbols, and more
- **Deep Analysis** - Code metrics, dependency analysis, clone detection, and call hierarchies

### TypeScript Analysis (TSP)
- **TypeScript Server Protocol** - Native TSP integration for accurate TypeScript analysis
- **14 Comprehensive Tools** - Full suite covering navigation, analysis, refactoring, and workspace management
- **Advanced Features** - Imports management, quick fixes, workspace loading, and symbol hierarchies
- **Project Management** - Load tsconfig.json projects with full monorepo workspace support
- **Real-time Diagnostics** - Compilation error detection with intelligent fixes

### AI-Optimized Experience
- **AI-First Design** - Structured outputs with insights, next actions, and error recovery
- **Smart Token Management** - Automatic response truncation to prevent context overflow
- **Progressive Disclosure** - Automatic response summarization for large results
- **Intelligent Hooks** - Claude Code integration with smart type verification suggestions
- **Cross-platform Support** - Windows, macOS, and Linux compatibility

## 📦 Installation

### Prerequisites

- .NET 9.0 SDK or later
- Windows, macOS, or Linux
- AI assistant with MCP support (Claude Desktop, etc.)
- **For TypeScript**: TypeScript installed globally (`npm install -g typescript`)

### Quick Install (Recommended)

#### Via dotnet global tool

```bash
# Install the global tool from NuGet
dotnet tool install --global COA.CodeNav.McpServer

# Add to Claude Desktop configuration
# The tool will be available as 'coa-codenav' command
```

#### Manual Claude Desktop Configuration

Add to your Claude configuration file:

**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
**macOS/Linux:** `~/.config/Claude/claude_desktop_config.json`

```json
{
  "mcpServers": {
    "coa-codenav": {
      "command": "coa-codenav"
    }
  }
}
```

### Alternative: Build from Source

```bash
# Clone and build
git clone https://github.com/anortham/coa-codenav-mcp.git
cd coa-codenav-mcp
dotnet build -c Release

# Add to Claude Desktop configuration
# Windows
"command": "C:\\path\\to\\coa-codenav-mcp\\COA.CodeNav.McpServer\\bin\\Release\\net9.0\\COA.CodeNav.McpServer.exe"

# macOS/Linux
"command": "/path/to/coa-codenav-mcp/COA.CodeNav.McpServer/bin/Release/net9.0/COA.CodeNav.McpServer"
```

### Update Tool

```bash
# Update to latest version
dotnet tool update --global COA.CodeNav.McpServer
```

### Uninstall Tool

```bash
# Remove global tool
dotnet tool uninstall --global COA.CodeNav.McpServer
```

## 🛠️ Available Tools

### Quick Reference

> 💡 **New**: With auto-loading enabled, solutions and TypeScript projects load automatically - no manual loading required!

#### C# Tools (31 tools)

| Tool                         | Purpose                | Example Usage                       |
| ---------------------------- | ---------------------- | ----------------------------------- |
| `csharp_load_solution`       | Load VS solution*      | "Load MyApp.sln"                    |
| `csharp_goto_definition`     | Jump to definition     | "Go to UserService definition"      |
| `csharp_find_all_references` | Find usages            | "Where is ProcessOrder used?"       |
| `csharp_symbol_search`       | Search symbols         | "Find all \*Service classes"        |
| `csharp_get_diagnostics`     | Get errors/warnings    | "Show me all errors"                |
| `csharp_rename_symbol`       | Rename across solution | "Rename UserService to UserManager" |
| `csharp_extract_interface`   | Extract interface      | "Extract IUserService interface"     |
| `csharp_move_type`           | Move type to new file  | "Move User class to User.cs"        |
| `csharp_inline_method`       | Inline method calls    | "Inline the helper method"          |
| `csharp_call_hierarchy`      | View call graph        | "Show who calls ProcessOrder"       |
| `csharp_code_clone_detection`| Find duplicate code    | "Find duplicated code blocks"       |

*Only needed if auto-loading fails or for additional solutions

#### TypeScript Tools (14 tools)

| Tool                         | Purpose                    | Example Usage                       |
| ---------------------------- | -------------------------- | ----------------------------------- |
| `ts_load_tsconfig`          | Load TypeScript project*   | "Load tsconfig.json"                |
| `ts_load_workspace`         | Load multi-project workspace* | "Load TypeScript monorepo"        |
| `ts_goto_definition`        | Navigate to definitions    | "Go to UserService definition"      |
| `ts_find_all_references`    | Find symbol references     | "Where is processOrder used?"       |
| `ts_find_implementations`   | Find interface implementations | "Find all User implementations"   |
| `ts_get_diagnostics`        | Get TypeScript errors      | "Check for TypeScript errors"       |
| `ts_hover`                  | Get symbol information     | "What does this function do?"       |
| `ts_document_symbols`       | Extract file structure     | "Show all classes and methods"      |
| `ts_symbol_search`          | Search for symbols         | "Find all *Service classes"         |
| `ts_rename_symbol`          | Rename across files        | "Rename UserService to UserManager" |
| `ts_call_hierarchy`         | Analyze call relationships | "Show call hierarchy for function"  |
| `ts_add_missing_imports`    | Auto-add import statements | "Add missing imports to file"       |
| `ts_organize_imports`       | Sort and organize imports  | "Clean up import statements"        |
| `ts_apply_quick_fix`        | Apply TypeScript fixes     | "Fix this TypeScript error"         |

*Only needed if auto-loading fails or for additional projects

### 🔄 Auto-Loading System

The MCP server now features an intelligent auto-loading system that automatically discovers and loads your projects at startup, eliminating the need for manual workspace setup in most cases.

#### How Auto-Loading Works

1. **Startup Detection**: When the MCP server starts, it scans the current directory and subdirectories
2. **Multi-Language Discovery**: Simultaneously searches for:
   - C# solutions (`.sln` files)
   - C# projects (`.csproj` files) 
   - TypeScript configs (`tsconfig.json` files)
3. **Smart Prioritization**: Prefers solutions over individual projects, respects configuration preferences
4. **Background Loading**: Loads workspaces in parallel without blocking the server startup
5. **Graceful Fallbacks**: Falls back to manual loading if auto-detection fails

#### Configuration (appsettings.json)

```json
{
  "Startup": {
    "AutoLoadSolution": true,              // Enable auto-loading
    "SolutionPath": "MyApp.sln",          // Preferred solution name
    "MaxSearchDepth": 5,                   // Directory search depth
    "PreferredSolutionName": "MyApp",      // Preferred solution prefix
    "RequireSolution": false               // Allow project-only loading
  },
  "CodeSearch": {
    "BaseUrl": "http://localhost:5020"     // CodeSearch service URL for development
  }
}
```

#### Environment Variables

For production deployments, configure the CodeSearch service URL via environment variables:

```bash
# Production deployment
export CODENAV_CODESEARCH_URL="https://codesearch-service:8080"

# Docker/Container deployment
export CODENAV_CODESEARCH_URL="http://codesearch-service:5020"

# Kubernetes deployment
export CODENAV_CODESEARCH_URL="http://codesearch-service.default.svc.cluster.local:5020"
```

**Configuration Priority** (highest to lowest):
1. Environment variable `CODENAV_CODESEARCH_URL`
2. Configuration section `CodeSearch:BaseUrl` 
3. Default development URL `http://localhost:5020`

**Security Note**: Never use `localhost` URLs in production environments. Always configure appropriate service URLs for your deployment target.

#### Auto-Loading Status

Use `csharp_get_workspace_statistics` to check if auto-loading succeeded:

```json
{
  "totalWorkspaces": 1,
  "workspaceDetails": [{
    "workspaceId": "C:\\Projects\\MyApp\\MyApp.sln",
    "loadedPath": "C:\\Projects\\MyApp\\MyApp.sln",
    "createdAt": "2025-01-20T10:30:00Z",
    "lastAccessedAt": "2025-01-20T10:35:00Z"
  }]
}
```

#### When Manual Loading is Still Needed

- **Additional Solutions**: Loading secondary solutions not in the startup directory
- **Specific Projects**: Loading individual projects when solution auto-loading fails
- **Remote Paths**: Loading solutions from network locations or different drives
- **Multi-Workspace**: Working with multiple unrelated solutions simultaneously

#### Benefits of Auto-Loading

- ✅ **Zero Configuration** - Works out of the box for most projects
- ✅ **Faster Startup** - Parallel loading reduces time to first usable state  
- ✅ **Multi-Language** - Handles C# and TypeScript projects simultaneously
- ✅ **Intelligence Ready** - Type verification and navigation tools available immediately
- ✅ **Backward Compatible** - Manual loading still available when needed

### Workspace Management

#### `csharp_load_solution`

Load a complete Visual Studio solution for analysis (typically only needed if auto-loading fails or for additional solutions).

**When to use:**

- "Load the MyApp.sln solution"
- "Open the solution file in C:\Projects\MyApp"
- "I want to analyze this C# solution"

**Example:**

```json
{
  "solutionPath": "C:\\Projects\\MyApp\\MyApp.sln",
  "workspaceId": "optional-custom-id"
}
```

#### `csharp_load_project`

Load a single C# project file.

**When to use:**

- "Load just the MyApp.Core project"
- "Open the csproj file"
- "I only need to analyze this one project"

**Example:**

```json
{
  "projectPath": "C:\\Projects\\MyApp\\MyApp.Core\\MyApp.Core.csproj"
}
```

#### `csharp_get_workspace_statistics`

Get statistics about loaded workspaces and resource usage.

**When to use:**

- "Show workspace memory usage"
- "How many workspaces are loaded?"
- "Check workspace performance"

### Code Navigation

#### `csharp_goto_definition`

Navigate to the definition of a symbol at a specific position.

**When to use:**

- "Where is UserService defined?"
- "Show me the definition of ProcessOrder method"
- "Jump to where this class is declared"

**Example:**

```json
{
  "filePath": "Program.cs",
  "line": 42,
  "column": 25
}
```

**Response includes:**

- Exact location of definition
- Symbol type and signature
- Next actions (find references, implementations, etc.)

#### `csharp_find_all_references`

Find all references to a symbol across the entire codebase.

**When to use:**

- "Where is UserService used?"
- "Find all calls to ProcessOrder"
- "Show me all references to this variable"

**Example:**

```json
{
  "filePath": "Services/UserService.cs",
  "line": 15,
  "column": 20,
  "maxResults": 100
}
```

**Features:**

- Groups results by file
- Shows usage context
- Handles large result sets with pagination

#### `csharp_find_implementations`

Find all implementations of interfaces and overrides of virtual/abstract methods.

**When to use:**

- "What classes implement IRepository?"
- "Show me all implementations of this interface"
- "What overrides ProcessOrder?"

#### `csharp_hover`

Get detailed information about a symbol including signature, documentation, and type info.

**When to use:**

- "What does this method do?"
- "Show me the documentation for ProcessOrder"
- "What parameters does this function take?"

### Code Search & Discovery

#### `csharp_symbol_search`

Search for symbols by name or pattern across the entire solution.

**When to use:**

- "Find all classes with 'Service' in the name"
- "Search for methods starting with 'Process'"
- "Find the UserController class"
- "Show me all interfaces in the Data namespace"

**Search types:**

- `contains` - Partial match anywhere in name (default)
- `exact` - Exact name match
- `startswith` - Name starts with query
- `endswith` - Name ends with query
- `wildcard` - Support \* and ? wildcards
- `regex` - Full regex patterns
- `fuzzy` - Fuzzy matching for typos

**Example:**

```json
{
  "query": "User*Service",
  "searchType": "wildcard",
  "symbolKinds": ["Class", "Interface"],
  "namespaceFilter": "MyApp.Services",
  "maxResults": 50
}
```

#### `csharp_document_symbols`

Extract the complete symbol hierarchy from a file.

**When to use:**

- "Show me the structure of this file"
- "What methods are in UserService.cs?"
- "Give me an outline of this class"

#### `csharp_get_type_members`

List all members of a type including methods, properties, fields, and events.

**When to use:**

- "What methods does UserService have?"
- "Show me all properties of Order class"
- "List members including inherited ones"

### Code Analysis

#### `csharp_get_diagnostics`

Get compilation errors, warnings, and analyzer diagnostics.

**When to use:**

- "Show me all errors in the solution"
- "What warnings do I have?"
- "Check for nullable reference warnings"
- "Find code quality issues"

**Example:**

```json
{
  "scope": "solution",
  "severities": ["Error", "Warning"],
  "includeAnalyzers": true,
  "idFilter": "CS8", // Filter for specific diagnostic IDs
  "maxResults": 50
}
```

#### `csharp_code_metrics`

Calculate code complexity and maintainability metrics.

**When to use:**

- "Calculate complexity of this method"
- "Find methods that are too complex"
- "Show maintainability index for this class"
- "Identify refactoring candidates"

**Metrics provided:**

- **Cyclomatic Complexity** - Number of code paths
- **Lines of Code** - Logical lines of code
- **Maintainability Index** - 0-100 score (higher is better)
- **Depth of Inheritance** - Inheritance hierarchy depth
- **Class Coupling** - Number of coupled classes

#### `csharp_find_unused_code`

Find potentially unused code elements including classes, methods, properties, and fields.

**When to use:**

- "Find dead code in the project"
- "Show me unused private methods"
- "Clean up unused classes"
- "Identify code that can be removed"

#### `csharp_type_hierarchy`

View the complete type hierarchy including base classes, derived types, and interface implementations.

**When to use:**

- "Show inheritance hierarchy of UserService"
- "What classes derive from BaseController?"
- "View the complete type hierarchy"
- "What interfaces does this class implement?"

### Advanced Analysis

#### `csharp_call_hierarchy`

View bidirectional call graph showing incoming and outgoing calls.

**When to use:**
- "Show all callers of this method"
- "What methods does this function call?"
- "View complete call hierarchy"
- "Understand method dependencies"

#### `csharp_find_all_overrides`

Find all overrides of virtual/abstract methods and properties.

**When to use:**
- "What overrides this virtual method?"
- "Find all implementations of abstract method"
- "Show override hierarchy"

#### `

…

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [anortham](https://github.com/anortham)
- **Source:** [anortham/coa-codenav-mcp](https://github.com/anortham/coa-codenav-mcp)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-anortham-coa-codenav-mcp
- Seller: https://agentstack.voostack.com/s/anortham
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
