import type { McpServer, CallToolResult } from "@modelcontextprotocol/server"; import type { Config } from "../../core/io/Config.js"; import { z } from "zod"; import { returnMcpToolSimpleResult, returnMcpToolResult } from "../util/returnMcpResult.js"; export const TOOL_GET_CONFIG = "get-config"; export const TOOL_SET_CONFIG = "set-config"; export function registerConfigurationHandlers(server: McpServer, config: Config): void { server.registerTool( TOOL_GET_CONFIG, { title: `Get configuration of MCP server`, description: `Show the basic settings of the MCP server. Contains data needed to interface with Aerofly FS 4 as well as the local file system. To change this configuration, call \`${TOOL_SET_CONFIG}\`.`, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: false, openWorldHint: true, }, }, () => returnMcpToolSimpleResult(config), ); server.registerTool( TOOL_SET_CONFIG, { title: `Set configuration of MCP server`, description: `Update the basic settings of the MCP server, like data needed to interface with Aerofly FS 4 as well as the local file system. After updating will return the new configuration state.`, inputSchema: z.object({ mainMcfFilePath: z .string() .optional() .describe( `Absolute path to the \`main.mcf\` file. This file is the main interface to Aerofly FS 4 and is crucial for reading and writting mission data to Aerofly FS 4.`, ), simBriefUserName: z .string() .optional() .describe( `Username or UserID for SimBrief API. Only required if user asks to populate Aerofly FS 4 by importing a SimBrief flightplan.`, ), }), annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: true, }, }, ({ mainMcfFilePath, simBriefUserName, }: { mainMcfFilePath?: string; simBriefUserName?: string; }): CallToolResult => { if (mainMcfFilePath !== undefined) { config.mainMcfFilePath = mainMcfFilePath; } if (simBriefUserName !== undefined) { config.simBriefUserName = simBriefUserName; } return returnMcpToolResult(config); }, ); }