Move whole rmcp crate to offcial rust sdk (#44)

* get rid of async-trait

* move rmcp to official-rust-sdk

* replace master with main

* update readme, change license

* fix typo

* Update README.md

Co-authored-by: Jefry Dewangga <jefrydco@gmail.com>

* fix typos

---------

Co-authored-by: = <=>
Co-authored-by: Jefry Dewangga <jefrydco@gmail.com>
This commit is contained in:
4t145 2025-03-28 05:33:41 +08:00 • committed by GitHub
commit 0be6067326
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,49 @@
use anyhow::Result;
use rmcp::{model::CallToolRequestParam, service::ServiceExt, transport::TokioChildProcess};
use tokio::process::Command;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
#[tokio::main]
async fn main() -> Result<()> {
// Initialize logging
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| format!("info,{}=debug", env!("CARGO_CRATE_NAME")).into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
let service = ()
.serve(TokioChildProcess::new(
Command::new("uvx").arg("mcp-server-git"),
)?)
.await?;
// or
// serve_client(
// (),
// TokioChildProcess::new(Command::new("uvx").arg("mcp-server-git"))?,
// )
// .await?;
// Initialize
let server_info = service.peer_info();
tracing::info!("Connected to server: {server_info:#?}");
// List tools
let tools = service.list_tools(Default::default()).await?;
tracing::info!("Available tools: {tools:#?}");
// Call tool 'git_status' with arguments = {"repo_path": "."}
let tool_result = service
.call_tool(CallToolRequestParam {
name: "git_status".into(),
arguments: serde_json::json!({ "repo_path": "." }).as_object().cloned(),
})
.await?;
tracing::info!("Tool result: {tool_result:#?}");
service.cancel().await?;
Ok(())
}