Files
cleveragents-core/features/tdd_stdio_transport.feature
T
CoreRasurae 3fcfaee02d
CI / helm (push) Successful in 38s
CI / build (push) Successful in 1m3s
CI / push-validation (push) Successful in 30s
CI / lint (push) Successful in 1m22s
CI / quality (push) Successful in 1m31s
CI / security (push) Successful in 1m46s
CI / typecheck (push) Successful in 1m53s
CI / integration_tests (push) Successful in 3m41s
CI / e2e_tests (push) Failing after 4m5s
CI / unit_tests (push) Successful in 4m58s
CI / docker (push) Successful in 1m30s
CI / benchmark-regression (push) Failing after 45s
CI / coverage (push) Successful in 11m32s
CI / status-check (push) Successful in 5s
CI / benchmark-publish (push) Successful in 1h20m26s
feat(mcp): implement StdioMCPTransport for JSON-RPC 2.0 stdio communication
Implements concrete StdioMCPTransport class that:
- Spawns MCP server as subprocess and communicates via JSON-RPC 2.0 over stdio
- Performs MCP handshake (initialize + notifications/initialized)
- Supports tools/list and tools/call methods
- Uses RLock for thread-safe concurrent access
- Auto-selected when transport='stdio' in MCPServerConfig

Adds BDD tests for stdio transport covering:
- Connection lifecycle and error handling
- Tool discovery and invocation
- MCPToolAdapter integration

ISSUES CLOSED: #4918
2026-05-13 07:13:34 +00:00

123 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