| 28 | const AppContext = createContext<AppContextType | undefined>(undefined); |
| 29 | |
| 30 | function sanitizeMCPConfig(config: MCPConfig): MCPConfig { |
| 31 | const newConfig = { ...config }; |
| 32 | |
| 33 | // Merge args into command if present |
| 34 | if (newConfig.args && newConfig.args.length > 0) { |
| 35 | if (!newConfig.command) newConfig.command = []; |
| 36 | if (Array.isArray(newConfig.command)) { |
| 37 | newConfig.command = [...newConfig.command, ...newConfig.args]; |
| 38 | } |
| 39 | delete newConfig.args; |
| 40 | } |
| 41 | |
| 42 | // Rename env to environment |
| 43 | if (newConfig.env) { |
| 44 | newConfig.environment = { ...newConfig.environment, ...newConfig.env }; |
| 45 | delete newConfig.env; |
| 46 | } |
| 47 | |
| 48 | return newConfig; |
| 49 | } |
| 50 | |
| 51 | export function AppProvider({ children }: { children: ReactNode }) { |
| 52 | const [config, setConfig] = useState<OpencodeConfig | null>(null); |