Skip to main content
Glama

Sharphy: CLR Intelligence & Runtime Forensic Bridge

Native Model Context Protocol (MCP) Server Empowering AI Coding Agents as Advanced .NET Runtime Diagnosticians, Memory Forensic Analysts, and Binary Architects.

Leveraging ECMA-335 Metadata Semantics, Cross-Platform Crash Dump Telemetry, and Rigid CIL Bytecode Navigation.

CAUTION

Legal Disclaimer & Limitation of Liability Sharphy is engineered exclusively for good-faith security research, production crash dump diagnostics, vulnerability assessments, incident response, and lawful software engineering. Users bear sole civil and criminal responsibility for complying with applicable territorial cyber laws, third-party End User License Agreements (EULAs), and intellectual property rights. The developer disclaims any liability for malicious misuse or unlawful reverse engineering. Full details: DISCLAIMER.md.

IMPORTANT

Install and execute Sharphy only from official distribution channels: verified NuGet packages (Sharphy.Cli under the verified Sharphy.* reserved prefix), official Model Context Protocol (MCP) Registry (io.github.baharmaulidiii/sharphy), or direct compilation from the official repository at github.com/baharmaulidiii/sharphy.


Architecture Overview & Philosophy

Mainstream AI coding agents (Cursor, Claude Code, Windsurf, Copilot) operate primarily on raw source code heuristics in an editor. They suffer from runtime blindness when confronting:

  • Production memory crashes and unhandled fatal exceptions

  • Multi-threaded synchronization deadlocks and lock cycle contention

  • Large Object Heap (LOH) fragmentation and memory leaks

  • Compiled third-party binaries lacking source code availability

Sharphy serves as a deterministic runtime forensic bridge implementing the open Model Context Protocol (MCP) specification. Over an isolated JSON-RPC 2.0 Stdio channel, Sharphy exposes Microsoft low-level diagnostics and decompilation engines directly to semantic AI reasoning loops.

