package tools import ( "encoding/json" "log" "time" "git.x2erp.com/qdy/go-svc-mcp/internal/mcp" ) func init() { mcp.Register("get_current_date", "获取当前服务器日期。所有以日期有关的计算,必须按此时间为基础计算。比如上年,最近7天等", map[string]interface{}{ "type": "object", "properties": map[string]interface{}{}, "required": []string{}, }, func(input json.RawMessage, deps *mcp.ToolDependencies) (interface{}, error) { now := time.Now() log.Printf("AI 调用工具-get_current_date: %s", now) log.Printf("AI 项目ID: %s", deps.ReqCtx.ProjectID) return map[string]interface{}{ "date": now.Format("2006-01-02"), "year": now.Year(), "month": int(now.Month()), "day": now.Day(), "iso_date": now.Format(time.RFC3339), "timestamp": now.Unix(), }, nil }, ) }