Skip to content

Commit 6801312

Browse files
committed
refactor(server.py): remove inheritance from Server class and use stdio_server for handling connections to simplify the code structure
bump(dependencies): update mcp dependency version to 1.1.1 for compatibility and improvements chore(pyproject.toml): add optional dependencies for testing and define pytest plugins in conftest.py for better test organization
1 parent 7b9cf38 commit 6801312

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

mcp_shell_server/server.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import asyncio
2-
from mcp import Server
1+
from mcp.server.stdio import stdio_server
32
from .shell_executor import ShellExecutor
43

54

6-
class ShellServer(Server):
5+
class ShellServer:
76
def __init__(self):
8-
super().__init__()
97
self.executor = ShellExecutor()
108

119
async def handle(self, args: dict) -> dict:
@@ -20,4 +18,4 @@ async def handle(self, args: dict) -> dict:
2018

2119
def main():
2220
server = ShellServer()
23-
server.run()
21+
stdio_server(server.handle)

pyproject.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ authors = [
66
{ name = "tumf" }
77
]
88
dependencies = [
9-
"mcp>=1.1.0",
9+
"mcp>=1.1.1",
1010
]
1111
requires-python = ">=3.11"
1212
readme = "README.md"
1313
license = { text = "MIT" }
1414

15+
[project.scripts]
16+
mcp-shell-server = "mcp_shell_server.server:main"
17+
18+
[project.optional-dependencies]
19+
test = [
20+
"pytest>=7.4.0",
21+
"pytest-asyncio>=0.23.0",
22+
"pytest-env>=1.1.0",
23+
]
24+
1525
[build-system]
1626
requires = ["hatchling"]
1727
build-backend = "hatchling.build"
18-
19-
[project.scripts]
20-
mcp-shell-server = "mcp_shell_server.server:main"

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import pytest
2+
3+
pytest_plugins = ('pytest_asyncio',)

0 commit comments

Comments
 (0)