docs: document tool support (#498)
Document tool support, and tweak the wording for prompts. For #442
This commit is contained in:
parent
28753c9f12
commit
5985a7cbba
1 changed files with 358 additions and 56 deletions
|
|
@ -29,16 +29,21 @@ func ExampleLoggingTransport() {
|
|||
ctx := context.Background()
|
||||
t1, t2 := mcp.NewInMemoryTransports()
|
||||
server := mcp.NewServer(&mcp.Implementation{Name: "server", Version: "v0.0.1"}, nil)
|
||||
if _, err := server.Connect(ctx, t1, nil); err != nil {
|
||||
serverSession, err := server.Connect(ctx, t1, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer serverSession.Wait()
|
||||
|
||||
client := mcp.NewClient(&mcp.Implementation{Name: "client", Version: "v0.0.1"}, nil)
|
||||
var b bytes.Buffer
|
||||
logTransport := &mcp.LoggingTransport{Transport: t2, Writer: &b}
|
||||
if _, err := client.Connect(ctx, logTransport, nil); err != nil {
|
||||
clientSession, err := client.Connect(ctx, logTransport, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer clientSession.Close()
|
||||
|
||||
// Sort for stability: reads are concurrent to writes.
|
||||
for _, line := range slices.Sorted(strings.SplitSeq(b.String(), "\n")) {
|
||||
fmt.Println(line)
|
||||
|
|
|
|||
Loading…
Reference in a new issue