package dto

import "time"

// MCPServerHTTPConfig holds HTTP transport configuration for an MCP server.
type MCPServerHTTPConfig struct {
	URL     string   `json:"url"`
	Headers []string `json:"headers,omitempty"`
}

// MCPServerStdioConfig holds stdio transport configuration for an MCP server.
type MCPServerStdioConfig struct {
	Command string   `json:"command"`
	Args    []string `json:"args,omitempty"`
	Env     []string `json:"env,omitempty"`
	CWD     string   `json:"cwd,omitempty"`
}

// MCPServerRequest is the JSON request body for creating or updating an MCP server.
type MCPServerRequest struct {
	ID          string                `json:"id,omitempty"`
	DisplayName string                `json:"displayName,omitempty"`
	Description string                `json:"description,omitempty"`
	Enabled     *bool                 `json:"enabled,omitempty"`
	Transport   string                `json:"transport"`
	HTTP        *MCPServerHTTPConfig  `json:"http,omitempty"`
	Stdio       *MCPServerStdioConfig `json:"stdio,omitempty"`
}

// MCPToolSummary describes a single tool advertised by an MCP server.
type MCPToolSummary struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
}

// MCPServerCheckResponse is the JSON response for an MCP server connectivity test.
type MCPServerCheckResponse struct {
	OK        bool             `json:"ok"`
	Stage     string           `json:"stage,omitempty"`
	Message   string           `json:"message,omitempty"`
	CheckedAt time.Time        `json:"checkedAt"`
	Tools     []MCPToolSummary `json:"tools,omitempty"`
}

// MCPServerResponse is the JSON response for an MCP server configuration.
type MCPServerResponse struct {
	ID          string                  `json:"id"`
	DisplayName string                  `json:"displayName"`
	Description string                  `json:"description,omitempty"`
	Enabled     bool                    `json:"enabled"`
	Transport   string                  `json:"transport"`
	HTTP        *MCPServerHTTPConfig    `json:"http,omitempty"`
	Stdio       *MCPServerStdioConfig   `json:"stdio,omitempty"`
	CreatedAt   *time.Time              `json:"createdAt,omitempty"`
	UpdatedAt   *time.Time              `json:"updatedAt,omitempty"`
	LastCheck   *MCPServerCheckResponse `json:"lastCheck,omitempty"`
}
