Skip to content

Commit 6168041

Browse files
committed
Add configuration files and improve project structure
- Introduced .codecov.yml for coverage reporting configuration. - Updated .gitignore to include serena cache and prompt.md. - Added Dockerfile for containerized deployment. - Created LICENSE file with MIT License. - Enhanced Makefile with new install-pre-commit target and improved coverage command. - Updated pyproject.toml to specify development dependencies. - Added README sections for installation and usage via Smithery. - Created .serena configuration and memory files for project management. - Added additional tests for ProcessManager and ShellExecutor to improve coverage.
1 parent f86e1e0 commit 6168041

29 files changed

+1840
-294
lines changed

.codecov.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 70%
6+
patch:
7+
default:
8+
target: 70%

.githooks/pre-commit

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
set -e
3+
4+
echo "[pre-commit] Running checks (prefer uv)..."
5+
if command -v uv >/dev/null 2>&1; then
6+
echo "[pre-commit] using uv to run make check"
7+
uv run make check || { echo "[pre-commit] uv run make check failed"; exit 1; }
8+
else
9+
echo "[pre-commit] uv not found; falling back to make check"
10+
if command -v make >/dev/null 2>&1; then
11+
make check || { echo "[pre-commit] make check failed"; exit 1; }
12+
else
13+
echo "[pre-commit] neither uv nor make available to run checks"; exit 1
14+
fi
15+
fi
16+
17+
echo "[pre-commit] Running coverage (prefer uv)..."
18+
if command -v uv >/dev/null 2>&1; then
19+
echo "[pre-commit] using uv to run make coverage"
20+
uv run make coverage || { echo "[pre-commit] uv run make coverage failed"; exit 1; }
21+
else
22+
echo "[pre-commit] uv not found; falling back to make coverage"
23+
if command -v make >/dev/null 2>&1; then
24+
make coverage || { echo "[pre-commit] make coverage failed"; exit 1; }
25+
else
26+
echo "[pre-commit] neither uv nor make available to run coverage"; exit 1
27+
fi
28+
fi
29+
30+
exit 0

.github/workflows/publish.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
python-version: ["3.11"]
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@v5
1717

1818
- name: Set up Python ${{ matrix.python-version }}
1919
uses: actions/setup-python@v5
@@ -42,7 +42,7 @@ jobs:
4242
id-token: write
4343

4444
steps:
45-
- uses: actions/checkout@v4
45+
- uses: actions/checkout@v5
4646

4747
- name: Update version from tag
4848
run: |
@@ -69,4 +69,3 @@ jobs:
6969
uses: pypa/gh-action-pypi-publish@release/v1
7070
with:
7171
password: ${{ secrets.PYPI_TOKEN }}
72-
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
python-version: ["3.11"]
1515

1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v5
1818

1919
- name: Set up Python ${{ matrix.python-version }}
2020
uses: actions/setup-python@v5

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,6 @@ share/python-wheels/
7777
*.egg
7878
MANIFEST
7979

80-
prompt.md
80+
prompt.md
81+
# Ignore serena cache
82+
.serena/cache/

