Skip to content

Commit d7df9c2

Browse files
authored
feat(server): expose instructions (#128)
* options, add instructions, sort, export missing typings * server, expose instructions
1 parent dd4b2b5 commit d7df9c2

5 files changed

Lines changed: 51 additions & 4 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ exports[`options defaults should return specific properties: defaults 1`] = `
111111
---
112112
113113
",
114+
"serverInstanceOptions": {
115+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
116+
},
114117
"stats": {
115118
"reportIntervalMs": {
116119
"health": 30000,

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ exports[`runServer should attempt to run server, create transport, connect, and
161161
"resources": {},
162162
"tools": {},
163163
},
164+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
164165
},
165166
],
166167
],
@@ -223,6 +224,7 @@ exports[`runServer should attempt to run server, disable SIGINT handler: diagnos
223224
"resources": {},
224225
"tools": {},
225226
},
227+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
226228
},
227229
],
228230
],
@@ -280,6 +282,7 @@ exports[`runServer should attempt to run server, enable SIGINT handler explicitl
280282
"resources": {},
281283
"tools": {},
282284
},
285+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
283286
},
284287
],
285288
],
@@ -351,6 +354,7 @@ exports[`runServer should attempt to run server, register a tool: diagnostics 1`
351354
"resources": {},
352355
"tools": {},
353356
},
357+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
354358
},
355359
],
356360
],
@@ -433,6 +437,7 @@ exports[`runServer should attempt to run server, register multiple tools: diagno
433437
"resources": {},
434438
"tools": {},
435439
},
440+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
436441
},
437442
],
438443
],
@@ -498,6 +503,7 @@ exports[`runServer should attempt to run server, use custom options: diagnostics
498503
"resources": {},
499504
"tools": {},
500505
},
506+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
501507
},
502508
],
503509
],
@@ -569,6 +575,7 @@ exports[`runServer should attempt to run server, use default tools, http: diagno
569575
"resources": {},
570576
"tools": {},
571577
},
578+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
572579
},
573580
],
574581
],
@@ -644,6 +651,7 @@ exports[`runServer should attempt to run server, use default tools, stdio: diagn
644651
"resources": {},
645652
"tools": {},
646653
},
654+
"instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.",
647655
},
648656
],
649657
],

src/__tests__/server.test.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,12 @@ describe('runServer', () => {
150150
};
151151

152152
const serverInstance = await runServer(
153-
{ minMax: DEFAULT_OPTIONS.minMax, patternflyOptions: DEFAULT_OPTIONS.patternflyOptions, ...options } as any,
153+
{
154+
minMax: DEFAULT_OPTIONS.minMax,
155+
patternflyOptions: DEFAULT_OPTIONS.patternflyOptions,
156+
serverInstanceOptions: DEFAULT_OPTIONS.serverInstanceOptions,
157+
...options
158+
} as any,
154159
Object.keys(settings).length > 0 ? settings : { allowProcessExit: false }
155160
);
156161

@@ -179,7 +184,13 @@ describe('runServer', () => {
179184
}
180185
])('should allow server to be stopped, $description', async ({ options }) => {
181186
const serverInstance = await runServer(
182-
{ minMax: DEFAULT_OPTIONS.minMax, patternflyOptions: DEFAULT_OPTIONS.patternflyOptions, ...options, name: 'test-server' } as any,
187+
{
188+
minMax: DEFAULT_OPTIONS.minMax,
189+
patternflyOptions: DEFAULT_OPTIONS.patternflyOptions,
190+
// Check serverInstanceOptions behavior, don't include it
191+
...options,
192+
name: 'test-server'
193+
} as any,
183194
{ allowProcessExit: false }
184195
);
185196

src/options.defaults.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { type ToolModule } from './server.toolsUser';
3333
* @property resourceModules - Array for programmatic registration of resource provider modules, similar to `toolModules` but
3434
* for MCP resources and currently only internal.
3535
* @property separator - Default string delimiter.
36+
* @property serverInstanceOptions - Server-instance options.
3637
* @property {StatsOptions} stats - Stats options.
3738
* @property {typeof TOOL_MEMO_OPTIONS} toolMemoOptions - Tool-specific memoization options.
3839
* @property {ToolModule|ToolModule[]} toolModules - Array of external tool modules (ESM specs or paths) to be loaded and
@@ -62,6 +63,7 @@ interface DefaultOptions<TLogOptions = LoggingOptions> {
6263
resourceMemoOptions: Partial<typeof RESOURCE_MEMO_OPTIONS>;
6364
resourceModules: unknown | unknown[];
6465
separator: string;
66+
serverInstanceOptions: ServerInstanceOptions;
6567
stats: StatsOptions;
6668
toolMemoOptions: Partial<typeof TOOL_MEMO_OPTIONS>;
6769
toolModules: ToolModule | ToolModule[];
@@ -244,6 +246,16 @@ interface LoggingSession extends LoggingOptions {
244246
readonly channelName: string;
245247
}
246248

249+
/**
250+
* MCP Server instance options.
251+
*
252+
* @interface ServerInstanceOptions
253+
* @property instructions Instructions for the MCP server instance.
254+
*/
255+
interface ServerInstanceOptions {
256+
instructions: string;
257+
}
258+
247259
/**
248260
* Base stats options.
249261
*/
@@ -397,6 +409,13 @@ const TOOL_MEMO_OPTIONS = {
397409
}
398410
};
399411

412+
/**
413+
* Default server instance options.
414+
*/
415+
const SERVER_INSTANCE_OPTIONS: ServerInstanceOptions = {
416+
instructions: 'Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.'
417+
};
418+
400419
/**
401420
* Default stats options.
402421
*/
@@ -498,6 +517,7 @@ const DEFAULT_OPTIONS: DefaultOptions = {
498517
repoName: basename(process.cwd() || '').trim(),
499518
repoResources: REPO_RESOURCES,
500519
resourceMemoOptions: RESOURCE_MEMO_OPTIONS,
520+
serverInstanceOptions: SERVER_INSTANCE_OPTIONS,
501521
stats: STATS_OPTIONS,
502522
resourceModules: [],
503523
toolMemoOptions: TOOL_MEMO_OPTIONS,
@@ -509,18 +529,21 @@ const DEFAULT_OPTIONS: DefaultOptions = {
509529
};
510530

511531
export {
512-
LOG_BASENAME,
513532
DEFAULT_OPTIONS,
533+
LOG_BASENAME,
514534
MODE_LEVELS,
515535
getNodeMajorVersion,
516536
type DefaultOptions,
517537
type DefaultOptionsOverrides,
518538
type HttpOptions,
519539
type LoggingOptions,
520540
type LoggingSession,
541+
type MinMax,
521542
type ModeOptions,
522543
type PatternFlyOptions,
523544
type PluginHostOptions,
545+
type RepoResources,
546+
type ServerInstanceOptions,
524547
type StatsSession,
525548
type WhitelistUrl,
526549
type XhrFetchOptions

src/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ const runServer = async (options: ServerOptions = getOptions(), {
233233

234234
try {
235235
const enableProtocolLogging = options?.logging?.protocol;
236+
const serverInstructions = options?.serverInstanceOptions?.instructions;
236237

237238
server = new McpServer(
238239
{
@@ -244,7 +245,8 @@ const runServer = async (options: ServerOptions = getOptions(), {
244245
tools: {},
245246
resources: {},
246247
...(enableProtocolLogging ? { logging: {} } : {})
247-
}
248+
},
249+
...(serverInstructions ? { instructions: serverInstructions } : {})
248250
}
249251
);
250252

0 commit comments

Comments
 (0)