Skip to content

test: add MCP protocol smoke test for the stdio transport#133

Open
yagna-1 wants to merge 1 commit into
haris-musa:mainfrom
yagna-1:add-mcp-protocol-smoke-test
Open

test: add MCP protocol smoke test for the stdio transport#133
yagna-1 wants to merge 1 commit into
haris-musa:mainfrom
yagna-1:add-mcp-protocol-smoke-test

Conversation

@yagna-1

@yagna-1 yagna-1 commented May 5, 2026

Copy link
Copy Markdown

What

Adds two end-to-end tests in tests/test_mcp_protocol.py that spawn excel-mcp-server stdio as a real subprocess and exercise the JSON-RPC protocol over its stdin/stdout:

  • test_initialize_handshake_succeeds — the server completes the MCP initialize handshake and advertises the tools capability.
  • test_documented_tools_are_listedcreate_workbook and get_workbook_metadata (both in TOOLS.md) are returned by tools/list with valid object input schemas.

Why

The existing test_sandbox_paths.py exercises path-resolution internals directly, but nothing currently runs the actual MCP entry point. A regression in __main__.py, the FastMCP wiring in server.py, or the handshake sequencing could ship without any test failing. These two tests close that gap.

Implementation

  • One new file, ~100 LoC, follows the existing unittest style of test_sandbox_paths.py.
  • Skipped automatically when pytest-mcp-plugin is not installed or excel-mcp-server is not on PATH, so the suite stays green in any environment, including the current publish.yml workflow which doesn't install dev deps.
  • No production code changes, no pyproject.toml deps changes, no workflow changes. You decide whether to wire it in.

To run locally:

```sh
uv add --dev "pytest-mcp-plugin>=0.2.3"
uv sync
uv run pytest tests/test_mcp_protocol.py -v
```

Verified locally

```text
$ uv run pytest tests/ -q
....... [100%]
7 passed in 0.97s
```

That's 5 existing + 2 new. Server runs in stdio mode — no Excel files touched.

Disclosure

I'm the author of pytest-mcp-plugin (MIT, on PyPI). It's a small community library that drives MCP servers over stdio/HTTP from inside the test runner — Apache/MIT-compatible, not a vendored dependency. Repo: https://github.com/yagna-1/mcp-test.

While testing this PR I caught and fixed a bug in pytest-mcp-plugin itself: the client wasn't sending notifications/initialized after the MCP initialize handshake, which FastMCP requires before it will return tools from tools/list. That fix shipped as v0.2.3 (May 5). The pin in this PR is >=0.2.3 so users get the working version.

Made with Cursor

Adds tests/test_mcp_protocol.py with two end-to-end tests that spawn
`excel-mcp-server stdio` as a real subprocess and exercise the JSON-RPC
protocol over stdin/stdout:

- test_initialize_handshake_succeeds: server completes the MCP
  initialize handshake and advertises the `tools` capability.
- test_documented_tools_are_listed: `create_workbook` and
  `get_workbook_metadata` (both in TOOLS.md) are returned by tools/list
  with valid object input schemas.

Why: the existing `test_sandbox_paths.py` exercises path-resolution
internals directly, but nothing currently runs the actual MCP entry
point. A regression in `__main__.py`, the FastMCP wiring in
`server.py`, or the handshake sequencing could ship without any test
failing. These two tests close that gap.

Implementation:
- Single new file, ~100 LoC, follows the existing unittest style of
  `test_sandbox_paths.py`.
- Skipped automatically when `pytest-mcp-plugin` is not installed or
  the `excel-mcp-server` entry point is not on PATH, so the suite stays
  green in any environment.
- No production code changes, no dev-deps in pyproject.toml, no new
  workflows. Maintainer can decide whether to wire it in.

To run locally:
    uv add --dev "pytest-mcp-plugin>=0.2.3"
    uv run pytest tests/test_mcp_protocol.py -v

Co-authored-by: Cursor <cursoragent@cursor.com>
@yagna-1

yagna-1 commented May 5, 2026

Copy link
Copy Markdown
Author

Heads-up: pytest-mcp-plugin v0.3.0 was just released. The >=0.2.3 requirement in the docstring still holds (newer versions are backward-compatible for this test); no changes needed here.

For context, v0.3.0 also runs Anthropic's @modelcontextprotocol/conformance suite in CI against its bundled FastMCP demo server with a locked baseline — so if you ever want a "do we pass the official MCP spec?" check for excel-mcp-server, the same machinery is now one CLI invocation away (mcp-test conformance --command "excel-mcp-server stdio").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant