Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/__tests__/__snapshots__/server.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down Expand Up @@ -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",
],
Expand Down
2 changes: 1 addition & 1 deletion src/docs.filterWords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion src/options.registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -44,7 +45,8 @@ const builtinResources: McpResourceCreator[] = [
*/
const builtinCollections: McpCollectionCreator[] = [
patternFlyDocsCollection,
patternFlySchemasCollection
patternFlySchemasCollection,
patternFlyApiCollection
];

export { builtinCollections, builtinResources, builtinTools };
4 changes: 3 additions & 1 deletion src/patternFly.getResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, unknown[]>)) || [],
...Array.from(componentNamesByDocs)
...Array.from(componentNamesByDocs),
...apiCollection?.records?.flatMap(({ data }) => Object.entries(data as Record<string, unknown[]>)) || []
];

const resources = new Map<string, PatternFlyMcpResourceMetadata>();
Expand Down
23 changes: 20 additions & 3 deletions src/patternFly.search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const calculateRelevance = (
const normalizedName = normalizeString.memo(result.name);
const normalizedQuery = normalizeString.memo(query);

// Exact match
if (normalizedName === normalizedQuery) {
return 0;
}
Expand All @@ -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;
};

/**
Expand Down
31 changes: 25 additions & 6 deletions tests/e2e/__snapshots__/httpTransport.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Use these parameters to filter the list of PatternFly components.

| Parameter | Valid Values | Description |
| :--- | :--- | :--- |
| \`category\` | \`accessibility\`, \`design-guidelines\`, \`react\` | Filter by category |
| \`category\` | \`accessibility\`, \`css\`, \`design-guidelines\`, \`html\`, \`react\`, \`text\` | Filter by category |
| \`version\` | \`v5\`, \`v6\` | Filter by version |

## Available Patterns
Expand All @@ -31,8 +31,8 @@ Use these parameters to filter the PatternFly documentation index.

| Parameter | Valid Values | Description |
| :--- | :--- | :--- |
| \`category\` | \`accessibility\`, \`design-guidelines\`, \`design-tokens\`, \`development-guidelines\`, \`grammar\`, \`react\`, \`writing-guides\` | Filter by category |
| \`section\` | \`ai\`, \`charts\`, \`components\`, \`content-design\`, \`extensions\`, \`foundations-and-styles\`, \`get-started\`, \`guidelines\`, \`layouts\`, \`patterns\`, \`resources\`, \`upgrade\` | Filter by section |
| \`category\` | \`about\`, \`about-rapid-prototyping\`, \`accessibility\`, \`analytics\`, \`chat-bot\`, \`css\`, \`customizing%20messages\`, \`demo\`, \`demo-demos\`, \`design-guidelines\`, \`design-tokens\`, \`development-guide\`, \`development-guidelines\`, \`enhancing-existing-projects\`, \`general\`, \`grammar\`, \`html\`, \`new-prototypes\`, \`overview\`, \`react\`, \`release-notes\`, \`text\`, \`upgrade-guide\`, \`writing-guidelines\`, \`writing-guides\` | Filter by category |
| \`section\` | \`accessibility\`, \`ai\`, \`charts\`, \`components\`, \`content-design\`, \`developer-guides\`, \`extensions\`, \`foundations-and-styles\`, \`get-help\`, \`get-involved\`, \`get-started\`, \`guidelines\`, \`layouts\`, \`patterns\`, \`releases\`, \`resources\`, \`upgrade\` | Filter by section |
| \`version\` | \`v4\`, \`v5\`, \`v6\` | Filter by version |

## Available Patterns
Expand All @@ -58,7 +58,7 @@ Use these parameters to filter the list of PatternFly component schemas.

| Parameter | Valid Values | Description |
| :--- | :--- | :--- |
| \`category\` | \`accessibility\`, \`design-guidelines\`, \`react\` | Filter by category |
| \`category\` | \`accessibility\`, \`css\`, \`design-guidelines\`, \`html\`, \`react\`, \`text\` | Filter by category |
| \`version\` | \`v5\`, \`v6\` | Filter by version |

## Available Patterns
Expand Down Expand Up @@ -107,19 +107,38 @@ exports[`Builtin tools, HTTP transport should initialize MCP session over HTTP 1
`;

exports[`Builtin tools, HTTP transport should return expected markdown structure for search results: markdown 1`] = `
"# Search results for PatternFly version "v6" and "button". Showing 2 exact matches.
"# Search results for PatternFly version "v6" and "button". Showing 3 exact matches.
1. **button**:
"usePatternFlyDocs" resource parameter "name" and "URLs"
- **Name**: button
- **URLs**:
- [Button - (v6) - Design Guidelines for the button component.](https://raw.githubusercontent.com/patternfly/patternfly-org/957756128e8ddfc4be5db49e72312a2c43b9d220/packages/documentation-site/patternfly-docs/content/components/button/button.md)
- [Button - (v6) - Accessibility for the button component.](https://raw.githubusercontent.com/patternfly/patternfly-org/957756128e8ddfc4be5db49e72312a2c43b9d220/packages/documentation-site/patternfly-docs/content/components/accessibility/button/button.md)
- [Button - (v6) - Examples for the button component.](https://raw.githubusercontent.com/patternfly/patternfly-react/6f2385bbcc03de22a7ae8be506481e1b4d653200/packages/react-core/src/components/Button/examples/Button.md)
- [Button CSS - (v6) - PatternFly variables and tokens for Button CSS.](https://main.patternfly-org.pages.dev/api/v6/components/button/css)
- [Button - (v6) - A favorite button should use a plain button with the star icon. Applying .pf-m-favorited to the button initiates a microanimation and indicates that the item is favorited.](https://main.patternfly-org.pages.dev/api/v6/components/button/html)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonBlock)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonCallToAction)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonDisabled)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonInlineSpanLink)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonLinks)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonProgress)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonSmall)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonVariations)
- [Button - (v6) - There are certain cases where specific buttons must be used within your UI.](https://main.patternfly-org.pages.dev/api/v6/components/button/text)
- **Resources**:
- **URI**: patternfly://docs/button?version=v6
- **JSON Schemas**: patternfly://schemas/button?version=v6

2. **patterns**:
2. **extensionscomponentgroupsclosebutton**:
"usePatternFlyDocs" resource parameter "name" and "URLs"
- **Name**: extensionscomponentgroupsclosebutton
- **URLs**:
- [Component Groups Close Button - (v6) - The close button component provides a way for users to exit a modal, dialogue, or similar action. To further customize this component, you can also utilize all properties of the button component.](https://main.patternfly-org.pages.dev/api/v6/extensions/component-groups_close-button/react)
- **Resources**:
- **URI**: patternfly://docs/extensionscomponentgroupsclosebutton?version=v6

3. **patterns**:
"usePatternFlyDocs" resource parameter "name" and "URLs"
- **Name**: patterns
- **URLs**:
Expand Down
35 changes: 29 additions & 6 deletions tests/e2e/__snapshots__/stdioTransport.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Use these parameters to filter the list of PatternFly components.

| Parameter | Valid Values | Description |
| :--- | :--- | :--- |
| \`category\` | \`accessibility\`, \`design-guidelines\`, \`react\` | Filter by category |
| \`category\` | \`accessibility\`, \`css\`, \`design-guidelines\`, \`html\`, \`react\`, \`text\` | Filter by category |
| \`version\` | \`v5\`, \`v6\` | Filter by version |

## Available Patterns
Expand All @@ -31,8 +31,8 @@ Use these parameters to filter the PatternFly documentation index.

| Parameter | Valid Values | Description |
| :--- | :--- | :--- |
| \`category\` | \`accessibility\`, \`design-guidelines\`, \`design-tokens\`, \`development-guidelines\`, \`grammar\`, \`react\`, \`writing-guides\` | Filter by category |
| \`section\` | \`ai\`, \`charts\`, \`components\`, \`content-design\`, \`extensions\`, \`foundations-and-styles\`, \`get-started\`, \`guidelines\`, \`layouts\`, \`patterns\`, \`resources\`, \`upgrade\` | Filter by section |
| \`category\` | \`about\`, \`about-rapid-prototyping\`, \`accessibility\`, \`analytics\`, \`chat-bot\`, \`css\`, \`customizing%20messages\`, \`demo\`, \`demo-demos\`, \`design-guidelines\`, \`design-tokens\`, \`development-guide\`, \`development-guidelines\`, \`enhancing-existing-projects\`, \`general\`, \`grammar\`, \`html\`, \`new-prototypes\`, \`overview\`, \`react\`, \`release-notes\`, \`text\`, \`upgrade-guide\`, \`writing-guidelines\`, \`writing-guides\` | Filter by category |
| \`section\` | \`accessibility\`, \`ai\`, \`charts\`, \`components\`, \`content-design\`, \`developer-guides\`, \`extensions\`, \`foundations-and-styles\`, \`get-help\`, \`get-involved\`, \`get-started\`, \`guidelines\`, \`layouts\`, \`patterns\`, \`releases\`, \`resources\`, \`upgrade\` | Filter by section |
| \`version\` | \`v4\`, \`v5\`, \`v6\` | Filter by version |

## Available Patterns
Expand All @@ -58,7 +58,7 @@ Use these parameters to filter the list of PatternFly component schemas.

| Parameter | Valid Values | Description |
| :--- | :--- | :--- |
| \`category\` | \`accessibility\`, \`design-guidelines\`, \`react\` | Filter by category |
| \`category\` | \`accessibility\`, \`css\`, \`design-guidelines\`, \`html\`, \`react\`, \`text\` | Filter by category |
| \`version\` | \`v5\`, \`v6\` | Filter by version |

## Available Patterns
Expand Down Expand Up @@ -107,19 +107,38 @@ exports[`Builtin tools, STDIO should expose expected tools and stable shape 1`]
`;

exports[`Builtin tools, STDIO should return expected markdown structure for search results: markdown 1`] = `
"# Search results for PatternFly version "v6" and "button". Showing 2 exact matches.
"# Search results for PatternFly version "v6" and "button". Showing 3 exact matches.
1. **button**:
"usePatternFlyDocs" resource parameter "name" and "URLs"
- **Name**: button
- **URLs**:
- [Button - (v6) - Design Guidelines for the button component.](https://raw.githubusercontent.com/patternfly/patternfly-org/957756128e8ddfc4be5db49e72312a2c43b9d220/packages/documentation-site/patternfly-docs/content/components/button/button.md)
- [Button - (v6) - Accessibility for the button component.](https://raw.githubusercontent.com/patternfly/patternfly-org/957756128e8ddfc4be5db49e72312a2c43b9d220/packages/documentation-site/patternfly-docs/content/components/accessibility/button/button.md)
- [Button - (v6) - Examples for the button component.](https://raw.githubusercontent.com/patternfly/patternfly-react/6f2385bbcc03de22a7ae8be506481e1b4d653200/packages/react-core/src/components/Button/examples/Button.md)
- [Button CSS - (v6) - PatternFly variables and tokens for Button CSS.](https://main.patternfly-org.pages.dev/api/v6/components/button/css)
- [Button - (v6) - A favorite button should use a plain button with the star icon. Applying .pf-m-favorited to the button initiates a microanimation and indicates that the item is favorited.](https://main.patternfly-org.pages.dev/api/v6/components/button/html)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonBlock)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonCallToAction)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonDisabled)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonInlineSpanLink)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonLinks)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonProgress)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonSmall)
- [Button - (v6) - PatternFly examples and demos for Button.](https://main.patternfly-org.pages.dev/api/v6/components/button/react/examples/ButtonVariations)
- [Button - (v6) - There are certain cases where specific buttons must be used within your UI.](https://main.patternfly-org.pages.dev/api/v6/components/button/text)
- **Resources**:
- **URI**: patternfly://docs/button?version=v6
- **JSON Schemas**: patternfly://schemas/button?version=v6

2. **patterns**:
2. **extensionscomponentgroupsclosebutton**:
"usePatternFlyDocs" resource parameter "name" and "URLs"
- **Name**: extensionscomponentgroupsclosebutton
- **URLs**:
- [Component Groups Close Button - (v6) - The close button component provides a way for users to exit a modal, dialogue, or similar action. To further customize this component, you can also utilize all properties of the button component.](https://main.patternfly-org.pages.dev/api/v6/extensions/component-groups_close-button/react)
- **Resources**:
- **URI**: patternfly://docs/extensionscomponentgroupsclosebutton?version=v6

3. **patterns**:
"usePatternFlyDocs" resource parameter "name" and "URLs"
- **Name**: patterns
- **URLs**:
Expand Down Expand Up @@ -159,6 +178,10 @@ 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-api
",
"[INFO]: Update collection: patternfly-component-schemas
",
Expand Down
Loading