@@ -86,6 +86,15 @@ const GetResourceReferenceSchema = z.object({
8686 . describe ( "ID of the resource to reference (1-100)" ) ,
8787} ) ;
8888
89+ const GetResourceLinksSchema = z . object ( {
90+ count : z
91+ . number ( )
92+ . min ( 1 )
93+ . max ( 10 )
94+ . default ( 3 )
95+ . describe ( "Number of resource links to return (1-10)" ) ,
96+ } ) ;
97+
8998enum ToolName {
9099 ECHO = "echo" ,
91100 ADD = "add" ,
@@ -95,6 +104,7 @@ enum ToolName {
95104 GET_TINY_IMAGE = "getTinyImage" ,
96105 ANNOTATED_MESSAGE = "annotatedMessage" ,
97106 GET_RESOURCE_REFERENCE = "getResourceReference" ,
107+ GET_RESOURCE_LINKS = "getResourceLinks" ,
98108}
99109
100110enum PromptName {
@@ -117,7 +127,7 @@ export const createServer = () => {
117127 logging : { } ,
118128 completions : { } ,
119129 } ,
120- instructions
130+ instructions,
121131 }
122132 ) ;
123133
@@ -164,13 +174,12 @@ export const createServer = () => {
164174 server . notification ( message ) ;
165175 } , 20000 ) ;
166176
167-
168177 // Set up update interval for stderr messages
169178 stdErrUpdateInterval = setInterval ( ( ) => {
170179 const shortTimestamp = new Date ( ) . toLocaleTimeString ( [ ] , {
171180 hour : "2-digit" ,
172181 minute : "2-digit" ,
173- second : "2-digit"
182+ second : "2-digit" ,
174183 } ) ;
175184 server . notification ( {
176185 method : "notifications/stderr" ,
@@ -459,6 +468,12 @@ export const createServer = () => {
459468 "Returns a resource reference that can be used by MCP clients" ,
460469 inputSchema : zodToJsonSchema ( GetResourceReferenceSchema ) as ToolInput ,
461470 } ,
471+ {
472+ name : ToolName . GET_RESOURCE_LINKS ,
473+ description :
474+ "Returns multiple resource links that reference different types of resources" ,
475+ inputSchema : zodToJsonSchema ( GetResourceLinksSchema ) as ToolInput ,
476+ } ,
462477 ] ;
463478
464479 return { tools } ;
@@ -648,6 +663,42 @@ export const createServer = () => {
648663 return { content } ;
649664 }
650665
666+ if ( name === ToolName . GET_RESOURCE_LINKS ) {
667+ const { count } = GetResourceLinksSchema . parse ( args ) ;
668+ const content = [ ] ;
669+
670+ // Add intro text
671+ content . push ( {
672+ type : "text" ,
673+ text : `Here are ${ count } resource links to resources available in this server:` ,
674+ } ) ;
675+
676+ // Return resource links to actual resources from ALL_RESOURCES
677+ const actualCount = Math . min ( count , ALL_RESOURCES . length ) ;
678+ for ( let i = 0 ; i < actualCount ; i ++ ) {
679+ const resource = ALL_RESOURCES [ i ] ;
680+ content . push ( {
681+ type : "resource_link" ,
682+ uri : resource . uri ,
683+ name : resource . name ,
684+ description : `Resource ${ i + 1 } : ${
685+ resource . mimeType === "text/plain"
686+ ? "plaintext resource"
687+ : "binary blob resource"
688+ } `,
689+ mimeType : resource . mimeType ,
690+ } ) ;
691+ }
692+
693+ // Add summary text
694+ content . push ( {
695+ type : "text" ,
696+ text : `\nThese resource links reference actual resources available through the resources/read endpoint.` ,
697+ } ) ;
698+
699+ return { content } ;
700+ }
701+
651702 throw new Error ( `Unknown tool: ${ name } ` ) ;
652703 } ) ;
653704
0 commit comments