Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion dev_kit_mcp_server/core/base_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ def docstring(self) -> str:

@property
@abc.abstractmethod
def _name(self) -> str:
"""Return the base name of the operation."""

@property
def name(self) -> str:
"""Return the name of the operation."""
"""Return the name of the operation with git/foldername prefix."""
folder_name = self._root_path.name
return f"git/{folder_name}/{self._name}"

@classmethod
def get_absolute_path(cls, root_path: Path, path: str) -> Path:
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/commands/make_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ExecMakeTarget(_BaseExec):

_make_file_exists: bool = field(init=False, default=False)

name = "exec_make_target"
_name = "exec_make_target"

def __post_init__(self) -> None:
"""Post-initialization to set the root path."""
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/commands/predefined.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PredefinedCommands(_BaseExec):
_pyproject_exists: bool = field(init=False, default=False)
commands_toml: Optional[str] = None

name = "predefined_commands"
_name = "predefined_commands"

# Class attribute for valid param regex
VALID_PARAM_REGEX = r"^[a-zA-Z0-9_\-\.\s\/\\:@=,]+$"
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/file_sys/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class CreateDirOperation(AsyncOperation):
"""Class to create a folder in the workspace."""

name = "create_dir"
_name = "create_dir"

def _create_folder(self, path: str) -> None:
"""Create a folder at the specified path.
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/file_sys/edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class EditFileOperation(AsyncOperation):
"""Class to edit a file in the workspace by replacing lines between start and end with new text."""

name = "edit_file"
_name = "edit_file"

def _edit_file(self, path: str, start_line: int, end_line: int, text: str) -> None:
"""Edit a file by replacing lines between start and end with new text.
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/file_sys/move.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class MoveDirOperation(AsyncOperation):
"""Class to move a file or folder in the workspace."""

name = "move_dir"
_name = "move_dir"

def _move_folder(self, path1: str, path2: str) -> None:
"""Move a file or folder from path1 to path2.
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/file_sys/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class RemoveFileOperation(AsyncOperation):
"""Class to Remove a file or folder."""

name = "remove_file"
_name = "remove_file"

def _remove_folder(self, path: str) -> None:
"""Remove a file or folder at the specified path.
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/file_sys/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class RenameOperation(AsyncOperation):
"""Class to rename a file or folder in the workspace."""

name = "rename_file"
_name = "rename_file"

def _rename_file_or_folder(self, path: str, new_name: str) -> None:
"""Rename a file or folder.
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/git/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GitAddOperation(AsyncOperation):
"""Class to add files to the git index."""

name = "git_add"
_name = "git_add"

async def __call__(
self,
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/git/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GitCheckoutOperation(AsyncOperation):
"""Class to checkout branches in a git repository."""

name = "git_checkout"
_name = "git_checkout"

async def __call__(
self,
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/git/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GitCommitOperation(AsyncOperation):
"""Class to commit changes to a git repository."""

name = "git_commit"
_name = "git_commit"

async def __call__(
self,
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/git/create_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GitCreateBranchOperation(AsyncOperation):
"""Class to create and checkout a new branch from a source branch in a git repository."""

name = "git_create_branch"
_name = "git_create_branch"

async def __call__(
self,
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/git/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GitDiffOperation(AsyncOperation):
"""Class to show diffs in a git repository."""

name = "git_diff"
_name = "git_diff"

async def __call__(
self,
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/git/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GitPullOperation(AsyncOperation):
"""Class to pull changes from a remote git repository."""

name = "git_pull"
_name = "git_pull"

async def __call__(
self,
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/git/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GitPushOperation(AsyncOperation):
"""Class to push changes to a remote git repository."""

name = "git_push"
_name = "git_push"

async def __call__(
self,
Expand Down
2 changes: 1 addition & 1 deletion dev_kit_mcp_server/tools/git/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GitStatusOperation(AsyncOperation):
"""Class to get the status of a git repository."""

name = "git_status"
_name = "git_status"

async def __call__(
self,
Expand Down
8 changes: 4 additions & 4 deletions tests/test_fastmcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ async def test_tool_functionality(fastmcp_server):
result = await client.list_tools()
list_tools = [tool.name for tool in result]
assert len(result) == len(__all__)
assert "move_dir" in list_tools
assert any(tool.endswith("/move_dir") for tool in list_tools)
# Find the make command by name
assert "exec_make_target" in list_tools
make_cmd = [tool for tool in result if tool.name == "exec_make_target"][0]
assert any(tool.endswith("/exec_make_target") for tool in list_tools)
make_cmd = [tool for tool in result if tool.name.endswith("/exec_make_target")][0]

res = await client.call_tool(make_cmd.name, {"commands": ["ls"]})
text = res[0].text
Expand All @@ -40,7 +40,7 @@ async def test_tool_functionality(fastmcp_server):
@pytest.mark.asyncio
async def test_encoding_error(fastmcp_server):
async with Client(fastmcp_server) as client:
make_cmd = [tool for tool in await client.list_tools() if tool.name == "exec_make_target"][0]
make_cmd = [tool for tool in await client.list_tools() if tool.name.endswith("/exec_make_target")][0]
res = await client.call_tool(make_cmd.name, {"commands": ["encoding-error"]})
# Check that the result contains the expected error message
assert "encoding-error" in res[0].text
Expand Down
5 changes: 4 additions & 1 deletion tests/test_fastmcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ def test_start_server(mock_parse_args, root_dir_type, expected_error, temp_dir):
# Check that the tools were registered
tools = asyncio.run(server.get_tools())
tool_names = [tool.name for tool in tools.values()]
assert all(name in tool_names for name in ["create_dir", "move_dir", "remove_file"])
assert all(
any(tool_name.endswith(f"/{name}") for tool_name in tool_names)
for name in ["create_dir", "move_dir", "remove_file"]
)


@pytest.mark.parametrize(
Expand Down
4 changes: 2 additions & 2 deletions tests/tools/test_commands_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async def test_exec_make_target_init(temp_dir):
mock_exists.side_effect = [True, True]
tool = ExecMakeTarget(root_dir=temp_dir)
assert tool._make_file_exists is True
assert tool.name == "exec_make_target"
assert tool.name.endswith("/exec_make_target")


@pytest.mark.asyncio
Expand Down Expand Up @@ -191,7 +191,7 @@ async def test_predefined_commands_init(temp_dir):
tool = PredefinedCommands(root_dir=temp_dir)
assert tool._pyproject_exists is True
assert tool._commands_config == {"test": "pytest", "lint": "ruff check"}
assert tool.name == "predefined_commands"
assert tool.name.endswith("/predefined_commands")


@pytest.mark.asyncio
Expand Down