(singleTenant bool)
| 609 | } |
| 610 | |
| 611 | func createEnvironmentFileReadTool(singleTenant bool) *Tool { |
| 612 | return &Tool{ |
| 613 | Definition: newEnvironmentTool( |
| 614 | envToolOptions{ |
| 615 | name: "environment_file_read", |
| 616 | description: "Read the contents of a file, specifying a line range or the entire file.", |
| 617 | useCurrentEnvironment: singleTenant, |
| 618 | }, |
| 619 | mcp.WithString("target_file", |
| 620 | mcp.Description("Path of the file to read, absolute or relative to the workdir"), |
| 621 | mcp.Required(), |
| 622 | ), |
| 623 | mcp.WithBoolean("should_read_entire_file", |
| 624 | mcp.Description("Whether to read the entire file. Defaults to false."), |
| 625 | ), |
| 626 | mcp.WithNumber("start_line_one_indexed_inclusive", |
| 627 | mcp.Description("The starting line (1-indexed, inclusive) to read from the file. Must specify both start_line and end_line if not reading entire file."), |
| 628 | ), |
| 629 | mcp.WithNumber("end_line_one_indexed_inclusive", |
| 630 | mcp.Description("The ending line (1-indexed, inclusive) to read from the file. Must specify both start_line and end_line if not reading entire file."), |
| 631 | ), |
| 632 | ), |
| 633 | Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { |
| 634 | _, env, err := openEnvironment(ctx, request) |
| 635 | if err != nil { |
| 636 | return nil, err |
| 637 | } |
| 638 | |
| 639 | targetFile, err := request.RequireString("target_file") |
| 640 | if err != nil { |
| 641 | return nil, err |
| 642 | } |
| 643 | |
| 644 | shouldReadEntireFile := request.GetBool("should_read_entire_file", false) |
| 645 | startLineOneIndexedInclusive := request.GetInt("start_line_one_indexed_inclusive", 0) |
| 646 | endLineOneIndexedInclusive := request.GetInt("end_line_one_indexed_inclusive", 0) |
| 647 | |
| 648 | fileContents, err := env.FileRead(ctx, targetFile, shouldReadEntireFile, startLineOneIndexedInclusive, endLineOneIndexedInclusive) |
| 649 | if err != nil { |
| 650 | return nil, fmt.Errorf("failed to read file: %w", err) |
| 651 | } |
| 652 | |
| 653 | return mcp.NewToolResultText(fileContents), nil |
| 654 | }, |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | func createEnvironmentFileListTool(singleTenant bool) *Tool { |
| 659 | return &Tool{ |
no test coverage detected