@@ -25,9 +25,9 @@ use crate::config;
2525use crate :: tool:: Tools ;
2626
2727pub fn list ( tools : & mut Tools ) {
28- tools. push ( _connect_tool_attr ( ) , connect) ;
29- tools. push ( _interact_tool_attr ( ) , interact) ;
30- tools. push ( _close_tool_attr ( ) , close) ;
28+ tools. push ( connect_tool_attr ( ) , connect) ;
29+ tools. push ( interact_tool_attr ( ) , interact) ;
30+ tools. push ( close_tool_attr ( ) , close) ;
3131}
3232
3333#[ derive( Serialize , Deserialize , JsonSchema ) ]
@@ -42,12 +42,7 @@ pub struct ConnectRequest {
4242/// To interact with the connection, use the `net_tcp_interact` tool. To close the connection, use
4343/// the `net_tcp_close` tool. The initial interaction is built-in by taking the same `input` field
4444/// as `net_tcp_interact` and returning the same fields.
45- #[ rmcp:: tool( name = "net_tcp_connect" , annotations( destructive_hint = false ) ) ]
46- async fn _connect ( _: Parameters < ConnectRequest > ) -> Result < Json < InteractResponse > , String > {
47- // TODO(https://github.com/modelcontextprotocol/rust-sdk/issues/495): Remove when fixed.
48- unreachable ! ( )
49- }
50-
45+ #[ rmcp:: tool( local, name = "net_tcp_connect" , annotations( destructive_hint = false ) ) ]
5146async fn connect ( params : Parameters < ConnectRequest > ) -> Result < Json < InteractResponse > , String > {
5247 let ConnectRequest { host, port, input } = params. 0 ;
5348 let stream = TcpStream :: connect ( ( host, port) ) . await . map_err ( |e| e. to_string ( ) ) ?;
@@ -73,13 +68,8 @@ pub struct InteractResponse {
7368///
7469/// The tool will listen until some amount of inactivity or some fixed deadline, whichever happens
7570/// first. The tool will fail if the peer sends binary data that is not UTF-8.
76- #[ rmcp:: tool( name = "net_tcp_interact" , annotations( destructive_hint = false ) ) ]
77- async fn _interact ( _: Parameters < InteractRequest > ) -> Result < Json < InteractResponse > , String > {
78- // TODO(https://github.com/modelcontextprotocol/rust-sdk/issues/495): Remove when fixed.
79- unreachable ! ( )
80- }
81-
8271#[ allow( clippy:: await_holding_lock) ]
72+ #[ rmcp:: tool( local, name = "net_tcp_interact" , annotations( destructive_hint = false ) ) ]
8373async fn interact ( params : Parameters < InteractRequest > ) -> Result < Json < InteractResponse > , String > {
8474 let InteractRequest { input } = params. 0 ;
8575 let mut state = STATE . lock ( ) . unwrap ( ) ;
@@ -119,12 +109,8 @@ async fn interact(params: Parameters<InteractRequest>) -> Result<Json<InteractRe
119109pub struct CloseRequest { }
120110
121111/// Closes an open TCP connection.
122- #[ rmcp:: tool( name = "net_tcp_close" , annotations( destructive_hint = false ) ) ]
123- async fn _close ( _: Parameters < CloseRequest > ) -> Result < Json < String > , String > {
124- unreachable ! ( )
125- }
126-
127112#[ allow( clippy:: await_holding_lock) ]
113+ #[ rmcp:: tool( name = "net_tcp_close" , annotations( destructive_hint = false ) ) ]
128114async fn close ( params : Parameters < CloseRequest > ) -> Result < Json < String > , String > {
129115 let CloseRequest { } = params. 0 ;
130116 let Some ( mut stream) = STATE . lock ( ) . unwrap ( ) . take ( ) else {
0 commit comments