11import { ErrorCode } from '@modelcontextprotocol/sdk/types.js' ;
22import { z } from 'zod' ;
33import { type McpTool } from './mcpSdk' ;
4- import { stringJoin , buildSearchString } from './server.helpers' ;
4+ import { stringJoin } from './server.helpers' ;
55import { assertInput , assertInputStringLength , assertInputStringNumberEnumLike } from './server.assertions' ;
66import { findClosest } from './server.search' ;
77import { getOptions } from './options.context' ;
@@ -106,11 +106,9 @@ const searchPatternFlyTool = (options = getOptions()): McpTool => {
106106 numberRecords += 1 ;
107107 recordNames . add ( record . displayName ) ;
108108
109- const recordUri = `${ record . uriId } ${ buildSearchString ( { version : record . version } , { prefix : true } ) } ` ;
110-
111- results . set ( recordUri , {
109+ results . set ( record . uriId , {
112110 type : 'resource_link' ,
113- uri : recordUri ,
111+ uri : record . uriId ,
114112 name : `${ record . displayName } - ${ record . displayCategory } (${ record . version } )` ,
115113 description : record . description ,
116114 mimeType : 'text/markdown' ,
@@ -122,11 +120,9 @@ const searchPatternFlyTool = (options = getOptions()): McpTool => {
122120 numberRecords += 1 ;
123121 recordNames . add ( record . displayName ) ;
124122
125- const schemaUri = `${ record . uriSchemasId } ${ buildSearchString ( { version : record . version } , { prefix : true } ) } ` ;
126-
127- results . set ( schemaUri , {
123+ results . set ( record . uriSchemasId , {
128124 type : 'resource_link' ,
129- uri : schemaUri ,
125+ uri : record . uriSchemasId ,
130126 name : `${ record . displayName } - JSON Schema (${ record . version } )` ,
131127 description : `Component JSON schema with property definitions for ${ record . displayName } .` ,
132128 mimeType : 'text/markdown' ,
@@ -135,7 +131,15 @@ const searchPatternFlyTool = (options = getOptions()): McpTool => {
135131 }
136132 } ) ;
137133
138- if ( ! result . entries . length ) {
134+ /**
135+ * FIXME: Schemas are intended to be part of collections. We're temporarily expanding our limit condition
136+ * to include `!result.entries.some(entry => Boolean(entry.path)` to make sure if a collection only has JSON
137+ * schemas available, the "collection" doesn't appear; this is specfically to work with the current MCP
138+ * resource structure. In the future when we've focused our MCP resources down to "collections" and
139+ * "records" we would review dropping this part of the check and allow a "collection" grouping to appear
140+ * if all it had were JSON schemas.
141+ */
142+ if ( ! result . entries . length || ! result . entries . some ( entry => Boolean ( entry . path ) ) ) {
139143 return ;
140144 }
141145
@@ -146,14 +150,10 @@ const searchPatternFlyTool = (options = getOptions()): McpTool => {
146150 // Track the name used for sorting this entire group
147151 groupSortNames . set ( result . groupId , collectionName . toLowerCase ( ) ) ;
148152
149- const hasDocs = result . entries . some ( entry => Boolean ( entry . path ) ) ;
150- const versionQuery = buildSearchString ( { version : updatedVersion } , { prefix : true } ) ;
151- const collectionUri = `patternfly://${ hasDocs ? 'docs' : 'schemas' } /${ result . groupId } ${ versionQuery } ` ;
152-
153153 results . set ( result . groupId , {
154154 type : 'resource_link' ,
155- uri : collectionUri ,
156- name : `${ collectionName } (${ hasDocs ? ' Collection' : 'Schema Collection' } )` ,
155+ uri : `patternfly://docs/ ${ result . groupId } ` ,
156+ name : `${ collectionName } (Collection)` ,
157157 description : `A resource collection series for ${ collectionNames } ` ,
158158 mimeType : 'text/markdown' ,
159159 groupId : result . groupId
0 commit comments