From 71507fb9b714088fc3aed6b46bd1e5cc80f6e8f4 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Mon, 9 Feb 2026 17:25:21 +0100 Subject: [PATCH] :recycle: Adjust ConfigurationLoader to use markdown file instead of yml --- .../server/src/ConfigurationLoader.ts | 61 +++---------------- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/mcp/packages/server/src/ConfigurationLoader.ts b/mcp/packages/server/src/ConfigurationLoader.ts index 0a24d88210..390522ff24 100644 --- a/mcp/packages/server/src/ConfigurationLoader.ts +++ b/mcp/packages/server/src/ConfigurationLoader.ts @@ -1,18 +1,7 @@ -import { readFileSync, existsSync } from "fs"; -import { join, dirname } from "path"; -import { fileURLToPath } from "url"; -import yaml from "js-yaml"; +import { existsSync, readFileSync } from "fs"; +import { join } from "path"; import { createLogger } from "./logger.js"; -/** - * Interface defining the structure of the prompts configuration file. - */ -export interface PromptsConfig { - /** Initial instructions displayed when the server starts or connects to a client */ - initial_instructions: string; - [key: string]: any; // Allow for future extension with additional prompt types -} - /** * Configuration loader for prompts and server settings. * @@ -23,7 +12,7 @@ export interface PromptsConfig { export class ConfigurationLoader { private readonly logger = createLogger("ConfigurationLoader"); private readonly baseDir: string; - private promptsConfig: PromptsConfig | null = null; + private initialInstructions: string; /** * Creates a new configuration loader instance. @@ -32,34 +21,14 @@ export class ConfigurationLoader { */ constructor(baseDir: string) { this.baseDir = baseDir; + this.initialInstructions = this.loadFileContent(join(this.baseDir, "data", "initial_instructions.md")); } - /** - * Loads the prompts configuration from the YAML file. - * - * Reads and parses the prompts.yml file, providing cached access - * to configuration values on subsequent calls. - * - * @returns The parsed prompts configuration object - */ - public getPromptsConfig(): PromptsConfig { - if (this.promptsConfig !== null) { - return this.promptsConfig; + private loadFileContent(filePath: string): string { + if (!existsSync(filePath)) { + throw new Error(`Configuration file not found at ${filePath}`); } - - const promptsPath = join(this.baseDir, "data", "prompts.yml"); - - if (!existsSync(promptsPath)) { - throw new Error(`Prompts configuration file not found at ${promptsPath}, using defaults`); - } - - const fileContent = readFileSync(promptsPath, "utf8"); - const parsedConfig = yaml.load(fileContent) as PromptsConfig; - - this.promptsConfig = parsedConfig || {}; - this.logger.info(`Loaded prompts configuration from ${promptsPath}`); - - return this.promptsConfig; + return readFileSync(filePath, "utf8"); } /** @@ -68,18 +37,6 @@ export class ConfigurationLoader { * @returns The initial instructions string, or undefined if not configured */ public getInitialInstructions(): string { - const config = this.getPromptsConfig(); - return config.initial_instructions; - } - - /** - * Reloads the configuration from disk. - * - * Forces a fresh read of the configuration file on the next access, - * useful for development or when configuration files are updated at runtime. - */ - public reloadConfiguration(): void { - this.promptsConfig = null; - this.logger.info("Configuration cache cleared, will reload on next access"); + return this.initialInstructions; } }