(server *MCPServer)
| 200 | } |
| 201 | |
| 202 | func registerMCPLibraryTools(server *MCPServer) { |
| 203 | AddTypedMCPTool(server, &mcp.Tool{Name: "library.list", Description: "获取当前用户可访问的知识库列表"}, func(ctx context.Context, _ *mcp.CallToolRequest, in MCPLibraryListInput) (*mcp.CallToolResult, any, error) { |
| 204 | userID, eid, _, err := CurrentMCPAuthInfo(ctx) |
| 205 | if err != nil { |
| 206 | return nil, nil, err |
| 207 | } |
| 208 | svc := mcpservice.NewLibraryService() |
| 209 | var spaceID *int64 |
| 210 | if in.SpaceID != nil { |
| 211 | decoded := in.SpaceID.Int64() |
| 212 | spaceID = &decoded |
| 213 | } |
| 214 | count, libraries, err := svc.ListVisibleLibraries(ctx, eid, userID, in.Name, in.Status, spaceID, in.Offset, in.Limit, in.WithFileCount) |
| 215 | if err != nil { |
| 216 | return nil, nil, err |
| 217 | } |
| 218 | return &mcp.CallToolResult{}, encodeMCPToolOutput(map[string]any{"count": count, "items": libraries}), nil |
| 219 | }) |
| 220 | |
| 221 | AddTypedMCPTool(server, &mcp.Tool{Name: "library.detail", Description: "获取知识库详情"}, func(ctx context.Context, _ *mcp.CallToolRequest, in MCPLibraryDetailInput) (*mcp.CallToolResult, any, error) { |
| 222 | userID, eid, _, err := CurrentMCPAuthInfo(ctx) |
| 223 | if err != nil { |
| 224 | return nil, nil, err |
| 225 | } |
| 226 | svc := mcpservice.NewLibraryService() |
| 227 | library, err := svc.GetVisibleLibraryDetail(ctx, eid, userID, in.LibraryID.Int64()) |
| 228 | if err != nil { |
| 229 | return nil, nil, err |
| 230 | } |
| 231 | return &mcp.CallToolResult{}, encodeMCPToolOutput(library), nil |
| 232 | }) |
| 233 | } |
| 234 | |
| 235 | func registerMCPFileTools(server *MCPServer) { |
| 236 | AddTypedMCPTool(server, &mcp.Tool{Name: "file.create", Description: "创建文件或文件夹"}, func(ctx context.Context, _ *mcp.CallToolRequest, in MCPFileCreateInput) (*mcp.CallToolResult, any, error) { |
no test coverage detected