import { SimpleLocalIntegration, SimpleLocalRuntime, type IIntegrationRuntime, type IIntegrationSetupContext } from '../../core/index.js';
import { McpClient } from './mcp.classes.client.js';
import { McpConfigFlow } from './mcp.classes.configflow.js';
import { createMcpDiscoveryDescriptor } from './mcp.discovery.js';
import type { IMcpConfig } from './mcp.types.js';
import { mcpDomain, mcpProfile } from './mcp.types.js';

export class McpIntegration extends SimpleLocalIntegration<IMcpConfig> {
  public readonly domain = mcpDomain;
  public readonly discoveryDescriptor = createMcpDiscoveryDescriptor();
  public readonly configFlow = new McpConfigFlow();

  constructor() {
    super(mcpProfile);
  }

  public async setup(configArg: IMcpConfig, contextArg: IIntegrationSetupContext): Promise<IIntegrationRuntime> {
    void contextArg;
    return new SimpleLocalRuntime(mcpProfile, new McpClient(configArg));
  }
}

export class HomeAssistantMcpIntegration extends McpIntegration {}
