返回 DeepSeek-Reasonix
mcp_interaction_http.go
根目录 / internal / serve / mcp_interaction_http.go
1 package serve
2
3 import (
4 "encoding/json"
5 "net/http"
6 )
7
8 // mcpInteraction resolves an mcp_interaction prompt after its transition is
9 // durable, mirroring the ask answer endpoint. Form values ride this call only.
10 func (s *Server) mcpInteraction(w http.ResponseWriter, r *http.Request) {
11 var body struct {
12 ID string `json:"id"`
13 Action string `json:"action"`
14 Content map[string]any `json:"content,omitempty"`
15 }
16 if err := json.NewDecoder(r.Body).Decode(&body); err != nil || body.ID == "" || body.Action == "" {
17 http.Error(w, "missing id or action", http.StatusBadRequest)
18 return
19 }
20 if err := s.ctl().AnswerMCPInteractionChecked(body.ID, body.Action, body.Content); err != nil {
21 http.Error(w, err.Error(), http.StatusBadRequest)
22 return
23 }
24 w.WriteHeader(http.StatusNoContent)
25 }
26
26 lines GO