1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//! MCP Integration Module
//!
//! Provides MCP (Model Context Protocol) client capabilities for Nika workflows.
//! Uses Anthropic's official rmcp SDK for real MCP connections.
//!
//! ## Module Structure
//!
//! - [`client`]: High-level MCP client with mock support
//! - [`rmcp_adapter`]: Thin wrapper around rmcp SDK (internal)
//! - [`types`]: Core MCP types (McpConfig, ToolCallRequest, ToolCallResult, etc.)
//! - [`protocol`]: JSON-RPC 2.0 types (utility, for testing/debugging)
//! - [`validation`]: Parameter validation with schema caching
//!
//! ## Usage
//!
//! ```yaml
//! # Workflow with MCP server configuration
//! schema: nika/workflow@0.2
//! mcp:
//! novanet:
//! command: "npx"
//! args: ["-y", "@novanet/mcp-server"]
//! env:
//! NEO4J_URI: "bolt://localhost:7687"
//!
//! tasks:
//! - id: generate
//! invoke: novanet.novanet_context
//! params:
//! mode: "page"
//! focus_key: "qr-code"
//! locale: "fr-FR"
//! ```
//!
//! ## Client Usage
//!
//! ```rust,ignore
//! use nika::mcp::{McpClient, McpConfig};
//! use serde_json::json;
//!
//! // Create and connect to MCP server
//! let config = McpConfig::new("novanet", "npx")
//! .with_args(["-y", "@novanet/mcp-server"]);
//! let client = McpClient::new(config)?;
//! client.connect().await?;
//!
//! // Call a tool
//! let result = client.call_tool("novanet_context", json!({
//! "mode": "page",
//! "focus_key": "qr-code",
//! "locale": "fr-FR"
//! })).await?;
//!
//! // For testing, use mock client
//! let mock = McpClient::mock("novanet");
//! assert!(mock.is_connected());
//! ```
//!
//! ## Architecture
//!
//! ```text
//! McpClient (public API)
//! │
//! ├── Mock Mode ──► Direct mock responses (testing)
//! │
//! └── Real Mode ──► RmcpClientAdapter
//! │
//! └── rmcp::Service<ClientHandler>
//! │
//! └── TokioChildProcess transport
//! ```
//!
//! ## Debug Utilities
//!
//! The `protocol` module provides low-level JSON-RPC types
//! useful for testing or debugging MCP protocol interactions.
// Re-export core types for convenience
pub use ;
pub use McpClientPool;
pub use ;
// Note: RmcpClientAdapter is pub(crate) - access MCP via McpClient
pub use ;
pub use ;
pub use ;
// MCP config loading
pub use ;