Sharphy

io.github.baharmaulidiii由 GitHub 账号 baharmaulidiii 发布v1.1.1更新于 Oct 31, 2026

CLR Intelligence and Runtime Forensic Bridge for AI Coding Agents.

已验证STDIO仅桌面开发者工具安全与监控

概览

AI 生成的概览

Sharphy 是一个本地 .NET 诊断 MCP 服务器,让 AI 编程助手分析 CLR 崩溃转储、检查托管堆,并反编译或修改 .NET 程序集。

可以做什么
  • 分析崩溃转储:对 Windows .dmp 与 Linux ELF core dump 做根因分析,提取崩溃线程调用栈与异常对象
  • 检查内存与线程:遍历托管堆、统计分代与碎片、定位内存泄漏持有者,并检测死锁环路
  • 反编译与比对:从 CIL 还原 C# 源码,并比较两个程序集版本的 API 与字节码变化
  • 检查与清理元数据:读取 ECMA-335 元数据表、P/Invoke 导入与资源,并分析混淆
  • 修改与生成代码:修补 CIL 指令并重新输出程序集、在隔离加载上下文中提取令牌,以及生成强类型 C# 包装代码
适用场景
适合在助手无法获得源码时理解 .NET 程序:根据已收集的转储诊断生产环境崩溃或卡死、排查内存泄漏,或理解并比较编译后的第三方程序集。定位是分析工作站上的事后分析,而非生产环境实时监控。
运行要求
以本地 stdio 进程运行,需通过 .NET SDK 安装 .NET 全局工具 Sharphy.Cli,并以 mcp start 参数启动;支持 .NET 8、9 或 10。转储文件需另行收集,例如使用 dotnet-dump。未声明任何认证、环境变量或请求头。
安装前请注意
该服务器可修改二进制文件:IL 修补工具会改写字节码并重新输出程序集,请只在副本上操作。反编译和分析第三方二进制可能涉及许可或法律风险,README 将合规责任归于用户。崩溃转储和程序集可能包含敏感内存内容,应在可信、最好离线的机器上分析。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Sharphy,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[Sharphy Logo]

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.

[NuGet Package] [NuGet Prefix Reserved] [Official MCP Registry Verified] [PulseMCP Listed] [Glama MCP Server] [MCP Catalog] [.NET 8/9/10] [Apache License 2.0] [Contributor Covenant] [GitHub Repo]

Architecture · Ecosystem · MCP Catalog · Agent Setup · Policies & Legal · Changelog · Contributing · Code of Conduct

[!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  │└─────────────────────────────────────────────────────────────┘

Package Ecosystem & Roles

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

Package / ModuleDistributionTarget AudienceArchitectural Role & Technical Scope
Sharphy.Cli.NET Global ToolEnd Users & AgentsCommand-line entry point. Operates as an instant zero-configuration launcher for the MCP host server (sharphy mcp start) or quick inspection utilities.
Sharphy.ServerClass Library / HostAgent Frameworks & HostsImplements 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.CoreClass Library EngineCLR Engineers & BuildersPure 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:

bash
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):

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.

Community Standards, Security & Legal Policies

License

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

来源:README.md,提交 ffe227b

工具

0
SourceWeft 曾在隔离沙箱中以无凭据方式启动该软件包一次,以列出其工具,但未能完成:该软件包类型无法在沙箱中运行。

版本历史

3
  1. v1.1.1最新Oct 31, 2026
  2. v1.1.0Oct 30, 2026
  3. v1.0.6Oct 29, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分