From a19f4f2310339804e85f8addaf4c450a9813e2d6 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Thu, 27 Aug 2026 20:13:37 -0400 Subject: [PATCH 1/2] feat(collections): pf-4402 activate patternfly api --- .../__snapshots__/server.test.ts.snap | 33 +++++++++++++++++++ src/options.registry.ts | 4 ++- src/patternFly.getResources.ts | 4 ++- .../__snapshots__/stdioTransport.test.ts.snap | 2 ++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/__tests__/__snapshots__/server.test.ts.snap b/src/__tests__/__snapshots__/server.test.ts.snap index a8a2a8db..e53d4ca0 100644 --- a/src/__tests__/__snapshots__/server.test.ts.snap +++ b/src/__tests__/__snapshots__/server.test.ts.snap @@ -21,6 +21,9 @@ exports[`runServer should allow server to be stopped, http stop server: diagnost [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -89,6 +92,9 @@ exports[`runServer should allow server to be stopped, stdio stop server: diagnos [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -157,6 +163,9 @@ exports[`runServer should attempt to run server, create transport, connect, and [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -236,6 +245,9 @@ exports[`runServer should attempt to run server, disable SIGINT handler: diagnos [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -310,6 +322,9 @@ exports[`runServer should attempt to run server, enable SIGINT handler explicitl [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -389,6 +404,9 @@ exports[`runServer should attempt to run server, log warnings for experimental o [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -483,6 +501,9 @@ exports[`runServer should attempt to run server, register a tool: diagnostics 1` [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -570,6 +591,9 @@ exports[`runServer should attempt to run server, register multiple tools: diagno [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -664,6 +688,9 @@ exports[`runServer should attempt to run server, use custom options: diagnostics [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -743,6 +770,9 @@ exports[`runServer should attempt to run server, use default tools, http: diagno [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], @@ -831,6 +861,9 @@ exports[`runServer should attempt to run server, use default tools, stdio: diagn [ "Registered collection: patternfly-component-schemas", ], + [ + "Registered collection: patternfly-api", + ], [ "Registered resource: patternfly-context", ], diff --git a/src/options.registry.ts b/src/options.registry.ts index cb87218e..c5103329 100644 --- a/src/options.registry.ts +++ b/src/options.registry.ts @@ -11,6 +11,7 @@ import { patternFlySchemasIndexResource } from './resource.patternFlySchemasInde import { patternFlySchemasTemplateResource } from './resource.patternFlySchemasTemplate'; import { patternFlyDocsCollection } from './collection.patternFlyDocs'; import { patternFlySchemasCollection } from './collection.patternFlySchemas'; +import { patternFlyApiCollection } from './collection.patternFlyApi'; /** * Built-in tools. @@ -44,7 +45,8 @@ const builtinResources: McpResourceCreator[] = [ */ const builtinCollections: McpCollectionCreator[] = [ patternFlyDocsCollection, - patternFlySchemasCollection + patternFlySchemasCollection, + patternFlyApiCollection ]; export { builtinCollections, builtinResources, builtinTools }; diff --git a/src/patternFly.getResources.ts b/src/patternFly.getResources.ts index 633ad7bc..6527f05b 100644 --- a/src/patternFly.getResources.ts +++ b/src/patternFly.getResources.ts @@ -492,10 +492,12 @@ const getPatternFlyMcpResources = async (contextPathOverride?: string): Promise< const { componentNamesIndex, byVersion: componentNamesByVersion, byDocs: componentNamesByDocs } = componentNames; const originalDocs = patternFlyRecordsRegistry.get('patternfly-docs'); + const apiCollection = patternFlyRecordsRegistry.get('patternfly-api'); const catalog = [ ...originalDocs?.records?.flatMap(({ data }) => Object.entries(data as Record)) || [], - ...Array.from(componentNamesByDocs) + ...Array.from(componentNamesByDocs), + ...apiCollection?.records?.flatMap(({ data }) => Object.entries(data as Record)) || [] ]; const resources = new Map(); diff --git a/tests/e2e/__snapshots__/stdioTransport.test.ts.snap b/tests/e2e/__snapshots__/stdioTransport.test.ts.snap index 6e3f4718..e4453929 100644 --- a/tests/e2e/__snapshots__/stdioTransport.test.ts.snap +++ b/tests/e2e/__snapshots__/stdioTransport.test.ts.snap @@ -159,6 +159,8 @@ exports[`Logging should allow setting logging options, stderr 1`] = ` "[INFO]: Registered collection: patternfly-docs ", "[INFO]: Registered collection: patternfly-component-schemas +", + "[INFO]: Registered collection: patternfly-api ", "[INFO]: Update collection: patternfly-component-schemas ", From 7d38e31d1b5e38eeef096d736d2791986eaa9a52 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Wed, 2 Sep 2026 10:33:18 -0400 Subject: [PATCH 2/2] fix: review update --- src/docs.filterWords.ts | 2 +- src/patternFly.search.ts | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/docs.filterWords.ts b/src/docs.filterWords.ts index 1350d35d..f02b63b3 100644 --- a/src/docs.filterWords.ts +++ b/src/docs.filterWords.ts @@ -4,7 +4,7 @@ * @note It's tempting to remove category and section names from this list, don't. Instead, the search * should be leveraging filters which allow for "section" and "category" specifically. */ -const INDEX_BLOCKLIST_WORDS = ['patternfly', 'component', 'components', 'documentation', 'example', 'examples', 'view']; +const INDEX_BLOCKLIST_WORDS = ['patternfly', 'component', 'components', 'documentation', 'example', 'examples', 'type', 'types', 'view']; /** * Technical terms and acronyms that should be exempt from length and noise filtering. diff --git a/src/patternFly.search.ts b/src/patternFly.search.ts index 17f4c03c..6b73d8cd 100644 --- a/src/patternFly.search.ts +++ b/src/patternFly.search.ts @@ -192,6 +192,7 @@ const calculateRelevance = ( const normalizedName = normalizeString.memo(result.name); const normalizedQuery = normalizeString.memo(query); + // Exact match if (normalizedName === normalizedQuery) { return 0; } @@ -200,16 +201,32 @@ const calculateRelevance = ( .map(entry => (entry.displayName ? normalizeString.memo(entry.displayName) : '')) .filter(Boolean); + // Exact match if (displayNames.some(name => name === normalizedQuery)) { return 0; } - if (normalizedName.includes(normalizedQuery) || - displayNames.some(name => name.includes(normalizedQuery))) { + // Substring match + if ( + normalizedName.includes(normalizedQuery) || + normalizedQuery.includes(normalizedName) || + displayNames.some(name => name.includes(normalizedQuery) || normalizedQuery.includes(name)) + ) { return 1; } - return 2; + // Multi-word name match + const queryTokens = normalizedQuery.split(' ').filter(token => token.length > 2); + const hasTokenMatch = queryTokens.some(token => + normalizedName === token || + displayNames.some(name => name === token)); + + if (hasTokenMatch) { + return 2; + } + + // Everything else + return 3; }; /**