MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / send

Method send

crates/opencode-mcp/src/transport.rs:67–90  ·  view source on GitHub ↗
(&self, request: &JsonRpcRequest)

Source from the content-addressed store, hash-verified

65#[async_trait]
66impl McpTransport for StdioTransport {
67 async fn send(&self, request: &JsonRpcRequest) -> Result<(), McpClientError> {
68 let mut stdin_guard = self.stdin.lock().await;
69 let stdin = stdin_guard
70 .as_mut()
71 .ok_or_else(|| McpClientError::TransportError("Process not running".to_string()))?;
72
73 let content = serde_json::to_string(request).map_err(|e| {
74 McpClientError::ProtocolError(format!("Failed to serialize request: {}", e))
75 })?;
76
77 let message = format!("Content-Length: {}\r\n\r\n{}", content.len(), content);
78
79 stdin
80 .write_all(message.as_bytes())
81 .await
82 .map_err(|e| McpClientError::TransportError(format!("Failed to write: {}", e)))?;
83
84 stdin
85 .flush()
86 .await
87 .map_err(|e| McpClientError::TransportError(format!("Failed to flush: {}", e)))?;
88
89 Ok(())
90 }
91
92 async fn receive(&self) -> Result<Option<JsonRpcMessage>, McpClientError> {
93 let mut process_guard = self.process.lock().await;

Callers 1

connectMethod · 0.45

Calls 6

containsMethod · 0.80
is_emptyMethod · 0.80
as_strMethod · 0.45
statusMethod · 0.45
getMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected