File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
mcp/src/test/java/io/modelcontextprotocol/client Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 55package io .modelcontextprotocol .client ;
66
77import java .time .Duration ;
8+ import java .util .Map ;
89import java .util .concurrent .CountDownLatch ;
910import java .util .concurrent .TimeUnit ;
1011import java .util .concurrent .atomic .AtomicReference ;
@@ -130,6 +131,30 @@ void testListResourceTemplates() {
130131 });
131132 }
132133
134+ @ Test
135+ void testEmbeddedResources () {
136+ McpClientTransport transport = createMcpTransport ();
137+
138+ withClient (transport , client -> {
139+ client .initialize ();
140+
141+ McpSchema .CallToolResult result = client .callTool (new McpSchema .CallToolRequest ("getResourceReference" ,
142+ Map .of (
143+ "resourceId" , 1
144+ )));
145+
146+ assertThat (result .content ()).hasAtLeastOneElementOfType (McpSchema .EmbeddedResource .class );
147+ assertThat (result .content ()).allSatisfy (content -> {
148+ if (!(content instanceof McpSchema .EmbeddedResource resource )) return ;
149+
150+ McpSchema .TextResourceContents text = assertInstanceOf (McpSchema .TextResourceContents .class , resource .resource ());
151+ assertThat (text .mimeType ()).isEqualTo ("text/plain" );
152+ assertThat (text .uri ()).isNotEmpty ();
153+ assertThat (text .text ()).isNotEmpty ();
154+ });
155+ });
156+ }
157+
133158 protected Duration getInitializationTimeout () {
134159 return Duration .ofSeconds (6 );
135160 }
You can’t perform that action at this time.
0 commit comments