┌─────────────────────────────────────────────────────────────┐
│                   AI Coding Agent Client                    │
│           (Cursor / Claude Code / Windsurf / LLM)           │
└──────────────────────────────┬──────────────────────────────┘
                               │ JSON-RPC 2.0 over Stdio
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                    Sharphy.Server (Host)                    │
│   ┌─────────────────────────────────────────────────────┐   │
│   │  Pure Stdio Channel (stdout: Payloads / stderr: Log)│   │
│   │  JSON-RPC Dispatcher & Tool Registry (10 Tools)     │   │
│   └──────────────────────────┬──────────────────────────┘   │
└──────────────────────────────┼──────────────────────────────┘
                               │ Strongly-Typed In-Process Calls
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                     Sharphy.Core Engine                     │
│  ┌───────────────────────┐       ┌───────────────────────┐  │
│  │   ClrMD Forensics     │       │     ILSpy Engine      │  │
│  │ (Crash Dump & Heap)   │       │ (C# Decompilation)    │  │
│  ├───────────────────────┤       ├───────────────────────┤  │
│  │   Mono.Cecil Engine   │       │   Roslyn & Sandbox    │  │
│  │ (Metadata & Mutation) │       │ (UnsafeAccessor & ALC)│  │
│  └───────────────────────┘       └───────────────────────┘  │
└──────────────────────────────┬──────────────────────────────┘
                               │ Deterministic Low-Level Inspection
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                  Runtime Analysis Target                    │
│  • Windows / Linux Crash Dump Files (.dmp / ELF core dump)  │
│  • Compiled Binary Assemblies (.dll / .exe ECMA-335)        │
│  • Active Runtime Processes & Isolated AssemblyLoadContext  │
└─────────────────────────────────────────────────────────────┘

Related MCP server: ASPNET Core Debugging MCP Server

Package Ecosystem & Roles

The Sharphy solution is organized into three modular projects with distinct boundaries:

Package / Module

Distribution

Target Audience

Architectural Role & Technical Scope

Sharphy.Cli

.NET Global Tool

End Users & Agents

Command-line entry point. Operates as an instant zero-configuration launcher for the MCP host server (sharphy mcp start) or quick inspection utilities.

Sharphy.Server

Class Library / Host

Agent Frameworks & Hosts

Implements the official Model Context Protocol (MCP) using JSON-RPC 2.0. Enforces pure Stdio stream separation: stdout is dedicated to JSON-RPC payloads, while all internal diagnostic logging is routed to stderr.

Sharphy.Core

Class Library Engine

CLR Engineers & Builders

Pure analytical engine with no MCP protocol dependencies. Abstacts low-level libraries: Microsoft.Diagnostics.Runtime (ClrMD), ICSharpCode.Decompiler (ILSpy), Mono.Cecil, and Microsoft.CodeAnalysis.CSharp (Roslyn).


Operational Architecture: Zero-Footprint Production Forensics

A common enterprise architectural question is whether diagnostic servers must be deployed to live production machines.

Does Sharphy need to be installed on your production servers? NO.

Sharphy follows a Zero-Footprint, Post-Mortem Forensic Workflow. The analytical engines, decompilers, and AI agents run strictly in isolated development, CI/CD, or security analyst workstations:

┌──────────────────────────────────────────────┐
│         PRODUCTION ENVIRONMENT               │
│  (Zero Sharphy Footprint Required)           │
│                                              │
│  1. Unhandled crash / freeze occurs          │
│  2. Collect memory dump via official CLI:    │
│     dotnet-dump collect -p <PID>             │
│  3. Output: crash.dmp (Windows) / core (ELF) │
└──────────────────────┬───────────────────────┘
                       │ Secure SCP / S3 Dump Transfer
                       ▼
┌──────────────────────────────────────────────┐
│     ANALYST WORKSTATION / AI ENVIRONMENT     │
│  (Isolated Off-Site Inspection)              │
│                                              │
│  • AI Coding Agent (Cursor / Claude Code)    │
│  • Sharphy MCP Server (Sharphy.Cli / Server) │
│  • Automated RCA:                            │
│    - sharphy_analyze_dump                    │
│    - sharphy_inspect_heap                    │
│    - sharphy_deadlock_detector               │
└──────────────────────────────────────────────┘

Key Operational Benefits:

  1. Zero Production Risk: No third-party daemons, background agents, or persistent listeners are installed on mission-critical production servers.

  2. Standard Microsoft Tooling: Dump collection uses standard, officially supported Microsoft utilities (dotnet-dump, createdump, or OS crash reporting).

  3. Regulatory & Audit Compliance: Keeps production environments compliant with strict compliance standards (PCI-DSS, ISO/IEC 27001, SOC 2) by avoiding intrusive monitoring hooks.

  4. Air-Gapped & Offline Ready: Analysis can be performed in completely isolated, offline lab environments without remote runtime connectivity.


10 MCP Tools Catalog

Sharphy exposes ten specialized tools covering the full spectrum of .NET runtime analysis:

┌────────────────────────────────────────────────────────────────────────────┐
│                     SHARPHY 10 MCP TOOLS CATALOG                           │
├────────────────────────┬─────────────────────────┬─────────────────────────┤
│ Memory & Forensics     │ Decompilation & Diff    │ Bytecode & Metadata     │
├────────────────────────┼─────────────────────────┼─────────────────────────┤
│ • sharphy_analyze_dump │ • sharphy_decompile_... │ • sharphy_inspect_me... │
│ • sharphy_inspect_heap │ • sharphy_diff_assem... │ • sharphy_extract_to... │
│ • sharphy_deadlock_... │ • sharphy_clean_obfu... │ • sharphy_patch_il      │
│                        │                         │ • sharphy_generate_w... │
└────────────────────────┴─────────────────────────┴─────────────────────────┘

1. sharphy_analyze_dump

Automated Root Cause Analysis (RCA) on Windows (.dmp) and Linux (ELF core dump) CoreCLR memory crash dumps. Extracts crashing thread call stacks, unhandled exception objects, and faulty HRESULT codes.

2. sharphy_inspect_heap

Deep managed heap inspection, traversing GC segments, measuring generation distribution (Gen 0, Gen 1, Gen 2, LOH, POH), calculating fragmentation, and pinpointing memory leak retainers.

3. sharphy_deadlock_detector

Traverses the CLR SyncBlock synchronization cache and active thread Monitor locks, building a Wait-For Graph (WFG) to detect thread synchronization deadlock cycles.

4. sharphy_decompile_method

Reconstructs clean, modern idiomatic C# source code from compiled CIL bytecode using the embedded ILSpy engine, reconstructing async state machines and lambda captures.

5. sharphy_diff_assemblies

Performs semantic binary comparisons between two versions of an assembly, flagging added/removed types, breaking changes to public/protected APIs, and CIL instruction size shifts.

6. sharphy_inspect_metadata

Inspects ECMA-335 metadata tables, decoding TypeDef, MethodDef, FieldDef, custom attributes, P/Invoke native imports, and embedded resources.

7. sharphy_clean_obfuscation

Analyzes obfuscated assemblies, demangling Control Flow Graph (CFG) switch-flattening patterns, trimming excessive NOP sleds, and identifying dynamic proxy delegates.

8. sharphy_extract_tokens

Extracts tokens and types by loading assemblies into an isolated, collectible AssemblyLoadContext (isCollectible: true) without locking files on disk or polluting the host process.

9. sharphy_patch_il

Surgically modifies CIL bytecode instructions by replacing target opcodes, adjusting branch offsets, and re-emitting patched binary assemblies.

10. sharphy_generate_wrapper

Generates zero-overhead, strongly-typed C# wrapper code leveraging .NET 8+ [UnsafeAccessor] attributes to access private members and fields without reflection overhead.


Installation & Agent Integration

Quick Start

Install the global CLI tool via the .NET SDK:

dotnet tool install -g Sharphy.Cli

Agent Configuration (MCP Setup)

Add Sharphy to your AI coding client configuration:

Cursor (~/.cursor/mcp.json) or Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "sharphy": {
      "command": "sharphy",
      "args": ["mcp", "start"]
    }
  }
}

