3.17Setting MCP/2.0 Message Content
Created on Aug 17, 2026~3 min read
SetMcpContent is an extension method specifically designed for the MCP (Model Context Protocol) 2.0 protocol, used to quickly build requests conforming to the JSON‑RPC 2.0 format and automatically attach the required MCP request headers. It supports sending two message types: requests (which require a response) and notifications (which require no response).
HttpRequestBuilder.Post("https://mcp.example.com/mcp") .SetMcpContent("MyClient", "tools/list");// Carries parametersHttpRequestBuilder.Post("https://mcp.example.com/mcp") .SetMcpContent("MyClient", "tools/list", new { name = "get_weather" });// Custom IDHttpRequestBuilder.Post("https://mcp.example.com/mcp") .SetMcpContent("MyClient", new McpMessageData("tools/list") { Id = "custom-001" });// Used together with Server Sent Events streaming responsesHttpRequestBuilder.ServerSentEvents("https://mcp.example.com/mcp") .SetMcpContent("MyClient", "tools/call", new { name = "get_weather" });