rig
rig copied to clipboard
bug: MCP submodule failed to compile
- [*] I have looked for existing issues (including closed) about this
Bug Report
rig-core failed to compile with MCP feature enabled when mcp-core and mcp-core-macros are also in the dependency list.
Compiling rig-core v0.12.0
error[E0769]: tuple variant `mcp_core::types::ToolResponseContent::Text` written as struct variant
--> /home/archer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rig-core-0.12.0/src/tool.rs:283:25
|
283 | mcp_core::types::ToolResponseContent::Text { text } => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: use the tuple variant pattern syntax instead
|
283 | mcp_core::types::ToolResponseContent::Text(text) => {
| ~~~~~~
error[E0769]: tuple variant `mcp_core::types::ToolResponseContent::Text` written as struct variant
--> /home/archer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rig-core-0.12.0/src/tool.rs:297:21
|
297 | mcp_core::types::ToolResponseContent::Text { text } => text,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: use the tuple variant pattern syntax instead
|
297 | mcp_core::types::ToolResponseContent::Text(text) => text,
| ~~~~~~
error[E0769]: tuple variant `mcp_core::types::ToolResponseContent::Image` written as struct variant
--> /home/archer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rig-core-0.12.0/src/tool.rs:298:21
|
298 | ... mcp_core::types::ToolResponseContent::Image { data, mime_type } => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: use the tuple variant pattern syntax instead
|
298 | mcp_core::types::ToolResponseContent::Image(_) => {
| ~~~
error[E0769]: tuple variant `mcp_core::types::ToolResponseContent::Audio` written as struct variant
--> /home/archer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rig-core-0.12.0/src/tool.rs:301:21
|
301 | ... mcp_core::types::ToolResponseContent::Audio { data, mime_type } => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: use the tuple variant pattern syntax instead
|
301 | mcp_core::types::ToolResponseContent::Audio(_) => {
| ~~~
error[E0027]: pattern does not mention fields `text`, `blob`
--> /home/archer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rig-core-0.12.0/src/tool.rs:305:35
|
305 | ...esource: mcp_core::types::ResourceContents { uri, mime_type },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing fields `text`, `blob`
|
help: include the missing fields in the pattern
|
305 | resource: mcp_core::types::ResourceContents { uri, mime_type, text, blob },
| ~~~~~~~~~~~~~~
help: if you don't care about these missing fields, you can explicitly ignore them
|
305 | resource: mcp_core::types::ResourceContents { uri, mime_type, text: _, blob: _ },
| ~~~~~~~~~~~~~~~~~~~~
help: or always ignore missing fields here
|
305 | resource: mcp_core::types::ResourceContents { uri, mime_type, .. },
| ~~~~~~
error[E0769]: tuple variant `mcp_core::types::ToolResponseContent::Resource` written as struct variant
--> /home/archer/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rig-core-0.12.0/src/tool.rs:304:21
|
304 | / ... mcp_core::types::ToolResponseContent::Resource {
305 | | ... resource: mcp_core::types::ResourceContents { uri, mime_type },
306 | | ... } => {
| |_______^
|
help: use the tuple variant pattern syntax instead
|
304 | mcp_core::types::ToolResponseContent::Resource(mcp_core::types::ResourceContents { uri, mime_type }) => {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Some errors have detailed explanations: E0027, E0769.
For more information about an error, try `rustc --explain E0027`.
error: could not compile `rig-core` (lib) due to 6 previous errors
It is the rig-core library that fails to compile.
Reproduction
- Create an empty rust project
- Add
rig-core,mcp-coreand other necessary dependencies toCargo.toml(all latest version) - Copy and paste the
mcp-toolexample inrig-coreintomain.rs. - Run
cargo build, the program fails to compile.
Source code
Cargo.toml
[package]
name = "test-rig-mcp"
version = "0.1.0"
edition = "2024"
[dependencies]
anyhow = "1.0.98"
mcp-core = { version = "0.1.50", features = ["sse"] }
mcp-core-macros = "0.1.30"
rig-core = { version = "0.12.0", features = ["mcp"] }
serde_json = "1.0.140"
tokio = { version = "1.44.2", features = ["full"] }
tracing-subscriber = "*"
tracing = "*"
serde = "*"
schemars = "*"
main.rs
use anyhow::Result;
use mcp_core::{
client::ClientBuilder,
server::Server,
tool_text_content,
transport::{ClientSseTransportBuilder, ServerSseTransport},
types::{ClientCapabilities, Implementation, ServerCapabilities, ToolResponseContent},
};
use mcp_core_macros::{tool, tool_param};
use rig::{
completion::Prompt,
providers::{self},
};
use serde_json::json;
#[tool(
name = "Add",
description = "Adds two numbers together.",
annotations(
title = "Add",
readOnlyHint = false,
destructiveHint = false,
idempotentHint = false,
openWorldHint = false
)
)]
async fn add_tool(
a: tool_param!(f64, description = "The first number to add"),
b: tool_param!(f64, description = "The second number to add"),
) -> Result<ToolResponseContent> {
Ok(tool_text_content!((a + b).to_string()))
}
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
tracing_subscriber::fmt().init();
// Create the MCP server
let mcp_server_protocol = Server::builder(
"add".to_string(),
"1.0".to_string(),
mcp_core::types::ProtocolVersion::V2025_03_26,
)
.capabilities(ServerCapabilities {
tools: Some(json!({
"listChanged": false,
})),
..Default::default()
})
.register_tool(AddTool::tool(), AddTool::call())
.build();
let mcp_server_transport =
ServerSseTransport::new("127.0.0.1".to_string(), 3000, mcp_server_protocol);
tokio::spawn(async move { Server::start(mcp_server_transport).await });
// Create the MCP client
let mcp_client = ClientBuilder::new(
ClientSseTransportBuilder::new("http://127.0.0.1:3000/sse".to_string()).build(),
)
.build();
// Start the MCP client
mcp_client.open().await?;
let init_res = mcp_client.initialize().await?;
println!("Initialized: {:?}", init_res);
let tools_list_res = mcp_client.list_tools(None, None).await?;
println!("Tools: {:?}", tools_list_res);
tracing::info!("Building RIG agent");
let completion_model = providers::openai::Client::from_env();
let mut agent_builder = completion_model.agent("gpt-4o");
// Add MCP tools to the agent
agent_builder = tools_list_res
.tools
.into_iter()
.fold(agent_builder, |builder, tool| {
builder.mcp_tool(tool, mcp_client.clone().into())
});
let agent = agent_builder.build();
tracing::info!("Prompting RIG agent");
let response = agent.prompt("Add 10 + 10").await?;
tracing::info!("Agent response: {:?}", response);
Ok(())
}
Expected behavior
The program compiles.
Screenshots
None
Additional context
rig-corev0.12.0mcp-corev0.1.50mcp-core-macrosv0.1.30
rig 0.12.0 + mcp-core 0.1.46 + mcp-core-derive 0.1.22 compiles.
Try do the following:
- Modify
mcp-coreandmcp-core-macroversion inCargo.toml - Run
cargo update -p mcp-core --precise 0.1.46andcargo update -p mcp-core-macro --precise 0.1.22to downgrade the dependencies - Re-build the project
However, I still think rig should adapt to the latest mcp-core crate version.
fixed in this PR
also .capabilities is now removed, use .set_capabilities as shown in example rig-core/examples/mcp_tool.rs