Add MCP test automation: wire-protocol tests and setup script smoke test#58
Conversation
Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/bcbbfe9c-443e-4778-b9fa-0d9a5d00fc75 Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com>
Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/67dfed60-b36b-48f1-83f5-84cca466abb9 Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds automated validation around the DevOps-OS MCP server by introducing true wire-protocol (stdio JSON-RPC) tests and a GitHub Actions workflow that smoke-tests the end-to-end MCP setup script on a clean runner.
Changes:
- Add
tests/test_mcp_protocol.pyto spawnpython -m mcp_server.serverand verify MCP handshake, tool discovery, tool invocation, error handling, and sequential calls over stdio. - Add
.github/workflows/mcp-setup-smoke.ymlto runsetup_devops_os_mcp.sh --localand verify venv creation, dependency importability, CLI registration (via stub), and basic JSON-RPC interactions. - Update
.github/workflows/sanity.ymlto run the new wire-protocol tests and include them in the HTML report generation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
tests/test_mcp_protocol.py |
New subprocess-based MCP stdio wire-protocol test suite (handshake/tools/list/tools/call/error/sequential). |
.github/workflows/sanity.yml |
Runs the new protocol tests in CI and includes them in the combined pytest-html report. |
.github/workflows/mcp-setup-smoke.yml |
New workflow to smoke-test the setup script and validate basic MCP server operability in a fresh venv. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self._proc.stdin.write(json.dumps(msg) + "\n") | ||
| self._proc.stdin.flush() | ||
| raw = self._proc.stdout.readline() | ||
| if not raw: | ||
| stderr_out = self._proc.stderr.read() |
There was a problem hiding this comment.
_send_request() uses blocking stdout.readline() with no timeout. If the server deadlocks or fails to respond, the test suite can hang indefinitely in CI. Add a per-request timeout (e.g., via selectors/polling + deadline) and fail fast while terminating the subprocess and surfacing stderr for debugging.
| finally: | ||
| s._proc.terminate() | ||
| s._proc.wait(timeout=5) | ||
|
|
There was a problem hiding this comment.
The direct subprocess cleanup in this test calls terminate() then wait(timeout=5) but doesn’t handle TimeoutExpired (unlike _MCPSession.exit). If the server doesn’t exit quickly, the test will error/flap instead of ensuring cleanup; reuse the context manager or mirror the kill-on-timeout logic here.
| proc.stdin.write(json.dumps(msg) + "\n") | ||
| proc.stdin.flush() | ||
| if req_id is not None: | ||
| return json.loads(proc.stdout.readline()) | ||
|
|
There was a problem hiding this comment.
The embedded Python reads responses with proc.stdout.readline() without any timeout. If the server never replies (or writes a partial line), this step can hang until the workflow timeout. Add a bounded read (selectors/alarm) or use communicate() with timeout and surface stderr on failure.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@copilot apply changes based on this feedback |
* docs(mcp): improve MCP setup for beginners across all AI tools - Rewrote mcp_server/README.md with step-by-step guides for Claude Code, Claude Desktop, Cursor, VS Code Copilot, Windsurf, and Zed - Added tools table entry for generate_unittest_config (was missing) - Added troubleshooting section for common setup failures - Fixed setup_devops_os_mcp.sh: replaced hardcoded ~/gsdev path with configurable INSTALL_DIR (default ~/devops_os), added --local flag for users already inside a clone, added --help and Python version check - Added .mcp.json (Claude Code project-level config) - Added .cursor/mcp.json (Cursor IDE project-level config) - Added .vscode/mcp.json (VS Code Copilot project-level config) - Updated .gitignore to track IDE MCP configs while ignoring personal settings - Removed "WIP" label from MCP section in main README.md, added curl one-liner Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add MCP test automation: wire-protocol tests and setup script smoke test (#58) * Add MCP test automation: wire-protocol tests and setup script smoke test Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/bcbbfe9c-443e-4778-b9fa-0d9a5d00fc75 Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * fix: use importlib.metadata to check mcp version in smoke test Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/67dfed60-b36b-48f1-83f5-84cca466abb9 Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> * Update tests/test_mcp_protocol.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update tests/test_mcp_protocol.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/mcp-setup-smoke.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/mcp-setup-smoke.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> Co-authored-by: Saravanan Gnanaguru <g.gsaravanan@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .mcp.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update mcp_server/setup_devops_os_mcp.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update mcp_server/setup_devops_os_mcp.sh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update mcp_server/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update mcp_server/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * docs: replace curl|bash with download-then-inspect-then-run in README.md Agent-Logs-Url: https://github.com/cloudengine-labs/devops_os/sessions/a2bcc76b-f5a7-421e-9984-542b39e55436 Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
tests/test_mcp_protocol.py— 15 MCP JSON-RPC wire-protocol tests.github/workflows/mcp-setup-smoke.yml— setup script smoke testsanity.ymlto include the new protocol test scenariomcphas no__version__attribute — useimportlib.metadata.version('mcp')+ importFastMCPdirectly to verify the package is usable