Configures MCP client and server in ASP.NET Core hosts using CrestApps.Core. Covers SSE/StdIO transports, OAuth2 token service, tool exposure, agents as MCP tools, prompts, resources, and upgrading 1.x hosts.
Ships in crestapps-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
CrestApps.Core.AI.Mcp provides both sides of MCP: a client that turns remote MCP servers into orchestrator tools, and server handlers that expose CrestApps tools, tool instances, agents, prompts and resources through the official MCP C# SDK. FTP and SFTP resource types are covered in crestapps-core-mcp-file-resources; giving tools to AI agents in the browser through document.modelContext is covered in crestapps-core-webmcp.
builder.Services.AddCrestAppsCore(crestApps => crestApps
.AddAISuite(ai => ai
.AddOpenAI()
.AddMcpClient(mcpClient => mcpClient
.AddEntityCoreStores())) // or .AddYesSqlStores(); registers the McpConnection catalog
.AddEntityCoreSqliteDataStore("Data Source=app.db"));
AddCoreAIMcpClient(includeStdIoTransport: true) registers McpService, IOAuth2TokenService, metadata caching, IMcpCapabilityResolver, McpToolRegistryProvider, McpAICompletionContextBuilderHandler and the sse and stdIo transports. Pass false, or call AddCoreAIMcpServices() plus AddCoreAISseMcpClientTransport(), to leave out the local-process transport.McpConnection.Source names the transport. Settings live in SseMcpConnectionMetadata or StdioMcpConnectionMetadata on its Properties; secrets are protected with Data Protection.AIProfileMcpMetadata.ConnectionIds. Tools appear as mcp:{connectionId}:{toolName} entries.IMcpClientTransportProvider and McpClientAIOptions.AddTransportType(...).AddCoreAIOAuth2TokenService() (called by AddCoreAIServices() and AddCoreAIMcpServices()) registers IOAuth2TokenService (DefaultOAuth2TokenService, tokens cached in IMemoryCache), the named HttpClient DefaultOAuth2TokenService.HttpClientName ("DefaultOAuth2TokenService") and IOAuth2MtlsHandlerFactory (DefaultOAuth2MtlsHandlerFactory). A host that registers DefaultOAuth2TokenService itself calls AddCoreAIOAuth2TokenService() instead.
https, to add a trailing slash) fails and the error log names the target; configure that address as the token endpoint.SocketsHttpHandler or HttpClientHandler set as its primary handler (also inside a DelegatingHandler, before or after registration) is kept with redirects turned off; any other handler is left as it is with a warning logged once.IOAuth2MtlsHandlerFactory.CreateHandler(X509Certificate2), which the service disposes; ConfigureHttpClientDefaults does not reach it. Register your own factory to control where mTLS requests connect:using System.Security.Cryptography.X509Certificates;
using CrestApps.Core.AI.Services;
public sealed class GuardedOAuth2MtlsHandlerFactory : IOAuth2MtlsHandlerFactory
{
public HttpMessageHandler CreateHandler(X509Certificate2 clientCertificate)
{
return new SocketsHttpHandler
{
AllowAutoRedirect = false,
UseProxy = false,
SslOptions =
{
ClientCertificates = [clientCertificate],
LocalCertificateSelectionCallback = (_, _, _, _, _) => clientCertificate,
},
ConnectCallback = AddressGuard.ConnectAsync,
};
}
}
builder.Services.AddSingleton<IOAuth2MtlsHandlerFactory, GuardedOAuth2MtlsHandlerFactory>();
AddressGuard.ConnectAsync stands for the host's own callback that resolves the host, refuses addresses it should not reach and opens the socket. UseProxy = false matters: through a proxy, ConnectCallback only sees the proxy's address. Code that constructs DefaultOAuth2TokenService passes an IOAuth2MtlsHandlerFactory as the second argument.
using CrestApps.Core.AI.Mcp;
using CrestApps.Core.AI.Mcp.Knowledge;
using CrestApps.Core.AI.Mcp.Models;
builder.Services.AddCrestAppsCore(crestApps => crestApps
.AddAISuite(ai => ai
.AddOpenAI()
.AddMcpServer(mcpServer => mcpServer
.AddYesSqlStores() // McpPrompt and McpResource catalogs
.AddKnowledgeResources())));
builder.Services.Configure<McpServerOptions>(options =>
{
options.AuthenticationType = McpServerAuthenticationType.ApiKey;
options.ApiKey = builder.Configuration["Mcp:ServerApiKey"];
options.Tools = ["crestapps-docs", "calculator"];
options.Agents = ["researcher"];
});
builder.Services.AddMcpServer(options =>
{
options.ServerInfo = new() { Name = "My MCP Server", Version = "1.0" };
})
.WithHttpTransport(options =>
{
// The SDK default (Stateless) does not map GET and DELETE /mcp.
options.SessionMode = HttpServerSessionMode.StatefulForInitializeClients;
})
.WithCrestAppsHandlers();
var app = builder.Build();
app.MapMcp("mcp");
AddMcpServer(...) is the CrestApps builder (AddCoreAIMcpServer() registers IMcpServerPromptService and IMcpServerResourceService). builder.Services.AddMcpServer(), WithHttpTransport() and app.MapMcp(...) come from the MCP SDK.WithCrestAppsHandlers() wires list and call handlers for tools, prompts, resources and resource templates.POST /mcp for JSON-RPC, GET /mcp for a session's server-to-client stream and DELETE /mcp to end a session. HttpServerSessionMode (ModelContextProtocol.AspNetCore) is StatefulForInitializeClients (clients using the initialize handshake get an Mcp-Session-Id; clients on the 2026-07-28 revision or later are served without a session; the sample hosts' default), Stateful or Stateless (no GET/DELETE, answered 405). Sessions live in process memory, so several nodes need session affinity or Stateless. The sample hosts read the mode from CrestApps:AI:McpServer:SessionMode.McpServerOptions is read through IOptionsMonitor, so hosts that back it with site settings change exposure without a redeploy.McpServerOptions.AuthenticationType is OpenId (default), ApiKey or None (development only), and RequireAccessPermission (default true) asks the host to require an access permission for OpenId callers. These are settings, not middleware: the framework does not enforce them on /mcp. The sample hosts add a UseWhen branch for the endpoint path itself (/mcp, with or without a trailing slash, so admin pages under /Mcp/... keep the normal sign-in) that reads IOptionsMonitor<McpServerOptions>, compares the bearer or ApiKey header for ApiKey mode, challenges anonymous users for OpenId, and checks a role when RequireAccessPermission is set. Apply equivalent authentication before exposing the endpoint.Exposure is opt-in. Nothing is listed or callable until allowed.
| Option | Effect |
|---|---|
Tools | allow-list of tool and tool instance names, case-insensitive, also matched by a tool's aliases; read even when ExposeAllTools is on |
ExposeAllTools | every selectable tool and tool instance except Destructive and Security tools and tools that require an approval (.RequireApproval(), or External without .RequireApproval(false)), which are exposed only when Tools names them; system and hidden tools are never exposed |
Agents | allow-list of agent profile names |
ExposeAllAgents | every agent profile (AIProfileType.Agent) that has a description, including code-defined system agents |
Tools runs without one. Name such tools only for clients you trust with them.Read (readOnlyHint), Write, Destructive and Security (destructiveHint true for the last two), External (openWorldHint). A tool without a kind has no annotations.prompt.Tools, and using them does not make them directly callable.AgentMetadata.AllowToolInvocation = true. Nested agent delegation stays suppressed. AgentAvailability is ignored for MCP.AIInvocationScope for each call, so agents run at top-level depth and citation tools register their references.McpToolResultMapper maps a tool result onto MCP content blocks: a string is one text block, an IMcpToolContentProvider returns its own ContentBlock list, and an IAIToolContentProvider (for example DataSourceRetrievalResult or KnowledgeObjectToolResult) is mapped from its AIContent list, so a search that found a figure returns text plus a resource link. In chat completions the same results reach the model as text.
using CrestApps.Core.AI.Mcp;
using CrestApps.Core.AI.Mcp.Models;
using Microsoft.Extensions.Localization;
using ModelContextProtocol.Protocol;
// IProductCatalog is the host's own service.
public sealed class ProductSheetResourceHandler : McpResourceTypeHandlerBase
{
public const string TypeName = "product-sheet";
private readonly IProductCatalog _catalog;
public ProductSheetResourceHandler(IProductCatalog catalog)
: base(TypeName)
{
_catalog = catalog;
}
protected override async Task<ReadResourceResult> GetResultAsync(
McpResource resource,
IReadOnlyDictionary<string, string> variables,
CancellationToken cancellationToken)
{
if (!variables.TryGetValue("sku", out var sku) || string.IsNullOrWhiteSpace(sku))
{
return CreateErrorResult(resource.Resource.Uri, "A product SKU is required.");
}
var markdown = await _catalog.GetSheetMarkdownAsync(sku, cancellationToken);
return new ReadResourceResult
{
Contents =
[
new TextResourceContents
{
Uri = resource.Resource.Uri,
MimeType = "text/markdown",
Text = markdown,
},
],
};
}
}
builder.Services
.AddCoreAIMcpServer()
.AddCoreAIMcpResourceType<ProductSheetResourceHandler>(ProductSheetResourceHandler.TypeName, entry =>
{
entry.DisplayName = new LocalizedString("ProductSheet", "Product sheet");
entry.Description = new LocalizedString("ProductSheet Description", "Reads a product data sheet by SKU.");
entry.SupportedVariables = [new McpResourceVariable("sku")];
});
AddCoreAIMcpResourceType<THandler>(type, configure) adds an McpResourceTypeEntry to McpOptions, registers the handler scoped, as IMcpResourceTypeHandler, and keyed by type. Some docs call it AddMcpResourceType; that method does not exist.McpResource with Source = "product-sheet" and a URI template such as product-sheet://catalog/{sku} is published as a resource template; a fixed URI is published as a resource. McpResourceUri.TryMatch extracts the variables, and the last variable may span path segments.SanitizePath(...) from the base class for path variables, and IMcpResourceHandler.Exporting to strip secrets from exported resources.AddKnowledgeResources() (CrestApps.Core.AI.Mcp.Knowledge, type datasource-figure) publishes crestapps://datasource/{dataSourceId}/figure/{figureId} and serves only figures and charts that belong to that data source.ExposeAllTools leaves out Destructive and Security tools and tools that require an approval; name them in Tools to expose them. Hosts that set no kinds and call .RequireApproval() on no tool see no change.Stateless, which answers GET and DELETE /mcp with 405; set HttpServerTransportOptions.SessionMode.IOAuth2MtlsHandlerFactory.Agents or ExposeAllAgents to expose agents; existing Tools and ExposeAllTools settings never expose agents.IAIToolContentProvider or IMcpToolContentProvider on rich results.CrestApps.Core.AI.Mcp.Ftp and CrestApps.Core.AI.Mcp.Sftp are replaced by CrestApps.Core.AI.Ftp and CrestApps.Core.AI.Sftp; see crestapps-core-mcp-file-resources.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
/crestapps-core:crestapps-core-mcpfrom crestapps-core
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-core51 skills in this plugin
/crestapps-core-a2aSkill for Agent-to-Agent (A2A) protocol support in CrestApps.Core on the A2A 1.0 SDK. Covers AddA2AClient and AddCoreAIA2AClient with Entity Framework Core or YesSql connection stores, A2AConnection and A2AConnectionMetadata authentication, AIProfileA2AMetadata, the agent card cache and A2AToolRegistryProvider, the listAvailableAgents, findAgentForTask and findToolsForTask tools, building an A2A host with IAgentHandler, A2AServer, ITaskStore and MapA2A, A2A 1.0 agent cards with supportedInterfaces published at /.well-known/agent-card.json, A2AHostOptions authentication and ExposeAgentsAsSkill, system agents exposed through the host, and upgrading from the 0.3 SDK./crestapps-core-ag-uiSkill for running the CrestApps.Core 2.0 AI chat as an AG-UI agent. Covers the CrestApps.Core.AI.AGUI package (AGUIRunEventWriter, AGUIRunRequest, AGUIJson), AIChatHubCore.RunAgent over SignalR and MapAGUIChat with Server-Sent Events, the RunAgentInput members and streamed events, tool approvals with RequireApproval or an approval tool kind, ApprovalRequiredAIFunction, interrupts and resume, approvals inside agents, page context with crestAppsAGUI.registerContextProvider, shared state with registerStateProvider and update_shared_state, frontend tools, stored tool calls (ChatTurnToolActivity), runs that continue on the next page, AGUIChatOptions.DisconnectedRunTimeout, the protocol and sendPageContext chat options, and the AICompletionContextKeys and ChatResponseHandlerContext members. Use it when showing tool calls in the chat, asking a person before a tool runs, sharing page state with the agent, connecting CopilotKit or another AG-UI client, or troubleshooting approvals and continued runs.Other plugins' skills for the same job