33 lines
1.1 KiB
Go
33 lines
1.1 KiB
Go
|
|
package model
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"time"
|
|||
|
|
|
|||
|
|
"github.com/google/uuid"
|
|||
|
|
"gorm.io/gorm"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// MCP MCP工具配置
|
|||
|
|
type MCP struct {
|
|||
|
|
ID string `json:"id" gorm:"primaryKey"`
|
|||
|
|
Name string `json:"name" gorm:"uniqueIndex;size:100;not null"`
|
|||
|
|
Description string `json:"description" gorm:"type:text"` // 英文描述
|
|||
|
|
DescriptionCN string `json:"description_cn" gorm:"type:text"` // 中文描述
|
|||
|
|
Category string `json:"category" gorm:"size:50;not null"` // 分类
|
|||
|
|
Transport string `json:"transport" gorm:"size:20;default:'stdio'"` // stdio, http, sse
|
|||
|
|
Command string `json:"command" gorm:"size:500"` // 启动命令
|
|||
|
|
Args string `json:"args" gorm:"type:text"` // 参数,JSON数组格式
|
|||
|
|
Env string `json:"env" gorm:"type:text"` // 环境变量,JSON对象格式
|
|||
|
|
Status string `json:"status" gorm:"size:20;default:'active'"`
|
|||
|
|
CreatedAt time.Time `json:"created_at"`
|
|||
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// BeforeCreate 创建前自动生成ID
|
|||
|
|
func (m *MCP) BeforeCreate(tx *gorm.DB) error {
|
|||
|
|
if m.ID == "" {
|
|||
|
|
m.ID = uuid.New().String()
|
|||
|
|
}
|
|||
|
|
return nil
|
|||
|
|
}
|