MR

melbournedeveloper/restclient.net

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

404 stars 51 forks 品質 53 トレンド 39

MCPジェネレーターを使ってC#でRESTコールを行う最も安全な方法

概要

OpenAPIの仕様からMCPサーバーを生成してください!! 関数型プログラミング、型安全、最新の.NETパターンを一から導入して構築されています。オリジナル RestClient.Net の後継です。 このライブラリは型安全性と機能設計において妥協を許さないアプローチを取っています:- - IHttpClientFactory.CreateClient()によるHttpClientライフサイクル管理に対応し - - 例外なしの明示的エラー処理 - - Exhaustionによるコンパイル時保証 - - インターフェースなしの純粋な関数 - OpenAPI 3.x仕様からのもの - - コンパイルタイム安全性のために閉階層型で結果>を返す(Outcomeパッケージ) - - 予測可能なエラー処理のための例外スローなし - - 組み込みのダウンロード/アップロード進捗追跡 - - 慣例ベースの再試行ポリシーおよびレジリエンスパターンのサポート - - 全般的な非同期パターン - - IHttpClientFactoryと連携。

概要(AI 翻訳)

**C#**でRESTコールを行う最も安全な方法

新た! OpenAPI仕様からMCPサーバーを生成してください!!

関数型プログラミング、型安全、最新の.NETパターンを一から導入して構築されています。オリジナル RestClient.Net の後継です。

何が違うのか

このライブラリは型安全性と機能設計において妥協を許さないアプローチを取っています:

  • *HttpClient拡張 - [[T0]を通じてHttpClientライフサイクル管理に対応します。
  • 結果タイプ - 例外なしの明示的なエラー処理
  • 網羅性チェック- Exhaustionによるコンパイルタイム保証
  • 関数合成 - インターフェースを持たない純粋な関数

特徴

  • OpenAPI 3.x仕様からMCPサーバーおよびクライアントコードを生成。
  • 結果タイプ - コンパイル時安全性のために閉じた階層型でResult >]を返す(Outcomeパッケージ)
  • ゼロ例外 - 予測可能なエラー処理のための例外スローなし
  • 進捗報告 - 組み込みのダウンロード/アップロード進捗追跡
  • Polly Integration - 慣例に基づく再試行ポリシーとレジリエンスパターンのサポート
  • Async/Await Only - 現代の非同期パターンが全編にわたって使われています

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

RestClient.Net

The safest way to make REST calls in C#

New! Generate MCP servers from OpenAPI specs!!!

Built from the ground up with functional programming, type safety, and modern .NET patterns. Successor to the original RestClient.Net.

What Makes It Different

This library is uncompromising in its approach to type safety and functional design:

  • HttpClient extensions - Works with HttpClient lifecycle management via IHttpClientFactory.CreateClient()
  • Result types - Explicit error handling without exceptions
  • Exhaustiveness checking - Compile-time guarantees via Exhaustion
  • Functional composition - Pure functions with no interfaces

Features

  • Generate an MCP Server and client code from an OpenAPI 3.x spec.
  • Result Types - Returns Result> with closed hierarchy types for compile-time safety (Outcome package)
  • Zero Exceptions - No exception throwing for predictable error handling
  • Progress Reporting - Built-in download/upload progress tracking
  • Polly Integration - Support for convention-based retry policies and resilience patterns
  • Async/Await Only - Modern async patterns throughout
  • HttpClient Extensions - Works with IHttpClientFactory.CreateClient() for proper pooled connections and DNS behavior handling
  • Exhaustiveness Checking - Uses Exhaustion for compile-time completeness guarantees (stopgap until C# adds discriminated unions)

The design focuses on discriminated unions for results, and adding the Exhaustion analyzer package gives you exhaustive pattern matching on type in C#. RestClient.Net is well ahead of the game. You can use discriminated unions with exhaustiveness checks in C# right now.

Installation

Install the core package:

dotnet add package RestClient.Net

RestClient.Net installs the Exhaustion analyzer. Is is a Roslyn analyzer that provides compile-time exhaustiveness checking for pattern matching. Without it, you lose one of RestClient.Net’s core safety guarantees.

Usage

Basic GET Request

A complete example making a GET request to JSONPlaceholder:

using System.Text.Json;
using RestClient.Net;
using Urls;

// Define models
GitHub で README 全文を見る

インストール

This server does not publish a one-line install command.

Open the repository installation guide MCP 初心者?mcpskill.org のガイドから始めましょう →