MCPSharp.Core
1.0.0
dotnet add package MCPSharp.Core --version 1.0.0
NuGet\Install-Package MCPSharp.Core -Version 1.0.0
<PackageReference Include="MCPSharp.Core" Version="1.0.0" />
<PackageVersion Include="MCPSharp.Core" Version="1.0.0" />
<PackageReference Include="MCPSharp.Core" />
paket add MCPSharp.Core --version 1.0.0
#r "nuget: MCPSharp.Core, 1.0.0"
#:package MCPSharp.Core@1.0.0
#addin nuget:?package=MCPSharp.Core&version=1.0.0
#tool nuget:?package=MCPSharp.Core&version=1.0.0
<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
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
๐ License
MIT License - see LICENSE file
<p align="center"> <sub>Built with โค๏ธ for the .NET and AI communities</sub> </p>
| Product | Versions 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. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 11.0.0-preview.1.26104.118)
- Microsoft.Extensions.Hosting (>= 11.0.0-preview.1.26104.118)
- Microsoft.Extensions.Logging (>= 11.0.0-preview.1.26104.118)
- Microsoft.Extensions.Logging.Console (>= 11.0.0-preview.1.26104.118)
- ModelContextProtocol (>= 1.0.0)
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 |