-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtools.py
More file actions
407 lines (404 loc) · 15.6 KB
/
Copy pathtools.py
File metadata and controls
407 lines (404 loc) · 15.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#!/usr/bin/env python3
"""Tool definitions for the MCP file server."""
from models import Tool
def get_tool_definitions():
"""Return the list of tools that the server supports."""
return [
Tool(
name="read_file",
description="Read the contents of a file inside the working directory. Use binary=True to read binary files (returns base64-encoded content).",
input_schema={
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "File path to read (relative to the working directory)",
},
"binary": {
"type": "boolean",
"description": "Whether to read the file as binary data (returns base64-encoded content)",
"default": False
}
},
"required": ["path"],
},
),
Tool(
name="write_file",
description="Write content to a file inside the working directory. Use binary=True to write binary data (content should be base64-encoded).",
input_schema={
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "File path to write (relative to the working directory)",
},
"content": {"type": "string", "description": "Content to write (text or base64-encoded binary data)"},
"binary": {
"type": "boolean",
"description": "Whether the content is binary data (base64-encoded)",
"default": False
}
},
"required": ["path", "content"],
},
),
Tool(
name="list_files",
description="List files inside the working directory with optional extension filtering and recursion control.",
input_schema={
"type": "object",
"properties": {
"extensions": {
"type": "array",
"items": {"type": "string"},
"description": "Optional list of file extensions to filter by (e.g., ['.py', '.txt']). If empty or omitted, all files are included."
},
"recursive": {
"type": "boolean",
"description": "Whether to search recursively in subdirectories (default: true)",
"default": True
},
"show_empty_dirs": {
"type": "boolean",
"description": "Whether to show directories that contain no files (either truly empty or containing no files matching the extension filter) (default: true)",
"default": True
}
}
},
),
Tool(
name="create_directory",
description="Create a new sub‑directory inside the working directory.",
input_schema={
"type": "object",
"properties": {
"path": {"type": "string", "description": "Directory path to create"}
},
"required": ["path"],
},
),
Tool(
name="delete_file",
description="Delete a file inside the working directory.",
input_schema={
"type": "object",
"properties": {
"path": {"type": "string", "description": "Path of the file to delete"}
},
"required": ["path"],
},
),
Tool(
name="delete_directory",
description="Delete a directory and all its contents inside the working directory.",
input_schema={
"type": "object",
"properties": {
"path": {"type": "string", "description": "Path of the directory to delete"},
"force": {
"type": "boolean",
"description": "Force deletion even if directory is not empty",
"default": False
}
},
"required": ["path"],
},
),
Tool(
name="search_in_file",
description="Search for a string in a file or recursively in all files within a directory and return text excerpts around each occurrence. When path is a directory, searches through all files in the directory and its subdirectories. Useful for large files where you only need relevant sections.",
input_schema={
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "File or directory path to search in (relative to the working directory). When a directory is provided, searches recursively in all files within it."
},
"search_string": {
"type": "string",
"description": "String to search for in the file(s)"
},
"context_lines": {
"type": "integer",
"description": "Number of lines to include before and after each match (default: 3)",
"default": 3
},
"case_sensitive": {
"type": "boolean",
"description": "Whether the search should be case-sensitive (default: false)",
"default": False
},
"max_matches": {
"type": "integer",
"description": "Maximum number of matches to return per file (default: 50)",
"default": 50
}
},
"required": ["path", "search_string"],
},
),
Tool(
name="git_status",
description="Show the working tree status. Returns a short summary of changes in the repository.",
input_schema={
"type": "object",
"properties": {
"short": {
"type": "boolean",
"description": "Use short format output (default: true)",
"default": True
}
},
},
),
Tool(
name="git_log",
description="Show commit log history. Displays commits in a compact format.",
input_schema={
"type": "object",
"properties": {
"max_count": {
"type": "integer",
"description": "Maximum number of commits to show (default: 20)",
"default": 20
},
"oneline": {
"type": "boolean",
"description": "Show compact one-line format (default: true)",
"default": True
}
},
},
),
Tool(
name="git_checkout",
description="Switch to a different branch or commit.",
input_schema={
"type": "object",
"properties": {
"branch": {
"type": "string",
"description": "Branch name or commit hash to checkout"
}
},
"required": ["branch"],
},
),
Tool(
name="git_branch_create",
description="Create a new branch.",
input_schema={
"type": "object",
"properties": {
"branch": {
"type": "string",
"description": "Name of the new branch"
},
"start_point": {
"type": "string",
"description": "Starting point (branch or commit) for the new branch"
}
},
"required": ["branch"],
},
),
Tool(
name="git_branch_delete",
description="Delete a branch.",
input_schema={
"type": "object",
"properties": {
"branch": {
"type": "string",
"description": "Name of the branch to delete"
},
"force": {
"type": "boolean",
"description": "Force deletion even if branch has unmerged changes (default: false)",
"default": False
}
},
"required": ["branch"],
},
),
Tool(
name="git_branch_list",
description="List all branches in the repository.",
input_schema={
"type": "object",
"properties": {
"all": {
"type": "boolean",
"description": "List both local and remote branches (default: false)",
"default": False
}
},
},
),
Tool(
name="git_add",
description="Add file contents to the staging area.",
input_schema={
"type": "object",
"properties": {
"paths": {
"type": "array",
"items": {"type": "string"},
"description": "List of file paths to add"
}
},
"required": ["paths"],
},
),
Tool(
name="git_commit",
description="Record changes to the repository.",
input_schema={
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "Commit message"
},
"all": {
"type": "boolean",
"description": "Automatically stage all modified and deleted files (default: false)",
"default": False
}
},
"required": ["message"],
},
),
Tool(
name="git_push",
description="Push changes to a remote repository.",
input_schema={
"type": "object",
"properties": {
"remote": {
"type": "string",
"description": "Remote repository name (default: origin)",
"default": "origin"
},
"branch": {
"type": "string",
"description": "Branch to push (default: current branch)"
}
},
},
),
Tool(
name="git_pull",
description="Fetch from and integrate with a remote repository.",
input_schema={
"type": "object",
"properties": {
"remote": {
"type": "string",
"description": "Remote repository name (default: origin)",
"default": "origin"
},
"branch": {
"type": "string",
"description": "Branch to pull (default: current branch)"
}
},
},
),
Tool(
name="git_diff",
description="Show changes between commits, commit and working tree, etc.",
input_schema={
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Specific file or directory to show diff for"
}
},
},
),
Tool(
name="git_clone",
description="Clone a repository into a new directory. Use with caution - will overwrite existing directories.",
input_schema={
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL of the repository to clone (HTTPS or SSH)"
},
"path": {
"type": "string",
"description": "Directory name where the repository will be cloned (relative to working directory)"
},
"branch": {
"type": "string",
"description": "Specific branch to checkout after cloning"
},
"recursive": {
"type": "boolean",
"description": "Clone submodules recursively (default: false)",
"default": False
}
},
"required": ["url", "path"],
},
),
Tool(
name="git_submodule_add",
description="Add a submodule to the repository.",
input_schema={
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL of the repository to add as submodule"
},
"path": {
"type": "string",
"description": "Path where the submodule will be placed"
},
"name": {
"type": "string",
"description": "Name for the submodule (optional, defaults to path)"
}
},
"required": ["url", "path"],
},
),
Tool(
name="git_submodule_update",
description="Update existing submodules.",
input_schema={
"type": "object",
"properties": {
"init": {
"type": "boolean",
"description": "Initialize submodules before updating (default: true)",
"default": True
},
"recursive": {
"type": "boolean",
"description": "Update submodules recursively (default: true)",
"default": True
}
},
},
),
Tool(
name="git_submodule_list",
description="List all submodules in the repository.",
input_schema={
"type": "object",
"properties": {
"summary": {
"type": "boolean",
"description": "Show summary of submodule status (default: true)",
"default": True
}
},
},
),
]