Logo SharpToolsMCP

SharpToolsMCP

Cộng đồng
kooshi

A suite of MCP tools for AIs to analyze and modify C# solutions with high signal, Roslyn powered context.

Nhà phát hànhkooshi
Kho mãSharpToolsMCP
Ngôn ngữC#
Bản fork
37
Sao
224
Công cụ có sẵn
0
Phương thức truyền tảistdio
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    SharpToolsMCP cung cấp các khả năng MCP mà ứng dụng khách và tác nhân AI tương thích có thể sử dụng.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Cấu hình sẵn để sao chép

    Dùng các đoạn cấu hình cài đặt mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Chỉ số quan tâm đến mã nguồn mở

    224 sao và 37 bản fork từ kho mã được liên kết.

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 Undo for the last modification.
  • 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 .editorconfig settings 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 .sln file. This is the primary entry point.
  • SharpTool_LoadProject: Provides a detailed structural overview of a specific project within the loaded solution, including namespaces and types, to aid AI understanding of the project's layout.

Analysis Tools

  • SharpTool_GetMembers: Lists members (methods, properties, etc.) of a type, including signatures and XML documentation.
  • SharpTool_ViewDefinition: Displays the source code of a symbol (class, method, etc.), including contextual information like call graphs or type references.
  • SharpTool_ListImplementations: Finds all implementations of an interface/abstract method or derived classes of a base class.
  • SharpTool_FindReferences: Locates all usages of a symbol across the solution, providing contextual code snippets.
  • SharpTool_SearchDefinitions: Performs a regex-based search across symbol declarations and signatures in both source code and compiled assemblies.
  • SharpTool_ManageUsings: Reads or overwrites using directives in a document.
  • SharpTool_ManageAttributes: Reads or overwrites attributes on a specific declaration.
  • SharpTool_AnalyzeComplexity: Performs complexity analysis (cyclomatic, cognitive, coupling, etc.) on methods, classes, or projects.
  • (Disabled) SharpTool_GetAllSubtypes: Recursively lists all nested members of a type.
  • (Disabled) SharpTool_ViewInheritanceChain: Shows the inheritance hierarchy for a type.
  • (Disabled) SharpTool_ViewCallGraph: Displays incoming and outgoing calls for a method.
  • (Disabled) SharpTool_FindPotentialDuplicates: Finds semantically similar methods or classes.

Document Tools

  • SharpTool_ReadRawFromRoslynDocument: Reads the raw content of a file (indentation omitted).
  • SharpTool_CreateRoslynDocument: Creates a new file with specified content.
  • SharpTool_OverwriteRoslynDocument: Overwrites an existing file with new content.
  • SharpTool_ReadTypesFromRoslynDocument: Lists all types and their members defined within a specific source file.

Modification Tools

  • SharpTool_AddMember: Adds a new member (method, property, field, nested type, etc.) to a specified type.
  • SharpTool_OverwriteMember: Replaces the definition of an existing member or type with new code, or deletes it.
  • SharpTool_RenameSymbol: Renames a symbol and updates all its references throughout the solution.
  • SharpTool_FindAndReplace: Performs regex-based find and replace operations within a specified symbol's declaration or across files matching a glob pattern.
  • SharpTool_MoveMember: Moves a member from one type/namespace to another.
  • SharpTool_Undo: Reverts the last applied change using Git integration.
  • (Disabled) SharpTool_ReplaceAllReferences: Replaces all references to a symbol with specified C# code.

Package Tools

  • (Disabled) SharpTool_AddOrModifyNugetPackage: Adds or updates a NuGet package reference in a project file.

Misc Tools

  • SharpTool_RequestNewTool: Allows the AI to request new tools or features, logging the request for human review.

Prerequisites

  • .NET 8+ SDK for running the server
  • The .NET SDK of your target solution

Building

To build the entire solution:

bash
dotnet build SharpTools.sln

This will build all services and server applications.

Running the Servers

SSE Server (HTTP)

The SSE server hosts the tools on an HTTP endpoint.

bash
# Navigate to the SseServer project directory
cd SharpTools.SseServer

# Run with default options (port 3001)
dotnet run

# Run with specific options
dotnet run -- --port 3005 --log-file ./logs/mcp-sse-server.log --log-level Debug

Key Options:

  • --port <number>: Port to listen on (default: 3001).
  • --log-file <path>: Path to a log file.
  • --log-level <level>: Minimum log level (Verbose, Debug, Information, Warning, Error, Fatal).
  • --load-solution <path>: Path to a .sln file to load on startup. Useful for manual testing. It is recommended to let the AI run the LoadSolution tool instead, as it returns some useful information.
  • --build-configuration <config>: Build configuration to use when loading the solution (e.g., Debug, Release).
  • --disable-git: Disables all Git integration features.

Stdio Server

The Stdio server communicates over standard input/output.

Configure it in your MCP client of choice. VSCode Copilot example:

json
"mcp": {
    "servers": {
        "SharpTools": {
            "type": "stdio",
            "command": "/path/to/repo/SharpToolsMCP/SharpTools.StdioServer/bin/Debug/net8.0/SharpTools.StdioServer",
            "args": [
                "--log-directory",
                "/var/log/sharptools/",
                "--log-level",
                "Debug",
            ]
        }
    }
},

Key Options:

  • --log-directory <path>: Directory to store log files.
  • --log-level <level>: Minimum log level.
  • --load-solution <path>: Path to a .sln file to load on startup. Useful for manual testing. It is recommended to let the AI run the LoadSolution tool instead, as it returns some useful information.
  • --build-configuration <config>: Build configuration to use when loading the solution (e.g., Debug, Release).
  • --disable-git: Disables all Git integration features.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Dùng MCP SharpToolsMCP với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối SharpToolsMCP, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Cài trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Cài trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Giữ tiến trình chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Giữ tiến trình trong cửa sổ Terminal chạy trong khi dùng các công cụ MCP.
3

Thêm SharpToolsMCP làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của SharpToolsMCP.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "sharptoolsmcp": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của SharpToolsMCP, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của SharpToolsMCP.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện TypingMind dùng các công cụ MCP đã bật với một mô hình AI được chọn
Bạn có thể dùng SharpToolsMCP giúp tôi làm việc này không?
SharpToolsMCP
Được. Tôi đã đọc.
Đây là kết quả tôi tìm được bằng SharpToolsMCP.

Câu hỏi thường gặp

Máy chủ MCP SharpToolsMCP dùng để làm gì?

SharpToolsMCP là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP SharpToolsMCP với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng SharpToolsMCP với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP SharpToolsMCP với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối SharpToolsMCP, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP SharpToolsMCP với TypingMind?

SharpToolsMCP hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP SharpToolsMCP cung cấp những công cụ nào trong TypingMind?

SharpToolsMCP cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP SharpToolsMCP không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu SharpToolsMCP yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