Microsoft.Agents.Mcp.Core 0.2.162-alpha

Prefix Reserved
This is a prerelease version of Microsoft.Agents.Mcp.Core.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Microsoft.Agents.Mcp.Core --version 0.2.162-alpha
                    
NuGet\Install-Package Microsoft.Agents.Mcp.Core -Version 0.2.162-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Agents.Mcp.Core" Version="0.2.162-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Agents.Mcp.Core" Version="0.2.162-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.Agents.Mcp.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Agents.Mcp.Core --version 0.2.162-alpha
                    
#r "nuget: Microsoft.Agents.Mcp.Core, 0.2.162-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Microsoft.Agents.Mcp.Core@0.2.162-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Microsoft.Agents.Mcp.Core&version=0.2.162-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.Agents.Mcp.Core&version=0.2.162-alpha&prerelease
                    
Install as a Cake Tool

Microsoft.Agents.Mcp.Core

Overview

The Microsoft Agents MCP (Model Context Protocol) Core Module provides a robust framework for handling JSON-RPC based communication, payload processing, and method invocation in a structured and type-safe manner.

Installation

Install the MCP Server SDK via NuGet:

dotnet add package Microsoft.Agents.Mcp.Core

Key Components

Payload Handlers

The module defines several abstract base classes for different types of payload handling:

  1. McpPayloadHandlerBase

    • Base interface for payload handlers
    • Defines method for creating and executing payloads
  2. McpMethodWithoutInputsPayloadHandlerBase

    • Handles methods that don't require input parameters
    • Provides a generic way to execute methods and post results
  3. McpMethodPayloadHandlerBase

    • Supports methods with specific request and (optionally) response types
    • Handles JSON deserialization of method parameters
    • Provides type-safe method execution
  4. McpNotificationHandlerBase

    • Handles notification-type payloads
    • Supports deserialization of notification parameters

Payload Types

  • McpRequest: Represents a method call with an ID and parameters
  • McpNotification: Represents a notification without an ID
  • McpResult: Represents the result of a method call

Serialization

The module uses System.Text.Json for payload serialization and deserialization, with custom serialization options defined in the Serialization utility class.

Example Usage

Creating a Method Handler

public class MyMethodHandler : McpMethodPayloadHandlerBase<MyRequestType, MyResponseType>
{
    public override string Method => "my/method";

    protected override async Task<MyResponseType> ExecuteMethodAsync(
        IMcpContext context, 
        McpRequest<MyRequestType> payload, 
        CancellationToken ct)
    {
        // Implement method logic
        var result = ProcessRequest(payload.Parameters);
        return result;
    }
}

Notification Handling

public class MyNotificationHandler : McpNotificationHandlerBase<MyNotificationType>
{
    protected override async Task ExecuteAsync(
        IMcpContext context, 
        McpNotification<MyNotificationType> payload, 
        CancellationToken ct)
    {
        // Handle notification
        await ProcessNotification(payload.Parameters);
    }
}

Key Features

  • Type-safe payload handling
  • JSON-RPC method and notification support
  • Flexible serialization
  • Cancellation token support
  • Context-based execution

Dependencies

  • Microsoft.Extensions.DependencyInjection

Logging and Transport

The module provides basic infrastructure for:

  • Log level configuration
  • Method and notification dispatching
  • Serialization and deserialization of payloads

Best Practices

  1. Always use the appropriate base handler for your method type
  2. Implement proper error handling in your method implementations
  3. Utilize cancellation tokens for long-running operations
  4. Follow the existing serialization patterns

License

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

Support

For issues and questions, please open a GitHub issue in the project repository.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated