Skip to content

Commit dcebd20

Browse files
authored
docs: fix ListTools usage to include ListToolsRequest parameter (#681)
* docs: fix ListTools usage to include ListToolsRequest parameter * fix ListResources
1 parent 5f205a6 commit dcebd20

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

www/docs/pages/clients/basics.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func demonstrateClientLifecycle() error {
156156

157157
func performClientOperations(ctx context.Context, c client.Client) error {
158158
// List available tools
159-
tools, err := c.ListTools(ctx)
159+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
160160
if err != nil {
161161
return err
162162
}
@@ -413,7 +413,7 @@ func reconnectClient(c client.Client) error {
413413
}
414414

415415
func suggestAlternativeTools(ctx context.Context, c client.Client) {
416-
tools, err := c.ListTools(ctx)
416+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
417417
if err != nil {
418418
log.Printf("Failed to list tools: %v", err)
419419
return
@@ -426,7 +426,7 @@ func suggestAlternativeTools(ctx context.Context, c client.Client) {
426426
}
427427

428428
func showToolSchema(ctx context.Context, c client.Client, toolName string) {
429-
tools, err := c.ListTools(ctx)
429+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
430430
if err != nil {
431431
log.Printf("Failed to list tools: %v", err)
432432
return
@@ -632,7 +632,7 @@ func (chm *ClientHealthMonitor) checkHealth(ctx context.Context) {
632632
defer cancel()
633633

634634
// Try to list tools as a health check
635-
_, err := chm.client.ListTools(ctx)
635+
_, err := chm.client.ListTools(ctx, mcp.ListToolsRequest{})
636636

637637
chm.mutex.Lock()
638638
chm.healthy = (err == nil)

www/docs/pages/clients/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func main() {
5353

5454
func demonstrateClientOperations(ctx context.Context, c client.Client) error {
5555
// List available tools
56-
tools, err := c.ListTools(ctx)
56+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
5757
if err != nil {
5858
return fmt.Errorf("failed to list tools: %w", err)
5959
}
@@ -64,7 +64,7 @@ func demonstrateClientOperations(ctx context.Context, c client.Client) error {
6464
}
6565

6666
// List available resources
67-
resources, err := c.ListResources(ctx)
67+
resources, err := c.ListResources(ctx, mcp.ListResourcesRequest{})
6868
if err != nil {
6969
return fmt.Errorf("failed to list resources: %w", err)
7070
}
@@ -328,7 +328,7 @@ func NewLLMApplication(mcpAddress string) (*LLMApplication, error) {
328328

329329
func (app *LLMApplication) ProcessUserQuery(ctx context.Context, query string) (string, error) {
330330
// Get available tools for the LLM
331-
tools, err := app.mcpClient.ListTools(ctx)
331+
tools, err := app.mcpClient.ListTools(ctx, mcp.ListToolsRequest{})
332332
if err != nil {
333333
return "", err
334334
}
@@ -425,7 +425,7 @@ func (msc *MultiServerClient) GetAllTools(ctx context.Context) (map[string][]mcp
425425
allTools := make(map[string][]mcp.Tool)
426426

427427
for serverName, c := range msc.clients {
428-
tools, err := c.ListTools(ctx)
428+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
429429
if err != nil {
430430
return nil, fmt.Errorf("failed to get tools from %s: %w", serverName, err)
431431
}

www/docs/pages/clients/operations.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727

2828
func listResources(ctx context.Context, c client.Client) error {
2929
// List all available resources
30-
resources, err := c.ListResources(ctx)
30+
resources, err := c.ListResources(ctx, mcp.ListResourcesRequest{})
3131
if err != nil {
3232
return fmt.Errorf("failed to list resources: %w", err)
3333
}
@@ -52,7 +52,7 @@ func listResources(ctx context.Context, c client.Client) error {
5252

5353
```go
5454
func listResourcesByType(ctx context.Context, c client.Client, mimeType string) ([]mcp.Resource, error) {
55-
resources, err := c.ListResources(ctx)
55+
resources, err := c.ListResources(ctx, mcp.ListResourcesRequest{})
5656
if err != nil {
5757
return nil, err
5858
}
@@ -68,7 +68,7 @@ func listResourcesByType(ctx context.Context, c client.Client, mimeType string)
6868
}
6969

7070
func listResourcesByPattern(ctx context.Context, c client.Client, pattern string) ([]mcp.Resource, error) {
71-
resources, err := c.ListResources(ctx)
71+
resources, err := c.ListResources(ctx, mcp.ListResourcesRequest{})
7272
if err != nil {
7373
return nil, err
7474
}
@@ -130,7 +130,7 @@ func readResource(ctx context.Context, c client.Client, uri string) (*mcp.ReadRe
130130

131131
func demonstrateResourceReading(ctx context.Context, c client.Client) {
132132
// List resources first
133-
resources, err := c.ListResources(ctx)
133+
resources, err := c.ListResources(ctx, mcp.ListResourcesRequest{})
134134
if err != nil {
135135
log.Printf("Failed to list resources: %v", err)
136136
return
@@ -324,7 +324,7 @@ func callTool(ctx context.Context, c client.Client, name string, args map[string
324324

325325
func demonstrateToolCalling(ctx context.Context, c client.Client) {
326326
// List available tools
327-
tools, err := c.ListTools(ctx)
327+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
328328
if err != nil {
329329
log.Printf("Failed to list tools: %v", err)
330330
return
@@ -427,7 +427,7 @@ func validateValue(value interface{}, schema map[string]any) error {
427427

428428
func callToolWithValidation(ctx context.Context, c client.Client, toolName string, args map[string]interface{}) (*mcp.CallToolResult, error) {
429429
// Get tool schema
430-
tools, err := c.ListTools(ctx)
430+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
431431
if err != nil {
432432
return nil, fmt.Errorf("failed to list tools: %w", err)
433433
}
@@ -551,7 +551,7 @@ func getPrompt(ctx context.Context, c client.Client, name string, args map[strin
551551

552552
func demonstratePromptUsage(ctx context.Context, c client.Client) {
553553
// List available prompts
554-
prompts, err := c.ListPrompts(ctx)
554+
prompts, err := c.ListPrompts(ctx, mcp.ListPromptsRequest{})
555555
if err != nil {
556556
log.Printf("Failed to list prompts: %v", err)
557557
return

www/docs/pages/clients/transports.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func createStdioClient() {
5656
}
5757

5858
// Use the client
59-
tools, err := c.ListTools(ctx, listToolsRequest)
59+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
6060
if err != nil {
6161
log.Fatal(err)
6262
}
@@ -300,7 +300,7 @@ func createStreamableHTTPClient() {
300300
}
301301

302302
// Use client
303-
tools, err := c.ListTools(ctx)
303+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
304304
if err != nil {
305305
log.Fatal(err)
306306
}
@@ -444,7 +444,7 @@ func createStreamableHTTPClientWithSession() {
444444

445445
ctx := context.Background()
446446
// Use client...
447-
_, err := c.ListTools(ctx)
447+
_, err := c.ListTools(ctx, mcp.ListToolsRequest{})
448448
// If the session is terminated, you must reinitialize the client
449449
if errors.Is(err, transport.ErrSessionTerminated) {
450450
c.Initialize(ctx) // Reinitialize if session is terminated
@@ -490,7 +490,7 @@ func createSSEClient() {
490490
}()
491491

492492
// Use client for regular operations
493-
tools, err := c.ListTools(ctx)
493+
tools, err := c.ListTools(ctx, mcp.ListToolsRequest{})
494494
if err != nil {
495495
log.Fatal(err)
496496
}

www/docs/pages/core-concepts.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ server.ServeStdio(s)
185185
```go
186186
// Client example - uses functionality
187187
client := client.NewStdioClient("database-server")
188-
tools, _ := client.ListTools(ctx)
188+
tools, _ := client.ListTools(ctx, mcp.ListToolsRequest{})
189189
result, _ := client.CallTool(ctx, queryRequest)
190190
```
191191

0 commit comments

Comments
 (0)