.serena/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/cache
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# コードスタイル・規約
2+
3+
## フォーマット
4+
- **black**: 88文字行長、Python 3.11対応
5+
- **isort**: blackプロファイル、88文字行長
6+
7+
## リンター設定(ruff)
8+
- **有効ルール**:
9+
- E(pycodestyle エラー)
10+
- F(pyflakes)
11+
- W(pycodestyle 警告)
12+
- I(isort)
13+
- C(comprehensions)
14+
- B(bugbear)
15+
- **無効ルール**:
16+
- E501(行長制限 - blackで処理)
17+
- B008(引数デフォルトでの関数呼び出し)
18+
- C901(複雑さ制限)
19+
20+
## 型ヒント
21+
- mypy による型チェック必須
22+
- src/ および tests/ ディレクトリ対象
23+
24+
## ドキュメント
25+
- 関数・クラスに詳細docstring
26+
- Google/Numpyスタイルのdocstring
27+
- 型情報とRaises情報を含む
28+
29+
## 命名規則
30+
- クラス名: PascalCase(例:ExecuteToolHandler)
31+
- 関数・変数名: snake_case(例:validate_directory)
32+
- 定数: UPPER_SNAKE_CASE(例:ALLOW_COMMANDS)
33+
- プライベート: アンダースコア接頭辞(例:_processes)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# コードベース構造
2+
3+
## ディレクトリ構成
4+
```
5+
mcp-shell-server/
6+
├── src/mcp_shell_server/ # メインソースコード
7+
├── tests/ # テストファイル
8+
├── .github/ # GitHub Actions設定
9+
├── .serena/ # Serena MCP設定
10+
└── [設定ファイル群]
11+
```
12+
13+
## メインモジュール構成
14+
```
15+
src/mcp_shell_server/
16+
├── __init__.py # パッケージエントリポイント
17+
├── version.py # バージョン情報
18+
├── server.py # MCPサーバーメイン実装
19+
├── shell_executor.py # シェルコマンド実行エンジン
20+
├── command_validator.py # コマンド検証ロジック
21+
├── command_preprocessor.py # コマンド前処理
22+
├── process_manager.py # プロセス管理
23+
├── io_redirection_handler.py # I/Oリダイレクト処理
24+
└── directory_manager.py # ディレクトリ管理
25+
```
26+
27+
## テスト構成
28+
- **19個のテストファイル** で包括的テストカバレッジ
29+
- 機能別テスト(validator, executor, server等)
30+
- エラーケース・エッジケース専用テスト
31+
- macOS固有テスト
32+
- パイプライン・リダイレクション専用テスト
33+
34+
## 主要クラス・モジュール
35+
- **ExecuteToolHandler**: MCPツール実行ハンドラー
36+
- **CommandValidator**: セキュリティ検証
37+
- **ShellExecutor**: コマンド実行エンジン
38+
- **ProcessManager**: プロセス生成・管理
39+
- **IORedirectionHandler**: I/Oリダイレクト
40+
- **DirectoryManager**: ディレクトリ検証
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# MCP Shell Server - プロジェクト概要
2+
3+
## 目的
4+
Model Context Protocol (MCP) を実装したセキュアなシェルコマンド実行サーバー。
5+
リモートからホワイトリストされたシェルコマンドの実行を標準入力サポート付きで提供。
6+
7+
## 主な機能
8+
- **セキュアコマンド実行**: ホワイトリストされたコマンドのみ実行可能
9+
- **標準入力サポート**: コマンドへの入力データ送信
10+
- **包括的出力**: stdout、stderr、終了ステータス、実行時間を返却
11+
- **シェル演算子安全性**: セミコロン、&&、||、| 後のコマンド検証
12+
- **タイムアウト制御**: コマンドの最大実行時間設定
13+
14+
## 対象ユーザー
15+
- Claude Desktop等のMCPクライアントの開発者
16+
- セキュアなリモートシェル実行が必要なシステム管理者
17+
- MCP プロトコルを利用したツール開発者
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Session Checkpoint - 2025-09-06
2+
3+
## Session Context
4+
- **Command**: `/sc:save --type "session" --checkpoint --summarize`
5+
- **Date**: September 6, 2025
6+
- **Workspace**: /workspace/mcp-shell-server
7+
- **Git Status**: main branch, clean working tree
8+
9+
## Session Activity Summary
10+
- Session initiated with `/sc:save` command for context persistence
11+
- Analyzed existing project memories: tech_stack, codebase_structure, project_purpose, code_style_conventions, suggested_commands, task_completion_checklist
12+
- No active coding tasks or modifications were performed in this session
13+
- Focus was on session management and context preservation
14+
15+
## Current State
16+
- **Working Directory**: /workspace/mcp-shell-server
17+
- **Git Repository**: Yes, on main branch
18+
- **Platform**: Linux 6.11.0-29-generic
19+
- **Environment**: Ubuntu user (uid:1000, gid:1000) with sudo access
20+
21+
## Available Memories
22+
1. `tech_stack` - Technology stack information
23+
2. `codebase_structure` - Project structure and organization
24+
3. `project_purpose` - Project goals and objectives
25+
4. `code_style_conventions` - Coding standards and patterns
26+
5. `suggested_commands` - Recommended development commands
27+
6. `task_completion_checklist` - Quality assurance guidelines
28+
29+
## Session Status
30+
- **Completion**: Session save operation in progress
31+
- **Next Actions**: Session context preserved for future continuation
32+
- **Recovery Point**: Full project context available for restoration
33+
34+
## Serena MCP Integration
35+
- Memory system functional and responsive
36+
- Cross-session persistence enabled
37+
- Project context preservation successful

0 commit comments

Comments
 (0)