Skip to content

Commit db57cda

Browse files
committed
Merge remote-tracking branch 'upstream/main' into revision-2025-03-26
2 parents 316c7c5 + c30d806 commit db57cda

File tree

11 files changed

+140
-18
lines changed

11 files changed

+140
-18
lines changed

.devcontainer/devcontainer.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
3+
{
4+
"name": "Rust",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
7+
"features": {
8+
"ghcr.io/devcontainers/features/node:1": {},
9+
"ghcr.io/devcontainers/features/python:1": {
10+
"version": "3.10",
11+
"toolsToInstall": "uv"
12+
}
13+
},
14+
// Configure tool-specific properties.
15+
"customizations": {
16+
"vscode": {
17+
"settings": {
18+
"editor.formatOnSave": true,
19+
"[rust]": {
20+
"editor.defaultFormatter": "rust-lang.rust-analyzer"
21+
}
22+
}
23+
}
24+
},
25+
// Use 'postCreateCommand' to run commands after the container is created.
26+
"postCreateCommand": "uv venv"
27+
// Use 'mounts' to make the cargo cache persistent in a Docker Volume.
28+
// "mounts": [
29+
// {
30+
// "source": "devcontainer-cargo-cache-${devcontainerId}",
31+
// "target": "/usr/local/cargo",
32+
// "type": "volume"
33+
// }
34+
// ]
35+
// Features to add to the dev container. More info: https://containers.dev/features.
36+
// "features": {},
37+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
38+
// "forwardPorts": [],
39+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
40+
// "remoteUser": "root"
41+
}

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ jobs:
6060

6161
- name: Run clippy
6262
run: cargo clippy --all-targets --all-features -- -D warnings
63+
64+
spelling:
65+
name: spell check with typos
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v4
69+
- name: Spell Check Repo
70+
uses: crate-ci/typos@master
6371

6472
test:
6573
name: Run Tests

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,7 @@ See [examples](examples/README.md)
188188

