Files

47 lines
2.6 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package models
import "time"
// BackendMcpServer MCP服务器配置表(真正的 MCP 协议接入配置)
// transport 支持三种:
// - stdio:本地进程方式(command + args + env)
// - http :Streamable HTTP 传输(url + headers)
// - sse :SSE 传输(url + headers)
type BackendMcpServer struct {
ID uint64 `orm:"column(id);pk;auto" json:"id"`
TenantID string `orm:"column(tenant_id);size(64)" json:"tenant_id"`
UserID uint64 `orm:"column(user_id);default(0)" json:"user_id"`
Name string `orm:"column(name);size(100)" json:"name"`
Transport string `orm:"column(transport);size(20)" json:"transport"` // stdio/http/sse
Command string `orm:"column(command);size(255)" json:"command"` // stdio 命令
Args string `orm:"column(args);type(text)" json:"args"` // stdio 参数 JSON数组
Env string `orm:"column(env);type(text)" json:"env"` // 环境变量 JSON对象
URL string `orm:"column(url);size(512)" json:"url"` // http/sse 地址
Headers string `orm:"column(headers);type(text)" json:"headers"` // 请求头 JSON对象
Description string `orm:"column(description);size(255)" json:"description"`
Provider string `orm:"column(provider);size(50)" json:"provider"` // 提供方名称
FromMarket string `orm:"column(from_market);size(50)" json:"from_market"` // 来源市场key
Enabled int8 `orm:"column(enabled);default(0)" json:"enabled"` // 0-禁用 1-启用(仅启用项在会话中生效)
Status int8 `orm:"column(status);default(0)" json:"status"` // 0-未测试 1-连接正常 2-连接失败
LastError string `orm:"column(last_error);size(500)" json:"last_error"`
ToolCount int `orm:"column(tool_count);default(0)" json:"tool_count"`
Remark string `orm:"column(remark);size(255)" json:"remark"`
CreateTime time.Time `orm:"column(create_time);auto_now_add;type(datetime)" json:"create_time"`
UpdateTime time.Time `orm:"column(update_time);auto_now;type(datetime)" json:"update_time"`
DeleteTime *time.Time `orm:"column(delete_time);type(datetime);null" json:"delete_time"`
// 非数据库字段:连接后发现的工具列表(用于前端展示)
Tools []McpToolInfo `orm:"-" json:"tools,omitempty"`
}
// McpToolInfo MCP 工具信息(用于前端展示与 LLM 工具注入)
type McpToolInfo struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema interface{} `json:"input_schema"`
}
func (m *BackendMcpServer) TableName() string {
return "yz_backend_mcp_server"
}