diff --git a/src/__tests__/__snapshots__/options.defaults.test.ts.snap b/src/__tests__/__snapshots__/options.defaults.test.ts.snap index 542271bd..606d4cf5 100644 --- a/src/__tests__/__snapshots__/options.defaults.test.ts.snap +++ b/src/__tests__/__snapshots__/options.defaults.test.ts.snap @@ -111,6 +111,9 @@ exports[`options defaults should return specific properties: defaults 1`] = ` --- ", + "serverInstanceOptions": { + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", + }, "stats": { "reportIntervalMs": { "health": 30000, diff --git a/src/__tests__/__snapshots__/server.test.ts.snap b/src/__tests__/__snapshots__/server.test.ts.snap index 4d3f1325..6ad3def8 100644 --- a/src/__tests__/__snapshots__/server.test.ts.snap +++ b/src/__tests__/__snapshots__/server.test.ts.snap @@ -161,6 +161,7 @@ exports[`runServer should attempt to run server, create transport, connect, and "resources": {}, "tools": {}, }, + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", }, ], ], @@ -223,6 +224,7 @@ exports[`runServer should attempt to run server, disable SIGINT handler: diagnos "resources": {}, "tools": {}, }, + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", }, ], ], @@ -280,6 +282,7 @@ exports[`runServer should attempt to run server, enable SIGINT handler explicitl "resources": {}, "tools": {}, }, + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", }, ], ], @@ -351,6 +354,7 @@ exports[`runServer should attempt to run server, register a tool: diagnostics 1` "resources": {}, "tools": {}, }, + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", }, ], ], @@ -433,6 +437,7 @@ exports[`runServer should attempt to run server, register multiple tools: diagno "resources": {}, "tools": {}, }, + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", }, ], ], @@ -498,6 +503,7 @@ exports[`runServer should attempt to run server, use custom options: diagnostics "resources": {}, "tools": {}, }, + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", }, ], ], @@ -569,6 +575,7 @@ exports[`runServer should attempt to run server, use default tools, http: diagno "resources": {}, "tools": {}, }, + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", }, ], ], @@ -644,6 +651,7 @@ exports[`runServer should attempt to run server, use default tools, stdio: diagn "resources": {}, "tools": {}, }, + "instructions": "Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.", }, ], ], diff --git a/src/__tests__/server.test.ts b/src/__tests__/server.test.ts index 3ba00c6b..96eab4be 100644 --- a/src/__tests__/server.test.ts +++ b/src/__tests__/server.test.ts @@ -150,7 +150,12 @@ describe('runServer', () => { }; const serverInstance = await runServer( - { minMax: DEFAULT_OPTIONS.minMax, patternflyOptions: DEFAULT_OPTIONS.patternflyOptions, ...options } as any, + { + minMax: DEFAULT_OPTIONS.minMax, + patternflyOptions: DEFAULT_OPTIONS.patternflyOptions, + serverInstanceOptions: DEFAULT_OPTIONS.serverInstanceOptions, + ...options + } as any, Object.keys(settings).length > 0 ? settings : { allowProcessExit: false } ); @@ -179,7 +184,13 @@ describe('runServer', () => { } ])('should allow server to be stopped, $description', async ({ options }) => { const serverInstance = await runServer( - { minMax: DEFAULT_OPTIONS.minMax, patternflyOptions: DEFAULT_OPTIONS.patternflyOptions, ...options, name: 'test-server' } as any, + { + minMax: DEFAULT_OPTIONS.minMax, + patternflyOptions: DEFAULT_OPTIONS.patternflyOptions, + // Check serverInstanceOptions behavior, don't include it + ...options, + name: 'test-server' + } as any, { allowProcessExit: false } ); diff --git a/src/options.defaults.ts b/src/options.defaults.ts index be052a44..66ac08f5 100644 --- a/src/options.defaults.ts +++ b/src/options.defaults.ts @@ -33,6 +33,7 @@ import { type ToolModule } from './server.toolsUser'; * @property resourceModules - Array for programmatic registration of resource provider modules, similar to `toolModules` but * for MCP resources and currently only internal. * @property separator - Default string delimiter. + * @property serverInstanceOptions - Server-instance options. * @property {StatsOptions} stats - Stats options. * @property {typeof TOOL_MEMO_OPTIONS} toolMemoOptions - Tool-specific memoization options. * @property {ToolModule|ToolModule[]} toolModules - Array of external tool modules (ESM specs or paths) to be loaded and @@ -62,6 +63,7 @@ interface DefaultOptions { resourceMemoOptions: Partial; resourceModules: unknown | unknown[]; separator: string; + serverInstanceOptions: ServerInstanceOptions; stats: StatsOptions; toolMemoOptions: Partial; toolModules: ToolModule | ToolModule[]; @@ -244,6 +246,16 @@ interface LoggingSession extends LoggingOptions { readonly channelName: string; } +/** + * MCP Server instance options. + * + * @interface ServerInstanceOptions + * @property instructions Instructions for the MCP server instance. + */ +interface ServerInstanceOptions { + instructions: string; +} + /** * Base stats options. */ @@ -397,6 +409,13 @@ const TOOL_MEMO_OPTIONS = { } }; +/** + * Default server instance options. + */ +const SERVER_INSTANCE_OPTIONS: ServerInstanceOptions = { + instructions: 'Use the PatternFly MCP when a user asks about: PatternFly, pf, pf docs, design tokens, design guidelines, accessibility, PatternFly components, and frontend development.' +}; + /** * Default stats options. */ @@ -498,6 +517,7 @@ const DEFAULT_OPTIONS: DefaultOptions = { repoName: basename(process.cwd() || '').trim(), repoResources: REPO_RESOURCES, resourceMemoOptions: RESOURCE_MEMO_OPTIONS, + serverInstanceOptions: SERVER_INSTANCE_OPTIONS, stats: STATS_OPTIONS, resourceModules: [], toolMemoOptions: TOOL_MEMO_OPTIONS, @@ -509,8 +529,8 @@ const DEFAULT_OPTIONS: DefaultOptions = { }; export { - LOG_BASENAME, DEFAULT_OPTIONS, + LOG_BASENAME, MODE_LEVELS, getNodeMajorVersion, type DefaultOptions, @@ -518,9 +538,12 @@ export { type HttpOptions, type LoggingOptions, type LoggingSession, + type MinMax, type ModeOptions, type PatternFlyOptions, type PluginHostOptions, + type RepoResources, + type ServerInstanceOptions, type StatsSession, type WhitelistUrl, type XhrFetchOptions diff --git a/src/server.ts b/src/server.ts index 10b59cf6..80034a0f 100644 --- a/src/server.ts +++ b/src/server.ts @@ -233,6 +233,7 @@ const runServer = async (options: ServerOptions = getOptions(), { try { const enableProtocolLogging = options?.logging?.protocol; + const serverInstructions = options?.serverInstanceOptions?.instructions; server = new McpServer( { @@ -244,7 +245,8 @@ const runServer = async (options: ServerOptions = getOptions(), { tools: {}, resources: {}, ...(enableProtocolLogging ? { logging: {} } : {}) - } + }, + ...(serverInstructions ? { instructions: serverInstructions } : {}) } );