Skip to content

Commit 9e06324

Browse files
committed
feat(server): refactor main entry point to use asyncio for better concurrency
feat(shell_executor): add get_allowed_commands method to retrieve allowed commands fix(server): include allowed commands in tool description for better clarity chore(pyproject): update entry point in scripts to reflect new main function location chore(pyproject): add asyncio as a dependency for proper functionality
1 parent 2cef7bb commit 9e06324

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

mcp_shell_server/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
"""MCP Shell Server Package."""
22

3-
from .server import main
3+
import asyncio
44

5+
from . import server
6+
7+
8+
def main():
9+
"""Main entry point for the package."""
10+
asyncio.run(server.main())
11+
12+
13+
# Optionally expose other important items at package level
14+
__all__ = ["main", "server"]
515
__version__ = "0.1.0"
6-
__all__ = ["main"]

mcp_shell_server/server.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ class ExecuteToolHandler:
2424
def __init__(self):
2525
self.executor = ShellExecutor()
2626

27+
def get_allowed_commands(self) -> list[str]:
28+
"""Get the allowed commands"""
29+
return self.executor.get_allowed_commands()
30+
2731
def get_tool_description(self) -> Tool:
2832
"""Get the tool description for the execute command"""
2933
return Tool(
3034
name=self.name,
31-
description=self.description,
35+
description=f"{self.description}\nAllowed commands: {', '.join(self.get_allowed_commands())}",
3236
inputSchema={
3337
"type": "object",
3438
"properties": {
@@ -101,6 +105,7 @@ async def call_tool(name: str, arguments: Any) -> Sequence[TextContent]:
101105

102106
async def main() -> None:
103107
"""Main entry point for the MCP shell server"""
108+
logger.info("Starting MCP shell server")
104109
try:
105110
from mcp.server.stdio import stdio_server
106111

mcp_shell_server/shell_executor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def _validate_command(self, command: List[str]) -> None:
7474
f"Command not allowed after {cleaned_arg}: {next_cmd}"
7575
)
7676

77+
def get_allowed_commands(self) -> list[str]:
78+
"""Get the allowed commands"""
79+
return list(self._get_allowed_commands())
80+
7781
async def execute(
7882
self, command: List[str], stdin: Optional[str] = None
7983
) -> Dict[str, Any]:

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ authors = [
77
{ name = "tumf" }
88
]
99
dependencies = [
10+
"asyncio>=3.4.3",
1011
"mcp>=1.1.0",
1112
]
1213
requires-python = ">=3.11"
1314
readme = "README.md"
1415
license = { text = "MIT" }
1516

1617
[project.scripts]
17-
mcp-shell-server = "mcp_shell_server.server:main"
18+
mcp-shell-server = "mcp_shell_server:main"
1819

1920
[project.optional-dependencies]
2021
test = [

uv.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)