Skip to content

Commit 9bbcc41

Browse files
committed
refactor(server.py): update ShellServer to inherit from mcp.Server for better integration
refactor(server.py): rename handle_request method to handle and adjust parameters for consistency chore(pyproject.toml): update dependencies to use mcp package instead of mcp-core for improved package management
1 parent cd18746 commit 9bbcc41

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

mcp_shell_server/server.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
import os
21
import asyncio
3-
from typing import Dict, List, Optional, Any
4-
from mcp_core import MCPServer, MCPRequest
2+
from mcp import Server
53
from .shell_executor import ShellExecutor
64

7-
class ShellServer(MCPServer):
5+
6+
class ShellServer(Server):
87
def __init__(self):
98
super().__init__()
109
self.executor = ShellExecutor()
1110

12-
async def handle_request(self, request: MCPRequest) -> Dict[str, Any]:
13-
command: List[str] = request.args.get("command", [])
14-
stdin: Optional[str] = request.args.get("stdin")
15-
11+
async def handle(self, args: dict) -> dict:
12+
command = args.get("command", [])
13+
stdin = args.get("stdin")
14+
1615
if not command:
17-
return {
18-
"error": "No command provided",
19-
"status": 1
20-
}
21-
22-
result = await self.executor.execute(command, stdin)
23-
return result
16+
return {"error": "No command provided", "status": 1}
17+
18+
return await self.executor.execute(command, stdin)
19+
2420

2521
def main():
2622
server = ShellServer()
27-
server.run()
23+
server.run()

pyproject.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ authors = [
66
{ name = "tumf" }
77
]
88
dependencies = [
9-
"uvicorn>=0.27.0",
10-
"fastapi>=0.109.0",
11-
"mcp-core>=0.2.0",
9+
"mcp>=1.1.0",
1210
]
1311
requires-python = ">=3.11"
1412
readme = "README.md"
@@ -18,8 +16,5 @@ license = { text = "MIT" }
1816
requires = ["hatchling"]
1917
build-backend = "hatchling.build"
2018

21-
[tool.hatch.metadata]
22-
allow-direct-references = true
23-
2419
[project.scripts]
2520
mcp-shell-server = "mcp_shell_server.server:main"

0 commit comments

Comments
 (0)