MCPSharp.Core 1.0.0

dotnet add package MCPSharp.Core --version 1.0.0
                    
NuGet\Install-Package MCPSharp.Core -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MCPSharp.Core" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MCPSharp.Core" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="MCPSharp.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MCPSharp.Core --version 1.0.0
                    
#r "nuget: MCPSharp.Core, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MCPSharp.Core@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MCPSharp.Core&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=MCPSharp.Core&version=1.0.0
                    
Install as a Cake Tool

<p align="center"> <img src="https://img.shields.io/badge/.NET-8.0-512BD4?style=for-the-badge&logo=dotnet&logoColor=white" alt=".NET 8.0" /> <img src="https://img.shields.io/badge/MCP-Protocol-FF6B6B?style=for-the-badge" alt="MCP Protocol" /> <img src="https://img.shields.io/badge/STDIO-Transport-4ECDC4?style=for-the-badge" alt="STDIO Transport" /> <img src="https://img.shields.io/badge/Cross--Platform-Linux%20%7C%20macOS%20%7C%20Windows-45B7D1?style=for-the-badge" alt="Cross Platform" /> </p>

<h1 align="center"> ๐Ÿ” MCPSharp </h1>

<p align="center"> <b>Advanced .NET Type Explorer for AI Agents</b><br> <i>Inspect, analyze, and deconstruct .NET assemblies through the Model Context Protocol</i> </p>

<p align="center"> <a href="#features">Features</a> โ€ข <a href="#installation">Installation</a> โ€ข <a href="#usage">Usage</a> โ€ข <a href="#mcp-tools">MCP Tools</a> โ€ข <a href="#configuration">Configuration</a> โ€ข <a href="#examples">Examples</a> โ€ข <a href="#sample-output">Sample Output</a> </p>


โœจ Features

Feature Description
๐Ÿ” Type Discovery Find classes, interfaces, enums, structs across projects and solutions
๐Ÿ•ธ๏ธ Dependency Analysis Map relationships: inheritance, composition, method signatures
๐ŸŽฏ Smart Filtering Exclude System, Microsoft, or custom namespaces; pattern-based filtering
๐Ÿ“„ Source Generation Generate C# code representations from compiled assemblies
๐ŸŒณ Hierarchy Visualization View complete inheritance trees and interface implementations
โšก MCP Native Full Model Context Protocol support via STDIO transport
๐Ÿง Cross-Platform Linux, macOS, Windows - zero platform-specific code

๐Ÿš€ Installation

From Source

# Clone repository
git clone https://github.com/rodrigoramosrs/mcpsharp.git
cd mcpsharp

# Build solution
dotnet build -c Release

# Run tests
dotnet test MCPSharp.Tests/MCPSharp.Tests.csproj

# Publish single-file executable
dotnet publish MCPSharp/MCPSharp.csproj -c Release -r linux-x64 --self-contained false

As NuGet Package (Coming Soon)

dotnet add package MCPSharp.Core

๐ŸŽฎ Quick Start

1. Start the Server

# With root directory for relative paths
./MCPSharp --root-dir /home/user/projects

# Or via environment variable
export MCPSHARP_ROOT_DIR=/home/user/projects
./MCPSharp

2. Configure Your AI Client

Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "dotnet-explorer": {
      "command": "/path/to/MCPSharp",
      "args": ["--root-dir", "/home/user/projects"],
      "env": {
        "DOTNET_ENVIRONMENT": "Production"
      }
    }
  }
}

Cline/VS Code (settings.json):

{
  "mcpServers": {
    "dotnet-explorer": {
      "command": "dotnet",
      "args": [
        "run", 
        "--project", 
        "/path/to/MCPSharp/MCPSharp.csproj",
        "--",
        "--root-dir",
        "/home/user/projects"
      ]
    }
  }
}

๐Ÿ› ๏ธ MCP Tools

class_explorer_find

Search for types by name (case-insensitive).

{
  "tool": "class_explorer_find",
  "arguments": {
    "projectPath": "MyApp/MyApp.csproj",
    "className": "UserService",
    "maxResults": 10
  }
}

class_explorer_analyze

Deep analysis with dependency exploration.

{
  "tool": "class_explorer_analyze",
  "arguments": {
    "projectPath": "MyApp/MyApp.csproj",
    "className": "OrderService",
    "analysisDepth": "full",
    "maxDepth": 3,
    "includeSystem": false,
    "includeMicrosoft": false,
    "excludeNamespaces": "MyApp.Tests,MyApp.Mocks",
    "excludePatterns": "Dto,Factory"
  }
}

