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을 사용하면 실시간으로 통나무를 따라갈 수 있습니다.지엑스피1
- 과거 기록의 경우 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(자바스크립트)
- 위치: ~/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(파이썬)
- 위치: ~/workspace/textgrad/tests/conftest.py
- 목적: MCP 서비스와 통합하기 위해 pytest를 구성합니다.
- 현재 상태: ~/workspace/mcp-pytest-server/python-sdk에서 Python SDK를 성공적으로 사용 중
SDKs
자바스크립트 SDK
- 위치: https://github.com/modelcontextprotocol/typescript-sdk
- 패키지 상태: npm에 '@modelcontextprotocol/sdk'로 게시됨
- 사용법: npm install @modelcontextprotocol/sdk를 통해 설치할 수 있습니다.
- 구현: MCP 통합을 위한 TypeScript/JavaScript 클라이언트 제공
파이썬 SDK
- 위치: ~/workspace/mcp-pytest-server/python-sdk
- 패키지 상태: 어떤 패키지 관리자(PyPI, Conda 등)에도 게시되지 않음
- 사용법: pytest 통합을 통해 내부적으로 사용됨
- 구현: MCP 통합을 위한 Python 클라이언트 제공
- 여러 프로젝트 설치:
- 패키지 디렉토리로 이동합니다: cd ~/workspace/mcp-pytest-server/python-sdk
- 개발 모드로 설치: pip install -e .
- 이제 이 패키지는 시스템의 모든 Python 프로젝트에서 사용할 수 있습니다.
- 업데이트하려면 저장소에서 최신 변경 사항을 가져오기만 하면 됩니다.
구현 상태
세 가지 도구(record_session_start, record_test_outcome, record_session_finish)의 핵심 기능은 index.js에 구현되어 있습니다. 구현 내용은 다음과 같습니다.
구현 상태: 세 가지 도구(record_session_start, record_test_outcome, record_session_finish)의 핵심 기능이 index.js에 구현되었습니다. 구현 내용은 다음과 같습니다.
- 모든 도구에 대한 입력 검증
- 적절한 오류 처리 및 로깅
- 도구 등록 및 요청 처리
- 기본 응답 생성
1. record_session_start
[구현됨]
설명: 이 도구는 pytest 세션 시작 시 호출됩니다. memory
MCP 서버에 "TestRun_Latest" 및 "Env_Current" 엔티티를 생성하거나 업데이트하여 현재 테스트 실행의 컨텍스트를 초기화합니다. 중요한 점은 이 도구가 "TestRun_Latest"와 관련된 이전 테스트 실행의 모든 데이터를 삭제하여 마지막 실행에 대한 단일 진실 소스(SSO)를 유지한다는 것입니다.
구현 세부 정보:
- 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": "통과", "기간": 0.123}' use_mcp_tool pytest-mcp record_test_outcome '{"nodeid": "test_module.py:_failure", "outcome": "실패", "기간": 0.05, "오류": "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}}'
노드 ~/workspace/mcp-pytest-server/index.js
ps aux | grep index.js sudo tcpdump -i any -s 0 -w mcp_traffic.pcap port <포트 번호>
use_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.
ModelContextProtocol(MCP) 서비스 도구를 활용하기 위해 pytest와 통합된 Node.js 서버로, 테스트 실행 기록 및 환경 추적을 지원합니다.
- 패키지 상태
- 로그 보기
- 시작하기
- mcp-pytest-server 개발 전용 설치
- 검사 서비스
- 아키텍처 및 구현
- 개요
- 구성 요소 세부 정보
- 구현 상태
- 1. record_session_start \[구현됨]
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityNode.js server implementing Model Context Protocol (MCP) for filesystem operations.Last updated -14116,82863,134TypeScriptMIT License
- -securityAlicense-qualityNode.js server implementing Model Context Protocol (MCP) for filesystem operations, allowing AI systems to read, write, edit files and manage directories within specified allowed paths.Last updated -116,828JavaScriptMIT License
- -securityAlicense-qualityNode.js server implementing Model Context Protocol (MCP) for filesystem operations with regex support for allowed directories, enabling AI assistants to safely read, write, and manipulate files through natural language.Last updated -116,828JavaScriptMIT License
- AsecurityFlicenseAqualityA testing server that demonstrates Model Context Protocol features, providing access to user data, todos, and system information through resources, tools for user management and calculations, and prompt templates for various analyses.Last updated -4TypeScript