Multi-Targeting Architecture

Sharphy is engineered with native multi-targeting without emulation layers:

  • .NET 8.0 (LTS): Long-term enterprise stability.

  • .NET 9.0 (STS): Modern GC and performance optimizations.

  • .NET 10.0 (Latest): Cutting-edge compiler APIs and runtime features.


License

Sharphy is distributed under the Apache License, Version 2.0. Copyright (c) 2026 Moh. Baharudin Yuda Maulidi. All rights reserved.

Available Tools

10 tools
sharphy_analyze_dumpA

Performs automated Root Cause Analysis (RCA) on Windows (.dmp) and Linux (ELF core dump) crash dumps. Use this tool when diagnosing fatal process crashes, unhandled exceptions, or crashing thread call stacks. Do NOT use for thread deadlock cycles (use 'sharphy_deadlock_detector') or heap memory leaks (use 'sharphy_inspect_heap'). This is a non-destructive, read-only diagnostic inspection.

Inputs: dumpPath (required).

sharphy_clean_obfuscationA

Demangles control flow flattening (CFG demangling), trims dead code and excessive NOP sleds, and analyzes dynamic proxy delegates. Use this tool when reverse engineering obfuscated assemblies to produce a cleaner assembly for analysis. Do NOT use for direct opcode modification (use 'sharphy_patch_il'). Mutates by creating a cleaned assembly at outputPath.

Inputs: outputPath (required), assemblyPath (required).

sharphy_deadlock_detectorA

Detects thread synchronization deadlocks and lock contention by traversing CLR SyncBlocks and building a Wait-For Graph (WFG). Use this tool when diagnosing unresponsive or frozen .NET applications suspected of thread lock cycles. Do NOT use for unhandled exception crashes (use 'sharphy_analyze_dump') or heap analysis (use 'sharphy_inspect_heap'). Non-destructive, read-only inspection.

Inputs: dumpPath (required).

sharphy_decompile_methodA

Decompiles compiled CIL bytecode into idiomatic C# source code using the embedded ILSpy engine. Use this tool when inspecting method logic, lambda expressions, or async state machines of a compiled assembly. Do NOT use for metadata enumeration (use 'sharphy_inspect_metadata') or binary diffing (use 'sharphy_diff_assemblies'). Read-only inspection.

Inputs: typeName (required), methodName (required), assemblyPath (required).

sharphy_diff_assembliesA

Compares two versions of a compiled .NET assembly at the ECMA-335 metadata level to identify added/removed types, API breaking changes, and unified line-by-line CIL instruction diffs. Use this tool when validating library updates, regression testing, or detecting API modifications. Do NOT use for decompiling full method bodies (use 'sharphy_decompile_method'). Read-only comparison.

