ModelContextProtocol WebAPI
FreeNot checkedASP.NET Core WebAPI tabanlı Model Context Protocol (MCP) ile Tool oluşturma
About
ASP.NET Core WebAPI tabanlı Model Context Protocol (MCP) ile Tool oluşturma
README
ASP.NET Core tabanlı Model Context Protocol (MCP) HTTP sunucu implementasyonu — AI modellerinin harici araç ve servislerle entegre olmasını sağlar.
📖 İçindekiler
- Proje Hakkında
- MCP Nedir?
- Özellikler
- Teknolojiler & Paketler
- Kimlik Doğrulama Mimarisi
- OAuth 2.0 Akışı
- MCP Yapılandırması
- Kullanım
- Proje Yapısı
- Kaynaklar
🎯 Proje Hakkında
ModelContextProtocol.WebAPI, Anthropic tarafından tanımlanan Model Context Protocol (MCP) standardını ASP.NET Core WebAPI üzerinde uygulayan bir örnek/referans projesidir. Resmi ModelContextProtocol.AspNetCore NuGet paketi kullanılarak HTTP tabanlı bir MCP sunucusu inşa eder. Bu sayede Claude gibi AI modelleri, özel araçları (tools) HTTP üzerinden çağırabilir.
🧠 MCP Nedir?
Model Context Protocol (MCP), AI uygulamalarının harici veri kaynakları ve araçlarla entegrasyonunu standartlaştırmak için Anthropic tarafından geliştirilen açık bir protokoldür.
AI Modeli (Claude, vb.)
│
│ MCP Protokolü (HTTP / SSE)
▼
MCP Sunucusu ←── bu proje
│
├── Tool 1: Özel İş Mantığı
├── Tool 2: Veritabanı Sorgusu
└── Tool 3: Harici API Çağrısı
MCP ile AI modeliniz:
- Tools — Fonksiyon çağırabilir (POST endpoint benzeri, yan etkiler üretmek için kullanılır)
- Resources — Veri kaynaklarına okuma amaçlı erişebilir
- Prompts — Hazır prompt şablonlarını kullanabilir
✨ Özellikler
- ✅
ModelContextProtocol.AspNetCoreile HTTP tabanlı MCP sunucusu - ✅
[McpServerToolType]/[McpServerTool]attribute'ları ile deklaratif tool tanımı - ✅
WithToolsFromAssembly()ile otomatik tool keşfi - ✅
.mcp.jsonile Claude Desktop / MCP istemci entegrasyonu - ✅ Dependency Injection ile servis entegrasyonu
- ✅ Kolay genişletilebilir araç ekleme mimarisi
🛠 Teknolojiler & Paketler
| Paket | Açıklama |
|---|---|
ModelContextProtocol.AspNetCore |
HTTP tabanlı MCP sunucu desteği (WebAPI projeleri için) |
ModelContextProtocol |
Ana paket — hosting ve DI extension'ları |
| .NET 10 / ASP.NET Core |
Not: HTTP sunucu için
ModelContextProtocol.AspNetCoregereklidir. Sadece stdio tabanlı bir sunucu istiyorsanızModelContextProtocolpaketi yeterlidir.
NuGet ile kurulum:
dotnet add package ModelContextProtocol.AspNetCore --prerelease
🔐 Kimlik Doğrulama Mimarisi
Bu proje, MCP endpoint'ini korumak için iki katmanlı bir authentication yapısı kullanır:
| Scheme | Görev |
|---|---|
McpAuthenticationDefaults.AuthenticationScheme |
Yetkisiz isteklerde WWW-Authenticate header'ı ile MCP istemcisini OAuth akışına yönlendirir |
JwtBearerDefaults.AuthenticationScheme |
Gelen Bearer token'ı doğrular |
🔄 OAuth 2.0 Akışı
Bu sunucu, MCP istemcileri için tam bir OAuth 2.0 Authorization Code Flow + PKCE akışı uygular:
MCP İstemcisi Sunucu
│ │
│── GET /.well-known/oauth-... ───► │ Metadata discovery
│◄─ { authorization_endpoint, ... } │
│ │
│── POST /oauth/register ─────────► │ Dynamic client registration
│◄─ { client_id } │
│ │
│── GET /oauth/authorize ─────────► │ Login formu göster
│ (code_challenge, PKCE/S256) │
│◄─ HTML Login Form │
│ │
│── POST /oauth/login ────────────► │ Kullanıcı doğrula
│ (username, password) │ Authorization code üret
│◄─ 302 redirect_uri?code=... │
│ │
│── POST /oauth/token ────────────► │ PKCE doğrula (SHA256)
│ (code, code_verifier) │ JWT üret
│◄─ { access_token, refresh_token } │
│ │
│── POST /mcp ────────────────────► │ Bearer token ile MCP isteği
│ Authorization: Bearer <JWT> │ RequireAuthorization()
│◄─ MCP Response │
⚙️ MCP Yapılandırması
Claude Desktop ile Entegrasyon
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"ModelContextProtocol-WebAPI": {
"url": "http://localhost:5500/mcp"
}
}
}
Claude Desktop, /mcp endpoint'ine erişmek istediğinde sunucu WWW-Authenticate header'ı döner. İstemci otomatik olarak /.well-known/oauth-authorization-server discovery endpoint'ini bulur ve OAuth akışını başlatır.
.mcp.json
{
"mcpServers": {
"webapi": {
"url": "http://localhost:5500/mcp"
}
}
}
💡 Kullanım
Program.cs Yapısı
HTTP tabanlı MCP sunucusu şu şekilde kurulur:
using ModelContextProtocol.Server;
var builder = WebApplication.CreateBuilder(args);
builder.Services
.AddMcpServer()
.WithHttpTransport()
.WithToolsFromAssembly();
var app = builder.Build();
app.MapMcp(); // /mcp endpoint'ini otomatik olarak map eder
app.Run();
💡
urlalanı,app.MapMcp()tarafından oluşturulan endpoint'i gösterir. Default path/mcp'dir.
.mcp.json ile Entegrasyon
Projenin kök dizinindeki .mcp.json dosyası MCP istemcileri için sunucu yapılandırmasını içerir:
{
"mcpServers": {
"webapi": {
"url": "http://localhost:5000/mcp"
}
}
}
📁 Proje Yapısı
ModelContextProtocol-WebAPI/
│
├── ModelContextProtocol.WebAPI/ # Ana ASP.NET Core projesi
│ ├── MCP/ # [McpServerToolType] sınıfları
│ ├── Program.cs # AddMcpServer + MapMcp yapılandırması
│ └── appsettings.json # Uygulama yapılandırması
│
├── .mcp.json # MCP istemci URL yapılandırması
├── ModelContextProtocol.slnx # Visual Studio solution dosyası (.slnx yeni format)
📚 Kaynaklar
Installing ModelContextProtocol WebAPI
This server has no published package — it is built from source. Open the repository and follow its README.
▸ github.com/enesdonmez/ModelContextProtocol-WebAPIFAQ
Is ModelContextProtocol WebAPI MCP free?
Yes, ModelContextProtocol WebAPI MCP is free — one-click install via Unyly at no cost.
Does ModelContextProtocol WebAPI need an API key?
No, ModelContextProtocol WebAPI runs without API keys or environment variables.
Is ModelContextProtocol WebAPI hosted or self-hosted?
Self-hosted: the server runs locally on your machine via the install command above.
How do I install ModelContextProtocol WebAPI in Claude Desktop, Claude Code or Cursor?
Open ModelContextProtocol WebAPI on unyly.org, pick your client tab (Claude Desktop, Claude Code, Cursor) and press Install — the config is generated automatically, no JSON editing.
Related MCPs
GitHub
PRs, issues, code search, CI status
by GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Template MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
by mcpdotdirectCompare ModelContextProtocol WebAPI with
Not sure what to pick?
Find your stack in 60 seconds
Author?
Embed badge for your README
Browse similar
All development MCPs
