(c *gin.Context, req request)
| 215 | } |
| 216 | |
| 217 | func (s *Server) handleInitialize(c *gin.Context, req request) { |
| 218 | var params initializeParams |
| 219 | if len(req.Params) > 0 { |
| 220 | if err := json.Unmarshal(req.Params, ¶ms); err != nil { |
| 221 | c.JSON(http.StatusBadRequest, response{ |
| 222 | JSONRPC: "2.0", |
| 223 | ID: req.ID, |
| 224 | Error: &rpcError{Code: -32602, Message: "invalid initialize params"}, |
| 225 | }) |
| 226 | return |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | protocolVersion := negotiateProtocolVersion(params.ProtocolVersion) |
| 231 | currentSession := s.initializeSession( |
| 232 | c.Request.Context().Value(conf.UserKey).(*model.User).ID, |
| 233 | c.GetHeader(SessionHeader), |
| 234 | protocolVersion, |
| 235 | ) |
| 236 | c.Header(SessionHeader, currentSession.id) |
| 237 | c.JSON(http.StatusOK, response{ |
| 238 | JSONRPC: "2.0", |
| 239 | ID: req.ID, |
| 240 | Result: map[string]any{ |
| 241 | "protocolVersion": protocolVersion, |
| 242 | "capabilities": map[string]any{ |
| 243 | "tools": map[string]any{ |
| 244 | "listChanged": false, |
| 245 | }, |
| 246 | }, |
| 247 | "serverInfo": map[string]any{ |
| 248 | "name": "OpenList MCP", |
| 249 | "version": conf.Version, |
| 250 | }, |
| 251 | "instructions": "Complete initialization with notifications/initialized, then use tools/list and tools/call. Available tools include openlist.fs.list, openlist.fs.get, and openlist.fs.link.", |
| 252 | }, |
| 253 | }) |
| 254 | } |
| 255 | |
| 256 | func (s *Server) initializeSession(userID uint, requestedID string, protocolVersion string) *session { |
| 257 | s.mu.Lock() |
no test coverage detected