You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
_meta field not serialized in HTTP transport - blocks ChatGPT Apps SDK
Summary
Issue #856 was closed as complete, but HTTP serialization is an issue. While PR #857 added the API to SET metadata (McpMetaAttribute and Meta properties), the _meta field is not serialized when using HTTP transport (Streamable HTTP/SSE).
This is a critical blocker for ChatGPT Apps SDK integration, as ChatGPT only supports HTTP-based transports (Streamable HTTP and SSE, not stdio).
Impact
ChatGPT Apps SDK requires HTTP-based transports: Streamable HTTP or SSE (doesn't support stdio)
ChatGPT requires _meta.openai/outputTemplate in tool descriptors for custom UI
All ChatGPT Apps SDK users that have custom UX are affected
Both implementation approaches affected:
Dynamic: McpServerToolCreateOptions.Meta
Attribute: [McpMeta("key", "value")]
Reproduction
Setup
// Using dynamic approachvartoolOptions=newMcpServerToolCreateOptions{Meta=newJsonObject{["openai/outputTemplate"]="ui://task.html",["openai/widgetAccessible"]=true}};vartool=McpServerTool.Create(myFunction,options:toolOptions);// OR using attribute approach[McpServerTool][McpMeta("openai/outputTemplate","ui://task.html")]publicstaticstringGetTasks(){}
// Added logging in DynamicToolService.cs_logger.LogInformation("Meta is {Status}: {Meta}",tool.ProtocolTool.Meta!=null?"SET":"NULL",tool.ProtocolTool.Meta);
Output: Meta is SET: {"openai/outputTemplate":"ui://task.html",...}
Conclusion: Meta exists on tool.ProtocolTool.Meta internally, but HTTP serialization strips it.
Root Cause
The SDK uses source-generated JSON serialization (McpJsonUtilities.JsonContext):
✅ Tool.cs line 125: [JsonPropertyName("_meta")] public JsonObject? Meta { get; set; }
✅ McpJsonUtilities.cs line 134: [JsonSerializable(typeof(ListToolsResult))]
❌ Missing: [JsonSerializable(typeof(Tool))]
Source generators use compile-time metadata. When Tool.Meta was added in PR #857, the source generator wasn't updated. The HTTP layer serializes using the source-generated context, which doesn't include metadata for Tool, so _meta gets stripped.
Compare with ResourceContents: Has a custom JsonConverter that explicitly writes _meta (ResourceContents.cs lines 173-178). Tool doesn't have this.
Why Tests Pass But HTTP Fails
PR #857 added extensive lines of tests (McpMetaAttributeTests.cs) - all pass! But:
Tests serialize directly using McpJsonUtilities.DefaultOptions
Tests don't go through HTTP transport layer
HTTP serialization uses the source-generated JsonContext which lacks Tool metadata
_metafield not serialized in HTTP transport - blocks ChatGPT Apps SDKSummary
Issue #856 was closed as complete, but HTTP serialization is an issue. While PR #857 added the API to SET metadata (
McpMetaAttributeandMetaproperties), the_metafield is not serialized when using HTTP transport (Streamable HTTP/SSE).This is a critical blocker for ChatGPT Apps SDK integration, as ChatGPT only supports HTTP-based transports (Streamable HTTP and SSE, not stdio).
Impact
_meta.openai/outputTemplatein tool descriptors for custom UIMcpServerToolCreateOptions.Meta[McpMeta("key", "value")]Reproduction
Setup
Test with HTTP
Expected:
{"openai/outputTemplate": "ui://task.html", ...}Actual:
nullDebug Logging Confirms Meta Is Set
Output:
Meta is SET: {"openai/outputTemplate":"ui://task.html",...}Conclusion: Meta exists on
tool.ProtocolTool.Metainternally, but HTTP serialization strips it.Root Cause
The SDK uses source-generated JSON serialization (
McpJsonUtilities.JsonContext):Tool.csline 125:[JsonPropertyName("_meta")] public JsonObject? Meta { get; set; }McpJsonUtilities.csline 134:[JsonSerializable(typeof(ListToolsResult))][JsonSerializable(typeof(Tool))]Source generators use compile-time metadata. When
Tool.Metawas added in PR #857, the source generator wasn't updated. The HTTP layer serializes using the source-generated context, which doesn't include metadata forTool, so_metagets stripped.Compare with
ResourceContents: Has a customJsonConverterthat explicitly writes_meta(ResourceContents.cs lines 173-178).Tooldoesn't have this.Why Tests Pass But HTTP Fails
PR #857 added extensive lines of tests (
McpMetaAttributeTests.cs) - all pass! But:McpJsonUtilities.DefaultOptionsJsonContextwhich lacksToolmetadataEnvironment
ModelContextProtocol 0.4.0-preview.3,ModelContextProtocol.AspNetCore 0.4.0-preview.3Suggested Fix
Option 1: Add explicit serialization metadata:
Option 2: Add custom
JsonConverterforTool(likeResourceContentshas) that explicitly writes_metaRelated
Additional Context
#856 may have been closed prematurely: