@@ -67,7 +67,7 @@ public async Task ToolCallWithMetaFields()
6767 }
6868
6969 [ Fact ]
70- public async Task ResourceGetWithMetaFields ( )
70+ public async Task ResourceReadWithMetaFields ( )
7171 {
7272 Server . ServerOptions . ResourceCollection ? . Add ( McpServerResource . Create (
7373 ( RequestContext < ReadResourceRequestParams > context ) =>
@@ -100,4 +100,42 @@ public async Task ResourceGetWithMetaFields()
100100 Assert . NotNull ( textContent ) ;
101101 Assert . Contains ( "bar baz" , textContent . Text ) ;
102102 }
103+
104+
105+ [ Fact ]
106+ public async Task PromptGettWithMetaFields ( )
107+ {
108+ Server . ServerOptions . PromptCollection ? . Add ( McpServerPrompt . Create (
109+ ( RequestContext < GetPromptRequestParams > context ) =>
110+ {
111+ // Access the foo property of _meta field from the request parameters
112+ var metaFoo = context . Params ? . Meta ? [ "foo" ] ? . ToString ( ) ;
113+
114+ // Assert that the meta foo is correctly passed
115+ Assert . NotNull ( metaFoo ) ;
116+
117+ return $ "Prompt with Meta foo is { metaFoo } ";
118+ } ,
119+ new ( ) { Name = "meta_prompt" } ) ) ;
120+
121+ await using McpClient client = await CreateMcpClientForServer ( ) ;
122+
123+ var requestOptions = new RequestOptions ( )
124+ {
125+ Meta = new JsonObject ( )
126+ {
127+ { "foo" , "bar baz" }
128+ }
129+ } ;
130+
131+ var result = await client . GetPromptAsync ( "meta_prompt" , options : requestOptions , cancellationToken : TestContext . Current . CancellationToken ) ;
132+
133+ Assert . NotNull ( result ) ;
134+ Assert . NotEmpty ( result . Messages ) ;
135+ var message = result . Messages . First ( ) ;
136+ Assert . NotNull ( message . Content ) ;
137+ var textContent = message . Content as TextContentBlock ;
138+ Assert . NotNull ( textContent ) ;
139+ Assert . Contains ( "bar baz" , textContent . Text ) ;
140+ }
103141}
0 commit comments