Skip to content

Commit 477fa5d

Browse files
committed
Merge branch 'main' into acitx-web-example
2 parents b07cd3a + 989453d commit 477fa5d

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

crates/mcp-macros/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
name = "mcp-macros"
33
version.workspace = true
44
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
57

68
[lib]
79
proc-macro = true

crates/mcp-server/src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,17 @@ where
105105
R: AsyncRead + Unpin,
106106
W: AsyncWrite + Unpin,
107107
{
108-
pub async fn write_message(&mut self, msg: JsonRpcMessage) -> Result<(), std::io::Error> {
108+
pub async fn write_message(
109+
self: &mut Pin<&mut Self>,
110+
msg: JsonRpcMessage,
111+
) -> Result<(), std::io::Error> {
109112
let json = serde_json::to_string(&msg)?;
110-
Pin::new(&mut self.writer)
111-
.write_all(json.as_bytes())
112-
.await?;
113-
Pin::new(&mut self.writer).write_all(b"\n").await?;
114-
Pin::new(&mut self.writer).flush().await?;
113+
114+
let mut this = self.as_mut().project();
115+
this.writer.write_all(json.as_bytes()).await?;
116+
this.writer.write_all(b"\n").await?;
117+
this.writer.flush().await?;
118+
115119
Ok(())
116120
}
117121
}
@@ -139,6 +143,7 @@ where
139143
{
140144
use futures::StreamExt;
141145
let mut service = self.service;
146+
let mut transport = Pin::new(&mut transport);
142147

143148
tracing::info!("Server started");
144149
while let Some(msg_result) = transport.next().await {

examples/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ This directory contains examples demonstrating how to use the Model Context Prot
1212

1313
The client examples demonstrate different ways to connect to MCP servers.
1414

15+
Before running the examples, ensure you have `uv` installed. You can find the installation instructions [here](https://github.com/astral-sh/uv).
16+
1517
### Available Examples
1618

1719
You can run the examples in two ways:

0 commit comments

Comments
 (0)