class_explorer_hierarchy

View inheritance tree.

{
  "tool": "class_explorer_hierarchy",
  "arguments": {
    "projectPath": "MyApp/MyApp.csproj",
    "className": "OrderService",
    "includeSystemTypes": false
  }
}

class_explorer_dependencies

Generate dependency graph.

{
  "tool": "class_explorer_dependencies",
  "arguments": {
    "projectPath": "MyApp/MyApp.csproj",
    "className": "PaymentGateway",
    "includeSystem": false,
    "maxDepth": 2
  }
}

class_explorer_export

Export analysis to .cs file.

{
  "tool": "class_explorer_export",
  "arguments": {
    "projectPath": "MyApp/MyApp.csproj",
    "className": "ComplexService",
    "outputDirectory": "./analysis",
    "analysisDepth": "full"
  }
}

class_explorer_clear_cache

Clear analysis cache.

{
  "tool": "class_explorer_clear_cache",
  "arguments": {
    "projectPath": "all"
  }
}

โš™๏ธ Configuration

Path Resolution

Path Type Example Resolution
Absolute /home/user/project/MyApp.csproj Used as-is
Relative MyApp/MyApp.csproj Concatenated with --root-dir

Analysis Depth Levels

Level Description
none Target class only
hierarchy Base classes + interfaces
signature Method parameters, return types, properties
full Complete dependency graph (recursive)

Filter Configuration

// Example: Strict filtering
{
  "includeSystem": false,        // Exclude System.*
  "includeMicrosoft": false,     // Exclude Microsoft.*
  "includeThirdParty": false,    // Exclude Newtonsoft, etc.
  "excludeNamespaces": "Tests,Mocks",
  "excludePatterns": "Dto,Factory,Helper"
}

๐Ÿ“Š Real-World Examples

Understanding a Legacy Codebase

"Show me all dependencies of the PaymentService class, excluding test mocks and DTOs"

{
  "tool": "class_explorer_analyze",
  "arguments": {
    "projectPath": "LegacyApp/LegacyApp.csproj",
    "className": "PaymentService",
    "analysisDepth": "full",
    "maxDepth": 3,
    "excludePatterns": "Mock,Dto,Stub"
  }
}

Interface Implementation Audit

"List all classes implementing IRepository in the domain layer"

{
  "tool": "class_explorer_list_namespace",
  "arguments": {
    "projectPath": "Domain/Domain.csproj",
    "namespaceName": "MyApp.Domain.Repositories",
    "includeNested": true
  }
}

Refactoring Impact Analysis

"What's the inheritance hierarchy of BaseController? Include framework types."

{
  "tool": "class_explorer_hierarchy",
  "arguments": {
    "projectPath": "WebApp/WebApp.csproj",
    "className": "MyApp.Web.Controllers.BaseController",
    "includeSystemTypes": true
  }
}

๐Ÿ“‹ Sample Output

Example 1: Type Discovery (class_explorer_find)

Input:

{
  "tool": "class_explorer_find",
  "arguments": {
    "projectPath": "ECommerce/ECommerce.csproj",
    "className": "Order",
    "maxResults": 5
  }
}

Output to LLM:

Found 3 type(s) matching 'Order':

1. [class] ECommerce.Domain.Models.Order (Assembly: ECommerce.Domain)
2. [class] ECommerce.Services.OrderProcessingService (Assembly: ECommerce.Services)
3. [enum] ECommerce.Domain.Enums.OrderStatus (Assembly: ECommerce.Domain)

Use 'class_explorer_analyze' with the full type name for detailed analysis.

Example 2: Deep Analysis with Dependencies (class_explorer_analyze)

Input:

{
  "tool": "class_explorer_analyze",
  "arguments": {
    "projectPath": "ECommerce/ECommerce.csproj",
    "className": "ECommerce.Services.OrderService",
    "analysisDepth": "full",
    "maxDepth": 2,
    "includeSystem": false,
    "excludePatterns": "Dto"
  }
}

Output to LLM:

// Class Analysis Report
// Generated: 2024-01-15 14:32:18 UTC
// Project: /home/user/projects/ECommerce/ECommerce.csproj
// Target: ECommerce.Services.OrderService
// Dependencies Found: 4
// Filters: System:Excluded | Microsoft:Excluded | ThirdParty:Excluded | ExcludedPatterns:[Dto]