Inputs: newAssemblyPath (required), oldAssemblyPath (required), includeCilDiff.

sharphy_extract_tokensA

Safely extracts runtime tokens and types by loading target assemblies inside an isolated collectible AssemblyLoadContext (isCollectible: true). Use this tool when dynamically inspecting types without locking files on disk or polluting the host runtime. Do NOT use for static disassembly without runtime loading (use 'sharphy_inspect_metadata'). Sandboxed read-only execution.

Inputs: assemblyPath (required).

sharphy_generate_wrapperA

Generates strongly-typed C# wrapper source code utilizing .NET 8+ [UnsafeAccessor] attributes to access private members and fields with zero reflection overhead. Use this tool when testing or accessing inaccessible internal/private APIs. Do NOT use for bytecode modification (use 'sharphy_patch_il'). Mutates disk by writing a new C# (.cs) source file to outputPath.

Inputs: typeName (required), outputPath (required), assemblyPath (required).

sharphy_inspect_heapA

Inspects managed heap allocations, generation sizes (Gen 0/1/2, LOH, POH), fragmentation, and object leak retainers in a memory dump. Use this tool when diagnosing high memory usage, memory leaks, or OutOfMemoryException. Do NOT use for general crash RCA (use 'sharphy_analyze_dump') or thread lock cycles (use 'sharphy_deadlock_detector'). Non-destructive, read-only inspection.

Inputs: dumpPath (required), topObjects.

sharphy_inspect_metadataA

Decodes ECMA-335 metadata tables including TypeDef, MethodDef, FieldDef, custom attributes, P/Invoke imports, and embedded resources. Use this tool when discovering types and member signatures of an assembly without decompiling method bodies. Do NOT use for binary comparisons (use 'sharphy_diff_assemblies'). Read-only inspection.

Inputs: assemblyPath (required).

sharphy_patch_ilA

Surgically modifies CIL bytecode instructions by replacing target opcodes, adjusting branch targets, and emitting a patched binary. Use this tool when bypassing validation logic, inserting NOP sleds, or altering execution flow. Do NOT use for general obfuscation stripping (use 'sharphy_clean_obfuscation'). Mutates by writing a patched assembly to outputPath.

Inputs: typeName (required), newOpCode (required), methodName (required), outputPath (required), +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 10 tools

    Disambiguation5/5

    Each tool targets a distinct action and artifact: metadata inspection, decompilation, IL patching, obfuscation cleanup, diffing, wrapper generation, token extraction, and three separate runtime diagnostics. The descriptions explicitly disambiguate close areas, such as metadata inspection vs runtime token extraction and crash RCA vs deadlock vs heap analysis.

    Naming Consistency4/5

    All tools use a consistent sharphy_ snake_case prefix, and most follow a clear verb_noun pattern such as sharphy_inspect_metadata, sharphy_patch_il, and sharphy_decompile_method. The one deviation is sharphy_deadlock_detector, which is noun-based rather than verb_noun, but it remains readable and predictable.

    Tool Count5/5

    Ten tools is well-scoped for a .NET reverse-engineering and diagnostics server. Each tool covers a distinct stage or artifact, and there is no obvious filler or redundant tool.

    Completeness4/5

    The surface covers the major workflows: metadata inspection, decompilation, IL patching, obfuscation cleanup, assembly diffing, wrapper generation, runtime token extraction, crash dumps, deadlocks, and heap analysis. Minor gaps remain, such as an explicit raw IL disassembly/listing operation or bulk type/member search, but agents can work around these with existing tools.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      An Model Context Protocol server that enables LLMs to autonomously reverse engineer applications by exposing Ghidra's decompilation and analysis tools. It allows AI agents to list code structures, rename methods, and analyze binaries directly through MCP-compatible clients.
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      A local, privacy-first MCP server that orchestrates Ghidra, Binary Ninja, x64dbg, and system tools to provide AI assistants with powerful binary analysis capabilities.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      An MCP server that exposes dynamic binary instrumentation, memory editing, pointer scanning, and scripting capabilities to AI agents, enabling real-time process inspection and modification.
      MIT