pub struct McpServer { /* private fields */ }Expand description
MCP Server implementation
Implementations§
Source§impl McpServer
impl McpServer
Sourcepub fn new_local() -> Self
pub fn new_local() -> Self
Create a new MCP server for in-process/local usage.
Unlike Self::new_stdio, this does not spawn any stdio reader/writer threads
and will not lock stdout. This is intended for CLI flows that need to query
tool metadata or invoke tools directly without running a long-lived stdio server.
Sourcepub fn new(transport: Arc<dyn Transport>) -> Self
pub fn new(transport: Arc<dyn Transport>) -> Self
Create a new MCP server with custom transport
Sourcepub fn with_tool_registry(self, registry: Arc<ToolRegistry>) -> Self
pub fn with_tool_registry(self, registry: Arc<ToolRegistry>) -> Self
Attach the full CodeTether tool registry to the MCP server.
All tools from the registry will be exposed as MCP tools, replacing
the hardcoded basic tool set. Call before Self::run.
Sourcepub fn with_agent_bus(self, bus: Arc<AgentBus>) -> Self
pub fn with_agent_bus(self, bus: Arc<AgentBus>) -> Self
Attach a local agent bus for publishing tool calls to the S3 sink.
Call this before Self::run so every tool invocation gets
recorded as a ToolRequest + ToolResponse on the bus.
Sourcepub async fn with_bus(self, bus_url: String) -> Self
pub async fn with_bus(self, bus_url: String) -> Self
Attach a bus bridge and register bus-aware tools + resources.
Call this before Self::run to enable live bus monitoring.
Sourcepub async fn register_tool(
&self,
name: &str,
description: &str,
input_schema: Value,
handler: Arc<dyn Fn(Value) -> Result<CallToolResult> + Send + Sync>,
)
pub async fn register_tool( &self, name: &str, description: &str, input_schema: Value, handler: Arc<dyn Fn(Value) -> Result<CallToolResult> + Send + Sync>, )
Register a tool
Sourcepub async fn register_resource(
&self,
uri: &str,
name: &str,
description: &str,
mime_type: Option<&str>,
handler: Arc<dyn Fn(String) -> Result<ReadResourceResult> + Send + Sync>,
)
pub async fn register_resource( &self, uri: &str, name: &str, description: &str, mime_type: Option<&str>, handler: Arc<dyn Fn(String) -> Result<ReadResourceResult> + Send + Sync>, )
Register a resource
Sourcepub async fn get_tool_metadata(&self, name: &str) -> Option<ToolMetadata>
pub async fn get_tool_metadata(&self, name: &str) -> Option<ToolMetadata>
Get tool metadata by name
Sourcepub async fn get_all_tool_metadata(&self) -> Vec<ToolMetadata>
pub async fn get_all_tool_metadata(&self) -> Vec<ToolMetadata>
Get all tool metadata
Sourcepub async fn get_resource_metadata(&self, uri: &str) -> Option<ResourceMetadata>
pub async fn get_resource_metadata(&self, uri: &str) -> Option<ResourceMetadata>
Get resource metadata by URI
Sourcepub async fn get_all_resource_metadata(&self) -> Vec<ResourceMetadata>
pub async fn get_all_resource_metadata(&self) -> Vec<ResourceMetadata>
Get all resource metadata
Sourcepub async fn register_prompt(
&self,
name: &str,
handler: Arc<dyn Fn(Value) -> Result<GetPromptResult> + Send + Sync>,
)
pub async fn register_prompt( &self, name: &str, handler: Arc<dyn Fn(Value) -> Result<GetPromptResult> + Send + Sync>, )
Register a prompt handler
Sourcepub async fn get_prompt_handler(
&self,
name: &str,
) -> Option<Arc<dyn Fn(Value) -> Result<GetPromptResult> + Send + Sync>>
pub async fn get_prompt_handler( &self, name: &str, ) -> Option<Arc<dyn Fn(Value) -> Result<GetPromptResult> + Send + Sync>>
Get a prompt handler by name
Sourcepub async fn list_prompts(&self) -> Vec<String>
pub async fn list_prompts(&self) -> Vec<String>
List all registered prompt names
Sourcepub async fn setup_tools_public(&self)
pub async fn setup_tools_public(&self)
Setup default tools (public, for CLI use)
Sourcepub async fn call_tool_direct(
&self,
name: &str,
arguments: Value,
) -> Result<CallToolResult>
pub async fn call_tool_direct( &self, name: &str, arguments: Value, ) -> Result<CallToolResult>
Call a tool directly without going through the transport
Auto Trait Implementations§
impl !Freeze for McpServer
impl !RefUnwindSafe for McpServer
impl Send for McpServer
impl Sync for McpServer
impl Unpin for McpServer
impl UnsafeUnpin for McpServer
impl !UnwindSafe for McpServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request