@@ -130,16 +130,19 @@ func TestCapabilities(t *testing.T) {
130
130
anthropicServer := start (t ,anthropic )
131
131
githubServer := start (t ,github )
132
132
133
- req := newInitializeRequest (
134
- initializeRequestParams {
133
+ req := initializeRequest {
134
+ JSONRPC :"2.0" ,
135
+ ID :1 ,
136
+ Method :"initialize" ,
137
+ Params :initializeParams {
135
138
ProtocolVersion :"2025-03-26" ,
136
139
Capabilities :clientCapabilities {},
137
140
ClientInfo :clientInfo {
138
141
Name :"ConformanceTest" ,
139
142
Version :"0.0.1" ,
140
143
},
141
144
},
142
- )
145
+ }
143
146
144
147
require .NoError (t ,anthropicServer .send (req ))
145
148
@@ -274,48 +277,39 @@ func (s server) receive(res response) error {
274
277
return res .unmarshal (line )
275
278
}
276
279
280
+ type request interface {
281
+ marshal () ([]byte ,error )
282
+ }
283
+
284
+ type response interface {
285
+ unmarshal ([]byte )error
286
+ }
287
+
277
288
type jsonRPRCRequest [params any ]struct {
278
289
JSONRPC string `json:"jsonrpc"`
279
290
ID int `json:"id"`
280
291
Method string `json:"method"`
281
292
Params params `json:"params"`
282
293
}
283
294
295
+ func (r jsonRPRCRequest [any ])marshal () ([]byte ,error ) {
296
+ return json .Marshal (r )
297
+ }
298
+
284
299
type jsonRPRCResponse [result any ]struct {
285
300
JSONRPC string `json:"jsonrpc"`
286
301
ID int `json:"id"`
287
302
Method string `json:"method"`
288
303
Result result `json:"result"`
289
304
}
290
305
291
- type request interface {
292
- marshal () ([]byte ,error )
293
- }
294
-
295
- type response interface {
296
- unmarshal ([]byte )error
297
- }
298
-
299
- func newInitializeRequest (params initializeRequestParams )initializeRequest {
300
- return initializeRequest {
301
- jsonRPRCRequest :jsonRPRCRequest [initializeRequestParams ]{
302
- JSONRPC :"2.0" ,
303
- ID :1 ,
304
- Method :"initialize" ,
305
- Params :params ,
306
- },
307
- }
308
- }
309
-
310
- type initializeRequest struct {
311
- jsonRPRCRequest [initializeRequestParams ]
306
+ func (r * jsonRPRCResponse [any ])unmarshal (b []byte )error {
307
+ return json .Unmarshal (b ,r )
312
308
}
313
309
314
- func (r initializeRequest )marshal () ([]byte ,error ) {
315
- return json .Marshal (r )
316
- }
310
+ type initializeRequest = jsonRPRCRequest [initializeParams ]
317
311
318
- type initializeRequestParams struct {
312
+ type initializeParams struct {
319
313
ProtocolVersion string `json:"protocolVersion"`
320
314
Capabilities clientCapabilities `json:"capabilities"`
321
315
ClientInfo clientInfo `json:"clientInfo"`
@@ -328,13 +322,7 @@ type clientInfo struct {
328
322
Version string `json:"version"`
329
323
}
330
324
331
- type initializeResponse struct {
332
- jsonRPRCResponse [initializeResult ]
333
- }
334
-
335
- func (r * initializeResponse )unmarshal (b []byte )error {
336
- return json .Unmarshal (b ,r )
337
- }
325
+ type initializeResponse = jsonRPRCResponse [initializeResult ]
338
326
339
327
type initializeResult struct {
340
328
ProtocolVersion string `json:"protocolVersion"`