MCPify 0.0.7

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package MCPify --version 0.0.7
                    
NuGet\Install-Package MCPify -Version 0.0.7
                    
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="MCPify" Version="0.0.7" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MCPify" Version="0.0.7" />
                    
Directory.Packages.props
<PackageReference Include="MCPify" />
                    
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 MCPify --version 0.0.7
                    
#r "nuget: MCPify, 0.0.7"
                    
#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 MCPify@0.0.7
                    
#: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=MCPify&version=0.0.7
                    
Install as a Cake Addin
#tool nuget:?package=MCPify&version=0.0.7
                    
Install as a Cake Tool

MCPify

MCPify is a .NET library that bridges the gap between your existing ASP.NET Core APIs (or external OpenAPI/Swagger specs) and the Model Context Protocol (MCP). It allows you to expose API operations as MCP tools that can be consumed by AI assistants like Claude Desktop, ensuring seamless integration with your existing services.

Features

  • Automatic Tool Generation: Dynamically converts OpenAPI (Swagger) v2/v3 definitions into MCP tools.
  • Hybrid Support: Expose your local ASP.NET Core endpoints and external public APIs simultaneously.
  • Seamless Authentication: Built-in support for OAuth 2.0 Authorization Code Flow with PKCE.
    • Includes a login_auth_code_pkce tool that handles the browser-based login flow automatically.
    • Securely stores tokens per session using encrypted local storage.
    • Automatically refreshes tokens when they expire.
  • Dual Transport: Supports both Stdio (for local desktop apps like Claude) and Http (SSE) transports.
  • Production Ready: Robust logging, error handling, and configurable options.

Quick Start

1. Installation

Install the package into your ASP.NET Core project:

dotnet add package MCPify

2. Configuration

Add MCPify to your Program.cs:

using MCPify.Hosting;

var builder = WebApplication.CreateBuilder(args);

// ... Add other services ...

// 1. Add MCPify services
builder.Services.AddMcpify(options =>
{
    // Choose Transport (Stdio for local tools, Http for remote)
    options.Transport = McpTransportType.Stdio;

    // Option A: Expose Local Endpoints
    options.LocalEndpoints = new LocalEndpointsOptions
    {
        Enabled = true,
        ToolPrefix = "myapp_",
        // Optional: Filter which endpoints to expose
        Filter = op => op.Route.StartsWith("/api")
    };

    // Option B: Expose External APIs via Swagger
    options.ExternalApis.Add(new ExternalApiOptions
    {
        ApiBaseUrl = "https://petstore.swagger.io/v2",
        OpenApiUrl = "https://petstore.swagger.io/v2/swagger.json",
        ToolPrefix = "petstore_"
    });
});

var app = builder.Build();

// 2. Add Middleware
app.UseMcpifyContext();
app.UseMcpifyOAuth(); // If using Authentication

// ... Map your endpoints ...

// 3. Map the MCP endpoint (required for Http transport, optional for Stdio)
app.MapMcpifyEndpoint();

app.Run();

3. Usage with Claude Desktop

To use your MCPify app with Claude Desktop, edit your config file (%APPDATA%\Claude\claude_desktop_config.json on Windows or ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):

{
  "mcpServers": {
    "my-app": {
      "command": "dotnet",
      "args": [
        "run",
        "--project",
        "/absolute/path/to/YourProject.csproj", 
        "--",
        "--Mcpify:Transport=Stdio"
      ]
    }
  }
}

Note: When using dotnet run, ensure your application does not print build logs to stdout, as this corrupts the MCP JSON-RPC protocol. You can suppress logs or publish your app as a single-file executable for a cleaner setup.

Authentication

MCPify provides a first-class experience for APIs secured with OAuth 2.0.

Enabling OAuth

Register the authentication provider in your Program.cs:

services.AddScoped<OAuthAuthorizationCodeAuthentication>(sp => {
    return new OAuthAuthorizationCodeAuthentication(
        clientId: "your-client-id",
        authorizationEndpoint: "https://auth.example.com/authorize",
        tokenEndpoint: "https://auth.example.com/token",
        scope: "api_access",
        secureTokenStore: sp.GetRequiredService<ISecureTokenStore>(),
        mcpContextAccessor: sp.GetRequiredService<IMcpContextAccessor>(),
        redirectUri: "http://localhost:5000/auth/callback" // Your app must handle this
    );
});

// Register the Login Tool
services.AddLoginTool(sp => new LoginTool());

The Login Flow

  1. The user asks Claude: "Please login" or uses a tool that requires auth.
  2. Claude calls the login_auth_code_pkce tool.
  3. MCPify automatically opens the system browser to the login page.
  4. The user logs in and approves the request.
  5. The browser redirects back to your application (e.g., /auth/callback).
  6. Your app saves the token and displays a success message.
  7. The login_auth_code_pkce tool detects the successful login and reports back to Claude.
  8. Claude can now invoke authenticated tools!

Contributing

We welcome contributions! Please see our Contributing Guide for details.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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
0.0.8-preview 0 12/26/2025
0.0.7 66 12/23/2025
0.0.7-preview 70 12/20/2025
0.0.6-preview 109 12/13/2025
0.0.5-preview 156 12/7/2025
0.0.4 621 12/3/2025
0.0.4-preview 608 12/2/2025
0.0.3 613 12/3/2025
0.0.3-preview 129 11/24/2025
0.0.2 614 12/2/2025
0.0.2-preview 106 11/23/2025
0.0.1 112 11/23/2025
0.0.1-preview 100 11/23/2025