// ----------------------------------------------------------------------------
// DEPENDENCIES
// ----------------------------------------------------------------------------

// >>> ECommerce.Domain.Models.Order [ECommerce.Domain]
namespace ECommerce.Domain.Models
{
    public class Order
    {
        public int Id { get; set; }
        public decimal Total { get; set; }
        public OrderStatus Status { get; set; }
        public List<OrderItem> Items { get; set; }
        public Customer Customer { get; set; }
    }
}

// >>> ECommerce.Domain.Models.OrderItem [ECommerce.Domain]
namespace ECommerce.Domain.Models
{
    public class OrderItem
    {
        public int ProductId { get; set; }
        public string ProductName { get; set; }
        public int Quantity { get; set; }
        public decimal UnitPrice { get; set; }
    }
}

// >>> ECommerce.Domain.Models.Customer [ECommerce.Domain]
namespace ECommerce.Domain.Models
{
    public class Customer
    {
        public int Id { get; set; }
        public string Email { get; set; }
        public string Name { get; set; }
    }
}

// >>> ECommerce.Domain.Enums.OrderStatus [ECommerce.Domain]
namespace ECommerce.Domain.Enums
{
    public enum OrderStatus
    {
        Pending,
        Paid,
        Shipped,
        Delivered,
        Cancelled
    }
}

// ----------------------------------------------------------------------------
// PRIMARY CLASS
// ----------------------------------------------------------------------------

namespace ECommerce.Services
{
    public class OrderService
    {
        private readonly IOrderRepository _orderRepository;
        private readonly IPaymentGateway _paymentGateway;
        private readonly IEmailService _emailService;
        
        public OrderService(IOrderRepository orderRepository, 
                           IPaymentGateway paymentGateway, 
                           IEmailService emailService) { }
        
        public Order CreateOrder(int customerId, List<OrderItem> items) { }
        public void ProcessPayment(int orderId, PaymentInfo payment) { }
        public void ShipOrder(int orderId) { }
        public void CancelOrder(int orderId) { }
        public Order GetOrder(int orderId) { }
    }
}

// ----------------------------------------------------------------------------
// RESUMO DE RELACIONAMENTOS
// ----------------------------------------------------------------------------
// ECommerce.Services.OrderService -> ECommerce.Domain.Models.Order [MethodReturn]
// ECommerce.Services.OrderService -> ECommerce.Domain.Models.OrderItem [MethodParameter]
// ECommerce.Services.OrderService -> ECommerce.Domain.Models.Customer [PropertyType]
// ECommerce.Services.OrderService -> ECommerce.Domain.Enums.OrderStatus [PropertyType]

Example 3: Inheritance Hierarchy (class_explorer_hierarchy)

Input:

{
  "tool": "class_explorer_hierarchy",
  "arguments": {
    "projectPath": "WebApp/WebApp.csproj",
    "className": "ECommerce.Web.Controllers.ApiController",
    "includeSystemTypes": true
  }
}

Output to LLM:

// Inheritance Hierarchy for: ECommerce.Web.Controllers.ApiController
// Project: /home/user/projects/WebApp/WebApp.csproj

โ””โ”€โ”€ ApiController (class)
  โ””โ”€โ”€ extends ControllerBase
    โ””โ”€โ”€ extends Controller
      โ””โ”€โ”€ extends Microsoft.AspNetCore.Mvc.ControllerBase
        โ””โ”€โ”€ implements IActionFilter
        โ””โ”€โ”€ implements IAsyncActionFilter
        โ””โ”€โ”€ implements IFilterMetadata
        โ””โ”€โ”€ implements IDisposable

// Related Types:
//   [interface] ECommerce.Web.Filters.IApiExceptionFilter
//   [interface] ECommerce.Web.Filters.IRequestValidator
//   [class] ECommerce.Web.Controllers.BaseController

Example 4: Dependency Graph (class_explorer_dependencies)

Input:

{
  "tool": "class_explorer_dependencies",
  "arguments": {
    "projectPath": "PaymentService/PaymentService.csproj",
    "className": "PaymentService.Core.PaymentProcessor",
    "includeSystem": false,
    "maxDepth": 2
  }
}

Output to LLM:

// Dependency Report for: PaymentService.Core.PaymentProcessor
// Project: /home/user/projects/PaymentService/PaymentService.csproj
// Analysis Depth: 2
// Total Dependencies: 6
// Filtered Out: System types excluded

