-
Notifications
You must be signed in to change notification settings - Fork 718
MCPサーバ実装 #6832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dotani1111
wants to merge
40
commits into
EC-CUBE:4.4
Choose a base branch
from
dotani1111:feature/poc-mcp
base: 4.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
MCPサーバ実装 #6832
Changes from 37 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
4e797dd
chore: apply Rector to codeception fixture BundleCompilerPass
dotani1111 d0787f8
feat: MCP サーバ土台と商品/在庫 3 ツールを追加
dotani1111 0527b4c
test(mcp): 商品/在庫 3 Tool の DB 結合テスト
dotani1111 bf61603
fix(mcp): EntityArraySerializer の Doctrine Proxy 対応 + 深さデフォルトを 1 に
dotani1111 e708261
feat(mcp): 注文領域 3 ツールを追加 (search_orders / get_order / get_shipping)
dotani1111 2801d7a
feat(mcp): 顧客会員領域 3 ツールを追加 (search_customers / get_customer / get_cus…
dotani1111 28e78a0
feat(mcp): プラグイン管理 2 ツールを追加 (list_plugins / get_plugin)
dotani1111 4722657
fix(mcp): scope 不足を ToolCallException で返す
dotani1111 273096f
fix(mcp): Get 系 Tool の不在応答を {"found": false} に統一
dotani1111 80396f7
feat(mcp): IP / client_id 2 段の Rate Limiter を追加
dotani1111 7ed1f07
test(mcp): tools/list と allow_list の契約テストを追加
dotani1111 83cea02
feat(mcp): mcp チャネル直書きを禁止する PHPStan custom rule を追加
dotani1111 3cf35d6
test(mcp): MCP firewall が oauth2 経路を通ることを統合テスト化
dotani1111 03fc2c2
test(mcp): 失効 / Member 無効化で即 401 をテスト化 (AC #6 #9)
dotani1111 16e1b0f
test(mcp): Api44 install/enable で MCP 依存登録を担保 (AC #7)
dotani1111 2e1f316
refactor(mcp): scope 検査を中央 ReferenceHandler 層に集約 (設計案 A)
dotani1111 8dc4c9a
refactor(mcp): 監査ログの単一入口を alias 削除で保証 (PHPStan rule 撤去)
dotani1111 2ba2692
fix(mcp): Rate Limiter を cache 障害時 fail-closed にする
dotani1111 962cd6e
test(mcp): 正常 JWT 受理を 200 + JSON-RPC result で検証
dotani1111 9d73280
test(mcp): 全 Tool が McpToolScopeMap に scope を持つ契約テストを追加
dotani1111 80c89d4
fix(mcp): 監査ログ alias 削除の空振りを build 失敗で検出する
dotani1111 e319562
test(mcp): scope 強制の配線を回帰テストで担保
dotani1111 ac42582
fix(mcp): Rate Limiter の監査ログ失敗で拒否レスポンスを崩さない
dotani1111 3a4ca7e
fix(mcp): 監査ログ失敗時に default チャンネルへフォールバック記録する
dotani1111 92c7d03
test(mcp): 401 の WWW-Authenticate と経路を検証する
dotani1111 05f2d28
fix(mcp): 監査ログを専用ファイル mcp.log に分離する
dotani1111 eca5f3d
test(mcp): 監査ログが mcp.log に分離され site.log に漏れないことを担保
dotani1111 ddd1fd0
feat(mcp): 認証失敗(401)を mcp.log に記録する
dotani1111 c264a87
test(mcp): 認証失敗ログの reason 分岐 (ヘッダ有無) を検証
dotani1111 aca6597
Merge branch '4.4' into feature/poc-mcp
dotani1111 6b3b383
fix(mcp): 関連 Entity 要約の id 露出を allow_list で塞ぐ
dotani1111 05c29cf
fix(mcp): Tool の検索キーを正規化し日付書式を検証する
dotani1111 73228c8
fix(mcp): Tool 結果の data 契約違反を内部エラーとして扱う
dotani1111 2c610fe
test(mcp): 検索系テストを作成データの出現まで検証する
dotani1111 fa5fad4
style(mcp): 型注釈と重複する @param mixed $level を除去する
dotani1111 3ccae9a
fix(mcp): 本体を Api44/league クラスへのハード依存から切り離す
dotani1111 525091b
test(mcp): Api44 前提テストを mcp グループに分離し専用 CI ジョブで実走
dotani1111 1db2254
fix(ci): mcp ジョブの Api44 アーカイブを dist 展開可能な形式にする
dotani1111 ec85cd4
ci(mcp): Api44 を MCP firewall を含む feat/mcp-server-scorp で導入する
dotani1111 f0d801d
Merge branch '4.4' into feature/poc-mcp
dotani1111 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| services: | ||
| Psr\Http\Message\RequestFactoryInterface: '@http_discovery.psr17_factory' | ||
| Psr\Http\Message\ResponseFactoryInterface: '@http_discovery.psr17_factory' | ||
| Psr\Http\Message\ServerRequestFactoryInterface: '@http_discovery.psr17_factory' | ||
| Psr\Http\Message\StreamFactoryInterface: '@http_discovery.psr17_factory' | ||
| Psr\Http\Message\UploadedFileFactoryInterface: '@http_discovery.psr17_factory' | ||
| Psr\Http\Message\UriFactoryInterface: '@http_discovery.psr17_factory' | ||
|
|
||
| http_discovery.psr17_factory: | ||
| class: Http\Discovery\Psr17Factory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| mcp: | ||
| app: 'EC-CUBE MCP Server' | ||
| version: '4.4.0' | ||
| description: 'EC-CUBE 4.4 の管理データ (商品/在庫・注文・顧客会員・プラグイン管理) を AI クライアントから自然言語で参照する読み取り専用 MCP サーバ。 認証認可は API プラグイン (api44) の OAuth2 / scope に委譲する。' | ||
| client_transports: | ||
| http: true | ||
| stdio: true | ||
| http: | ||
| path: '/%eccube_admin_route%/mcp' | ||
| session: | ||
| store: file | ||
| discovery: | ||
| scan_dirs: | ||
| - src/Eccube/Service/Mcp/Tool |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # MCP サーバの Rate Limiter 設定 (設計 §5「Rate Limiter 連携」)。 | ||
| # | ||
| # 2 段構成: | ||
| # - mcp_ip: リモート IP 単位の制限 (firewall 前で消費、 認証エラー連発攻撃にも効く) | ||
| # - mcp_client: OAuth2 client_id 単位の制限 (firewall 通過後の OAuth2Token から client_id を取得して消費) | ||
| # | ||
| # 既定値は PoC レベルの控えめな値。 GA 運用開始時に再評価する。 | ||
| framework: | ||
| rate_limiter: | ||
| mcp_ip: | ||
| policy: fixed_window | ||
| limit: 60 | ||
| interval: '1 minute' | ||
| cache_pool: rate_limiter.cache | ||
| mcp_client: | ||
| policy: fixed_window | ||
| limit: 300 | ||
| interval: '1 minute' | ||
| cache_pool: rate_limiter.cache |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,14 @@ | ||
| monolog: | ||
| channels: ['front', 'admin'] | ||
| channels: ['front', 'admin', 'mcp'] | ||
| handlers: | ||
| # MCP 監査ログ: PII を含み得るため site.log と分離した専用ファイルに、 1 レコード 1 JSON で出力する。 | ||
| # fingers_crossed を挟まず info から常時書き出す (監査記録は error 連動で握り潰してはならない)。 | ||
| # 保管日数は ECCUBE_MCP_LOG_RETENTION_DAYS (既定 90)。 ファイルは所有者/グループのみ読める権限にする。 | ||
| mcp: | ||
| type: rotating_file | ||
| path: '%kernel.logs_dir%/%kernel.environment%/mcp.log' | ||
| channels: ['mcp'] | ||
| level: info | ||
| formatter: eccube.mcp.log.formatter.json | ||
| max_files: '%env(int:ECCUBE_MCP_LOG_RETENTION_DAYS)%' | ||
| file_permission: 0640 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: EC-CUBE/ec-cube
Length of output: 41
🌐 Web query:
actions/checkout persist-credentials default behavior security GitHub token💡 Result:
The persist-credentials input in actions/checkout defaults to true [1][2][3]. When enabled, this setting configures the local Git environment—specifically the Git configuration—to use the provided GitHub token or SSH key [1][4][2]. This allows subsequent steps in the same GitHub Actions job to execute authenticated Git commands (such as git fetch or git push) without needing to re-authenticate [1][4][2]. From a security perspective, persisting credentials makes them available to any subsequent process or action running within that job [5][6]. Historically, this meant the token was stored directly in.git/config, which made it easily accessible to other steps [5][6]. Recent versions of actions/checkout have improved security by storing these credentials in a separate, temporary file under $RUNNER_TEMP rather than directly in.git/config, though they remain accessible to the workflow process [1][7]. If your security requirements dictate that subsequent steps should not have access to these credentials, you should explicitly set persist-credentials to false in your workflow configuration [1][4][2]: - with: persist-credentials: false While setting this to false prevents the action from configuring Git with the token, it does not affect the inherent accessibility of the GITHUB_TOKEN if it is explicitly passed to other actions or scripts [5][6]. Always ensure your workflow permissions are set to the least privilege necessary [5][6][2].
Citations:
persist-credentialsor change the default tofalseactions/checkout#485persist-credentialsor change the default tofalseactions/checkout#485🏁 Script executed:
Repository: EC-CUBE/ec-cube
Length of output: 447
checkout アクションに
persist-credentials: falseの設定を検討してください。両方の checkout アクション(本体リポジトリと Api44 リポジトリ)で
persist-credentialsが設定されていません。デフォルトではtrueとなり、GITHUB_TOKENがジョブ内の後続ステップからアクセス可能な状態になります。最新バージョンでは認証情報は.git/configではなく一時ファイル($RUNNER_TEMP配下)に保存されていますが、ワークフロープロセスには引き続きアクセス可能です。最小権限の原則に従い、必要がなければ両方の checkout に
persist-credentials: falseを追加することを推奨します。🧰 Tools
🪛 zizmor (1.25.2)
[warning] 186-187: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
[warning] 189-194: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Source: Linters/SAST tools