Skip to main content

YggMcpServer

Struct YggMcpServer 

Source
pub struct YggMcpServer;
Expand description

MCP 服务器实例(无状态:每个请求由 service_factory 新建一份)。

共享状态(DB 连接等)通过 get_conn() 全局池获取,无需在实例里持有。 工具方法分散在各 tools/*.rsimpl YggMcpServer 块里。

Implementations§

Source§

impl YggMcpServer

Source

fn combined_router() -> ToolRouter<Self>

组合所有工具组的路由表。新增工具组时在此追加一行。

Source§

impl YggMcpServer

Source

pub fn list_comments_tool_attr() -> Tool

Generated tool metadata function for list_comments

Source

fn list_comments( &self, Parameters: Parameters<ListCommentsParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

列出评论(分页,可按状态筛选)。要求 write 作用域。

Source

pub fn approve_comment_tool_attr() -> Tool

Generated tool metadata function for approve_comment

Source

fn approve_comment( &self, Parameters: Parameters<CommentIdParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

通过指定评论(同时递归通过所有 pending 祖先评论)。要求 write 作用域。

Source

pub fn delete_comment_tool_attr() -> Tool

Generated tool metadata function for delete_comment

Source

fn delete_comment( &self, Parameters: Parameters<CommentIdParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

删除指定评论(软删除:设置 deleted_at 与 status=trash)。要求 write 作用域。

Source

pub fn set_comment_status_tool_attr() -> Tool

Generated tool metadata function for set_comment_status

Source

fn set_comment_status( &self, Parameters: Parameters<SetCommentStatusParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

设置评论状态(approved/spam/trash)。要求 write 作用域。

Source

pub fn comments_router() -> ToolRouter<Self>

Source§

impl YggMcpServer

Source

pub fn upload_media_tool_attr() -> Tool

Generated tool metadata function for upload_media

Source

fn upload_media( &self, Parameters: Parameters<UploadMediaParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

从一个图片 URL 抓取并入库(服务端转 WebP 若更小),返回可直接嵌入 Markdown 正文的 /uploads/... URL。要求 write 作用域。

仅接受 https:// URL;服务端做 SSRF 防护(私网/回环/保留段拒绝、 DNS 锁定防 rebinding、禁重定向、体积上限)。二进制不经 JSON-RPC。

Source

pub fn media_router() -> ToolRouter<Self>

Source§

impl YggMcpServer

Source

pub fn create_post_tool_attr() -> Tool

Generated tool metadata function for create_post

Source

fn create_post( &self, Parameters: Parameters<CreatePostParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

创建一篇新文章(草稿或直接发布)。要求 write 作用域。

Source

pub fn update_post_tool_attr() -> Tool

Generated tool metadata function for update_post

Source

fn update_post( &self, Parameters: Parameters<UpdatePostParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

更新指定文章(PATCH 语义:仅更新提供的字段)。要求 write 作用域。 仅文章原作者可更新。

Source

pub fn publish_post_tool_attr() -> Tool

Generated tool metadata function for publish_post

Source

fn publish_post( &self, Parameters: Parameters<PostIdParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

发布指定文章(设置 status=published 与 published_at)。要求 write 作用域。

Source

pub fn trash_post_tool_attr() -> Tool

Generated tool metadata function for trash_post

Source

fn trash_post( &self, Parameters: Parameters<PostIdParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

将指定文章移入回收站(软删除:设置 deleted_at)。要求 write 作用域。

Source

pub fn delete_post_tool_attr() -> Tool

Generated tool metadata function for delete_post

Source

fn delete_post( &self, Parameters: Parameters<PostIdParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

彻底删除指定文章(物理删除,不可恢复)。要求 write 作用域。

Source

pub fn posts_router() -> ToolRouter<Self>

Source§

impl YggMcpServer

Source

pub fn search_posts_tool_attr() -> Tool

Generated tool metadata function for search_posts

Source

fn search_posts( &self, Parameters: Parameters<SearchPostsParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

全文搜索已发布文章(知识库)。返回标题/slug/摘要/标签。

Source

pub fn get_post_tool_attr() -> Tool

Generated tool metadata function for get_post

Source

fn get_post( &self, Parameters: Parameters<GetPostParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

按 slug 取单篇已发布文章(草稿对 read 不可见)。

Source

pub fn list_tags_tool_attr() -> Tool

Generated tool metadata function for list_tags

Source

fn list_tags( &self, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

列出全部标签 + 各自关联的已发布文章数。

Source

pub fn read_router() -> ToolRouter<Self>

Source§

impl YggMcpServer

Source

pub fn run_code_tool_attr() -> Tool

Generated tool metadata function for run_code

Source

fn run_code( &self, Parameters: Parameters<RunCodeParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

在容器沙箱内执行代码并返回输出。要求 admin 作用域。

Source

pub fn runner_router() -> ToolRouter<Self>

Source§

impl YggMcpServer

Source

pub fn get_settings_tool_attr() -> Tool

Generated tool metadata function for get_settings

Source

fn get_settings( &self, Parameters: Parameters<GetSettingsParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

读取站点回收站设置。要求 admin 作用域。

Source

pub fn update_settings_tool_attr() -> Tool

Generated tool metadata function for update_settings

Source

fn update_settings( &self, Parameters: Parameters<UpdateSettingsParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

更新站点回收站设置。要求 admin 作用域。retention_days 会 clamp 到 [1, 365]。

Source

pub fn settings_router() -> ToolRouter<Self>

Source§

impl YggMcpServer

Source

pub fn create_tag_tool_attr() -> Tool

Generated tool metadata function for create_tag

Source

fn create_tag( &self, Parameters: Parameters<CreateTagParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

创建一个新标签。若同名标签已存在则返回已有标签 id。要求 write 作用域。

Source

pub fn rename_tag_tool_attr() -> Tool

Generated tool metadata function for rename_tag

Source

fn rename_tag( &self, Parameters: Parameters<RenameTagParams>, Extension: Extension<Parts>, ) -> Pin<Box<dyn Future<Output = Result<CallToolResult, McpError>> + Send + '_>>

重命名指定标签。要求 write 作用域。

Source

pub fn tags_router() -> ToolRouter<Self>

Trait Implementations§

Source§

impl Clone for YggMcpServer

Source§

fn clone(&self) -> YggMcpServer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for YggMcpServer

Source§

fn default() -> YggMcpServer

Returns the “default value” for a type. Read more
Source§

impl ServerHandler for YggMcpServer

单一 ServerHandler:工具调度委托给合并后的路由表。 router = Self::combined_router()tool_handler 宏生成的 call_tool/list_tools/get_tool 全部走组合路由。

Source§

async fn call_tool( &self, request: CallToolRequestParams, context: RequestContext<RoleServer>, ) -> Result<CallToolResponse, ErrorData>

Handle a tools/call request from a client. Read more
Source§

async fn list_tools( &self, _request: Option<PaginatedRequestParams>, _context: RequestContext<RoleServer>, ) -> Result<ListToolsResult, ErrorData>

Source§

fn get_tool(&self, name: &str) -> Option<Tool>

Get a tool definition by name. Read more
Source§

fn get_info(&self) -> ServerInfo

§

fn ping( &self, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

§

fn initialize( &self, request: InitializeRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<InitializeResult, ErrorData>> + MaybeSendFuture

§

fn supported_protocol_versions(&self) -> Cow<'static, [ProtocolVersion]>

Return the protocol versions supported by this server.
§

fn discover( &self, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<DiscoverResult, ErrorData>> + MaybeSendFuture

Return this server’s discovery information.
§

fn complete( &self, request: CompleteRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CompleteResult, ErrorData>> + MaybeSendFuture

§

fn set_level( &self, request: SetLevelRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

§

fn get_prompt( &self, request: GetPromptRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetPromptResponse, ErrorData>> + MaybeSendFuture

§

fn list_prompts( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListPromptsResult, ErrorData>> + MaybeSendFuture

§

fn list_resources( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListResourcesResult, ErrorData>> + MaybeSendFuture

§

fn list_resource_templates( &self, request: Option<PaginatedRequestParams>, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ListResourceTemplatesResult, ErrorData>> + MaybeSendFuture

§

fn read_resource( &self, request: ReadResourceRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<ReadResourceResponse, ErrorData>> + MaybeSendFuture

§

fn accepted_subscription_filter( &self, requested: &SubscriptionFilter, ) -> Option<SubscriptionFilter>

Return the subset of a requested notification filter this server accepts. Read more
§

fn listen( &self, context: SubscriptionContext, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

Run one established subscription until it is cancelled or closed gracefully. Read more
§

fn subscribe( &self, request: SubscribeRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

👎Deprecated:

resources/subscribe is legacy-only; implement accepted_subscription_filter and listen for protocol version 2026-07-28

§

fn unsubscribe( &self, request: UnsubscribeRequestParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

👎Deprecated:

resources/unsubscribe is legacy-only; subscriptions/listen is cancelled through its request lifecycle

§

fn on_custom_request( &self, request: CustomRequest, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<CustomResult, ErrorData>> + MaybeSendFuture

§

fn on_cancelled( &self, notification: CancelledNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn on_progress( &self, notification: ProgressNotificationParam, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn on_initialized( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn on_roots_list_changed( &self, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn on_custom_notification( &self, notification: CustomNotification, context: NotificationContext<RoleServer>, ) -> impl Future<Output = ()> + MaybeSendFuture

§

fn get_task( &self, request: GetTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<GetTaskResult, ErrorData>> + MaybeSendFuture

SEP-2663 tasks/get: return the current [DetailedTask] state.
§

fn update_task( &self, request: UpdateTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

SEP-2663 tasks/update: accept responses to outstanding in-task input requests. Returns an empty acknowledgement on success.
§

fn cancel_task( &self, request: CancelTaskParams, context: RequestContext<RoleServer>, ) -> impl Future<Output = Result<(), ErrorData>> + MaybeSendFuture

SEP-2663 tasks/cancel: cooperative cancellation. Returns an empty acknowledgement; the task’s observable status may lag.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

§

impl<R, S> DynService<R> for S
where R: ServiceRole, S: Service<R>,

§

fn handle_request( &self, request: <R as ServiceRole>::PeerReq, context: RequestContext<R>, ) -> Pin<Box<dyn Future<Output = Result<<R as ServiceRole>::Resp, ErrorData>> + Send + '_>>

§

fn handle_notification( &self, notification: <R as ServiceRole>::PeerNot, context: NotificationContext<R>, ) -> Pin<Box<dyn Future<Output = Result<(), ErrorData>> + Send + '_>>

§

fn get_info(&self) -> <R as ServiceRole>::Info

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> InitializeFromFunction<T> for T

§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<H> Service<RoleServer> for H
where H: ServerHandler,

§

async fn handle_request( &self, request: <RoleServer as ServiceRole>::PeerReq, context: RequestContext<RoleServer>, ) -> Result<<RoleServer as ServiceRole>::Resp, ErrorData>

§

async fn handle_notification( &self, notification: <RoleServer as ServiceRole>::PeerNot, context: NotificationContext<RoleServer>, ) -> Result<(), ErrorData>

§

fn get_info(&self) -> <RoleServer as ServiceRole>::Info

§

impl<S> ServiceExt<RoleServer> for S
where S: Service<RoleServer>,

§

fn serve_with_ct<T, E, A>( self, transport: T, ct: CancellationToken, ) -> impl Future<Output = Result<RunningService<RoleServer, S>, ServerInitializeError>> + MaybeSendFuture
where T: IntoTransport<RoleServer, E, A>, E: Error + Send + Sync + 'static,

§

fn into_dyn(self) -> Box<dyn DynService<R>>

Convert this service to a dynamic boxed service Read more
§

fn serve<T, E, A>( self, transport: T, ) -> impl Future<Output = Result<RunningService<R, Self>, <R as ServiceRole>::InitializeError>> + MaybeSendFuture
where T: IntoTransport<R, E, A>, E: Error + Send + Sync + 'static, Self: Sized,

§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

§

fn super_from(input: T) -> O

Convert from a type to another type.
§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,