189189
- [MCP Specification](https://spec.modelcontextprotocol.io/specification/2024-11-05/)
190190
- [Schema](https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts)
191+
192+
## Development with Dev Container
193+
194+
See [docs/DEVCONTAINER.md](docs/DEVCONTAINER.md) for instructions on using Dev Container for development.

crates/rmcp-macros/src/tool.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
213213
// let mut fommated_fn_args: Punctuated<FnArg, Comma> = Punctuated::new();
214214
let mut unextractable_args_indexes = HashSet::new();
215215
for (index, mut fn_arg) in input_fn.sig.inputs.iter_mut().enumerate() {
216-
enum Catched {
216+
enum Caught {
217217
Param(ToolFnParamAttrs),
218218
Aggregated(PatType),
219219
}
220-
let mut catched = None;
220+
let mut caught = None;
221221
match &mut fn_arg {
222222
FnArg::Receiver(_) => {
223223
continue;
@@ -244,15 +244,15 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
244244
"input param must have an ident as name",
245245
));
246246
};
247-
catched.replace(Catched::Param(ToolFnParamAttrs {
247+
caught.replace(Caught::Param(ToolFnParamAttrs {
248248
serde_meta: Vec::new(),
249249
schemars_meta: Vec::new(),
250250
ident: arg_ident,
251251
rust_type: pat_type.ty.clone(),
252252
}));
253253
}
254254
ParamMarker::Aggregated => {
255-
catched.replace(Catched::Aggregated(pat_type.clone()));
255+
caught.replace(Caught::Aggregated(pat_type.clone()));
256256
}
257257
}
258258
} else if meta_list.path.is_ident(SERDE_IDENT) {
@@ -268,8 +268,8 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
268268
}
269269
}
270270
}
271-
match catched {
272-
Some(Catched::Param(mut param)) => {
271+
match caught {
272+
Some(Caught::Param(mut param)) => {
273273
param.serde_meta = serde_metas;
274274
param.schemars_meta = schemars_metas;
275275
match &mut tool_macro_attrs.params {
@@ -282,7 +282,7 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
282282
}
283283
unextractable_args_indexes.insert(index);
284284
}
285-
Some(Catched::Aggregated(rust_type)) => {
285+
Some(Caught::Aggregated(rust_type)) => {
286286
tool_macro_attrs.params = ToolParams::Aggregated { rust_type };
287287
unextractable_args_indexes.insert(index);
288288
}
@@ -361,7 +361,7 @@ pub(crate) fn tool_fn_item(attr: TokenStream, mut input_fn: ItemFn) -> syn::Resu
361361
// async fn #tool_tool_call(context: rmcp::handler::server::tool::ToolCallContext<'_, Self>)
362362
// -> std::result::Result<rmcp::model::CallToolResult, rmcp::Error>
363363
//
364-
// and the block part shoule be like:
364+
// and the block part should be like:
365365
// {
366366
// use rmcp::handler::server::tool::*;
367367
// let (t0, context) = <T0>::from_tool_call_context_part(context)?;

crates/rmcp/tests/test_complex_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Demo {
4444
fn test_complex_schema() {
4545
let attr = Demo::chat_tool_attr();
4646
let input_schema = attr.input_schema;
47-
let enum_numer = input_schema
47+
let enum_number = input_schema
4848
.get("definitions")
4949
.unwrap()
5050
.as_object()
@@ -58,6 +58,6 @@ fn test_complex_schema() {
5858
.as_array()
5959
.unwrap()
6060
.len();
61-
assert_eq!(enum_numer, 4);
61+
assert_eq!(enum_number, 4);
6262
println!("{}", serde_json::to_string_pretty(&input_schema).unwrap());
6363
}

docs/DEVCONTAINER.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## Development with Dev Container and GitHub Codespaces
2+
3+
This repository provides a Dev Container to easily set up a development environment. Using Dev Container allows you to work in a consistent development environment with pre-configured dependencies and tools, whether locally or in the cloud with GitHub Codespaces.
4+
5+
### Prerequisites
6+
7+
**For Local Development:**
8+
9+
* [Docker Desktop](https://www.docker.com/products/docker-desktop/) or any other compatible container runtime (e.g., Podman, OrbStack) installed.
10+
* [Visual Studio Code](https://code.visualstudio.com/) with the [Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed.
11+
12+
**For GitHub Codespaces:**
13+
14+
* A GitHub account.
15+
16+
### Starting Dev Container
17+
18+
**Using Visual Studio Code (Local):**
19+
20+
1. Clone the repository.
21+
2. Open the repository in Visual Studio Code.
22+
3. Open the command palette in Visual Studio Code (`Ctrl + Shift + P` or `Cmd + Shift + P`) and execute `Dev Containers: Reopen in Container`.
23+
24+
**Using GitHub Codespaces (Cloud):**
25+
26+
1. Navigate to the repository on GitHub.
27+
2. Click the "<> Code" button.
28+
3. Select the "Codespaces" tab.
29+
4. Click "Create codespace on main" (or your desired branch).
30+
31+
### Dev Container Configuration
32+
33+
Dev Container settings are configured in `.devcontainer/devcontainer.json`. In this file, you can set the Docker image to use, extensions to install, port forwarding, and more. This configuration is used both for local development and GitHub Codespaces.
34+
35+
### Development
36+
37+
Once the Dev Container is started, you can proceed with development as usual. The container already has the necessary tools and libraries installed. In GitHub Codespaces, you will have a fully configured VS Code in your browser or desktop application.
38+
39+
### Stopping Dev Container
40+
41+
**Using Visual Studio Code (Local):**
42+
43+
To stop the Dev Container, open the command palette in Visual Studio Code and execute `Remote: Close Remote Connection`.
44+
45+
**Using GitHub Codespaces (Cloud):**
46+
47+
GitHub Codespaces will automatically stop after a period of inactivity. You can also manually stop the codespace from the Codespaces menu in GitHub.
48+
49+
### More Information
50+
51+
* [Visual Studio Code Dev Containers](https://code.visualstudio.com/docs/remote/containers)
52+
* [Dev Container Specification](https://containers.dev/implementors/json_reference/)
53+
* [GitHub Codespaces](https://github.com/features/codespaces)
54+
55+
This document describes the basic usage of Dev Container and GitHub Codespaces. Add project-specific settings and procedures as needed.

examples/rig-integration/src/chat.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,24 @@ pub async fn output_error(
7474
e: impl std::fmt::Display,
7575
output: &mut BufWriter<tokio::io::Stdout>,
7676
) -> std::io::Result<()> {
77-
output.write_all(b"\x1b[31mERROR: \x1b[0m").await?;
77+
output
78+
.write_all(b"\x1b[1;31m\xE2\x9D\x8C ERROR: \x1b[0m")
79+
.await?;
7880
output.write_all(e.to_string().as_bytes()).await?;
7981
output.write_all(b"\n").await?;
82+
output.flush().await?;
8083
Ok(())
8184
}
8285

8386
pub async fn output_agent(
8487
content: impl std::fmt::Display,
8588
output: &mut BufWriter<tokio::io::Stdout>,
8689
) -> std::io::Result<()> {
90+
output
91+
.write_all(b"\x1b[1;34m\xF0\x9F\xA4\x96 Agent: \x1b[0m")
92+
.await?;
8793
output.write_all(content.to_string().as_bytes()).await?;
94+
output.write_all(b"\n").await?;
8895
output.flush().await?;
8996
Ok(())
9097
}
@@ -93,22 +100,29 @@ pub async fn stream_output_toolcall(
93100
content: impl std::fmt::Display,
94101
output: &mut BufWriter<tokio::io::Stdout>,
95102
) -> std::io::Result<()> {
96-
output.write_all(b"\x1b[33mtool>\x1b[0m ").await?;
103+
output
104+
.write_all(b"\x1b[1;33m\xF0\x9F\x9B\xA0 Tool Call: \x1b[0m")
105+
.await?;
97106
output.write_all(content.to_string().as_bytes()).await?;
98107
output.write_all(b"\n").await?;
108+
output.flush().await?;
99109
Ok(())
100110
}
101111

102112
pub async fn stream_output_agent_start(
103113
output: &mut BufWriter<tokio::io::Stdout>,
104114
) -> std::io::Result<()> {
105-
output.write_all(b"\x1b[34magent>\x1b[0m ").await?;
115+
output
116+
.write_all(b"\x1b[1;34m\xF0\x9F\xA4\x96 Agent: \x1b[0m")
117+
.await?;
118+
output.flush().await?;
106119
Ok(())
107120
}
108121

109122
pub async fn stream_output_agent_finished(
110123
output: &mut BufWriter<tokio::io::Stdout>,
111124
) -> std::io::Result<()> {
112125
output.write_all(b"\n").await?;
126+
output.flush().await?;
113127
Ok(())
114128
}

examples/rig-integration/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Config {
1212
}
1313

1414
impl Config {
15-
pub async fn retrive(path: impl AsRef<Path>) -> anyhow::Result<Self> {
15+
pub async fn retrieve(path: impl AsRef<Path>) -> anyhow::Result<Self> {
1616
let content = tokio::fs::read_to_string(path).await?;
1717
let config: Self = toml::from_str(&content)?;
1818
Ok(config)

examples/rig-integration/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod config;
1111
pub mod mcp_adaptor;
1212
#[tokio::main]
1313
async fn main() -> anyhow::Result<()> {
14-
let config = config::Config::retrive("config.toml").await?;
14+
let config = config::Config::retrieve("config.toml").await?;
1515
let openai_client = {
1616
if let Some(key) = config.deepseek_key {
1717
deepseek::Client::new(&key)

examples/servers/src/common/calculator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ impl Calculator {
2020
(a + b).to_string()
2121
}
2222

23-
#[tool(description = "Calculate the sum of two numbers")]
23+
#[tool(description = "Calculate the sub of two numbers")]
2424
fn sub(
2525
&self,
2626
#[tool(param)]
2727
#[schemars(description = "the left hand side number")]
2828
a: i32,
2929
#[tool(param)]
30-
#[schemars(description = "the left hand side number")]
30+
#[schemars(description = "the right hand side number")]
3131
b: i32,
3232
) -> Json<i32> {
3333
Json(a - b)

0 commit comments

Comments
 (0)