Skip to content
Merged
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
3 changes: 3 additions & 0 deletions src/__tests__/__snapshots__/options.defaults.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/__snapshots__/server.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
],
],
Expand Down Expand Up @@ -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.",
},
],
],
Expand Down Expand Up @@ -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.",
},
],
],
Expand Down Expand Up @@ -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.",
},
],
],
Expand Down Expand Up @@ -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.",
},
],
],
Expand Down Expand Up @@ -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.",
},
],
],
Expand Down Expand Up @@ -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.",
},
],
],
Expand Down Expand Up @@ -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.",
},
],
],
Expand Down
15 changes: 13 additions & 2 deletions src/__tests__/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
);

Expand Down Expand Up @@ -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 }
);

Expand Down
25 changes: 24 additions & 1 deletion src/options.defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -62,6 +63,7 @@ interface DefaultOptions<TLogOptions = LoggingOptions> {
resourceMemoOptions: Partial<typeof RESOURCE_MEMO_OPTIONS>;
resourceModules: unknown | unknown[];
separator: string;
serverInstanceOptions: ServerInstanceOptions;
stats: StatsOptions;
toolMemoOptions: Partial<typeof TOOL_MEMO_OPTIONS>;
toolModules: ToolModule | ToolModule[];
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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,
Expand All @@ -509,18 +529,21 @@ const DEFAULT_OPTIONS: DefaultOptions = {
};

export {
LOG_BASENAME,
DEFAULT_OPTIONS,
LOG_BASENAME,
MODE_LEVELS,
getNodeMajorVersion,
type DefaultOptions,
type DefaultOptionsOverrides,
type HttpOptions,
type LoggingOptions,
type LoggingSession,
type MinMax,
type ModeOptions,
type PatternFlyOptions,
type PluginHostOptions,
type RepoResources,
type ServerInstanceOptions,
type StatsSession,
type WhitelistUrl,
type XhrFetchOptions
Expand Down
4 changes: 3 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ const runServer = async (options: ServerOptions = getOptions(), {

try {
const enableProtocolLogging = options?.logging?.protocol;
const serverInstructions = options?.serverInstanceOptions?.instructions;

server = new McpServer(
{
Expand All @@ -244,7 +245,8 @@ const runServer = async (options: ServerOptions = getOptions(), {
tools: {},
resources: {},
...(enableProtocolLogging ? { logging: {} } : {})
}
},
...(serverInstructions ? { instructions: serverInstructions } : {})
}
);

Expand Down
Loading