Açıklama Yok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

get_current_date.go 896B

1234567891011121314151617181920212223242526272829303132
  1. package tools
  2. import (
  3. "encoding/json"
  4. "log"
  5. "time"
  6. "git.x2erp.com/qdy/go-svc-mcp/internal/mcp"
  7. )
  8. func init() {
  9. mcp.Register("get_current_date", "获取当前服务器日期。所有以日期有关的计算,必须按此时间为基础计算。比如上年,最近7天等",
  10. map[string]interface{}{
  11. "type": "object",
  12. "properties": map[string]interface{}{},
  13. "required": []string{},
  14. },
  15. func(input json.RawMessage, deps *mcp.ToolDependencies) (interface{}, error) {
  16. now := time.Now()
  17. log.Printf("AI 调用工具-get_current_date: %s", now)
  18. log.Printf("AI 项目ID: %s", deps.ReqCtx.ProjectID)
  19. return map[string]interface{}{
  20. "date": now.Format("2006-01-02"),
  21. "year": now.Year(),
  22. "month": int(now.Month()),
  23. "day": now.Day(),
  24. "iso_date": now.Format(time.RFC3339),
  25. "timestamp": now.Unix(),
  26. }, nil
  27. },
  28. )
  29. }