Merge pull request #1238 from trheyi/main

Add MCP client loading in engine
This commit is contained in:
Max 2025-10-26 11:32:36 +08:00 committed by GitHub
commit ee508050e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View file

@ -21,6 +21,7 @@ import (
"github.com/yaoapp/yao/fs"
"github.com/yaoapp/yao/i18n"
"github.com/yaoapp/yao/kb"
"github.com/yaoapp/yao/mcp"
"github.com/yaoapp/yao/messenger"
"github.com/yaoapp/yao/moapi"
"github.com/yaoapp/yao/model"
@ -282,6 +283,13 @@ func Load(cfg config.Config, options LoadOption) (warnings []Warning, err error)
warnings = append(warnings, Warning{Widget: "Pipe", Error: err})
}
// Load MCP Clients
err = mcp.Load(cfg)
if err != nil {
// printErr(cfg.Mode, "MCP", err)
warnings = append(warnings, Warning{Widget: "MCP", Error: err})
}
// Load Knowledge Base
_, err = kb.Load(cfg)
if err != nil {
@ -506,6 +514,12 @@ func Reload(cfg config.Config, options LoadOption) (err error) {
printErr(cfg.Mode, "AIGC", err)
}
// Load MCP Clients
err = mcp.Load(cfg)
if err != nil {
printErr(cfg.Mode, "MCP", err)
}
// Load Knowledge Base
_, err = kb.Load(cfg)
if err != nil {

View file

@ -364,6 +364,8 @@ func (u *DefaultUser) CreateRobotMember(ctx context.Context, teamID string, robo
robotFields := []string{
"role_id", "system_prompt", "manager_id", "robot_config", "agents", "mcp_servers",
"language_model", "cost_limit", "autonomous_mode", "robot_status",
"permissions", "restrictions", "notes", "metadata",
"__yao_created_by", "__yao_updated_by", "__yao_team_id", "__yao_tenant_id",
}
for _, field := range robotFields {
@ -412,6 +414,8 @@ func (u *DefaultUser) AddMember(ctx context.Context, teamID string, userID strin
"invited_at": time.Now(),
"invitation_token": token,
"invitation_expires_at": time.Now().Add(7 * 24 * time.Hour), // 7 days expiry
"__yao_created_by": invitedBy,
"__yao_team_id": teamID,
}
return u.CreateMember(ctx, memberData)