Skip to content

Commit be6de6e

Browse files
committed
feat(tools-user): user-facing helpers for tools-as-plugins
* build, meta.import test package, lint rule to avoid incorrect use of memo keyHash * options.defaults, tool timeouts, permissions base * server.caching, typing updates to avoid incorrect use of args on keyHash * server.helpers, function, object helper * server.tools, inline vs external tool setup, proxy for running external tools * server.toolsHost, copy update * server.toolsHostCreator, apply strict static properties, toolName * server.toolsUser, types, tool creation, normalization for both user and internal use * server, adjustments to help with user facing types, copy updates * tool, align and add static toolName property
1 parent be4f884 commit be6de6e

22 files changed

+4384
-22
lines changed

eslint.config.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,25 @@ export default [
8181
}],
8282
'n/no-process-exit': 0,
8383
// Disallow console.log/info in runtime to protect STDIO; allow warn/error
84-
'no-console': ['error', { allow: ['warn', 'error'] }]
84+
'no-console': ['error', { allow: ['warn', 'error'] }],
85+
// Custom syntax rules
86+
'no-restricted-syntax': [
87+
'error',
88+
{
89+
// Disallow rest parameters in a property named `keyHash`
90+
selector:
91+
"Property[key.name='keyHash'] > :matches(FunctionExpression, ArrowFunctionExpression) > RestElement",
92+
message:
93+
'keyHash must accept a single array parameter (args). Do not use rest params (...args).'
94+
},
95+
{
96+
// Also catch when `keyHash` lives in a CallExpression options object (e.g., memo(fn, { keyHash() {} }))
97+
selector:
98+
"CallExpression > ObjectExpression > Property[key.name='keyHash'] > :matches(FunctionExpression, ArrowFunctionExpression) > RestElement",
99+
message:
100+
'keyHash must accept a single array parameter (args). Do not use rest params (...args).'
101+
}
102+
]
85103
}
86104
},
87105
{

jest.config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,25 @@ export default {
2525
roots: ['src'],
2626
testMatch: ['<rootDir>/src/**/*.test.ts'],
2727
setupFilesAfterEnv: ['<rootDir>/jest.setupTests.ts'],
28-
...baseConfig
28+
...baseConfig,
29+
transform: {
30+
'^.+\\.(ts|tsx)$': [
31+
'ts-jest',
32+
{
33+
...tsConfig,
34+
diagnostics: {
35+
ignoreCodes: [1343]
36+
},
37+
astTransformers: {
38+
before: [
39+
{
40+
path: 'ts-jest-mock-import-meta'
41+
}
42+
]
43+
}
44+
}
45+
]
46+
}
2947
},
3048
{
3149
displayName: 'e2e',

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@
44
"description": "PatternFly documentation MCP server built with Node.js and TypeScript",
55
"main": "dist/index.js",
66
"type": "module",
7+
"imports": {
8+
"#toolsHost": "./dist/server.toolsHost.js"
9+
},
710
"exports": {
8-
".": "./dist/index.js"
11+
".": {
12+
"types": "./dist/index.d.ts",
13+
"default": "./dist/index.js"
14+
}
915
},
1016
"bin": {
1117
"patternfly-mcp": "dist/cli.js",
@@ -64,6 +70,7 @@
6470
"jest": "^30.2.0",
6571
"pkgroll": "^2.20.1",
6672
"ts-jest": "29.4.4",
73+
"ts-jest-mock-import-meta": "^1.3.1",
6774
"ts-node": "^10.1.0",
6875
"tsx": "^4.21.0",
6976
"typescript": "^5.9.3",

src/__tests__/__snapshots__/options.defaults.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ exports[`options defaults should return specific properties: defaults 1`] = `
3737
"invokeTimeoutMs": 10000,
3838
"loadTimeoutMs": 5000,
3939
},
40+
"pluginIsolation": "none",
4041
"repoName": "patternfly-mcp",
4142
"resourceMemoOptions": {
4243
"default": {
@@ -70,6 +71,7 @@ exports[`options defaults should return specific properties: defaults 1`] = `
7071
"expire": 60000,
7172
},
7273
},
74+
"toolModules": [],
7375
"urlRegex": /\\^\\(https\\?:\\)\\\\/\\\\//i,
7476
"version": "0.0.0",
7577
}

src/__tests__/__snapshots__/server.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ exports[`runServer should attempt to run server, register a tool: diagnostics 1`
168168
"test-server-5 server running on stdio transport",
169169
],
170170
[
171-
"Tool "loremIpsum" has a nonZod inputSchema. This may cause unexpected issues.",
171+
"Tool "loremIpsum" has a non Zod inputSchema. This may cause unexpected issues.",
172172
],
173173
],
174174
"hasDebugLogs": true,
@@ -213,10 +213,10 @@ exports[`runServer should attempt to run server, register multiple tools: diagno
213213
"test-server-6 server running on stdio transport",
214214
],
215215
[
216-
"Tool "loremIpsum" has a nonZod inputSchema. This may cause unexpected issues.",
216+
"Tool "loremIpsum" has a non Zod inputSchema. This may cause unexpected issues.",
217217
],
218218
[
219-
"Tool "dolorSit" has a nonZod inputSchema. This may cause unexpected issues.",
219+
"Tool "dolorSit" has a non Zod inputSchema. This may cause unexpected issues.",
220220
],
221221
],
222222
"hasDebugLogs": true,

0 commit comments

Comments
 (0)