Pytest MCP サービス
パッケージのステータス
ローカルコンパイルされたソースではなく、公開されているnpmパッケージ(@modelcontextprotocol/mcp-pytest-server)を実行しています。これは以下の方法で確認できます。
- 実行可能パス: ~/.npm/_npx/15b07286cbcc3329/node_modules/.bin/mcp-server-memory
- バイナリを指定するpackage.json構成はdist/index.jsにビルドされる必要があります。
- npmグローバルキャッシュの存在
参考までに、Python SDK リリースは次の場所から入手できます: https://github.com/modelcontextprotocol/python-sdk/tags
ログの表示
サーバーの出力とログを表示するには:
- サーバーが稼働しているライブターミナル出力を表示する
- ~/workspace/mcp-pytest-server/output.log のログファイルを確認します。
- ログをリアルタイムで追跡するには、tail を使用します。
- 履歴ログの場合は、less または cat を使用します。
はじめる
前提条件
- Node.js v16以上
- Python 3.8以上
- npmがインストールされている
- メモリ サービス (@modelcontextprotocol/server-memory) が実行中 (バックグラウンド実行には uvx を使用することをお勧めします):
- uvxをインストールします:
npm install -g uvx
- uvx 構成 (uvx.config.js) を作成します。
- サービスを開始:
uvx start memory
- uvxをインストールします:
mcp-pytest-server 開発のみのインストール
プロジェクトディレクトリに移動する
JavaScript依存関係をインストールする
MCP Pytestサーバーを起動する
MCP統合でPytestを実行する
検査サービス
メモリサービスの検査
メモリ サービスを検査するには:
- デバッグモードでサービスを開始します。
- chrome://inspect で Chrome DevTools を開きます。
- 「Node専用のDevToolsを開く」をクリックします
- ブレークポイントを設定してサービスの実行を検査する
あるいは、VSCode に組み込まれている Node.js デバッグを使用します。
- launch.json 構成を作成します。
開発中のMCP-Pytestサービスの検査
mcp-pytest サービスを検査するには:
- デバッグモードでサービスを開始します。
- chrome://inspect で Chrome DevTools を開きます。
- 「Node専用のDevToolsを開く」をクリックします
- ブレークポイントを設定してサービスの実行を検査する
あるいは、VSCode に組み込まれている Node.js デバッグを使用します。
- launch.json 構成を作成します。
アーキテクチャと実装
概要
MCP pytest 統合は複数のコンポーネントで構成されています。
- mcp-pytest-server : MCP サービスツールを実装した Node.js サーバー
- conftest.py : pytest を MCP サービスと統合するテスト構成
- SDK : MCP 統合用の JavaScript と Python の両方の SDK
コンポーネントの詳細
mcp-pytest-server (JavaScript)
- 場所: ~/workspace/mcp-pytest-server
- 実装: Node.js (index.js)
- ステータス: 公開された npm パッケージを実行中 (ローカルでコンパイルされていません)
- パッケージステータス: npm で '@modelcontextprotocol/mcp-pytest-server' として公開されています
- 実行可能パス: ~/.npm/_npx/15b07286cbcc3329/node_modules/.bin/mcp-server-memory (公開パッケージの使用状況を確認)
- 機能: pytest 統合用の MCP サービス ツールを提供します
conftest.py (Python)
- 場所: ~/workspace/textgrad/tests/conftest.py
- 目的: pytest を MCP サービスと統合するように設定する
- 現在の状態: ~/workspace/mcp-pytest-server/python-sdk から Python SDK を正常に使用しています
SDK
JavaScript SDK
- 場所: https://github.com/modelcontextprotocol/typescript-sdk
- パッケージステータス: npm で '@modelcontextprotocol/sdk' として公開されています
- 使用方法: npm install @modelcontextprotocol/sdk でインストールできます
- 実装: MCP 統合用の TypeScript/JavaScript クライアントを提供します
Python SDK
- 場所: ~/workspace/mcp-pytest-server/python-sdk
- パッケージのステータス: どのパッケージ マネージャー (PyPI、Conda など) でも公開されていません
- 使用法: pytest統合によって内部的に使用される
- 実装: MCP 統合用の Python クライアントを提供する
- 複数のプロジェクトへのインストール:
- パッケージディレクトリに移動します: cd ~/workspace/mcp-pytest-server/python-sdk
- 開発モードでインストールします: pip install -e 。
- パッケージはシステム上のすべてのPythonプロジェクトで利用できるようになります。
- 更新するには、リポジトリから最新の変更をプルするだけです
実施状況
3つのツール(record_session_start、record_test_outcome、record_session_finish)のコア機能はindex.jsに実装されています。実装内容は次のとおりです。
実装状況: 3つのツール(record_session_start、record_test_outcome、record_session_finish)のコア機能がindex.jsに実装されました。実装内容は以下のとおりです。
- すべてのツールの入力検証
- 適切なエラー処理とログ記録
- ツールの登録とリクエストの処理
- 基本的な応答生成
1. record_session_start
[実装済み]
**説明:**このツールは、pytestセッションの開始時に呼び出されます。 memory
MCPサーバーに「TestRun_Latest」および「Env_Current」エンティティを作成または更新することで、現在のテスト実行のコンテキストを初期化します。重要な点として、このツールは「TestRun_Latest」に関連付けられた以前のテスト実行のデータをすべてクリアし、最後の実行に関する唯一の信頼できる情報源を維持することも保証します。
実装の詳細:
- environment.os と environment.python_version の入力検証
- 環境の詳細を含む基本的な応答生成
- 無効なパラメータのエラー処理
入力スキーマ:
mcp 呼び出し pytest-mcp record_session_start '{"environment": {"os": "Macos", "python_version": "3.13.1"}}'
use_mcp_tool pytest-mcp record_session_start '{"環境": {"os": "Macos", "python_version": "3.13.1"}}'
{ "nodeid": "文字列", "outcome": "文字列(合格|不合格|スキップ)", "duration": "数値", "error": "文字列(オプション)" }
use_mcp_tool pytest-mcp record_test_outcome '{"nodeid": "test_module.py:_example", "outcome": "passed", "duration": 0.123}' use_mcp_tool pytest-mcp record_test_outcome '{"nodeid": "test_module.py:_failure", "outcome": "failed", "duration": 0.05, "error": "AssertionError: ... "}'
{ "summary": { "total_tests": "integer", "passed": "integer", "failed": "integer", "skipped": "integer", "exitstatus": "integer" } }
use_mcp_tool pytest-mcp record_session_finish '{"summary": {"total_tests": 10, "passed": 7, "failed": 2, "skipped": 1, "exitstatus": 0}}'
ノード ~/ワークスペース/mcp-pytest-server/index.js
ps aux | grep index.js sudo tcpdump -i any -s 0 -w mcp_traffic.pcap port <ポート番号>
pytest-mcp を使用する
This server cannot be installed
local-only server
The server can only run on the client's local machine because it depends on local resources.
pytest と統合して ModelContextProtocol (MCP) サービス ツールを容易にし、テスト実行の記録と環境の追跡を可能にする Node.js サーバー。
- パッケージのステータス
- ログの表示
- はじめる
- mcp-pytest-server 開発のみのインストール
- 検査サービス
- アーキテクチャと実装
- 概要
- コンポーネントの詳細
- 実施状況
- record_session_start \[実装済み]
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA comprehensive Model Context Protocol server that provides advanced Node.js development tooling for automating project creation, component generation, package management, and documentation with AI-powered assistance.Last updated -72JavaScriptMIT License
- AsecurityFlicenseAqualityAn MCP server that executes tox commands to run Python tests within a project using pytest, allowing users to run all tests or specific test groups, files, cases, or directories.Last updated -14JavaScript
- -securityAlicense-qualityProvides quick access to local system utilities including time/date, hostname, public IP, directory listings, Node.js version, and port usage through an MCP server interface compatible with Cursor and other MCP clients.Last updated -2JavaScriptMIT License
- -securityAlicense-qualityA Node.js package that provides Model Context Protocol server infrastructure for AWS Lambda functions with SSE support, enabling developers to implement MCP tools and prompts as serverless functions.Last updated -1129TypeScriptMIT License