Remove 'replace_line_range' tool from filesystem MCP server and mock server

This commit is contained in:
Cheikh Seck committed 2026-06-05 21:48:03 +00:00
1 parent a64e0ac7b5
commit 9a3ed0c06a
4 files changed
+1 -98

No files matched your search

+1 -1
View File
@@ -47,7 +47,7 @@ The server exposes a subset of GoDex’s filesystem tools, including:
- `create_directory`, `delete_file`
- `search_files`, `search_in_file`, `search_directory_text`, `search_file_text`
- `get_file_info`, `read_file_line_range`
- `replace_first_in_file`, `replace_line_range`, `insert_at_line`
- `replace_first_in_file`, `insert_at_line`
- `list_allowed_paths`
## Add to OpenCode
-10
View File
@@ -172,16 +172,6 @@ func serveFilesystemMCP(baseAllowedPaths []string, autoConfirm bool, useRoots bo
},
Required: []string{"path", "find", "replace"},
})
addProxyTool("replace_line_range", "Replace a range of lines in a file.", mcplib.ToolInputSchema{
Type: "object",
Properties: map[string]any{
"path": map[string]any{"type": "string", "description": "File path."},
"start": map[string]any{"type": "number", "description": "Start line number (1-indexed)."},
"end": map[string]any{"type": "number", "description": "End line number (inclusive)."},
"new_content": map[string]any{"type": "string", "description": "New content to insert at the deleted location."},
},
Required: []string{"path", "start", "end", "new_content"},
})
addProxyTool("insert_at_line", "Insert content at a specific line number.", mcplib.ToolInputSchema{
Type: "object",
Properties: map[string]any{
-26
View File
@@ -89,15 +89,6 @@ DYNO_TOOL_CALL_BATCHES = [
"content": "inserted line",
},
},
{
"name": "replace_line_range",
"arguments": {
"path": "/dyno/workspace/example_dir/example.txt",
"start_line": 2,
"end_line": 2,
"new_content": "replaced second line",
},
},
{
"name": "search_directory_text",
"arguments": {"path": "/dyno/workspace", "query": "replaced second line"},
@@ -324,23 +315,6 @@ SYSTEM_TOOLS = [
}
}
},
{
"type": "function",
"function": {
"name": "replace_line_range",
"description": "Replace a range of lines in a file",
"parameters": {
"type": "object",
"properties": {
"path": {"type": "string", "description": "File path"},
"start": {"type": "integer", "description": "Start line"},
"end": {"type": "integer", "description": "End line"},
"new": {"type": "string", "description": "New content"}
},
"required": ["path", "start", "end", "new"]
}
}
},
{
"type": "function",
"function": {
-61
View File
@@ -106,11 +106,6 @@ func NewFileSystemServer(allowedPaths []string, autoConfirm bool) *FileSystemSer
Description: "Replace the first occurrence of a text string in a file",
InputSchema: json.RawMessage(`{"type":"object","properties":{"path":{"type":"string","description":"Absolute path to the file"},"find":{"type":"string","description":"Text to find (plain string, not regex)"},"replace":{"type":"string","description":"Replacement text"}},"required":["path","find","replace"]}`),
},
{
Name: "replace_line_range",
Description: "Delete a range of lines and insert new content at that location in a file",
InputSchema: json.RawMessage(`{"type":"object","properties":{"path":{"type":"string","description":"Absolute path to the file"},"start":{"type":"integer","description":"Start line number (1-indexed)"},"end":{"type":"integer","description":"End line number (inclusive)"},"new_content":{"type":"string","description":"New content to insert at the deleted location"},"start_line":{"type":"integer","description":"Alias for start"},"end_line":{"type":"integer","description":"Alias for end"}},"required":["path","start","end","new_content"]}`),
},
{
Name: "insert_at_line",
Description: "Insert content at a specific line number",
@@ -171,8 +166,6 @@ func (s *FileSystemServer) CallTool(ctx context.Context, name string, arguments
return s.readFileLineRange(arguments)
case "replace_first_in_file":
return s.replaceFirstInFile(arguments)
case "replace_line_range":
return s.replaceLineRange(arguments)
case "insert_at_line":
return s.insertAtLine(arguments)
case "search_file_text":
@@ -547,60 +540,6 @@ func (s *FileSystemServer) replaceFirstInFile(args map[string]interface{}) (stri
return fmt.Sprintf("Replaced first occurrence of %s in %s", find, path), nil
}
func (s *FileSystemServer) replaceLineRange(args map[string]interface{}) (string, error) {
path, ok := args["path"].(string)
if !ok {
return "", fmt.Errorf("path is required")
}
if err := s.checkAndMaybeAddPath(path); err != nil {
return "", err
}
content, err := os.ReadFile(path)
if err != nil {
return "", fmt.Errorf("failed to read file: %w", err)
}
lines := strings.Split(string(content), "\n")
start, ok := getIntArg(args, "start", "start_line")
if !ok {
return "", fmt.Errorf("start is required")
}
end, ok := getIntArg(args, "end", "end_line")
if !ok {
return "", fmt.Errorf("end is required")
}
newContent, ok := args["new_content"].(string)
if !ok {
return "", fmt.Errorf("new_content is required")
}
startIdx := int(start) - 1
endIdx := int(end)
if startIdx < 0 || startIdx >= len(lines) {
return "", fmt.Errorf("start line out of range")
}
if endIdx < startIdx {
return "", fmt.Errorf("end line must be greater than or equal to start line")
}
if endIdx > len(lines) {
endIdx = len(lines)
}
deletedLines := endIdx - startIdx
newLines := strings.Split(newContent, "\n")
result := append(lines[:startIdx], append(newLines, lines[endIdx:]...)...)
if err := os.WriteFile(path, []byte(strings.Join(result, "\n")), 0644); err != nil {
return "", fmt.Errorf("failed to write file: %w", err)
}
return fmt.Sprintf("Replaced lines %d-%d (%d lines deleted) with %d lines in %s", int(start), int(end), deletedLines, len(newLines), path), nil
}
func (s *FileSystemServer) insertAtLine(args map[string]interface{}) (string, error) {
path, ok := args["path"].(string)
if !ok {