generated from VLADIMIR/template
add mcp label
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"time"
|
||||
|
||||
"evening_detective_server/internal/modules/storytelling"
|
||||
"evening_detective_server/internal/repos/actions_repo"
|
||||
"evening_detective_server/internal/services/game_service"
|
||||
|
||||
"github.com/mark3labs/mcp-go/mcp"
|
||||
@@ -29,7 +30,7 @@ const defaultCallTimeout = 10 * time.Second
|
||||
// *game_service.GameService; интерфейс позволяет тестировать сервис
|
||||
// без БД.
|
||||
type GamePlayer interface {
|
||||
GetTeamActions(ctx context.Context, teamId int, password string) (*storytelling.Story, *game_service.Game, error)
|
||||
GetTeamActions(ctx context.Context, teamId int, password string) (*storytelling.Story, *game_service.Game, []actions_repo.Action, error)
|
||||
AddTeamAction(ctx context.Context, teamId int, password, actionCode string, viaMCP bool) error
|
||||
SubmitTeamAnswers(ctx context.Context, teamId int, password string, answers []game_service.Answer) error
|
||||
}
|
||||
@@ -203,7 +204,7 @@ func (s *MCPService) handleConnect(ctx context.Context, req mcp.CallToolRequest)
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultCallTimeout)
|
||||
defer cancel()
|
||||
|
||||
story, game, err := s.game.GetTeamActions(ctx, int(args.teamID), args.password)
|
||||
story, game, _, err := s.game.GetTeamActions(ctx, int(args.teamID), args.password)
|
||||
if err != nil {
|
||||
return mcp.NewToolResultError(fmt.Sprintf("connect: %v", err)), nil
|
||||
}
|
||||
@@ -234,7 +235,7 @@ func (s *MCPService) handleGetTeamStory(ctx context.Context, req mcp.CallToolReq
|
||||
ctx, cancel := context.WithTimeout(ctx, defaultCallTimeout)
|
||||
defer cancel()
|
||||
|
||||
story, game, err := s.game.GetTeamActions(ctx, int(teamID), password)
|
||||
story, game, _, err := s.game.GetTeamActions(ctx, int(teamID), password)
|
||||
if err != nil {
|
||||
return mcp.NewToolResultError(fmt.Sprintf("get_team_story: %v", err)), nil
|
||||
}
|
||||
@@ -265,7 +266,7 @@ func (s *MCPService) handleMakeMove(ctx context.Context, req mcp.CallToolRequest
|
||||
return mcp.NewToolResultError(fmt.Sprintf("make_move: %v", err)), nil
|
||||
}
|
||||
|
||||
story, game, err := s.game.GetTeamActions(ctx, int(teamID), password)
|
||||
story, game, _, err := s.game.GetTeamActions(ctx, int(teamID), password)
|
||||
if err != nil {
|
||||
return mcp.NewToolResultError(fmt.Sprintf("make_move: %v", err)), nil
|
||||
}
|
||||
@@ -337,7 +338,7 @@ func (s *MCPService) handleSubmitAnswers(ctx context.Context, req mcp.CallToolRe
|
||||
return mcp.NewToolResultError(fmt.Sprintf("submit_answers: %v", err)), nil
|
||||
}
|
||||
|
||||
story, game, err := s.game.GetTeamActions(ctx, int(args.teamID), args.password)
|
||||
story, game, _, err := s.game.GetTeamActions(ctx, int(args.teamID), args.password)
|
||||
if err != nil {
|
||||
return mcp.NewToolResultError(fmt.Sprintf("submit_answers: %v", err)), nil
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"evening_detective_server/internal/modules/storytelling"
|
||||
"evening_detective_server/internal/repos/actions_repo"
|
||||
"evening_detective_server/internal/services/game_service"
|
||||
|
||||
"github.com/mark3labs/mcp-go/client"
|
||||
@@ -23,11 +24,11 @@ type fakeGamePlayer struct {
|
||||
viaMCP bool
|
||||
}
|
||||
|
||||
func (f *fakeGamePlayer) GetTeamActions(_ context.Context, teamID int, password string) (*storytelling.Story, *game_service.Game, error) {
|
||||
func (f *fakeGamePlayer) GetTeamActions(_ context.Context, teamID int, password string) (*storytelling.Story, *game_service.Game, []actions_repo.Action, error) {
|
||||
if f.err != nil {
|
||||
return nil, nil, f.err
|
||||
return nil, nil, nil, f.err
|
||||
}
|
||||
return f.story, f.game, nil
|
||||
return f.story, f.game, nil, nil
|
||||
}
|
||||
|
||||
func (f *fakeGamePlayer) AddTeamAction(_ context.Context, teamID int, password, code string, viaMCP bool) error {
|
||||
|
||||
Reference in New Issue
Block a user