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
465 changes: 170 additions & 295 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/options.defaults.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ exports[`options defaults should return specific properties: defaults 1`] = `
"invokeTimeoutMs": 10000,
"loadTimeoutMs": 5000,
},
"pluginIsolation": "none",
"pluginIsolation": "strict",
"repoName": "patternfly-mcp",
"resourceMemoOptions": {
"default": {
Expand Down
26 changes: 26 additions & 0 deletions src/__tests__/__snapshots__/options.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ exports[`parseCliOptions should attempt to parse args with --allowed-hosts 1`] =
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -37,6 +39,8 @@ exports[`parseCliOptions should attempt to parse args with --allowed-origins 1`]
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -52,6 +56,8 @@ exports[`parseCliOptions should attempt to parse args with --docs-host flag 1`]
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -69,6 +75,8 @@ exports[`parseCliOptions should attempt to parse args with --http and --host 1`]
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -86,6 +94,8 @@ exports[`parseCliOptions should attempt to parse args with --http and --port 1`]
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -101,6 +111,8 @@ exports[`parseCliOptions should attempt to parse args with --http and invalid --
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -116,6 +128,8 @@ exports[`parseCliOptions should attempt to parse args with --http flag 1`] = `
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -131,6 +145,8 @@ exports[`parseCliOptions should attempt to parse args with --log-level flag 1`]
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -146,6 +162,8 @@ exports[`parseCliOptions should attempt to parse args with --log-stderr flag and
"stderr": true,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -161,6 +179,8 @@ exports[`parseCliOptions should attempt to parse args with --verbose flag 1`] =
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -176,6 +196,8 @@ exports[`parseCliOptions should attempt to parse args with --verbose flag and --
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -191,6 +213,8 @@ exports[`parseCliOptions should attempt to parse args with other arguments 1`] =
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;

Expand All @@ -206,5 +230,7 @@ exports[`parseCliOptions should attempt to parse args without --docs-host flag 1
"stderr": false,
"transport": "stdio",
},
"pluginIsolation": undefined,
"toolModules": [],
}
`;
39 changes: 39 additions & 0 deletions src/__tests__/__snapshots__/server.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ exports[`runServer should allow server to be stopped, http stop server: diagnost
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"Registered tool: usePatternFlyDocs",
],
Expand Down Expand Up @@ -35,6 +38,9 @@ exports[`runServer should allow server to be stopped, stdio stop server: diagnos
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"Registered tool: usePatternFlyDocs",
],
Expand Down Expand Up @@ -64,6 +70,9 @@ exports[`runServer should attempt to run server, create transport, connect, and
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"test-server-4 server running on stdio transport",
],
Expand Down Expand Up @@ -98,6 +107,9 @@ exports[`runServer should attempt to run server, disable SIGINT handler: diagnos
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"test-server-7 server running on stdio transport",
],
Expand Down Expand Up @@ -127,6 +139,9 @@ exports[`runServer should attempt to run server, enable SIGINT handler explicitl
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"test-server-8 server running on stdio transport",
],
Expand Down Expand Up @@ -161,12 +176,18 @@ exports[`runServer should attempt to run server, register a tool: diagnostics 1`
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"Registered tool: loremIpsum",
],
[
"test-server-5 server running on stdio transport",
],
[
"Built-in tool at index 0 is missing the static name property, "toolName"",
],
[
"Tool "loremIpsum" has a non Zod inputSchema. This may cause unexpected issues.",
],
Expand Down Expand Up @@ -203,6 +224,9 @@ exports[`runServer should attempt to run server, register multiple tools: diagno
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"Registered tool: loremIpsum",
],
Expand All @@ -212,6 +236,12 @@ exports[`runServer should attempt to run server, register multiple tools: diagno
[
"test-server-6 server running on stdio transport",
],
[
"Built-in tool at index 0 is missing the static name property, "toolName"",
],
[
"Built-in tool at index 1 is missing the static name property, "toolName"",
],
[
"Tool "loremIpsum" has a non Zod inputSchema. This may cause unexpected issues.",
],
Expand Down Expand Up @@ -252,6 +282,9 @@ exports[`runServer should attempt to run server, use custom options: diagnostics
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"test-server-3 server running on stdio transport",
],
Expand Down Expand Up @@ -286,6 +319,9 @@ exports[`runServer should attempt to run server, use default tools, http: diagno
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"Registered tool: usePatternFlyDocs",
],
Expand Down Expand Up @@ -333,6 +369,9 @@ exports[`runServer should attempt to run server, use default tools, stdio: diagn
[
"Server logging enabled.",
],
[
"No external tools loaded.",
],
[
"Registered tool: usePatternFlyDocs",
],
Expand Down
30 changes: 28 additions & 2 deletions src/__tests__/__snapshots__/server.tools.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ exports[`composeTools should attempt to setup creators, file package creators 1`
exports[`composeTools should attempt to setup creators, file package creators, Node.js 20 1`] = `
{
"log": [
[
"Existing Tools Host session detected test-session-id. Shutting down the existing host before creating a new one.",
],
[
"External tool plugins require Node >= 22; skipping file-based tools.",
],
Expand All @@ -27,14 +30,21 @@ exports[`composeTools should attempt to setup creators, file package creators, N

exports[`composeTools should attempt to setup creators, file package creators, Node.js 24 1`] = `
{
"log": [],
"log": [
[
"Existing Tools Host session detected test-session-id. Shutting down the existing host before creating a new one.",
],
],
"toolsCount": 5,
}
`;

exports[`composeTools should attempt to setup creators, file package creators, Node.js undefined 1`] = `
{
"log": [
[
"Existing Tools Host session detected test-session-id. Shutting down the existing host before creating a new one.",
],
[
"External tool plugins require Node >= 22; skipping file-based tools.",
],
Expand All @@ -46,6 +56,9 @@ exports[`composeTools should attempt to setup creators, file package creators, N
exports[`composeTools should attempt to setup creators, file package duplicate creators 1`] = `
{
"log": [
[
"Existing Tools Host session detected test-session-id. Shutting down the existing host before creating a new one.",
],
[
"Skipping tool plugin "@patternfly/tools" – name already used by built-in/inline tool.",
],
Expand All @@ -56,14 +69,21 @@ exports[`composeTools should attempt to setup creators, file package duplicate c

exports[`composeTools should attempt to setup creators, inline and file package creators 1`] = `
{
"log": [],
"log": [
[
"Existing Tools Host session detected test-session-id. Shutting down the existing host before creating a new one.",
],
],
"toolsCount": 7,
}
`;

exports[`composeTools should attempt to setup creators, inline and file package creators duplicate builtin creators 1`] = `
{
"log": [
[
"Existing Tools Host session detected test-session-id. Shutting down the existing host before creating a new one.",
],
[
"Skipping inline tool "loremipsum" because a tool with the same name is already provided (built-in or earlier).",
],
Expand All @@ -78,6 +98,9 @@ exports[`composeTools should attempt to setup creators, inline and file package
exports[`composeTools should attempt to setup creators, inline and file package creators, duplicates 1`] = `
{
"log": [
[
"Existing Tools Host session detected test-session-id. Shutting down the existing host before creating a new one.",
],
[
"Skipping tool plugin "@patternfly/tools" – name already used by built-in/inline tool.",
],
Expand All @@ -92,6 +115,9 @@ exports[`composeTools should attempt to setup creators, inline and file package
exports[`composeTools should attempt to setup creators, inline and file package creators, duplicates, Node.js 20 1`] = `
{
"log": [
[
"Existing Tools Host session detected test-session-id. Shutting down the existing host before creating a new one.",
],
[
"External tool plugins require Node >= 22; skipping file-based tools.",
],
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { runServer } from '../server';
jest.mock('../options');
jest.mock('../options.context');
jest.mock('../server');
jest.mock('../server.tools');

const mockParseCliOptions = parseCliOptions as jest.MockedFunction<typeof parseCliOptions>;
const mockSetOptions = setOptions as jest.MockedFunction<typeof setOptions>;
Expand Down
19 changes: 14 additions & 5 deletions src/__tests__/options.context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,33 @@ const MockStdioServerTransport = StdioServerTransport as jest.MockedClass<typeof

describe('setOptions', () => {
it('should ignore valid but incorrect options for merged options', () => {
const updatedOptions = setOptions({ logging: 'oops' as any, resourceMemoOptions: 'gotcha' as any, toolMemoOptions: 'really?' as any });
const updatedOptions = setOptions({
logging: 'oops' as any,
resourceMemoOptions: 'gotcha' as any,
toolMemoOptions: 'really?' as any,
pluginIsolation: 'fun' as any
});

expect(updatedOptions.logging.protocol).toBe(DEFAULT_OPTIONS.logging.protocol);
expect(updatedOptions.resourceMemoOptions?.readFile?.expire).toBe(DEFAULT_OPTIONS.resourceMemoOptions?.readFile?.expire);
expect(updatedOptions.toolMemoOptions?.fetchDocs?.expire).toBe(DEFAULT_OPTIONS.toolMemoOptions?.fetchDocs?.expire);
expect(updatedOptions.pluginIsolation).toBe(DEFAULT_OPTIONS.pluginIsolation);
});

it('should ignore null/invalid nested overrides safely', () => {
const updatedOptions = setOptions({ logging: null as any, resourceMemoOptions: null as any });
const updatedOptions = setOptions({ logging: null as any, resourceMemoOptions: null as any, pluginIsolation: null as any });

expect(typeof updatedOptions.logging.protocol === 'boolean').toBe(true);
expect(typeof updatedOptions.logging.protocol).toBe('boolean');
expect(updatedOptions.logging.protocol).toBe(DEFAULT_OPTIONS.logging.protocol);

expect(typeof updatedOptions.resourceMemoOptions?.readFile?.expire === 'number').toBe(true);
expect(typeof updatedOptions.resourceMemoOptions?.readFile?.expire).toBe('number');
expect(updatedOptions.resourceMemoOptions?.readFile?.expire).toBe(DEFAULT_OPTIONS.resourceMemoOptions?.readFile?.expire);

expect(typeof updatedOptions.toolMemoOptions?.fetchDocs?.expire === 'number').toBe(true);
expect(typeof updatedOptions.toolMemoOptions?.fetchDocs?.expire).toBe('number');
expect(updatedOptions.toolMemoOptions?.fetchDocs?.expire).toBe(DEFAULT_OPTIONS.toolMemoOptions?.fetchDocs?.expire);

expect(typeof updatedOptions.pluginIsolation).toBe('string');
expect(updatedOptions.pluginIsolation).toBe(DEFAULT_OPTIONS.pluginIsolation);
});
});

Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/server.toolsUser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
sanitizeStaticToolName,
type Tool,
type ToolCreator,
type MultiToolConfig,
type ToolMultiConfig,
type ToolConfig
} from '../server.toolsUser';
import { isZodSchema } from '../server.schema';
Expand Down Expand Up @@ -710,7 +710,7 @@ describe('createMcpTool', () => {
createMcpTool(['dolorSit', { description: 'dolor sit', inputSchema: { type: 'object', properties: {} } }, () => {}]),
createMcpTool('@scope/pkg4'),
'@scope/pkg5'
] as MultiToolConfig
] as ToolMultiConfig
}
])('should normalize configs, $description', ({ config }) => {
const result = createMcpTool(config);
Expand Down
Loading
Loading