Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mcp/mcp_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func Example_lifecycle() {
server := mcp.NewServer(&mcp.Implementation{Name: "server", Version: "v0.0.1"}, nil)

// Connect the server and client using in-memory transports.
t1, t2 := mcp.NewInMemoryTransports()
t1, t4 := mcp.NewInMemoryTransports()
serverSession, err := server.Connect(ctx, t1, nil)
if err != nil {
log.Fatal(err)
}
clientSession, err := client.Connect(ctx, t2, nil)
clientSession, err := client.Connect(ctx, t4, nil)
if err != nil {
log.Fatal(err)
}
Expand Down
18 changes: 9 additions & 9 deletions mcp/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (m *InputRequestMap) UnmarshalJSON(data []byte) error {
Params json.RawMessage `json:"params"`
}
var rawMap map[string]raw
if err := json.Unmarshal(data, &rawMap); err != nil {
if err := internaljson.Unmarshal(data, &rawMap); err != nil {
return err
}
if rawMap == nil {
Expand All @@ -117,19 +117,19 @@ func (m *InputRequestMap) UnmarshalJSON(data []byte) error {
switch raw.Method {
case methodElicit:
var p ElicitParams
if err := json.Unmarshal(raw.Params, &p); err != nil {
if err := internaljson.Unmarshal(raw.Params, &p); err != nil {
return err
}
result[k] = &p
case methodCreateMessage:
var p CreateMessageWithToolsParams
if err := json.Unmarshal(raw.Params, &p); err != nil {
if err := internaljson.Unmarshal(raw.Params, &p); err != nil {
return err
}
result[k] = &p
case methodListRoots:
var p ListRootsParams
if err := json.Unmarshal(raw.Params, &p); err != nil {
if err := internaljson.Unmarshal(raw.Params, &p); err != nil {
return err
}
result[k] = &p
Expand All @@ -153,7 +153,7 @@ type InputResponseMap map[string]InputResponse

func (m *InputResponseMap) UnmarshalJSON(data []byte) error {
var rawMap map[string]json.RawMessage
if err := json.Unmarshal(data, &rawMap); err != nil {
if err := internaljson.Unmarshal(data, &rawMap); err != nil {
return err
}
result := make(InputResponseMap, len(rawMap))
Expand All @@ -176,25 +176,25 @@ func unmarshalInputResponse(data json.RawMessage) (InputResponse, error) {
Role json.RawMessage `json:"role"`
Roots json.RawMessage `json:"roots"`
}
if err := json.Unmarshal(data, &probe); err != nil {
if err := internaljson.Unmarshal(data, &probe); err != nil {
return nil, err
}
switch {
case probe.Roots != nil:
var p ListRootsResult
if err := json.Unmarshal(data, &p); err != nil {
if err := internaljson.Unmarshal(data, &p); err != nil {
return nil, err
}
return &p, nil
case probe.Action != nil:
var p ElicitResult
if err := json.Unmarshal(data, &p); err != nil {
if err := internaljson.Unmarshal(data, &p); err != nil {
return nil, err
}
return &p, nil
case probe.Role != nil:
var p CreateMessageWithToolsResult
if err := json.Unmarshal(data, &p); err != nil {
if err := internaljson.Unmarshal(data, &p); err != nil {
return nil, err
}
return &p, nil
Expand Down
Loading