style: fmt the project (#54)
add rustfmt.toml Signed-off-by: jokemanfire <hu.dingyang@zte.com.cn>
This commit is contained in:
parent
59bfb6e748
commit
0a2f13a1f4
36 changed files with 158 additions and 132 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
|
@ -41,11 +41,11 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust fmt
|
||||||
uses: dtolnay/rust-toolchain@stable
|
run: rustup toolchain install nightly --component rustfmt
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: cargo fmt --all -- --check
|
run: cargo +nightly fmt --all -- --check
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
name: Lint with Clippy
|
name: Lint with Clippy
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
cargo-features = ["edition2024"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["crates/rmcp", "crates/rmcp-macros", "examples/*"]
|
members = ["crates/rmcp", "crates/rmcp-macros", "examples/*"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
@ -12,7 +14,7 @@ version = "0.1.5"
|
||||||
authors = ["4t145 <u4t145@163.com>"]
|
authors = ["4t145 <u4t145@163.com>"]
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
repository = "https://github.com/modelcontextprotocol/rust-sdk/"
|
repository = "https://github.com/modelcontextprotocol/rust-sdk/"
|
||||||
description = "Rust SDK for the Model Context Protocol"
|
description = "Rust SDK for Model Context Protocol"
|
||||||
keywords = ["mcp", "sdk", "tokio", "modelcontextprotocol"]
|
keywords = ["mcp", "sdk", "tokio", "modelcontextprotocol"]
|
||||||
homepage = "https://github.com/modelcontextprotocol/rust-sdk"
|
homepage = "https://github.com/modelcontextprotocol/rust-sdk"
|
||||||
categories = [
|
categories = [
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
|
cargo-features = ["edition2024"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "rmcp-macros"
|
name = "rmcp-macros"
|
||||||
license.workspace = true
|
license = { workspace = true }
|
||||||
version.workspace = true
|
version = { workspace = true }
|
||||||
edition.workspace = true
|
edition = { workspace = true }
|
||||||
repository.workspace = true
|
repository = { workspace = true }
|
||||||
homepage.workspace = true
|
homepage = { workspace = true }
|
||||||
readme.workspace = true
|
readme = { workspace = true }
|
||||||
description = "Rust SDK for Model Context Protocol macros library"
|
description = "Rust SDK for Model Context Protocol macros library"
|
||||||
documentation = "https://docs.rs/rmcp-macros"
|
documentation = "https://docs.rs/rmcp-macros"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
|
cargo-features = ["edition2024"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "rmcp"
|
name = "rmcp"
|
||||||
license.workspace = true
|
license = { workspace = true }
|
||||||
version.workspace = true
|
version = { workspace = true }
|
||||||
edition.workspace = true
|
edition = { workspace = true }
|
||||||
repository.workspace = true
|
repository = { workspace = true }
|
||||||
homepage.workspace = true
|
homepage = { workspace = true }
|
||||||
readme.workspace = true
|
readme = { workspace = true }
|
||||||
description = "Rust SDK for Model Context Protocol"
|
description = "Rust SDK for Model Context Protocol"
|
||||||
documentation = "https://docs.rs/rmcp"
|
documentation = "https://docs.rs/rmcp"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use crate::error::Error as McpError;
|
use crate::{
|
||||||
use crate::model::*;
|
error::Error as McpError,
|
||||||
use crate::service::{Peer, RequestContext, RoleClient, Service, ServiceRole};
|
model::*,
|
||||||
|
service::{Peer, RequestContext, RoleClient, Service, ServiceRole},
|
||||||
|
};
|
||||||
|
|
||||||
impl<H: ClientHandler> Service<RoleClient> for H {
|
impl<H: ClientHandler> Service<RoleClient> for H {
|
||||||
async fn handle_request(
|
async fn handle_request(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use crate::error::Error as McpError;
|
use crate::{
|
||||||
use crate::model::*;
|
error::Error as McpError,
|
||||||
use crate::service::{Peer, RequestContext, RoleServer, Service, ServiceRole};
|
model::*,
|
||||||
|
service::{Peer, RequestContext, RoleServer, Service, ServiceRole},
|
||||||
|
};
|
||||||
|
|
||||||
mod resource;
|
mod resource;
|
||||||
pub mod tool;
|
pub mod tool;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@ pub use error::Error;
|
||||||
pub mod model;
|
pub mod model;
|
||||||
#[cfg(any(feature = "client", feature = "server"))]
|
#[cfg(any(feature = "client", feature = "server"))]
|
||||||
pub mod service;
|
pub mod service;
|
||||||
|
#[cfg(feature = "client")]
|
||||||
|
pub use handler::client::ClientHandler;
|
||||||
|
#[cfg(feature = "server")]
|
||||||
|
pub use handler::server::ServerHandler;
|
||||||
#[cfg(any(feature = "client", feature = "server"))]
|
#[cfg(any(feature = "client", feature = "server"))]
|
||||||
pub use service::{Peer, Service, ServiceError, ServiceExt};
|
pub use service::{Peer, Service, ServiceError, ServiceExt};
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
|
|
@ -13,21 +17,15 @@ pub use service::{RoleClient, serve_client};
|
||||||
#[cfg(feature = "server")]
|
#[cfg(feature = "server")]
|
||||||
pub use service::{RoleServer, serve_server};
|
pub use service::{RoleServer, serve_server};
|
||||||
|
|
||||||
#[cfg(feature = "client")]
|
|
||||||
pub use handler::client::ClientHandler;
|
|
||||||
#[cfg(feature = "server")]
|
|
||||||
pub use handler::server::ServerHandler;
|
|
||||||
|
|
||||||
pub mod handler;
|
pub mod handler;
|
||||||
pub mod transport;
|
pub mod transport;
|
||||||
|
|
||||||
#[cfg(all(feature = "macros", feature = "server"))]
|
|
||||||
pub use rmcp_macros::tool;
|
|
||||||
|
|
||||||
// re-export
|
// re-export
|
||||||
#[cfg(all(feature = "macros", feature = "server"))]
|
#[cfg(all(feature = "macros", feature = "server"))]
|
||||||
pub use paste::paste;
|
pub use paste::paste;
|
||||||
#[cfg(all(feature = "macros", feature = "server"))]
|
#[cfg(all(feature = "macros", feature = "server"))]
|
||||||
|
pub use rmcp_macros::tool;
|
||||||
|
#[cfg(all(feature = "macros", feature = "server"))]
|
||||||
pub use schemars;
|
pub use schemars;
|
||||||
#[cfg(feature = "macros")]
|
#[cfg(feature = "macros")]
|
||||||
pub use serde;
|
pub use serde;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ pub use capabilities::*;
|
||||||
pub use content::*;
|
pub use content::*;
|
||||||
pub use prompt::*;
|
pub use prompt::*;
|
||||||
pub use resource::*;
|
pub use resource::*;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
pub use tool::*;
|
pub use tool::*;
|
||||||
|
|
@ -964,9 +963,10 @@ impl From<CancelledNotification> for ClientNotification {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_notification_serde() {
|
fn test_notification_serde() {
|
||||||
let raw = json!( {
|
let raw = json!( {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
RawContent, RawEmbeddedResource, RawImageContent, RawResource, RawResourceTemplate,
|
RawContent, RawEmbeddedResource, RawImageContent, RawResource, RawResourceTemplate,
|
||||||
RawTextContent, Role,
|
RawTextContent, Role,
|
||||||
};
|
};
|
||||||
use chrono::{DateTime, Utc};
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
use super::JsonObject;
|
use std::{collections::BTreeMap, marker::PhantomData};
|
||||||
|
|
||||||
use paste::paste;
|
use paste::paste;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use std::marker::PhantomData;
|
use super::JsonObject;
|
||||||
pub type ExperimentalCapabilities = BTreeMap<String, JsonObject>;
|
pub type ExperimentalCapabilities = BTreeMap<String, JsonObject>;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Default)]
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
//! Content sent around agents, extensions, and LLMs
|
//! Content sent around agents, extensions, and LLMs
|
||||||
//! The various content types can be display to humans but also understood by models
|
//! The various content types can be display to humans but also understood by models
|
||||||
//! They include optional annotations used to help inform agent usage
|
//! They include optional annotations used to help inform agent usage
|
||||||
use super::resource::ResourceContents;
|
|
||||||
use super::{AnnotateAble, Annotated};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
|
use super::{AnnotateAble, Annotated, resource::ResourceContents};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct RawTextContent {
|
pub struct RawTextContent {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
use super::content::{EmbeddedResource, ImageContent};
|
|
||||||
use super::resource::ResourceContents;
|
|
||||||
use super::{AnnotateAble, Annotations, RawEmbeddedResource, RawImageContent};
|
|
||||||
use base64::engine::{Engine, general_purpose::STANDARD as BASE64_STANDARD};
|
use base64::engine::{Engine, general_purpose::STANDARD as BASE64_STANDARD};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use super::{
|
||||||
|
AnnotateAble, Annotations, RawEmbeddedResource, RawImageContent,
|
||||||
|
content::{EmbeddedResource, ImageContent},
|
||||||
|
resource::ResourceContents,
|
||||||
|
};
|
||||||
|
|
||||||
/// A prompt that can be used to generate text from a model
|
/// A prompt that can be used to generate text from a model
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
use crate::error::Error as McpError;
|
|
||||||
use crate::model::{
|
|
||||||
CancelledNotification, CancelledNotificationParam, JsonRpcMessage, Message, RequestId,
|
|
||||||
};
|
|
||||||
use crate::transport::IntoTransport;
|
|
||||||
use futures::future::BoxFuture;
|
use futures::future::BoxFuture;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
error::Error as McpError,
|
||||||
|
model::{
|
||||||
|
CancelledNotification, CancelledNotificationParam, JsonRpcMessage, Message, RequestId,
|
||||||
|
},
|
||||||
|
transport::IntoTransport,
|
||||||
|
};
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
mod client;
|
mod client;
|
||||||
#[cfg(feature = "client")]
|
#[cfg(feature = "client")]
|
||||||
|
|
@ -15,10 +18,9 @@ mod server;
|
||||||
pub use server::*;
|
pub use server::*;
|
||||||
#[cfg(feature = "tower")]
|
#[cfg(feature = "tower")]
|
||||||
mod tower;
|
mod tower;
|
||||||
|
use tokio_util::sync::CancellationToken;
|
||||||
#[cfg(feature = "tower")]
|
#[cfg(feature = "tower")]
|
||||||
pub use tower::*;
|
pub use tower::*;
|
||||||
|
|
||||||
use tokio_util::sync::CancellationToken;
|
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
|
|
@ -189,11 +191,12 @@ impl<R: ServiceRole, S: Service<R>> DynService<R> for S {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::{
|
||||||
use std::ops::Deref;
|
collections::HashMap,
|
||||||
use std::sync::Arc;
|
ops::Deref,
|
||||||
use std::sync::atomic::AtomicU32;
|
sync::{Arc, atomic::AtomicU32},
|
||||||
use std::time::Duration;
|
time::Duration,
|
||||||
|
};
|
||||||
|
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
use futures::{SinkExt, StreamExt};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
use crate::model::{
|
use crate::model::{
|
||||||
CallToolRequest, CallToolRequestParam, CallToolResult, CancelledNotification,
|
CallToolRequest, CallToolRequestParam, CallToolResult, CancelledNotification,
|
||||||
CancelledNotificationParam, ClientInfo, ClientMessage, ClientNotification, ClientRequest,
|
CancelledNotificationParam, ClientInfo, ClientMessage, ClientNotification, ClientRequest,
|
||||||
|
|
@ -12,9 +15,6 @@ use crate::model::{
|
||||||
UnsubscribeRequest, UnsubscribeRequestParam,
|
UnsubscribeRequest, UnsubscribeRequestParam,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
|
||||||
use futures::{SinkExt, StreamExt};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||||
pub struct RoleClient;
|
pub struct RoleClient;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
use futures::{SinkExt, StreamExt};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
use crate::model::{
|
use crate::model::{
|
||||||
CancelledNotification, CancelledNotificationParam, ClientInfo, ClientNotification,
|
CancelledNotification, CancelledNotificationParam, ClientInfo, ClientNotification,
|
||||||
ClientRequest, ClientResult, CreateMessageRequest, CreateMessageRequestParam,
|
ClientRequest, ClientResult, CreateMessageRequest, CreateMessageRequestParam,
|
||||||
|
|
@ -8,9 +11,6 @@ use crate::model::{
|
||||||
ServerResult, ToolListChangedNotification,
|
ServerResult, ToolListChangedNotification,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
|
||||||
use futures::{SinkExt, StreamExt};
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
|
||||||
pub struct RoleServer;
|
pub struct RoleServer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,8 @@ use tokio::{
|
||||||
process::{ChildStdin, ChildStdout},
|
process::{ChildStdin, ChildStdout},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::service::{RxJsonRpcMessage, ServiceRole, TxJsonRpcMessage};
|
|
||||||
|
|
||||||
use super::IntoTransport;
|
use super::IntoTransport;
|
||||||
|
use crate::service::{RxJsonRpcMessage, ServiceRole, TxJsonRpcMessage};
|
||||||
|
|
||||||
pub(crate) fn child_process(
|
pub(crate) fn child_process(
|
||||||
mut child: tokio::process::Child,
|
mut child: tokio::process::Child,
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,14 @@ use std::marker::PhantomData;
|
||||||
use futures::{Sink, SinkExt, Stream, StreamExt};
|
use futures::{Sink, SinkExt, Stream, StreamExt};
|
||||||
use serde::{Serialize, de::DeserializeOwned};
|
use serde::{Serialize, de::DeserializeOwned};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use tokio::io::{AsyncRead, AsyncWrite};
|
use tokio::io::{AsyncRead, AsyncWrite};
|
||||||
use tokio_util::{
|
use tokio_util::{
|
||||||
bytes::{Buf, BufMut, BytesMut},
|
bytes::{Buf, BufMut, BytesMut},
|
||||||
codec::{Decoder, Encoder, FramedRead, FramedWrite},
|
codec::{Decoder, Encoder, FramedRead, FramedWrite},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::service::{RxJsonRpcMessage, ServiceRole, TxJsonRpcMessage};
|
|
||||||
|
|
||||||
use super::IntoTransport;
|
use super::IntoTransport;
|
||||||
|
use crate::service::{RxJsonRpcMessage, ServiceRole, TxJsonRpcMessage};
|
||||||
|
|
||||||
#[cfg(feature = "transport-io")]
|
#[cfg(feature = "transport-io")]
|
||||||
/// # StdIO Transport
|
/// # StdIO Transport
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
//! reference: https://html.spec.whatwg.org/multipage/server-sent-events.html
|
//! reference: https://html.spec.whatwg.org/multipage/server-sent-events.html
|
||||||
use crate::model::{ClientJsonRpcMessage, ServerJsonRpcMessage};
|
use std::{collections::VecDeque, sync::Arc, time::Duration};
|
||||||
|
|
||||||
use futures::{FutureExt, Sink, Stream, StreamExt, future::BoxFuture, stream::BoxStream};
|
use futures::{FutureExt, Sink, Stream, StreamExt, future::BoxFuture, stream::BoxStream};
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
Client as HttpClient, IntoUrl, Url,
|
Client as HttpClient, IntoUrl, Url,
|
||||||
header::{ACCEPT, HeaderValue},
|
header::{ACCEPT, HeaderValue},
|
||||||
};
|
};
|
||||||
use sse_stream::{Error as SseError, Sse, SseStream};
|
use sse_stream::{Error as SseError, Sse, SseStream};
|
||||||
use std::{collections::VecDeque, sync::Arc, time::Duration};
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::model::{ClientJsonRpcMessage, ServerJsonRpcMessage};
|
||||||
const MIME_TYPE: &str = "text/event-stream";
|
const MIME_TYPE: &str = "text/event-stream";
|
||||||
const HEADER_LAST_EVENT_ID: &str = "Last-Event-ID";
|
const HEADER_LAST_EVENT_ID: &str = "Last-Event-ID";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
use crate::{
|
use std::{collections::HashMap, net::SocketAddr, sync::Arc};
|
||||||
RoleServer, Service,
|
|
||||||
model::ClientJsonRpcMessage,
|
|
||||||
service::{RxJsonRpcMessage, TxJsonRpcMessage},
|
|
||||||
};
|
|
||||||
use axum::{
|
use axum::{
|
||||||
Json, Router,
|
Json, Router,
|
||||||
extract::{Query, State},
|
extract::{Query, State},
|
||||||
|
|
@ -14,13 +11,16 @@ use axum::{
|
||||||
routing::{get, post},
|
routing::{get, post},
|
||||||
};
|
};
|
||||||
use futures::{Sink, SinkExt, Stream, StreamExt};
|
use futures::{Sink, SinkExt, Stream, StreamExt};
|
||||||
use std::{collections::HashMap, net::SocketAddr};
|
use tokio::io;
|
||||||
use tokio_stream::wrappers::ReceiverStream;
|
use tokio_stream::wrappers::ReceiverStream;
|
||||||
use tokio_util::sync::{CancellationToken, PollSender};
|
use tokio_util::sync::{CancellationToken, PollSender};
|
||||||
use tracing::Instrument;
|
use tracing::Instrument;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use crate::{
|
||||||
use tokio::io;
|
RoleServer, Service,
|
||||||
|
model::ClientJsonRpcMessage,
|
||||||
|
service::{RxJsonRpcMessage, TxJsonRpcMessage},
|
||||||
|
};
|
||||||
type SessionId = Arc<str>;
|
type SessionId = Arc<str>;
|
||||||
type TxStore =
|
type TxStore =
|
||||||
Arc<tokio::sync::RwLock<HashMap<SessionId, tokio::sync::mpsc::Sender<ClientJsonRpcMessage>>>>;
|
Arc<tokio::sync::RwLock<HashMap<SessionId, tokio::sync::mpsc::Sender<ClientJsonRpcMessage>>>>;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
use rmcp::{ServerHandler, handler::server::tool::ToolCallContext, tool};
|
use rmcp::{ServerHandler, handler::server::tool::ToolCallContext, tool};
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, JsonSchema)]
|
#[derive(Serialize, Deserialize, JsonSchema)]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
cargo-features = ["edition2024"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "mcp-client-examples"
|
name = "mcp-client-examples"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,9 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use rmcp::service::ServiceExt;
|
use rmcp::{model::CallToolRequestParam, service::ServiceExt, transport::TokioChildProcess};
|
||||||
use rmcp::{model::CallToolRequestParam, transport::TokioChildProcess};
|
|
||||||
|
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,8 @@ use rmcp::{
|
||||||
object,
|
object,
|
||||||
transport::TokioChildProcess,
|
transport::TokioChildProcess,
|
||||||
};
|
};
|
||||||
|
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use rmcp::model::{ClientCapabilities, ClientInfo, Implementation};
|
use rmcp::{
|
||||||
use rmcp::{ServiceExt, model::CallToolRequestParam, transport::SseTransport};
|
ServiceExt,
|
||||||
|
model::{CallToolRequestParam, ClientCapabilities, ClientInfo, Implementation},
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
transport::SseTransport,
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
};
|
||||||
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use rmcp::{model::CallToolRequestParam, service::ServiceExt, transport::TokioChildProcess};
|
use rmcp::{model::CallToolRequestParam, service::ServiceExt, transport::TokioChildProcess};
|
||||||
|
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
|
cargo-features = ["edition2024"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "rig-integration"
|
name = "rig-integration"
|
||||||
edition.workspace = true
|
edition = { workspace = true }
|
||||||
version.workspace = true
|
version = { workspace = true }
|
||||||
authors.workspace = true
|
authors = { workspace = true }
|
||||||
license.workspace = true
|
license = { workspace = true }
|
||||||
repository.workspace = true
|
repository = { workspace = true }
|
||||||
description.workspace = true
|
description = { workspace = true }
|
||||||
keywords.workspace = true
|
keywords = { workspace = true }
|
||||||
homepage.workspace = true
|
homepage = { workspace = true }
|
||||||
categories.workspace = true
|
categories = { workspace = true }
|
||||||
readme.workspace = true
|
readme = { workspace = true }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rig-core = "0.10.0"
|
rig-core = "0.10.0"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
cargo-features = ["edition2024"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "mcp-server-examples"
|
name = "mcp-server-examples"
|
||||||
version = "0.1.5"
|
version = "0.1.5"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
use rmcp::transport::sse_server::SseServer;
|
use rmcp::transport::sse_server::SseServer;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{
|
||||||
|
layer::SubscriberExt,
|
||||||
use tracing_subscriber::{self};
|
util::SubscriberInitExt,
|
||||||
|
{self},
|
||||||
|
};
|
||||||
mod common;
|
mod common;
|
||||||
use common::counter::Counter;
|
use common::counter::Counter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
use rmcp::transport::sse_server::{SseServer, SseServerConfig};
|
use rmcp::transport::sse_server::{SseServer, SseServerConfig};
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
use tracing_subscriber::{
|
||||||
|
layer::SubscriberExt,
|
||||||
use tracing_subscriber::{self};
|
util::SubscriberInitExt,
|
||||||
|
{self},
|
||||||
|
};
|
||||||
mod common;
|
mod common;
|
||||||
use common::counter::Counter;
|
use common::counter::Counter;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ use rmcp::{
|
||||||
Error as McpError, RoleServer, ServerHandler, const_string, model::*, schemars,
|
Error as McpError, RoleServer, ServerHandler, const_string, model::*, schemars,
|
||||||
service::RequestContext, tool,
|
service::RequestContext, tool,
|
||||||
};
|
};
|
||||||
|
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use common::counter::Counter;
|
use common::counter::Counter;
|
||||||
use rmcp::{ServiceExt, transport::stdio};
|
use rmcp::{ServiceExt, transport::stdio};
|
||||||
|
|
||||||
use tracing_subscriber::{self, EnvFilter};
|
use tracing_subscriber::{self, EnvFilter};
|
||||||
mod common;
|
mod common;
|
||||||
/// npx @modelcontextprotocol/inspector cargo run -p mcp-server-examples --example std_io
|
/// npx @modelcontextprotocol/inspector cargo run -p mcp-server-examples --example std_io
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
|
cargo-features = ["edition2024"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "transport"
|
name = "transport"
|
||||||
edition.workspace = true
|
edition = { workspace = true }
|
||||||
version.workspace = true
|
version = { workspace = true }
|
||||||
authors.workspace = true
|
authors = { workspace = true }
|
||||||
license.workspace = true
|
license = { workspace = true }
|
||||||
repository.workspace = true
|
repository = { workspace = true }
|
||||||
description.workspace = true
|
description = { workspace = true }
|
||||||
keywords.workspace = true
|
keywords = { workspace = true }
|
||||||
homepage.workspace = true
|
homepage = { workspace = true }
|
||||||
categories.workspace = true
|
categories = { workspace = true }
|
||||||
readme.workspace = true
|
readme = { workspace = true }
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
use common::calculator::Calculator;
|
use common::calculator::Calculator;
|
||||||
use rmcp::{serve_client, serve_server};
|
use rmcp::{serve_client, serve_server};
|
||||||
use std::fs;
|
|
||||||
use tokio::net::{UnixListener, UnixStream};
|
use tokio::net::{UnixListener, UnixStream};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ use std::marker::PhantomData;
|
||||||
|
|
||||||
use common::calculator::Calculator;
|
use common::calculator::Calculator;
|
||||||
use futures::{Sink, Stream};
|
use futures::{Sink, Stream};
|
||||||
|
|
||||||
use rmcp::{
|
use rmcp::{
|
||||||
RoleClient, RoleServer, ServiceExt,
|
RoleClient, RoleServer, ServiceExt,
|
||||||
service::{RunningService, RxJsonRpcMessage, ServiceRole, TxJsonRpcMessage},
|
service::{RunningService, RxJsonRpcMessage, ServiceRole, TxJsonRpcMessage},
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
|
cargo-features = ["edition2024"]
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
edition.workspace = true
|
edition = { workspace = true }
|
||||||
version.workspace = true
|
version = { workspace = true }
|
||||||
authors.workspace = true
|
authors = { workspace = true }
|
||||||
license.workspace = true
|
license = { workspace = true }
|
||||||
repository.workspace = true
|
repository = { workspace = true }
|
||||||
description.workspace = true
|
description = { workspace = true }
|
||||||
keywords.workspace = true
|
keywords = { workspace = true }
|
||||||
homepage.workspace = true
|
homepage = { workspace = true }
|
||||||
categories.workspace = true
|
categories = { workspace = true }
|
||||||
readme.workspace = true
|
readme = { workspace = true }
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
|
||||||
6
rustfmt.toml
Normal file
6
rustfmt.toml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
newline_style = "Unix"
|
||||||
|
unstable_features = true # Cargo fmt now needs to be called with `cargo +nightly fmt`
|
||||||
|
group_imports = "StdExternalCrate" # Create 3 groups: std, external crates, and self.
|
||||||
|
imports_granularity = "Crate" # Merge imports from the same crate into a single use statement
|
||||||
|
style_edition = "2024"
|
||||||
|
max_width = 100
|
||||||
Loading…
Reference in a new issue