logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

dotnet-pkg-context-engine

A service implementing the Model Context Protocol (MCP) to furnish comprehensive metadata concerning .NET dependencies managed via NuGet. It facilitates programmatic querying of package catalogs, dependency resolution from project files, and metadata retrieval from remote feeds, thereby integrating live package context into automated workflows.

Author

dotnet-pkg-context-engine logo

plucked

MIT License

Quick Info

GitHub GitHub Stars 3
NPM Weekly Downloads 0
Tools 1
Last Updated 2026-02-19

Tags

nugetapishttpnuget contextnuget packagessearches nuget

Dependency Context Server for .NET (NuGet Focus)

License: MIT smithery badge CI Status

This C# utility operates as a dedicated server adhering to the Model Context Protocol (MCP) specification. Its primary function is furnishing contextual intelligence regarding C#/.NET project dependencies (specifically NuGet artifacts) to advanced computational models (LLMs) or specialized tooling.

System Overview

The engine systematically parses C# solution (.sln) and project (.csproj) definitions to distill intricate NuGet package relationship data. It interfaces directly with configured NuGet artifact repositories to procure version information and descriptive metadata, persisting frequently accessed data locally via an SQLite database for optimized retrieval speeds. All these functionalities are exposed as callable tools conforming to the MCP standard, enabling external systems to query dependency landscapes programmatically.

Exposed Capabilities

The server offers the following distinct MCP operations:

  • AnalyzeProjectDependencies: Scans specified solution or project files, identifying direct NuGet dependencies and determining their currently available superior versions.
  • SearchNuGetPackages: Executes catalog searches against configured repositories using a query string, supporting result pagination and inclusion of unstable (pre-release) versions.
  • GetNuGetPackageVersions: Enumerates every known published revision (both stable and unstable) for a given package identifier.
  • GetLatestNuGetPackageVersion: Fetches the most recent stable or pre-release version string associated with a package ID.
  • GetNuGetPackageDetails: Retrieves exhaustive descriptive attributes (summaries, authorship, source URLs, etc.) for a package at a specified version or its latest release.

Essential Requirements

  • A compatible .NET Runtime Environment, specifically targeting .NET 9 SDK or a later iteration.

Acquisition & Compilation

  1. Source Code Retrieval: bash git clone https://github.com/plucked/nuget-context-server cd nuget-context-server
  2. Building the Executable: bash dotnet build --configuration Release The operational binary resides in the src/NuGetContextMcpServer.Host/bin/Release/net9.0/ pathway (verify exact path post-compilation).

Quality Assurance

Testing relies on NUnit for foundational unit validation and Moq for simulating external dependencies in isolated unit tests.

To execute the complete test suite, navigate to the repository root directory and run:

dotnet test

Crucial Note: Executing the integration suite (NuGetContextMcpServer.Integration.Tests) necessitates an active Docker installation, as these tests frequently employ containerized environments for resource simulation.

Test project breakdown within the tests/ folder: * NuGetContextMcpServer.Application.Tests: Validates business logic and service layer interactions. * NuGetContextMcpServer.Infrastructure.Tests: Focuses on data access, parsing, and caching implementations. * NuGetContextMcpServer.Integration.Tests: Verifies end-to-end functionality, potentially touching the filesystem or simulated external services.

Operational Guide & Parametrization

This server component is intended to be initiated by an external MCP consumer (e.g., an IDE plugin). The client manages the server process lifecycle and handles inter-process communication, typically over standard input/output (stdio).

Configuration Parameters:

Configuration settings are managed via appsettings.json (and environment-specific overrides) located within the src/NuGetContextMcpServer.Host structure:

  • NuGetSettings Section:
    • QueryFeedUrl: The endpoint index for the NuGet v3 API (default: https://api.nuget.org/v3/index.json).
    • Username (Optional): Credentials for accessing secured artifact sources.
    • PasswordOrPat (Optional): Secret token or password for authenticated feeds.
  • CacheSettings Section:
    • DatabasePath: Specifies the location for the local SQLite persistence store (default: nuget_cache.db relative to the working directory).
    • DefaultExpirationMinutes: Time-to-live (TTL) for cached entries, measured in minutes (default: 60).
  • Logging: Handled via Serilog settings within the configuration file; output is generally directed to a log file by default.

Example Client Invocation (Using stdio Transport):

An MCP client configuration block might resemble this (syntax is client-dependent):

{
  "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 interpreter (dotnet).
  • args: Parameters passed. During development, dotnet watch run facilitates auto-reloading on source file modifications. The --transport stdio directive instructs the server to use standard I/O channels for MCP message exchange. For deployment/production, replace "watch" with "run" and omit "--non-interactive".
  • cwd: The execution starting directory (typically the repository root).

Structural Design

The engine adheres to the .NET Generic Host pattern, featuring distinct architectural layers:

  • Host Layer: Manages application lifecycle, configuration sourcing, dependency injection setup, logging integration, and initialization of the MCP communication channel.
  • Application Layer: Defines the abstract service contracts and encapsulates the core processing logic, including the definition schemas for all exposed MCP tools.
  • Infrastructure Layer: Contains concrete implementation details for external interactions:
    • NuGet Feed Connectivity (NuGet.Protocol libraries).
    • Build File Parsing Utilities (Microsoft.Build components).
    • Data Persistence and Retrieval mechanisms (Microsoft.Data.Sqlite).

Collaboration

Contributions are actively encouraged! Consult the CONTRIBUTING.md documentation for submission protocols and guidelines.

Licensing

This software is distributed under the permissive MIT License. See the accompanying LICENSE file for exhaustive terms.

See Also

`