SharpToolsMCP
A suite of MCP tools for AIs to analyze and modify C solutions with high signal, Roslyn powered context.。主要特性包括: FQN based navigation means the agent rarely needs to read unrelated code.、 Comprehensive Source Resolution: Retrieves source code for symbols from:、 Local solution files.。还包含 2 个其他特性。
详细介绍
项目简介
A suite of MCP tools for AIs to analyze and modify C solutions with high signal, Roslyn powered context.。主要特性包括: FQN based navigation means the agent rarely needs to read unrelated code.、 Comprehensive Source Resolution: Retrieves source code for symbols from:、 Local solution files.。还包含 2 个其他特性。
主要特性
- • Dynamic Project Structure Mapping: Generates a "map" of the solution, detailing namespaces and types, with complexity-adjusted resolution.
- • Contextual Navigation Aids: Provides simplified call graphs and dependency trees for local code understanding.
- • All indentation is omitted in returned code, saving roughly 10% of tokens without affecting performance on the smartest models.
- • FQN based navigation means the agent rarely needs to read unrelated code.
- • FQN Fuzzy Matching: Intelligently resolves potentially imprecise or incomplete Fully Qualified Names (FQNs) to exact Roslyn symbols.
- • Comprehensive Source Resolution: Retrieves source code for symbols from:
适用场景
快速开始
# 克隆仓库
git clone https://github.com/kooshi/SharpToolsMCP
# 进入目录
cd SharpToolsMCP
# 查看文档
cat README.md原文 README
SharpTools: Roslyn Powered C# Analysis & Modification MCP Server
SharpTools is a robust service designed to empower AI agents with advanced capabilities for understanding, analyzing, and modifying C# codebases. It leverages the .NET Compiler Platform (Roslyn) to provide deep static analysis and precise code manipulation, going far beyond simple text-based operations.
SharpTools is designed to give AI the same insights and tools a human developer relies on, leading to more intelligent and reliable code assistance. It is effectively a simple IDE, made for an AI user.
Due to the comprehensive nature of the suite, it can almost be used completely standalone for editing existing C# solutions. If you use the SSE server and port forward your router, I think it's even possible to have Claude's web chat ui connect to this and have it act as a full coding assistant.
Prompts
The included Identity Prompt is my personal C# coding assistant prompt, and it works well in combination with this suite. You're welcome to use it as is, modify it to match your preferences, or omit it entirely.
In VS Code, set it as your copilot-instructions.md to have it included in every interaction.
The Tool Use Prompt is fomulated specifically for Github Copilot's Agent mode. It overrides specific sections within the Copilot Agent System Prompt so that it avoids the built in tools.
It is available as an MCP prompt as well, so within Copilot, you just need to type /mcp, and it should show up as an option.
Something similar will be necessary for other coding assistants to prevent them from using their own default editing tools.
I recommend crafting custom tool use prompts for each agent you use this with, based on their individual system prompts.
Note
This is a personal project, slapped together over a few weeks, and built in no small part by its own tools. It generally works well as it is, but the code is still fairly ugly, and some of the features are still quirky (like removing newlines before and after overwritten members).
I intend to maintain and improve it for as long as I am using it, and I welcome feedback and contributions as a part of that.
Features
- Dynamic Project Structure Mapping: Generates a "map" of the solution, detailing namespaces and types, with complexity-adjusted resolution.
- Contextual Navigation Aids: Provides simplified call graphs and dependency trees for local code understanding.
- Token Efficient Operation Designed to provide only the highest signal context at every step to keep your agent on track longer without being overwhelmed or requiring summarization.
- All indentation is omitted in returned code, saving roughly 10% of tokens without affecting performance on the smartest models.
- FQN based navigation means the agent rarely needs to read unrelated code.
- FQN Fuzzy Matching: Intelligently resolves potentially imprecise or incomplete Fully Qualified Names (FQNs) to exact Roslyn symbols.
- Comprehensive Source Resolution: Retrieves source code for symbols from:
- Local solution files.
- External libraries via SourceLink.
- Embedded PDBs.
- Decompilation (ILSpy-based) as a fallback.
- Precise, Roslyn-Based Modifications: Enables surgical code changes (add/overwrite/rename/move members, find/replace) rather than simple text manipulation.
- Automated Git Integration:
- Creates dedicated, timestamped
sharptools/branches for all modifications. - Automatically commits every code change with a descriptive message.
- Offers a Git-powered
Undofor the last modification.
- Creates dedicated, timestamped
- Concise AI Feedback Loop:
- Confirms changes with precise diffs instead of full code blocks.
- Provides immediate, in-tool compilation error reports after modifications.
- Proactive Code Quality Analysis:
- Detects and warns about high code complexity (cyclomatic, cognitive).
- Identifies semantically similar code to flag potential duplicates upon member addition.
- Broad Project Support:
- Runs on Windows and Linux (and probably Mac)
- Can analyze projects targeting any .NET version, from Framework to Core to 5+
- Compatible with both modern SDK-style and legacy C# project formats.
- Respects
.editorconfigsettings for consistent code formatting.
- MCP Server Interface: Exposes tools via Model Context Protocol (MCP) through:
- Server-Sent Events (SSE) for remote clients.
- Standard I/O (Stdio) for local process communication.
Exposed Tools
SharpTools exposes a variety of "SharpTool_*" functions via MCP. Here's a brief overview categorized by their respective service files:
Solution Tools
SharpTool_LoadSolution: Initializes the workspace with a given.slnfile. This is the primary e