Use this command to install DimonSmart.NugetMcpServer:
winget install --id=DimonSmart.NugetMcpServer -e
MCP server for searching interfaces and their methods inside NuGet packages
DimonSmart.NugetMcpServer is a Model Context Protocol (MCP) server designed to enable communication between language models and external tools. It provides functionality for searching interfaces and their methods within NuGet packages, facilitating seamless integration between AI-driven applications and existing codebases.
Key Features:
MCP server implementation supporting STDIO transport for client communication.
Sample tool (TimeTool) that demonstrates basic functionality by returning the current server time in ISO 8601 format.
InterfaceLookupService for extracting interface definitions from NuGet packages, including support for listing all public interfaces within a package.
Built using .NET 9.0, ensuring compatibility with modern development environments.
Audience & Benefit:
Ideal for developers working with NuGet packages, AI-driven applications, or MCP protocol implementations. The server enables efficient integration of external tools and services into language model workflows, reducing the complexity of tool interaction while maintaining scalability.
The software can be installed via winget, ensuring straightforward setup and deployment across compatible environments.
README
NugetMcpServer
A powerful MCP server for getting accurate interface, class, enum, record, and struct definitions from NuGet packages. It helps reduce LLM hallucinations by giving precise information about real package APIs.
Certified by MCPHub
Overview
This application is not just a demo. It is a practical MCP server that provides accurate, up-to-date information about methods and types in specific NuGet package versions. Instead of using old training data, language models can ask for real package metadata and type definitions directly from NuGet.
The server uses the Model Context Protocol (MCP). This makes it easy to connect with AI assistants and development tools. It gives real-time access to package information, helping developers and AI systems make better decisions about API usage.
You can use this server with OllamaChat, VS Code with Copilot, and other MCP-compatible clients.
Features
Real-time extraction of interfaces, classes, records, structs, and enums from NuGet packages
Smart package search with AI-enhanced keyword generation
Two-phase search: direct search + AI fallback for better results
Comma-separated keyword search for fast targeted results with balanced distribution
Package popularity ranking by download count
Meta-package detection with clear warnings and dependency guidance
Reduces LLM hallucinations by giving accurate API information
Supports specific package versions or latest version
Supports generic types with correct C# formatting
Can list and read arbitrary files from NuGet packages
Uses STDIO for client communication
Includes a time utility tool for basic server checks
Built with .NET 9.0 for good performance
Easy to integrate with VS Code, OllamaChat, and other MCP clients
Prerequisites
.NET 9.0 SDK or higher
A compatible MCP client for testing (for example, OllamaChat)
Installation
Option 1: Install via WinGet (Recommended)
You can install NugetMcpServer using WinGet:
winget install DimonSmart.NugetMcpServer
After installation, you can add the server to VS Code and other MCP-compatible clients. For VS Code:
Services/MetaPackageDetector.cs - Detects and handles meta-packages
Services/Formatters/ - Specialized result formatters for different output types
Common/McpToolBase.cs - Base class for MCP tools with common functionality
Extensions/ - Extension methods for string formatting, exception handling, and progress notification
Implementation Details
The server uses the .NET Generic Host and includes:
Console logging set to trace level
MCP server registered with STDIO transport
Automatic discovery and registration of tools using reflection
HttpClient service for downloading NuGet packages
In-memory caching for improved performance
NuGetPackageService for package operations
Multiple formatting services for different C# constructs (interfaces, classes, enums)
Archive processing service for efficient package analysis
Meta-package detection and dependency resolution
Progress notification system for long-running operations
Version support with --version or -v command line arguments
Comprehensive test suite covering all tools and services
Windows-optimized single-file deployment with CET compatibility handling
Available Tools
TimeTool
get_current_time() - Returns the current server time in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ)
Interface Tools
get_interface_definition(packageId, interfaceName?, version?) - Gets the C# interface definition from a NuGet package. Parameters: packageId (NuGet package ID), interfaceName (optional, short name without namespace), version (optional, defaults to latest)
list_interfaces(packageId, version?) - Lists all public interfaces in a NuGet package. Returns package ID, version, and the list of interfaces
Enum Tools
get_enum_definition(packageId, enumName, version?) - Gets the C# enum definition from a NuGet package. Parameters: packageId (NuGet package ID), enumName (short name without namespace), version (optional, defaults to latest)
Class Tools
get_class_or_record_or_struct_definition(packageId, typeName, version?) - Gets the C# class, record or struct definition from a NuGet package. Parameters: packageId (NuGet package ID), typeName (short or full name), version (optional, defaults to latest)
list_classes_records_structs(packageId, version?) - Lists all public classes, records and structs in a NuGet package. Returns package ID, version, and the list of types
Package File Tools
list_package_files(packageId, version?) - Lists all files in a NuGet package.
get_package_file(packageId, filePath, version?, offset?, bytes?) - Reads a file from a NuGet package. Returns text or base64 for binary files. Maximum chunk size is 1 MB.
Package Search Tools
search_packages(query, maxResults?, fuzzySearch?) - Searches for NuGet packages by description or functionality.
Standard search mode (fuzzySearch=false, default): Performs direct search for the full query and also searches each comma-separated keyword if provided
Fuzzy search mode (fuzzySearch=true): Starts with the standard search and additionally tries each individual word and AI-generated package name alternatives
AI analyzes user's functional requirements and generates 3 most likely package names (e.g., "maze generation" → "MazeGenerator MazeBuilder MazeCreator")
Returns up to 50 most popular packages with details including download counts, descriptions, and project URLs
Results are sorted by popularity (download count) for better relevance
Package Information Tools
get_package_info(packageId, version?) - Gets comprehensive information about a NuGet package including metadata, dependencies, and meta-package status. Shows clear warnings for meta-packages and guidance on where to find actual implementations.
Package Dependencies Tools
Note: Package dependencies are now included in the get_package_info tool response, providing complete package information in a single call.
MCP Server Response Examples
Here are examples of server responses from the MCP tools using DimonSmart.MazeGenerator as a sample package:
GetInterfaceDefinition Example
User Query Example
A user might ask:
> "I want to generate mazes in my .NET application. Is there a package for that? Can you show me the interface for DimonSmart.MazeGenerator so I can see how to use it?"
The agent would use the MCP server to get the interface definition:
{
"result": "namespace DimonSmart.MazeGenerator\n{\n /// \n /// Interface for maze generation algorithms\n /// \n public interface IMazeGenerator\n {\n /// \n /// Creates a new maze with the specified dimensions\n /// \n /// Width of the maze\n /// Height of the maze\n /// A 2D array representing the maze\n bool[,] Generate(int width, int height);\n \n /// \n /// Gets the name of the algorithm used for maze generation\n /// \n string AlgorithmName { get; }\n }\n}"
}
The result is the actual JSON response from the MCP server:
The interface definition is a single string value
All newlines are escaped as \n
All double quotes are escaped as \"
The content is inside the result property as a JSON string
This is how an agent receives the interface definition from the MCP server. The agent then parses and displays it in a readable format for the user.
SearchPackages Example
User Query Example
A user might ask:
> "I need a library for working with JSON in my .NET application. Can you help me find the most popular packages for JSON handling?"
The agent would use the MCP server to search for packages:
Standard search mode (fuzzySearch=false): Direct search for the whole query plus searches for comma-separated keywords
Fuzzy search mode (fuzzySearch=true):
Runs the standard search
Searches each individual word from the query
Uses AI to suggest additional package names (e.g., "maze generation" → "MazeGenerator MazeBuilder MazeCreator")
Searches for the AI-generated names
Combines and deduplicates all results sorted by popularity
Technical Details
The application uses the ModelContextProtocol library (version 0.3.0-preview.2), which helps create MCP-compatible servers. The server uses standard input/output to talk to clients and includes comprehensive error handling and progress reporting.
NugetMcpServer - Main namespace (used in TimeTool.cs)
NuGetMcpServer.Tools - Tool components (all analysis and search tools)
NuGetMcpServer.Services - Service components (package processing, formatting, archive handling)
NuGetMcpServer.Common - Shared components and base classes
NuGetMcpServer.Extensions - Extension methods for strings, exceptions, and progress
NuGetMcpServer.Models - Data models and result types
Integration with Development Tools
You can use this MCP server with different development tools and AI assistants:
VS Code: Integrate through MCP server configuration
OllamaChat: Works with OllamaChat for local AI conversations
GitHub Copilot: Use as an MCP server to get accurate package information
Other MCP Clients: Any tool that supports the Model Context Protocol
By using this server, developers and AI systems get real-time, accurate information about NuGet package interfaces, enums, structs, and records. This reduces the chance of outdated or wrong API suggestions.
Benefits for AI Development
Reducing LLM Hallucinations
This MCP server helps solve a big problem in AI-assisted development: LLM hallucinations about package APIs. Common issues are:
Outdated Information: LLMs trained on old data may suggest removed methods or interfaces
Non-existent APIs: Models may generate method signatures that do not exist
Version Mismatches: Suggestions may be for a different package version than the one used
Incomplete Information: Missing important parameters, return types, or constraints
How NugetMcpServer Helps
Real-time Data: Gets current interface definitions directly from NuGet packages
Version-specific Information: Lets you query specific package versions for accurate compatibility
Complete Interface Definitions: Gives full method signatures, properties, and generic constraints
Accurate Type Information: Ensures correct parameter types, return types, and namespace information
Use Cases
Package Discovery: Search for packages by functionality description and see popularity metrics
API Discovery: See what interfaces are in a package before using it
Version Migration: Compare interfaces between package versions when upgrading
Code Generation: Generate accurate code from real package interfaces
Documentation: Get up-to-date interface documentation for development
Technology Research: Find the most popular packages for specific technologies or patterns
About the MCP Protocol
Model Context Protocol (MCP) is a protocol that standardizes communication between language models and external tools. It lets models call functions, get information, and interact with external systems through one interface.
License
Unlicense - This is free and unencumbered software released into the public domain.
All tools that analyze package content (class definitions, interface definitions, enum definitions, and listing tools) now automatically detect meta-packages and show clear warnings. Meta-packages are NuGet packages that group other packages together without containing actual implementation code. When a meta-package is detected, the tools will:
Display a prominent warning that it's a meta-package
List the dependencies that contain the actual implementations
Provide guidance on which packages to analyze instead
The meta-package detection is powered by the MetaPackageDetector service which analyzes package structure and dependency patterns to identify when a package serves only as a grouping mechanism.
Version Information
Current version: 1.0.11
You can check the version of your installation using: