Code-MCP

API Documentation

run_command

Execute a shell command and return its output.

Parameters

Parameter Type Required Description
command string Yes The shell command to execute

Example

run_command("ls -la")

git_operation

Execute a git operation in the project repository.

Parameters

Parameter Type Required Description
operation string Yes The git operation to perform (e.g., "status", "log", "branch")
confirm boolean No Set to true to execute operations that require confirmation (like push)

Example

git_operation("status")
git_operation("push origin main", confirm=True)

read_file

Read the contents of a file within the project directory.

Parameters

Parameter Type Required Description
file_path string Yes Path to the file (relative to project root or absolute)

Example

read_file("README.md")

edit_file

Edit a file with various operations: write, append, insert, replace, or delete.

Parameters

Parameter Type Required Description
file_path string Yes Path to the file (relative to project root or absolute)
operation string Yes Type of edit ('write', 'append', 'insert', 'replace', 'delete', 'delete_lines')
content string No Content to write, append, or insert, or replacement content
line_number integer No Line number for insert operation (1-based index)
pattern string No Pattern to find for replace or delete operations
start_line integer No First line to remove for delete_lines operation (1-based index)
end_line integer No Last line to remove for delete_lines operation (1-based index, inclusive)
confirm boolean No Set to true to execute the edit, false to preview only

Examples

edit_file("example.py", operation="write", content="print('Hello, World!')", confirm=True)
edit_file("example.py", operation="replace", pattern="Hello", content="Greetings", confirm=True)

smart_edit

Enhanced file editing with smart pattern matching and function-level operations.

Parameters

Parameter Type Required Description
file_path string Yes Path to the file (relative to project root or absolute)
operation string No Type of edit ('preview', 'update_function', 'replace', 'delete', 'append', 'write', 'edit_block')
function_name string No Target function name for function-level operations
pattern string No Pattern to find (with flexible whitespace matching)
new_content string No New content to insert/replace
regex_mode boolean No Enable regex pattern matching
context_lines integer No Number of context lines to show in previews
confirm boolean No Set to true to execute the edit, false to preview only
edit_format string No Format for edits ('search_replace', 'unified_diff', 'whole_file') when using edit_block operation
fuzzy_match boolean No Enable fuzzy matching for more flexible pattern matching
match_indent boolean No Account for indentation differences when matching patterns

Examples

smart_edit("app.py", operation="preview", function_name="process_data")
smart_edit("app.py", operation="update_function", function_name="process_data", new_content="def process_data(data):\n # Updated implementation\n if data is None:\n return {}\n return data", confirm=True)

edit_block

Process edit blocks to modify code across multiple files.

Parameters

Parameter Type Required Description
edit_content string Yes Text containing edit blocks in either search/replace or unified diff format
confirm boolean No Set to true to execute the edits, false to preview only

Example with Search/Replace Format

edit_block("""app.py <<<<<<< SEARCH def get_data(): return {"status": "ok"} ======= def get_data(): return {"status": "ok", "version": "1.0"} >>>>>>> REPLACE """, confirm=True)

list_directory

List the contents of a directory within the project in a tree-like format.

Parameters

Parameter Type Required Description
dir_path string No Path to the directory (relative to project root or absolute, empty for project root)
max_depth integer No Maximum depth for the directory tree (default: 10)

Example

list_directory("src", max_depth=2)

create_directory

Create a directory within the project.

Parameters

Parameter Type Required Description
dir_path string Yes Path to the directory to create (relative to project root or absolute)

Example

create_directory("new_folder/subfolder")

delete_path

Delete a file or directory within the project.

Parameters

Parameter Type Required Description
path_to_delete string Yes Path to delete (relative to project root or absolute)
confirm boolean No Set to true to execute the deletion, false to preview only

Example

delete_path("temp_file.txt", confirm=True)
← Back to Home