pub struct McpServer<Counterpart: Role, Run = NullRun> { /* private fields */ }Expand description
An MCP server that can be attached to ACP connections.
McpServer wraps an McpServerConnect implementation and can be used either:
- As a message handler via
Builder::with_handler, automatically attaching to new sessions - Manually for more control
§Creating an MCP Server
Use McpServer::builder to create a server with tools:
ⓘ
let server = McpServer::builder("my-server".to_string())
.instructions("A helpful assistant")
.tool(MyTool)
.build();Or implement McpServerConnect for custom server behavior:
ⓘ
let server = McpServer::new(MyCustomServerConnect);Implementations§
Source§impl<Host: Role> McpServer<Host, NullRun>
impl<Host: Role> McpServer<Host, NullRun>
Sourcepub fn builder(name: impl ToString) -> McpServerBuilder<Host, NullRun>
pub fn builder(name: impl ToString) -> McpServerBuilder<Host, NullRun>
Create an empty server with no content.
Source§impl<Counterpart: Role, Run> McpServer<Counterpart, Run>where
Run: RunWithConnectionTo<Counterpart>,
impl<Counterpart: Role, Run> McpServer<Counterpart, Run>where
Run: RunWithConnectionTo<Counterpart>,
Sourcepub fn new(c: impl McpServerConnect<Counterpart>, responder: Run) -> Self
pub fn new(c: impl McpServerConnect<Counterpart>, responder: Run) -> Self
Create an MCP server from something that implements the McpServerConnect trait.
§See also
See Self::builder to construct MCP servers from Rust code.
Trait Implementations§
Auto Trait Implementations§
impl<Counterpart, Run> Freeze for McpServer<Counterpart, Run>where
Run: Freeze,
impl<Counterpart, Run = NullRun> !RefUnwindSafe for McpServer<Counterpart, Run>
impl<Counterpart, Run> Send for McpServer<Counterpart, Run>where
Run: Send,
impl<Counterpart, Run> Sync for McpServer<Counterpart, Run>where
Run: Sync,
impl<Counterpart, Run> Unpin for McpServer<Counterpart, Run>
impl<Counterpart, Run> UnsafeUnpin for McpServer<Counterpart, Run>where
Run: UnsafeUnpin,
impl<Counterpart, Run = NullRun> !UnwindSafe for McpServer<Counterpart, Run>
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
Mutably borrows from an owned value. Read more