pub struct ScriptedMcpServer { /* private fields */ }Expand description
In-memory scripted mcp server fixture for SDK conformance tests. Use it to script deterministic behavior in memory; any transcript or endpoint mutation is documented on the method that performs it.
Implementations§
Source§impl ScriptedMcpServer
impl ScriptedMcpServer
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new testing::protocol::mcp value with explicit caller-provided inputs. This constructor is data-only and performs no I/O or external side effects.
Sourcepub fn tool(self, name: impl Into<String>, result: Value) -> Self
pub fn tool(self, name: impl Into<String>, result: Value) -> Self
Returns an updated testing::protocol::mcp value with tool applied. This is data construction only and does not execute the configured behavior.
Sourcepub fn resource(self, uri: impl Into<String>, text: impl Into<String>) -> Self
pub fn resource(self, uri: impl Into<String>, text: impl Into<String>) -> Self
Returns an updated value with resource configured. This configures or reads the scripted protocol mock in memory.
Sourcepub fn prompt(self, name: impl Into<String>, spec: Value) -> Self
pub fn prompt(self, name: impl Into<String>, spec: Value) -> Self
Adds a scripted prompt definition and returns the updated fake server. This mutates only the builder’s in-memory prompt map; request frames are appended later when a client asks the endpoint for prompts.
Sourcepub fn handle_next(
&mut self,
endpoint: &JsonRpcLineEndpoint,
) -> Result<bool, AgentError>
pub fn handle_next( &mut self, endpoint: &JsonRpcLineEndpoint, ) -> Result<bool, AgentError>
Handle next. This consumes one queued JSON-RPC frame from the in-memory endpoint and mutates only scripted mock state.
Sourcepub fn request_sampling(
&mut self,
endpoint: &JsonRpcLineEndpoint,
) -> Result<JsonRpcId, AgentError>
pub fn request_sampling( &mut self, endpoint: &JsonRpcLineEndpoint, ) -> Result<JsonRpcId, AgentError>
Request sampling. This appends the corresponding JSON-RPC frame to the in-memory test endpoint transcript.
Sourcepub fn request_elicitation(
&mut self,
endpoint: &JsonRpcLineEndpoint,
) -> Result<JsonRpcId, AgentError>
pub fn request_elicitation( &mut self, endpoint: &JsonRpcLineEndpoint, ) -> Result<JsonRpcId, AgentError>
Request elicitation. This appends the corresponding JSON-RPC frame to the in-memory test endpoint transcript.
Sourcepub fn response(
&self,
endpoint: &JsonRpcLineEndpoint,
) -> Result<JsonRpcResponse, AgentError>
pub fn response( &self, endpoint: &JsonRpcLineEndpoint, ) -> Result<JsonRpcResponse, AgentError>
Returns the response currently held by this value. This reads scripted protocol state or a queued response without contacting an external process.
Sourcepub fn initialized(&self) -> bool
pub fn initialized(&self) -> bool
Returns the initialized currently held by this value. This reads scripted protocol state or a queued response without contacting an external process.
Trait Implementations§
Source§impl Clone for ScriptedMcpServer
impl Clone for ScriptedMcpServer
Source§fn clone(&self) -> ScriptedMcpServer
fn clone(&self) -> ScriptedMcpServer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more