Files
cleveragents-core/features/tdd_stdio_transport.feature
T
HAL9000 f808abff86 chore(ci): fix pre-commit hook failures
Fix JSON syntax errors in .devcontainer/devcontainer.json (removed
invalid JS-style // comments) and .devcontainer/opencode.json (removed
90+ trailing commas). Apply auto-fixes for end-of-file and trailing
whitespace issues across 100+ files. Fix SIM105 ruff violations in
benchmarks/core_circuit_breaker_bench.py (use contextlib.suppress).

Note: The security fix from issue #7478 (validate_path startswith bypass)
was already delivered to master in commit e18ac5f2. This PR as currently
structured is non-atomic (35 commits across 10+ issues) and needs
significant restructure before merge. This commit only addresses the
CI/pre-commit failures.

ISSUES CLOSED: #7478
2026-06-14 09:51:14 -04:00

124 lines
5.4 KiB
Gherkin

Feature: Stdio MCP Transport
As an MCP client using the stdio transport
I want to connect to MCP servers via subprocess stdio
So that I can discover and invoke tools from real MCP servers
Background:
Given the MCP stdio stub server is available
# -------------------------------------------------------------------
# Connection Lifecycle
# -------------------------------------------------------------------
Scenario: Connect to MCP stdio server performs handshake
Given an MCP server config using the stdio stub server
When I create a stdio transport
And I connect the transport
Then the MCP stdio transport should be connected
And the server capabilities should include tools support
Scenario: Connect with missing command raises error
Given an MCP server config with stdio transport and no command
When I create a stdio transport and connect
Then the connection should fail with error containing "command"
Scenario: Connect with non-existent command raises error
Given an MCP server config with stdio transport and command "/nonexistent/binary"
When I create a stdio transport and connect
Then the connection should fail with error containing "not found"
Scenario: Double connect is idempotent
Given an MCP server config using the stdio stub server
And a connected stdio transport
When I connect the transport again
Then the MCP stdio transport should be connected
Scenario: Close transport terminates subprocess
Given an MCP server config using the stdio stub server
And a connected stdio transport
When I close the transport
Then the MCP stdio transport should not be connected
# -------------------------------------------------------------------
# Tool Discovery via Transport
# -------------------------------------------------------------------
Scenario: Discover tools via stdio transport
Given an MCP server config using the stdio stub server
And a connected stdio transport
When I call "tools/list" on the transport
Then the response should contain "tools" key
And the tools list should have 3 tools
And tool 0 should have name "test/echo"
Scenario: Call unknown method raises error
Given an MCP server config using the stdio stub server
And a connected stdio transport
When I call "nonexistent/method" on the transport
Then the call should fail with error containing "Unknown method"
# -------------------------------------------------------------------
# Tool Invocation via Transport
# -------------------------------------------------------------------
Scenario: Invoke test/echo tool via stdio transport
Given an MCP server config using the stdio stub server
And a connected stdio transport
When I call "tools/call" with arguments {"name": "test/echo", "arguments": {"message": "hello"}}
Then the call should succeed
And the response should contain "content" key
Scenario: Invoke test/multiply tool via stdio transport
Given an MCP server config using the stdio stub server
And a connected stdio transport
When I call "tools/call" with arguments {"name": "test/multiply", "arguments": {"a": 6, "b": 7}}
Then the call should succeed
And the response content should contain "42"
Scenario: Invoke unknown tool returns error response
Given an MCP server config using the stdio stub server
And a connected stdio transport
When I call "tools/call" with arguments {"name": "test/nonexistent", "arguments": {}}
Then the call should fail with error containing "Unknown tool"
# -------------------------------------------------------------------
# MCPToolAdapter Integration with Stdio Transport
# -------------------------------------------------------------------
Scenario: MCPToolAdapter uses StdioMCPTransport automatically for stdio config
Given an MCP server config for "test-server" with stdio transport
And the config command is set to the stdio stub server path
When I create an MCP adapter from the config
And I connect the adapter
Then the adapter transport type should be "stdio"
And the adapter should be connected
And the adapter server capabilities should be set
Scenario: MCPToolAdapter discovers tools via StdioMCPTransport
Given an MCP server config for "test-server" with stdio transport
And the config command is set to the stdio stub server path
When I create an MCP adapter from the config
And I connect the adapter
And I discover tools from the adapter
Then the adapter should have 3 discovered tools
Scenario: MCPToolAdapter invokes tools via StdioMCPTransport
Given an MCP server config for "test-server" with stdio transport
And the config command is set to the stdio stub server path
When I create an MCP adapter from the config
And I connect the adapter
And I discover tools from the adapter
And I invoke "test/echo" with arguments {"message": "test"}
Then the invocation should succeed
And the invocation result should contain key "content"
# -------------------------------------------------------------------
# Notifications
# -------------------------------------------------------------------
Scenario: Send notification to server
Given an MCP server config using the stdio stub server
And a connected stdio transport
When I send a "test/custom_notification" notification with params {}
Then the MCP stdio transport should still be connected