// Inherits:
//   PaymentProcessor โ”€โ”€โ”€โ–บ BasePaymentProcessor

// Implements:
//   PaymentProcessor โ”€โ”€โ”€โ”€โ–บ IPaymentProcessor
//   PaymentProcessor โ”€โ”€โ”€โ”€โ–บ IDisposable

// MethodParameter:
//   PaymentProcessor โ”€โ”€โ”€โ–บ PaymentRequest
//      via: ProcessPayment
//   PaymentProcessor โ”€โ”€โ”€โ–บ PaymentMethod
//      via: ProcessPayment
//   PaymentProcessor โ”€โ”€โ”€โ–บ FraudCheckResult
//      via: ValidateTransaction

// MethodReturn:
//   PaymentProcessor โ”€โ”€โ”€โ–บ PaymentResult
//      via: ProcessPayment
//   PaymentProcessor โ”€โ”€โ”€โ–บ TransactionLog
//      via: LogTransaction

// PropertyType:
//   PaymentProcessor โ”€โ”€โ”€โ–บ ILogger<PaymentProcessor>
//      via: _logger
//   PaymentProcessor โ”€โ”€โ”€โ–บ IConfiguration
//      via: _configuration

// External Dependencies:
//   [class] PaymentService.Models.PaymentRequest (PaymentService.Models)
//   [class] PaymentService.Models.PaymentResult (PaymentService.Models)
//   [class] PaymentService.Models.PaymentMethod (PaymentService.Models)
//   [class] PaymentService.Models.FraudCheckResult (PaymentService.Models)
//   [class] PaymentService.Models.TransactionLog (PaymentService.Models)
//   [interface] PaymentService.Core.IPaymentProcessor (PaymentService.Core)

Example 5: Namespace Listing (class_explorer_list_namespace)

Input:

{
  "tool": "class_explorer_list_namespace",
  "arguments": {
    "projectPath": "ECommerce/ECommerce.csproj",
    "namespaceName": "ECommerce.Domain.Models",
    "includeNested": false
  }
}

Output to LLM:

// Types in namespace: ECommerce.Domain.Models
// Excluding nested namespaces
// Total: 8 type(s)

namespace ECommerce.Domain.Models
{
    public class Order;
    public class OrderItem;
    public class Customer;
    public class Product;
    public class Category;
    public class ShoppingCart;
    public class CartItem;
    public class Address;
}

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   AI Client     โ”‚โ—„โ”€โ”€โ”€โ–บโ”‚   MCP Protocol   โ”‚โ—„โ”€โ”€โ”€โ–บโ”‚  MCPSharp       โ”‚
โ”‚  (Claude/Cline) โ”‚     โ”‚    (STDIO)       โ”‚     โ”‚   (STDIO Host)  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                                         โ”‚
                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                              โ”‚                         โ”‚                         โ”‚
                              โ–ผ                         โ–ผ                         โ–ผ
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚ TypeExplorer    โ”‚       โ”‚ Filter          โ”‚       โ”‚ Metadata        โ”‚
                    โ”‚ Service         โ”‚       โ”‚ Configuration   โ”‚       โ”‚ Load Context    โ”‚
                    โ”‚                 โ”‚       โ”‚                 โ”‚       โ”‚                 โ”‚
                    โ”‚ โ€ข Assembly Scan โ”‚       โ”‚ โ€ข System.*      โ”‚       โ”‚ โ€ข PEReader      โ”‚
                    โ”‚ โ€ข Type Resolutionโ”‚      โ”‚ โ€ข Microsoft.*   โ”‚       โ”‚ โ€ข TypeResolver  โ”‚
                    โ”‚ โ€ข Dependency Mapโ”‚       โ”‚ โ€ข Custom NS     โ”‚       โ”‚ โ€ข Signature     โ”‚
                    โ”‚                 โ”‚       โ”‚ โ€ข Patterns      โ”‚       โ”‚   Decoder       โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿงช Testing

# Run all tests
dotnet test

# Run with verbosity
dotnet test --logger "console;verbosity=detailed"

# Filter specific tests
dotnet test --filter "FullyQualifiedName~PathResolution"

๐Ÿค Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open Pull Request

๐Ÿ“œ License

MIT License - see LICENSE file


<p align="center"> <sub>Built with โค๏ธ for the .NET and AI communities</sub> </p>

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 104 3/2/2026