Sponsored by Deepsite.site

NuGet Context MCP Server

Created By
plucked8 months ago
MCP server written in .net to interact with NuGet package servers
Content

NuGet Context MCP Server

License: MIT smithery badge .NET Test

A C# application that functions as a Model Context Protocol (MCP) server, providing context about .NET project dependencies (NuGet packages) to Large Language Models (LLMs) or other development tools.

Overview

This server analyzes .NET solutions (.sln) and projects (.csproj) to extract NuGet package information. It interacts with NuGet feeds to fetch package details, versions, and metadata, caching results locally using SQLite for improved performance. These capabilities are exposed as tools via the Model Context Protocol (MCP), allowing AI agents or other tools to query NuGet information programmatically.

Features

The server exposes the following tools via MCP:

  • AnalyzeProjectDependencies: Analyzes a .sln or .csproj file to find NuGet dependencies and their latest available versions.
  • SearchNuGetPackages: Searches the configured NuGet feed for packages matching a search term, with options for pagination and including pre-release versions.
  • GetNuGetPackageVersions: Lists all available versions (stable or pre-release) for a specific package ID.
  • GetLatestNuGetPackageVersion: Gets the latest stable or pre-release version string for a specific package ID.
  • GetNuGetPackageDetails: Retrieves detailed metadata (description, authors, URLs, etc.) for a specific package ID and optional version.

Prerequisites

  • .NET 9 SDK (or later compatible version)

Installation & Build

  1. Clone the repository:
    git clone https://github.com/plucked/nuget-context-server
    cd nuget-context-server
    
  2. Build the server:
    dotnet build --configuration Release
    
    The main executable will be within the src/NuGetContextMcpServer.Host/bin/Release/net9.0/ directory (adjust path based on actual build output).

Testing

This project uses NUnit for unit and integration testing and Moq for mocking dependencies in unit tests.

To run all tests, navigate to the repository root and execute:

dotnet test

Note: Running the integration tests (NuGetContextMcpServer.Integration.Tests) requires Docker to be installed and running, as they may utilize test containers. You can download Docker Desktop from here.

The test projects are located in the tests/ directory:

  • NuGetContextMcpServer.Application.Tests: Unit tests for the application layer services.
  • NuGetContextMcpServer.Infrastructure.Tests: Unit tests for the infrastructure layer components (e.g., caching, parsing).
  • NuGetContextMcpServer.Integration.Tests: Integration tests that may interact with actual file systems or potentially external resources (though typically mocked or using local test assets).

Usage & Configuration

This server is designed to be run by an MCP client application (like an IDE extension). The client is responsible for starting the server process and communicating with it, typically via standard input/output (stdio).

Configuration:

The server uses appsettings.json (and environment-specific overrides like appsettings.Development.json) located in the src/NuGetContextMcpServer.Host directory for configuration:

  • NuGetSettings:
    • QueryFeedUrl: The URL of the NuGet v3 feed index (defaults to https://api.nuget.org/v3/index.json).
    • Username (optional): Username for authenticated feeds.
    • PasswordOrPat (optional): Password or Personal Access Token (PAT) for authenticated feeds.
  • CacheSettings:
    • DatabasePath: Path to the SQLite cache file (defaults to nuget_cache.db in the working directory).
    • DefaultExpirationMinutes: Default cache duration in minutes (defaults to 60).
  • Logging: Configured via Serilog settings in appsettings.json. Logs are written to a file by default.

Example MCP Client Configuration (using stdio):

An MCP client would typically need configuration similar to this (syntax may vary based on the client):

{
  "mcpServers": {
    "nuget-context": {
      "command": "dotnet",
      "args": [
        "watch",
        "run",
        "--non-interactive",
        "--project",
        "src/NuGetContextMcpServer.Host/NuGetContextMcpServer.Host.csproj",
        "--",
        "--transport", "stdio"
      ],
      "cwd": ".",
      "disabled": false
    }
  }
}
  • command: The executable to run (dotnet).
  • args: Arguments passed to the command. Uses dotnet watch run for development to automatically restart the server on file changes. The --transport stdio argument tells the server to use standard I/O for MCP communication. For production or non-watch scenarios, replace "watch" with "run" and remove "--non-interactive".
  • cwd: The working directory from which the command should be run (usually the repository root).

Architecture

The server uses a layered architecture built on the .NET Generic Host:

  • Host: Manages application lifetime, Dependency Injection (DI), configuration, logging, and MCP communication setup.
  • Application: Defines service interfaces and contains core application logic and MCP tool definitions.
  • Infrastructure: Provides concrete implementations for:
    • NuGet feed interaction (NuGet.Protocol).
    • Project/Solution parsing (Microsoft.Build).
    • Caching (Microsoft.Data.Sqlite).

Contributing

Contributions are welcome! Please refer to the contribution guidelines for more details.

License

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

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
WindsurfThe new purpose-built IDE to harness magic
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
CursorThe AI Code Editor
DeepChatYour AI Partner on Desktop
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Amap Maps高德地图官方 MCP Server
Tavily Mcp
ChatWiseThe second fastest AI chatbot™
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Serper MCP ServerA Serper MCP Server
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.