mle-kit-mcp 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mle_kit_mcp/tools/bash.py CHANGED
@@ -67,7 +67,7 @@ signal.signal(signal.SIGINT, cleanup_container)
67
67
  signal.signal(signal.SIGTERM, cleanup_container)
68
68
 
69
69
 
70
- def bash(command: str) -> str:
70
+ def bash(command: str, cwd: Optional[str] = None) -> str:
71
71
  """
72
72
  Run commands in a bash shell.
73
73
  When invoking this tool, the contents of the "command" parameter does NOT need to be XML-escaped.
@@ -80,12 +80,16 @@ def bash(command: str) -> str:
80
80
 
81
81
  Args:
82
82
  command: The bash command to run.
83
+ cwd: The working directory to run the command in. Relative to the workspace directory.
83
84
  """
84
85
 
85
86
  container = get_container()
87
+ workdir = DOCKER_WORKSPACE_DIR_PATH
88
+ if cwd:
89
+ workdir = DOCKER_WORKSPACE_DIR_PATH + "/" + cwd
86
90
  result = container.exec_run(
87
91
  ["bash", "-c", command],
88
- workdir=DOCKER_WORKSPACE_DIR_PATH,
92
+ workdir=workdir,
89
93
  stdout=True,
90
94
  stderr=True,
91
95
  )
@@ -50,17 +50,23 @@ def _insert(path: Path, insert_line: int, new_str: str) -> str:
50
50
  return truncate_content(new_content, WRITE_MAX_OUTPUT_LENGTH, target_line=insert_line)
51
51
 
52
52
 
53
- def _str_replace(path: Path, old_str: str, new_str: str) -> str:
53
+ def _str_replace(path: Path, old_str: str, new_str: str, dry_run: bool = False) -> str:
54
54
  assert path.is_file(), f"File not found: {path}"
55
55
  content = path.open().read()
56
56
  count = content.count(old_str)
57
57
  assert count != 0, "old_str not found in file"
58
58
  assert count == 1, "old_str is not unique in file"
59
59
  target_line = content[: content.find(old_str) + len(old_str)].count("\n")
60
- _save_file_state(path, content.splitlines(True))
61
60
  new_content = content.replace(old_str, new_str)
62
- path.write_text(new_content)
63
- return truncate_content(new_content, WRITE_MAX_OUTPUT_LENGTH, target_line=target_line)
61
+ if not dry_run:
62
+ _save_file_state(path, content.splitlines(True))
63
+ path.write_text(new_content)
64
+ display_content = truncate_content(
65
+ new_content, WRITE_MAX_OUTPUT_LENGTH, target_line=target_line
66
+ )
67
+ if dry_run:
68
+ display_content = f"Dry run:\n{display_content}"
69
+ return display_content
64
70
 
65
71
 
66
72
  def _undo_edit(path: Path) -> str:
@@ -129,6 +135,7 @@ def text_editor(
129
135
  view_start_line: Optional[int] = None,
130
136
  view_end_line: Optional[int] = None,
131
137
  show_lines: Optional[bool] = False,
138
+ dry_run: Optional[bool] = False,
132
139
  ) -> str:
133
140
  """
134
141
  Custom editing tool for viewing, creating and editing files.
@@ -167,6 +174,7 @@ def text_editor(
167
174
  new_str: Required for `str_replace`, `insert` and `append`.
168
175
  old_str: Required for `str_replace` containing the string in `path` to replace.
169
176
  show_lines: Optional for view command. If True, the command will also output line numbers.
177
+ dry_run: Optional for `str_replace` command. If True, the command won't modify the file but will display the result.
170
178
  """
171
179
  assert not path.startswith(
172
180
  "/"
@@ -191,7 +199,8 @@ def text_editor(
191
199
  if command == "str_replace":
192
200
  assert old_str is not None, "'old_str' is required for 'str_replace' command"
193
201
  assert new_str is not None, "'new_str' is required for 'str_replace' command"
194
- return _str_replace(path_obj, old_str, new_str)
202
+ assert dry_run is not None
203
+ return _str_replace(path_obj, old_str, new_str, dry_run=dry_run)
195
204
  if command == "undo_edit":
196
205
  return _undo_edit(path_obj)
197
206
  assert False, f"Not a valid command! List of commands: {valid_commands}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mle-kit-mcp
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: MCP server that provides different tools for MLE
5
5
  Author-email: Ilya Gusev <phoenixilya@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/IlyaGusev/mle_kit_mcp
@@ -6,13 +6,13 @@ mle_kit_mcp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  mle_kit_mcp/server.py,sha256=W4YJ3m1-NKheJ5QlGggfMQyXPghzKgg5zXqb-TLYH1U,1271
7
7
  mle_kit_mcp/utils.py,sha256=iHNcEZZzPD37bEYE18SzJ3WUjLP3Ym-kc91SwcW1vlI,1984
8
8
  mle_kit_mcp/tools/__init__.py,sha256=r2fIg2mZ6zaeq0CzEKCEdeUTjV0pcA9NZaaOfBNVTnE,332
9
- mle_kit_mcp/tools/bash.py,sha256=9YmwRCR2HHTJ6Jhnn-fHuLRkDjsHo9m26tpdXoGCFtQ,2608
9
+ mle_kit_mcp/tools/bash.py,sha256=kunYHc3dyPGOooT-KY9L7eI_N22lBrcDbTlcp_yTTws,2820
10
10
  mle_kit_mcp/tools/llm_proxy.py,sha256=9tm3k1R5y9o6Z4nkZXwILkYt6Ludc_TnQSwRw0KcNHA,5312
11
11
  mle_kit_mcp/tools/remote_gpu.py,sha256=Fv8SJC8bE3Oo8JHOKXoYpISXFMzUMFjEcCQOTyW7V1I,11544
12
- mle_kit_mcp/tools/text_editor.py,sha256=EJ832vgdFdycrLOf3eOYMXnlMgB2_iH_u4ANvZVrMsE,9139
13
- mle_kit_mcp-0.1.0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
14
- mle_kit_mcp-0.1.0.dist-info/METADATA,sha256=aNQJCc6kZW4IaOvKi7KrxPJ0NqQgnFCmQqVk1uJ3yTg,1011
15
- mle_kit_mcp-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- mle_kit_mcp-0.1.0.dist-info/entry_points.txt,sha256=-iHSUVPN49jkBj1ySpc-P0rVF5-IPHw-KWNayNIiEsk,49
17
- mle_kit_mcp-0.1.0.dist-info/top_level.txt,sha256=XeBtCq_CnVI0gh0Z_daZOLmGl5XPlkA8RgHaj5s5VQY,12
18
- mle_kit_mcp-0.1.0.dist-info/RECORD,,
12
+ mle_kit_mcp/tools/text_editor.py,sha256=0uGcSjcBjdPlqjYZYuWo29SmAMzBcWgKt4KRumFI3WE,9529
13
+ mle_kit_mcp-0.1.1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
14
+ mle_kit_mcp-0.1.1.dist-info/METADATA,sha256=FSfrW1_RnJTwVoreVEXP95GxxX4iGNr65ll2ry5o1a4,1011
15
+ mle_kit_mcp-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
+ mle_kit_mcp-0.1.1.dist-info/entry_points.txt,sha256=-iHSUVPN49jkBj1ySpc-P0rVF5-IPHw-KWNayNIiEsk,49
17
+ mle_kit_mcp-0.1.1.dist-info/top_level.txt,sha256=XeBtCq_CnVI0gh0Z_daZOLmGl5XPlkA8RgHaj5s5VQY,12
18
+ mle_kit_mcp-0.1.1.dist-info/RECORD,,