// =====================================================
// Interfaces: MCP Tool
// Modulo: MGN-022
// Version: 1.0.0
// =====================================================

import { McpContext } from './mcp-context.interface';

export interface JSONSchema {
  type: string;
  properties?: Record<string, JSONSchemaProperty>;
  required?: string[];
  items?: JSONSchemaProperty;
  description?: string;
}

export interface JSONSchemaProperty {
  type: string;
  description?: string;
  format?: string;
  enum?: string[];
  minimum?: number;
  maximum?: number;
  default?: any;
  items?: JSONSchemaProperty;
  properties?: Record<string, JSONSchemaProperty>;
  required?: string[];
}

export interface RateLimitConfig {
  maxCalls: number;
  windowMs: number;
  perTenant?: boolean;
}

export type ToolCategory =
  | 'products'
  | 'inventory'
  | 'orders'
  | 'customers'
  | 'fiados'
  | 'sales'
  | 'financial'
  | 'branches'
  | 'system';

export interface McpToolDefinition {
  name: string;
  description: string;
  parameters: JSONSchema;
  returns: JSONSchema;
  category: ToolCategory;
  permissions?: string[];
  rateLimit?: RateLimitConfig;
}

export type McpToolHandler<TParams = any, TResult = any> = (
  params: TParams,
  context: McpContext
) => Promise<TResult>;

export interface McpToolProvider {
  getTools(): McpToolDefinition[];
  getHandler(toolName: string): McpToolHandler | undefined;
}
