import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { McpServerClient } from './mcp_server.classes.client.js';
import { McpServerConfigFlow } from './mcp_server.classes.configflow.js';
import { createMcpServerDiscoveryDescriptor } from './mcp_server.discovery.js';
import type { IMcpServerConfig } from './mcp_server.types.js';
import { mcpServerDomain, mcpServerProfile } from './mcp_server.types.js';

export class McpServerIntegration extends SimpleLocalIntegration<IMcpServerConfig> {
  public readonly domain = mcpServerDomain;
  public readonly discoveryDescriptor = createMcpServerDiscoveryDescriptor();
  public readonly configFlow = new McpServerConfigFlow();

  constructor() {
    super(mcpServerProfile);
  }

  public async setup(configArg: IMcpServerConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(mcpServerProfile, new McpServerClient(configArg));
  }
}

export class HomeAssistantMcpServerIntegration extends McpServerIntegration {}
