[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DYNEPRY5VRA0VS8X914GYR":3,"skill-same:01M6DYNEPRY5VRA0VS8X914GYR":115},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":53,"linkOnly":54,"markdownContent":55,"markdownBody":56,"frontMatter":57,"refName":59,"commitSha":60,"skillDirectory":61,"forksCount":62,"repositoryHtmlUrl":63,"repositoryHomepageUrl":64,"ownerHtmlUrl":65,"ownerBlogUrl":66,"ownerDescription":67,"updatedAt":68,"install":69,"resources":82},"01M6DYNEPRY5VRA0VS8X914GYR","mcp",null,"Build or consume Model Context Protocol (MCP) servers and clients in .NET using the official MCP C# SDK, including stdio, Streamable HTTP, tools, prompts, resources, and capability negotiation. USE FOR: .NET MCP servers or clients; stdio versus HTTP transport choices; tools, resources, prompts, completions, and capability negotiation. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","managedcode\u002Fdotnet-skills","managedcode","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78253589?v=4","01M6DYDJR3EG8KB5G4PC65XCTT","Managed Code","01M6DYDJX0ZT432N04NYJW89DN",515,"MIT","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMCP\u002Fskills\u002Fmcp\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52],"MCP","model","2026","when","capability","inspect","relevant","resources","commands","do","build","files","unrelated","use","context","edit","Tools","repository","negotiation","lint","run","core","packages","tasks","http","official","test","model context protocol","sdk","2026-11-10 10:12:30",false,"---\nname: mcp\ndescription: \"Build or consume Model Context Protocol (MCP) servers and clients in .NET using the official MCP C# SDK, including stdio, Streamable HTTP, tools, prompts, resources, and capability negotiation. USE FOR: .NET MCP servers or clients; stdio versus HTTP transport choices; tools, resources, prompts, completions, and capability negotiation. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.\"\ncompatibility: \"Requires the official MCP C# SDK packages (`ModelContextProtocol.Core`, `ModelContextProtocol`, or `ModelContextProtocol.AspNetCore`) on .NET 8+; current guidance targets the v2.2 SDK and MCP 2026-07-28.\"\n---\n\n# MCP C# SDK for .NET\n\n## Trigger On\n\n- building or consuming MCP servers from a .NET application or library\n- choosing between stdio and HTTP transport for MCP\n- exposing tools, resources, prompts, completions, or logging to an MCP host\n- connecting a .NET app to an existing MCP server and passing discovered tools into `IChatClient`\n- bootstrapping a minimal MCP client\u002Fserver from the `.NET AI` quickstarts or publishing a server to the MCP Registry\n- implementing capability-aware flows such as roots, sampling, elicitation, subscriptions, session resumption, or enterprise managed authorization\n\n## Use This Skill Instead Of\n\n- Use `mcp` when **protocol interoperability** is the requirement.\n- Use `microsoft-extensions-ai` when you only need model\u002Fprovider abstraction or local tool orchestration without the MCP wire protocol.\n- Use `microsoft-agent-framework` when the main problem is agent orchestration; combine it with `mcp` only when those agents must consume or expose MCP endpoints.\n- Use the `.NET AI` quickstarts for the very first vertical slice, then come back here to harden transport, capability negotiation, publishing, and host interoperability.\n\n## Documentation\n\n- [MCP C# SDK overview](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002F)\n- [Getting Started](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fconcepts\u002Fgetting-started.html)\n- [API reference](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fapi\u002FModelContextProtocol.html)\n- [Conceptual docs](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fconcepts\u002Findex.html)\n- [Versioning policy](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fversioning.html)\n- [Experimental APIs](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fexperimental.html)\n- [MCP C# SDK repository](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fcsharp-sdk)\n- [Model Context Protocol specification](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002F)\n\n## References\n\nLoad only what the task needs:\n\n- [references\u002Fpatterns.md](references\u002Fpatterns.md) - current server\u002Fclient patterns, transports, capabilities, filters, and chat-client integration\n- [references\u002Fsecurity.md](references\u002Fsecurity.md) - safe error handling, auth boundaries, stdio logging hygiene, and defensive tool\u002Fresource patterns\n\n## Package Selection\n\n| Package | Choose when |\n|---------|-------------|\n| `ModelContextProtocol.Core` | You only need a client or low-level server APIs and want the smallest dependency set. |\n| `ModelContextProtocol` | You want the main SDK package with hosting, DI, attribute discovery, and stdio server support. Start here for most projects. |\n| `ModelContextProtocol.AspNetCore` | You are hosting a remote MCP server in ASP.NET Core over HTTP. This includes the main package. |\n\n## Transport Selection\n\n| Transport | Use when | Notes |\n|-----------|----------|-------|\n| `StdioClientTransport` \u002F `WithStdioServerTransport()` | The MCP server should run as a local child process. | Best for local tooling and editor\u002Fagent integrations. |\n| `HttpClientTransport` + `HttpTransportMode.StreamableHttp` | The server is remote or should be reachable over HTTP. | Recommended HTTP transport; supports streaming and session resumption. |\n| `HttpTransportMode.Sse` | You must connect to an older SSE-only server. | Legacy compatibility only; do not choose this for new servers. |\n\n## Current v2.2 Notes\n\n- The August 2026 `.NET AI` MCP documentation separates a getting-started hub, client and server quickstarts, MCP Registry publishing, and a server-resource index. Use those pages to bootstrap a vertical slice, then return to the C# SDK docs here for exact transport, capability, authorization, and lifecycle behavior.\n- SDK `v2.0.0` aligns with MCP `2026-07-28`: HTTP is stateless by default, clients negotiate with `server\u002Fdiscover` before falling back to legacy `initialize`, Tasks move to `ModelContextProtocol.Extensions.Tasks`, and Roots, Sampling, and Logging are deprecated for the new protocol. Set `HttpServerTransportOptions.Stateless = false` only for an intentional stateful compatibility requirement.\n- SDK `v2.1.0` adds an opt-in `subscriptions\u002Flisten` server handler, keeps AutoDetect usable after a provisional SSE failure, preserves HTTP status codes across target frameworks, and falls back to `initialize` when `server\u002Fdiscover` fails at the HTTP layer. Add custom notification streams only when both peers negotiate the extension.\n- SDK `v2.2.0` adds `HttpServerSessionMode` so one ASP.NET Core endpoint can serve stateful and stateless clients across the MCP `2025-11-25` and `2026-07-28` protocol versions. Choose the mode explicitly, test both negotiated paths when compatibility matters, and upgrade before working around malformed percent-encoded request headers because the release fixes that decoding failure.\n- Before moving from `v1.4.x`, update structured-result consumers to accept non-object values directly, require `Tool.inputSchema` in custom payloads, move Tasks to the extension package, and test PKCE S256 plus issuer validation in OAuth metadata.\n- Enterprise managed authorization now has an SDK surface through `IdentityAssertionGrantProvider` for the Identity Assertion Authorization Grant flow. Use it only when the enterprise SSO and MCP authorization-server contract is part of the actual scenario.\n- `StdioClientTransportOptions.InheritEnvironmentVariables` controls whether child-process MCP servers inherit the parent environment. Set it intentionally when launching untrusted or third-party servers.\n- Streamable HTTP session `DELETE` is hardened to require the same authenticated user that opened the session. Do not build custom session cleanup paths that bypass that authorization check.\n- Stdio transport no longer logs child-process environment variables at trace level, but server authors should still treat environment variables as secrets.\n\n```mermaid\nflowchart LR\n    A[\"Need MCP interoperability in .NET\"] --> B{\"Role?\"}\n    B -->|\"Expose MCP surface\"| C{\"Where will it run?\"}\n    B -->|\"Consume an MCP server\"| D{\"Transport?\"}\n    C -->|\"Local child process\"| E[\"ModelContextProtocol\\nAddMcpServer()\\nWithStdioServerTransport()\"]\n    C -->|\"Remote HTTP endpoint\"| F[\"ModelContextProtocol.AspNetCore\\nAddMcpServer()\\nWithHttpTransport()\\nMapMcp()\"]\n    D -->|\"stdio\"| G[\"StdioClientTransport\\nMcpClient.CreateAsync()\"]\n    D -->|\"HTTP\"| H[\"HttpClientTransport\\nAutoDetect or StreamableHttp\"]\n    E --> I[\"Register tools\u002Fresources\u002Fprompts\"]\n    F --> I\n    G --> J[\"Check ServerCapabilities\\nbefore optional features\"]\n    H --> J\n```\n\n## Workflow\n\n1. Pick the package and transport first.\n   - Local child-process server: `ModelContextProtocol` + `WithStdioServerTransport()`.\n   - Remote server: `ModelContextProtocol.AspNetCore` + `WithHttpTransport()` + `MapMcp()`.\n   - Client-only app: start with `ModelContextProtocol` or `ModelContextProtocol.Core`.\n   - Registry distribution: pair a minimal server with the MCP Registry publishing flow only after the server contract is stable.\n\n2. Model the MCP surface explicitly.\n   - Tools: `[McpServerToolType]` + `[McpServerTool]`\n   - Resources: `[McpServerResourceType]` + `[McpServerResource]`\n   - Prompts: `[McpServerPromptType]` + `[McpServerPrompt]`\n   - Use custom handlers or filters only for cross-cutting behavior, protocol extensions, or advanced routing.\n\n3. Prefer attribute discovery for straightforward servers.\n\n```csharp\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Microsoft.Extensions.Logging;\nusing ModelContextProtocol.Server;\nusing System.ComponentModel;\n\nvar builder = Host.CreateApplicationBuilder(args);\nbuilder.Logging.AddConsole(options =>\n{\n    options.LogToStandardErrorThreshold = LogLevel.Trace;\n});\n\nbuilder.Services\n    .AddMcpServer()\n    .WithStdioServerTransport()\n    .WithToolsFromAssembly();\n\nawait builder.Build().RunAsync();\n\n[McpServerToolType]\npublic static class EchoTool\n{\n    [McpServerTool, Description(\"Echoes the message back to the client.\")]\n    public static string Echo(string message) => $\"hello {message}\";\n}\n```\n\n4. For HTTP servers, use the ASP.NET Core transport and map the endpoint directly.\n\n```csharp\nusing ModelContextProtocol.Server;\nusing System.ComponentModel;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services\n    .AddMcpServer()\n    .WithHttpTransport()\n    .WithToolsFromAssembly();\n\nvar app = builder.Build();\napp.MapMcp(\"\u002Fmcp\");\napp.Run();\n\n[McpServerToolType]\npublic static class EchoTool\n{\n    [McpServerTool, Description(\"Echoes the message back to the client.\")]\n    public static string Echo(string message) => $\"hello {message}\";\n}\n```\n\n5. When consuming a server, use `McpClient.CreateAsync(...)` and stay capability-aware.\n\n```csharp\nusing ModelContextProtocol.Client;\nusing ModelContextProtocol.Protocol;\n\nvar transport = new StdioClientTransport(new StdioClientTransportOptions\n{\n    Name = \"Everything\",\n    Command = \"npx\",\n    Arguments = [\"-y\", \"@modelcontextprotocol\u002Fserver-everything\"],\n});\n\nawait using var client = await McpClient.CreateAsync(transport);\n\nIList\u003CMcpClientTool> tools = await client.ListToolsAsync();\n\nif (client.ServerCapabilities.Prompts is not null)\n{\n    var prompts = await client.ListPromptsAsync();\n}\n```\n\n6. Treat optional features as negotiated capabilities, not assumptions.\n   - Client capabilities: configure `McpClientOptions.Capabilities` for roots, sampling, and elicitation.\n   - Server capabilities are inferred from registered features.\n   - Check `client.ServerCapabilities` before using completions, logging, prompt list-change notifications, or resource subscriptions.\n   - Use `client.NegotiatedProtocolVersion` or `server.NegotiatedProtocolVersion` only when version-specific behavior matters.\n\n7. Keep HTTP guidance current.\n   - Streamable HTTP is the recommended transport for remote servers.\n   - `MapMcp()` also serves SSE compatibility endpoints for older clients.\n   - HTTP clients can use `AutoDetect` by default, or force `StreamableHttp` \u002F `Sse`.\n   - Session resumption is available for Streamable HTTP through `McpClient.ResumeSessionAsync(...)`.\n   - For authenticated Streamable HTTP sessions, cleanup and resume operations must preserve the same user boundary.\n\n8. Treat the `.NET AI` MCP quickstarts as bootstrap examples.\n   - `build-mcp-client` and `build-mcp-server` are good starting points when the surrounding app is still MEAI-centric.\n   - `publish-mcp-registry` is the distribution step, not the design step. Stabilize the protocol surface before publishing.\n\n9. Respect current error and serialization rules.\n   - Tool exceptions normally come back as `CallToolResult.IsError == true`.\n   - Throw `McpProtocolException` only for protocol-level JSON-RPC failures.\n   - `McpClientTool` inherits from `AIFunction`, so discovered tools can be passed directly into `IChatClient`.\n   - Experimental APIs use `MCPEXP...` diagnostics; suppress them intentionally, not globally by accident.\n   - If you use a custom `JsonSerializerContext`, prepend `McpJsonUtilities.DefaultOptions.TypeInfoResolver` so MCP protocol types keep the SDK's contract.\n\n## Anti-Patterns To Avoid\n\n| Anti-pattern | Why it causes trouble | Better approach |\n|--------------|-----------------------|-----------------|\n| Picking HTTP transport for a purely local child-process scenario | Adds unnecessary hosting, auth, and deployment surface | Use stdio for local\u002Feditor-hosted integrations |\n| Treating SSE as the default remote transport | Locks new work to legacy behavior | Prefer Streamable HTTP and keep SSE only for backward compatibility |\n| Writing tools without `[Description]` metadata | Hosts and models lose schema clarity | Describe tool purpose and parameters explicitly |\n| Returning huge binary\u002Ftext payloads from every tool call | Bloats context and slows hosts | Return focused content and move large data to resources |\n| Logging to stdout on stdio servers | Corrupts the protocol stream | Send logs to stderr |\n| Assuming prompts\u002Fresources\u002Flogging\u002Fcompletions exist | Breaks against partial implementations | Check negotiated capabilities first |\n| Using filters for normal business logic | Makes handlers opaque and hard to reason about | Keep filters for cross-cutting policy, audit, or protocol plumbing |\n\n## Deliver\n\n- a correctly packaged MCP server or client that matches the deployment topology\n- explicit tool\u002Fresource\u002Fprompt definitions with descriptions and bounded payloads\n- capability-aware handling for optional MCP features\n- validation notes for transport, auth boundary, and host\u002Fclient interoperability\n\n## Validate\n\n- chosen package matches the topology: `Core`, `ModelContextProtocol`, or `AspNetCore`\n- stdio servers do not write logs or diagnostics to stdout\n- HTTP servers use `MapMcp()` and are tested at the final route, for example `\u002Fmcp`\n- tools, resources, and prompts use current `[McpServer*]` attributes or documented handler\u002Ffilter alternatives\n- client code checks `ServerCapabilities` before using subscriptions, completions, logging, or prompt\u002Fresource list-change flows\n- Streamable HTTP is the default for new remote servers; SSE is used only for legacy compatibility\n- experimental APIs and custom serialization settings are reviewed intentionally rather than copied blindly\n","# MCP C# SDK for .NET\n\n## Trigger On\n\n- building or consuming MCP servers from a .NET application or library\n- choosing between stdio and HTTP transport for MCP\n- exposing tools, resources, prompts, completions, or logging to an MCP host\n- connecting a .NET app to an existing MCP server and passing discovered tools into `IChatClient`\n- bootstrapping a minimal MCP client\u002Fserver from the `.NET AI` quickstarts or publishing a server to the MCP Registry\n- implementing capability-aware flows such as roots, sampling, elicitation, subscriptions, session resumption, or enterprise managed authorization\n\n## Use This Skill Instead Of\n\n- Use `mcp` when **protocol interoperability** is the requirement.\n- Use `microsoft-extensions-ai` when you only need model\u002Fprovider abstraction or local tool orchestration without the MCP wire protocol.\n- Use `microsoft-agent-framework` when the main problem is agent orchestration; combine it with `mcp` only when those agents must consume or expose MCP endpoints.\n- Use the `.NET AI` quickstarts for the very first vertical slice, then come back here to harden transport, capability negotiation, publishing, and host interoperability.\n\n## Documentation\n\n- [MCP C# SDK overview](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002F)\n- [Getting Started](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fconcepts\u002Fgetting-started.html)\n- [API reference](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fapi\u002FModelContextProtocol.html)\n- [Conceptual docs](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fconcepts\u002Findex.html)\n- [Versioning policy](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fversioning.html)\n- [Experimental APIs](https:\u002F\u002Fcsharp.sdk.modelcontextprotocol.io\u002Fexperimental.html)\n- [MCP C# SDK repository](https:\u002F\u002Fgithub.com\u002Fmodelcontextprotocol\u002Fcsharp-sdk)\n- [Model Context Protocol specification](https:\u002F\u002Fmodelcontextprotocol.io\u002Fspecification\u002F)\n\n## References\n\nLoad only what the task needs:\n\n- [references\u002Fpatterns.md](references\u002Fpatterns.md) - current server\u002Fclient patterns, transports, capabilities, filters, and chat-client integration\n- [references\u002Fsecurity.md](references\u002Fsecurity.md) - safe error handling, auth boundaries, stdio logging hygiene, and defensive tool\u002Fresource patterns\n\n## Package Selection\n\n| Package | Choose when |\n|---------|-------------|\n| `ModelContextProtocol.Core` | You only need a client or low-level server APIs and want the smallest dependency set. |\n| `ModelContextProtocol` | You want the main SDK package with hosting, DI, attribute discovery, and stdio server support. Start here for most projects. |\n| `ModelContextProtocol.AspNetCore` | You are hosting a remote MCP server in ASP.NET Core over HTTP. This includes the main package. |\n\n## Transport Selection\n\n| Transport | Use when | Notes |\n|-----------|----------|-------|\n| `StdioClientTransport` \u002F `WithStdioServerTransport()` | The MCP server should run as a local child process. | Best for local tooling and editor\u002Fagent integrations. |\n| `HttpClientTransport` + `HttpTransportMode.StreamableHttp` | The server is remote or should be reachable over HTTP. | Recommended HTTP transport; supports streaming and session resumption. |\n| `HttpTransportMode.Sse` | You must connect to an older SSE-only server. | Legacy compatibility only; do not choose this for new servers. |\n\n## Current v2.2 Notes\n\n- The August 2026 `.NET AI` MCP documentation separates a getting-started hub, client and server quickstarts, MCP Registry publishing, and a server-resource index. Use those pages to bootstrap a vertical slice, then return to the C# SDK docs here for exact transport, capability, authorization, and lifecycle behavior.\n- SDK `v2.0.0` aligns with MCP `2026-07-28`: HTTP is stateless by default, clients negotiate with `server\u002Fdiscover` before falling back to legacy `initialize`, Tasks move to `ModelContextProtocol.Extensions.Tasks`, and Roots, Sampling, and Logging are deprecated for the new protocol. Set `HttpServerTransportOptions.Stateless = false` only for an intentional stateful compatibility requirement.\n- SDK `v2.1.0` adds an opt-in `subscriptions\u002Flisten` server handler, keeps AutoDetect usable after a provisional SSE failure, preserves HTTP status codes across target frameworks, and falls back to `initialize` when `server\u002Fdiscover` fails at the HTTP layer. Add custom notification streams only when both peers negotiate the extension.\n- SDK `v2.2.0` adds `HttpServerSessionMode` so one ASP.NET Core endpoint can serve stateful and stateless clients across the MCP `2025-11-25` and `2026-07-28` protocol versions. Choose the mode explicitly, test both negotiated paths when compatibility matters, and upgrade before working around malformed percent-encoded request headers because the release fixes that decoding failure.\n- Before moving from `v1.4.x`, update structured-result consumers to accept non-object values directly, require `Tool.inputSchema` in custom payloads, move Tasks to the extension package, and test PKCE S256 plus issuer validation in OAuth metadata.\n- Enterprise managed authorization now has an SDK surface through `IdentityAssertionGrantProvider` for the Identity Assertion Authorization Grant flow. Use it only when the enterprise SSO and MCP authorization-server contract is part of the actual scenario.\n- `StdioClientTransportOptions.InheritEnvironmentVariables` controls whether child-process MCP servers inherit the parent environment. Set it intentionally when launching untrusted or third-party servers.\n- Streamable HTTP session `DELETE` is hardened to require the same authenticated user that opened the session. Do not build custom session cleanup paths that bypass that authorization check.\n- Stdio transport no longer logs child-process environment variables at trace level, but server authors should still treat environment variables as secrets.\n\n```mermaid\nflowchart LR\n    A[\"Need MCP interoperability in .NET\"] --> B{\"Role?\"}\n    B -->|\"Expose MCP surface\"| C{\"Where will it run?\"}\n    B -->|\"Consume an MCP server\"| D{\"Transport?\"}\n    C -->|\"Local child process\"| E[\"ModelContextProtocol\\nAddMcpServer()\\nWithStdioServerTransport()\"]\n    C -->|\"Remote HTTP endpoint\"| F[\"ModelContextProtocol.AspNetCore\\nAddMcpServer()\\nWithHttpTransport()\\nMapMcp()\"]\n    D -->|\"stdio\"| G[\"StdioClientTransport\\nMcpClient.CreateAsync()\"]\n    D -->|\"HTTP\"| H[\"HttpClientTransport\\nAutoDetect or StreamableHttp\"]\n    E --> I[\"Register tools\u002Fresources\u002Fprompts\"]\n    F --> I\n    G --> J[\"Check ServerCapabilities\\nbefore optional features\"]\n    H --> J\n```\n\n## Workflow\n\n1. Pick the package and transport first.\n   - Local child-process server: `ModelContextProtocol` + `WithStdioServerTransport()`.\n   - Remote server: `ModelContextProtocol.AspNetCore` + `WithHttpTransport()` + `MapMcp()`.\n   - Client-only app: start with `ModelContextProtocol` or `ModelContextProtocol.Core`.\n   - Registry distribution: pair a minimal server with the MCP Registry publishing flow only after the server contract is stable.\n\n2. Model the MCP surface explicitly.\n   - Tools: `[McpServerToolType]` + `[McpServerTool]`\n   - Resources: `[McpServerResourceType]` + `[McpServerResource]`\n   - Prompts: `[McpServerPromptType]` + `[McpServerPrompt]`\n   - Use custom handlers or filters only for cross-cutting behavior, protocol extensions, or advanced routing.\n\n3. Prefer attribute discovery for straightforward servers.\n\n```csharp\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Hosting;\nusing Microsoft.Extensions.Logging;\nusing ModelContextProtocol.Server;\nusing System.ComponentModel;\n\nvar builder = Host.CreateApplicationBuilder(args);\nbuilder.Logging.AddConsole(options =>\n{\n    options.LogToStandardErrorThreshold = LogLevel.Trace;\n});\n\nbuilder.Services\n    .AddMcpServer()\n    .WithStdioServerTransport()\n    .WithToolsFromAssembly();\n\nawait builder.Build().RunAsync();\n\n[McpServerToolType]\npublic static class EchoTool\n{\n    [McpServerTool, Description(\"Echoes the message back to the client.\")]\n    public static string Echo(string message) => $\"hello {message}\";\n}\n```\n\n4. For HTTP servers, use the ASP.NET Core transport and map the endpoint directly.\n\n```csharp\nusing ModelContextProtocol.Server;\nusing System.ComponentModel;\n\nvar builder = WebApplication.CreateBuilder(args);\n\nbuilder.Services\n    .AddMcpServer()\n    .WithHttpTransport()\n    .WithToolsFromAssembly();\n\nvar app = builder.Build();\napp.MapMcp(\"\u002Fmcp\");\napp.Run();\n\n[McpServerToolType]\npublic static class EchoTool\n{\n    [McpServerTool, Description(\"Echoes the message back to the client.\")]\n    public static string Echo(string message) => $\"hello {message}\";\n}\n```\n\n5. When consuming a server, use `McpClient.CreateAsync(...)` and stay capability-aware.\n\n```csharp\nusing ModelContextProtocol.Client;\nusing ModelContextProtocol.Protocol;\n\nvar transport = new StdioClientTransport(new StdioClientTransportOptions\n{\n    Name = \"Everything\",\n    Command = \"npx\",\n    Arguments = [\"-y\", \"@modelcontextprotocol\u002Fserver-everything\"],\n});\n\nawait using var client = await McpClient.CreateAsync(transport);\n\nIList\u003CMcpClientTool> tools = await client.ListToolsAsync();\n\nif (client.ServerCapabilities.Prompts is not null)\n{\n    var prompts = await client.ListPromptsAsync();\n}\n```\n\n6. Treat optional features as negotiated capabilities, not assumptions.\n   - Client capabilities: configure `McpClientOptions.Capabilities` for roots, sampling, and elicitation.\n   - Server capabilities are inferred from registered features.\n   - Check `client.ServerCapabilities` before using completions, logging, prompt list-change notifications, or resource subscriptions.\n   - Use `client.NegotiatedProtocolVersion` or `server.NegotiatedProtocolVersion` only when version-specific behavior matters.\n\n7. Keep HTTP guidance current.\n   - Streamable HTTP is the recommended transport for remote servers.\n   - `MapMcp()` also serves SSE compatibility endpoints for older clients.\n   - HTTP clients can use `AutoDetect` by default, or force `StreamableHttp` \u002F `Sse`.\n   - Session resumption is available for Streamable HTTP through `McpClient.ResumeSessionAsync(...)`.\n   - For authenticated Streamable HTTP sessions, cleanup and resume operations must preserve the same user boundary.\n\n8. Treat the `.NET AI` MCP quickstarts as bootstrap examples.\n   - `build-mcp-client` and `build-mcp-server` are good starting points when the surrounding app is still MEAI-centric.\n   - `publish-mcp-registry` is the distribution step, not the design step. Stabilize the protocol surface before publishing.\n\n9. Respect current error and serialization rules.\n   - Tool exceptions normally come back as `CallToolResult.IsError == true`.\n   - Throw `McpProtocolException` only for protocol-level JSON-RPC failures.\n   - `McpClientTool` inherits from `AIFunction`, so discovered tools can be passed directly into `IChatClient`.\n   - Experimental APIs use `MCPEXP...` diagnostics; suppress them intentionally, not globally by accident.\n   - If you use a custom `JsonSerializerContext`, prepend `McpJsonUtilities.DefaultOptions.TypeInfoResolver` so MCP protocol types keep the SDK's contract.\n\n## Anti-Patterns To Avoid\n\n| Anti-pattern | Why it causes trouble | Better approach |\n|--------------|-----------------------|-----------------|\n| Picking HTTP transport for a purely local child-process scenario | Adds unnecessary hosting, auth, and deployment surface | Use stdio for local\u002Feditor-hosted integrations |\n| Treating SSE as the default remote transport | Locks new work to legacy behavior | Prefer Streamable HTTP and keep SSE only for backward compatibility |\n| Writing tools without `[Description]` metadata | Hosts and models lose schema clarity | Describe tool purpose and parameters explicitly |\n| Returning huge binary\u002Ftext payloads from every tool call | Bloats context and slows hosts | Return focused content and move large data to resources |\n| Logging to stdout on stdio servers | Corrupts the protocol stream | Send logs to stderr |\n| Assuming prompts\u002Fresources\u002Flogging\u002Fcompletions exist | Breaks against partial implementations | Check negotiated capabilities first |\n| Using filters for normal business logic | Makes handlers opaque and hard to reason about | Keep filters for cross-cutting policy, audit, or protocol plumbing |\n\n## Deliver\n\n- a correctly packaged MCP server or client that matches the deployment topology\n- explicit tool\u002Fresource\u002Fprompt definitions with descriptions and bounded payloads\n- capability-aware handling for optional MCP features\n- validation notes for transport, auth boundary, and host\u002Fclient interoperability\n\n## Validate\n\n- chosen package matches the topology: `Core`, `ModelContextProtocol`, or `AspNetCore`\n- stdio servers do not write logs or diagnostics to stdout\n- HTTP servers use `MapMcp()` and are tested at the final route, for example `\u002Fmcp`\n- tools, resources, and prompts use current `[McpServer*]` attributes or documented handler\u002Ffilter alternatives\n- client code checks `ServerCapabilities` before using subscriptions, completions, logging, or prompt\u002Fresource list-change flows\n- Streamable HTTP is the default for new remote servers; SSE is used only for legacy compatibility\n- experimental APIs and custom serialization settings are reviewed intentionally rather than copied blindly\n",{"name":5,"description":7,"compatibility":58},"Requires the official MCP C# SDK packages (`ModelContextProtocol.Core`, `ModelContextProtocol`, or `ModelContextProtocol.AspNetCore`) on .NET 8+; current guidance targets the v2.2 SDK and MCP 2026-07-28.","main","497cc9aba79a931ac6fb8d36a48cc22fe3d6d74b","catalog\u002FLibraries\u002FMCP\u002Fskills\u002Fmcp",41,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills","https:\u002F\u002Fskills.managed-code.com","https:\u002F\u002Fgithub.com\u002Fmanagedcode","https:\u002F\u002Fwww.managed-code.com","Open Source Community for .NET Developers: Reliable, Actively Maintained, and Community-Driven. Made in Ukraine 🇺🇦 with ❤️","2026-11-14 19:05:44",{"source":8,"skillName":5,"commands":70,"prompt":80,"zipAvailable":81},[71,74,77],{"tool":72,"command":73},"npx","npx skills add managedcode\u002Fdotnet-skills --skill mcp",{"tool":75,"command":76},"bunx","bunx skills add managedcode\u002Fdotnet-skills --skill mcp",{"tool":78,"command":79},"pnpm","pnpm dlx skills add managedcode\u002Fdotnet-skills --skill mcp","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMCP\u002Fskills\u002Fmcp\u002FSKILL.md",true,[83,89,93,97,103,107,111],{"path":84,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":87,"sourceHtmlUrl":88},"manifest.json","REFERENCE","参考文档",132,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMCP\u002Fskills\u002Fmcp\u002Fmanifest.json",{"path":90,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Fpatterns.md",11829,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMCP\u002Fskills\u002Fmcp\u002Freferences\u002Fpatterns.md",{"path":94,"resourceType":85,"resourceTypeDesc":86,"sizeBytes":95,"sourceHtmlUrl":96},"references\u002Fsecurity.md",7169,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FMCP\u002Fskills\u002Fmcp\u002Freferences\u002Fsecurity.md",{"path":98,"resourceType":99,"resourceTypeDesc":100,"sizeBytes":101,"sourceHtmlUrl":102},"scripts\u002Fdownload_coordinate_files.py","SCRIPT","脚本",3367,"https:\u002F\u002Fgithub.com\u002Ffranklee16\u002Facademic-research-skills\u002Fblob\u002Fmaster\u002Fscience-skills\u002Fpdb_database\u002Fscripts\u002Fdownload_coordinate_files.py",{"path":104,"resourceType":99,"resourceTypeDesc":100,"sizeBytes":105,"sourceHtmlUrl":106},"scripts\u002Ffetch_pdb_metadata.py",2015,"https:\u002F\u002Fgithub.com\u002Ffranklee16\u002Facademic-research-skills\u002Fblob\u002Fmaster\u002Fscience-skills\u002Fpdb_database\u002Fscripts\u002Ffetch_pdb_metadata.py",{"path":108,"resourceType":99,"resourceTypeDesc":100,"sizeBytes":109,"sourceHtmlUrl":110},"scripts\u002Ffetch_schema.py",7842,"https:\u002F\u002Fgithub.com\u002Ffranklee16\u002Facademic-research-skills\u002Fblob\u002Fmaster\u002Fscience-skills\u002Fpdb_database\u002Fscripts\u002Ffetch_schema.py",{"path":112,"resourceType":99,"resourceTypeDesc":100,"sizeBytes":113,"sourceHtmlUrl":114},"scripts\u002Fsearch_pdb.py",5756,"https:\u002F\u002Fgithub.com\u002Ffranklee16\u002Facademic-research-skills\u002Fblob\u002Fmaster\u002Fscience-skills\u002Fpdb_database\u002Fscripts\u002Fsearch_pdb.py",[116,145,167,197,207,234],{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":130,"publishedAt":53},"01M6DYQE1Y9FHAQHEDTVFQ3447","xtwitter-scraper","Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook\u002Fevent flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FXTwitterScraper\u002Fskills\u002Fxtwitter-scraper\u002FSKILL.md",[122,125],{"categoryNo":123,"categoryName":124,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口",{"categoryNo":126,"categoryName":127,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[131,132,133,44,134,135,136,41,137,138,139,140,39,36,141,35,142,32,143,144],"xtwitter scraper","browser automation","workflows","code","browser","search","api","Media","api client","access","webhooks","social","modeling","webhook",{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":157,"publishedAt":53},"01M6DYQ9S4PE1H6G8MCH9T21HR","sep","Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser\u002Fwriter options, and low-allocation row\u002Fcolumn workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FSep\u002Fskills\u002Fsep\u002FSKILL.md",[151,154],{"categoryNo":152,"categoryName":153,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":155,"categoryName":156,"taxonomyType":128,"taxonomyTypeDesc":129},"01JBSEEDCAT000000000000036","内容创作者",[147,158,159,133,47,44,41,160,161,162,39,38,36,35,33,163,164,165,32,166],"writing","performance","data","parsing","parser","writer","options","project","high-performance",{"skillNo":168,"name":169,"nameZh":6,"description":170,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":171,"categories":172,"keywords":173,"publishedAt":53},"01M6DZS2DNEPXCGGF6SSCW6G5V","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fwebgpu-claude-skill\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[174,175,176,177,178,179,180,181,182,183,184,185,37,186,187,188,189,190,191,192,193,194,195,196,27],"webgpu","threejs","webgpu threejs tsl","setup","shaders","gpu","integration","applications","js","node","syntax","guide","language","three","compute","post","processing","with","renderer","for","materials","wgsl","effects",{"skillNo":198,"name":199,"nameZh":6,"description":200,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":201,"categories":202,"keywords":203,"publishedAt":53},"01M6DZS0BQXW2B56A289XF1X76","roslynk","Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Froslynk\u002Fskills\u002Froslynk\u002FSKILL.md",[],[199,37,35,204,205,193,206],"semantic","razor","inspection",{"skillNo":208,"name":209,"nameZh":6,"description":210,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":211,"categories":212,"keywords":213,"publishedAt":53},"01M6DZRW6MEJCVW80K3S4XV60K","system-text-json-net11","Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fsystem-text-json-net11\u002FSKILL.md",[],[214,215,216,217,158,218,219,220,221,222,223,37,224,225,226,227,33,228,229,230,231,193,232,233,27],"system","json","text","system text json net11","policy","metadata","library","serialization","behavior","user","only","probe","guidance","later","type","dictionary","naming","targeting","custom","generic",{"skillNo":235,"name":236,"nameZh":6,"description":237,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":238,"categories":239,"keywords":242,"publishedAt":53},"01M6DZRRJP3S662NFSG1RSPQQ7","process-api-net11","Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText\u002FBytes\u002FLines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fprocess-api-net11\u002FSKILL.md",[240,241],{"categoryNo":123,"categoryName":124,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":126,"categoryName":127,"taxonomyType":128,"taxonomyTypeDesc":129},[137,243,244,245,44,246,181,214,37,226,227,33,247,248,249,250,231,193,251],"process","process api net11","diagnostics","start","basic","processes","output","usage","new"]