122 lines
4.7 KiB
Go
122 lines
4.7 KiB
Go
|
|
package servers
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"context"
|
|||
|
|
"encoding/json"
|
|||
|
|
"github.com/mark3labs/mcp-go/mcp"
|
|||
|
|
"github.com/mark3labs/mcp-go/server"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// ScheduleTools MCP工具:仅注册接口,不暴露提醒发送功能
|
|||
|
|
var ScheduleTools = []server.ServerTool{
|
|||
|
|
// 创建日程
|
|||
|
|
{
|
|||
|
|
Tool: mcp.NewTool(
|
|||
|
|
"createSchedule",
|
|||
|
|
mcp.WithDescription("创建个人日程 (不包含提醒发送)"),
|
|||
|
|
mcp.WithString("ownerStaffGuid", mcp.Required(), mcp.Description("所属员工GUID")),
|
|||
|
|
mcp.WithString("title", mcp.Required(), mcp.Description("标题")),
|
|||
|
|
mcp.WithString("description", mcp.Description("描述")),
|
|||
|
|
mcp.WithString("location", mcp.Description("地点")),
|
|||
|
|
mcp.WithString("startTime", mcp.Required(), mcp.Description("开始时间,ISO8601")),
|
|||
|
|
mcp.WithString("endTime", mcp.Required(), mcp.Description("结束时间,ISO8601")),
|
|||
|
|
mcp.WithBoolean("allDay", mcp.Description("是否全天")),
|
|||
|
|
mcp.WithNumber("remindMinutesBefore", mcp.Description("提前提醒分钟数,0为不提醒")),
|
|||
|
|
),
|
|||
|
|
Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
|||
|
|
// TODO: call procOa.CreateSchedule when implemented
|
|||
|
|
payload := map[string]interface{}{
|
|||
|
|
"message": "createSchedule is registered",
|
|||
|
|
}
|
|||
|
|
b, _ := json.Marshal(payload)
|
|||
|
|
return mcp.NewToolResultText(string(b)), nil
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
// 更新日程
|
|||
|
|
{
|
|||
|
|
Tool: mcp.NewTool(
|
|||
|
|
"updateSchedule",
|
|||
|
|
mcp.WithDescription("更新个人日程 (不包含提醒发送)"),
|
|||
|
|
mcp.WithString("scheduleGuid", mcp.Required(), mcp.Description("日程GUID")),
|
|||
|
|
mcp.WithString("title", mcp.Description("标题")),
|
|||
|
|
mcp.WithString("description", mcp.Description("描述")),
|
|||
|
|
mcp.WithString("location", mcp.Description("地点")),
|
|||
|
|
mcp.WithString("startTime", mcp.Description("开始时间,ISO8601")),
|
|||
|
|
mcp.WithString("endTime", mcp.Description("结束时间,ISO8601")),
|
|||
|
|
mcp.WithBoolean("allDay", mcp.Description("是否全天")),
|
|||
|
|
mcp.WithNumber("remindMinutesBefore", mcp.Description("提前提醒分钟数,0为不提醒")),
|
|||
|
|
),
|
|||
|
|
Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
|||
|
|
// TODO: call procOa.UpdateSchedule when implemented
|
|||
|
|
payload := map[string]interface{}{
|
|||
|
|
"message": "updateSchedule is registered",
|
|||
|
|
}
|
|||
|
|
b, _ := json.Marshal(payload)
|
|||
|
|
return mcp.NewToolResultText(string(b)), nil
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
// 查询日程
|
|||
|
|
{
|
|||
|
|
Tool: mcp.NewTool(
|
|||
|
|
"listSchedules",
|
|||
|
|
mcp.WithDescription("按员工与时间范围查询个人日程"),
|
|||
|
|
mcp.WithString("ownerStaffGuid", mcp.Required(), mcp.Description("所属员工GUID")),
|
|||
|
|
mcp.WithString("from", mcp.Description("开始范围,ISO8601,可选")),
|
|||
|
|
mcp.WithString("to", mcp.Description("结束范围,ISO8601,可选")),
|
|||
|
|
mcp.WithNumber("limit", mcp.Description("分页大小,默认20")),
|
|||
|
|
mcp.WithNumber("offset", mcp.Description("分页偏移,默认0")),
|
|||
|
|
),
|
|||
|
|
Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
|||
|
|
// TODO: call procOa.ListSchedules when implemented
|
|||
|
|
payload := map[string]interface{}{
|
|||
|
|
"message": "listSchedules is registered",
|
|||
|
|
}
|
|||
|
|
b, _ := json.Marshal(payload)
|
|||
|
|
return mcp.NewToolResultText(string(b)), nil
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
// 冲突检查
|
|||
|
|
{
|
|||
|
|
Tool: mcp.NewTool(
|
|||
|
|
"checkScheduleConflicts",
|
|||
|
|
mcp.WithDescription("检查日程时间是否冲突"),
|
|||
|
|
mcp.WithString("ownerStaffGuid", mcp.Required(), mcp.Description("所属员工GUID")),
|
|||
|
|
mcp.WithString("startTime", mcp.Required(), mcp.Description("开始时间,ISO8601")),
|
|||
|
|
mcp.WithString("endTime", mcp.Required(), mcp.Description("结束时间,ISO8601")),
|
|||
|
|
mcp.WithString("excludeGuid", mcp.Description("更新时排除自身GUID")),
|
|||
|
|
),
|
|||
|
|
Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
|||
|
|
// TODO: call procOa.CheckScheduleConflicts when implemented
|
|||
|
|
payload := map[string]interface{}{
|
|||
|
|
"message": "checkScheduleConflicts is registered",
|
|||
|
|
}
|
|||
|
|
b, _ := json.Marshal(payload)
|
|||
|
|
return mcp.NewToolResultText(string(b)), nil
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
// 取消日程(可选)
|
|||
|
|
{
|
|||
|
|
Tool: mcp.NewTool(
|
|||
|
|
"cancelSchedule",
|
|||
|
|
mcp.WithDescription("取消个人日程 (将状态置为取消)"),
|
|||
|
|
mcp.WithString("scheduleGuid", mcp.Required(), mcp.Description("日程GUID")),
|
|||
|
|
),
|
|||
|
|
Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
|||
|
|
// TODO: call procOa.CancelSchedule when implemented
|
|||
|
|
payload := map[string]interface{}{
|
|||
|
|
"message": "cancelSchedule is registered",
|
|||
|
|
}
|
|||
|
|
b, _ := json.Marshal(payload)
|
|||
|
|
return mcp.NewToolResultText(string(b)), nil
|
|||
|
|
},
|
|||
|
|
},
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// RegisterScheduleTools 将日程工具附加到传入工具数组
|
|||
|
|
func RegisterScheduleTools(tools *[]server.ServerTool) {
|
|||
|
|
if tools == nil {
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
*tools = append(*tools, ScheduleTools...)
|
|||
|
|
}
|