Skip to main content

Crate a2c_smcp

Crate a2c_smcp 

Source
Expand description

§A2C-SMCP Rust SDK

A Rust implementation of the A2C-SMCP protocol, providing Agent, Computer, and Server components for building intelligent agent systems with tool execution capabilities.

§Features

  • agent - Agent client implementation for connecting to SMCP servers
  • computer - Computer client implementation for managing MCP servers and desktop resources
  • server - Server implementation with Socket.IO support
  • full - Enables all features (default when using --all-features)

§Quick Start

Add to your Cargo.toml:

[dependencies]
a2c-smcp = { version = "0.1.0", features = ["agent", "computer"] }

§Example

// Add features to your Cargo.toml:
// a2c-smcp = { version = "0.1.0", features = ["agent", "computer"] }

#[cfg(feature = "agent")]
use a2c_smcp::agent::SmcpAgent;

#[cfg(feature = "computer")]
use a2c_smcp::computer::SmcpComputer;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Your SMCP application code here
    Ok(())
}

Re-exports§

pub use serde;
pub use serde_json;
pub use thiserror;
pub use tokio;
pub use tracing;

Modules§

error_codes
标准错误码模块 / Standard error codes module
events
SMCP事件常量定义
skill_name
SKILL name 解析与合成(段数消歧 lexer)/ SKILL name parse & synthesis (segment-count lexer)。 SKILL 命名合成与 lexer(v0.2.1 协议,裸名模型)/ SKILL name synthesis & lexer。
tool_meta
CallToolResult 的 A2C 标记键 / A2C marker keys for CallToolResult。
utils
基础设施工具模块 / Infrastructure utilities(原子 IO / 环境变量 / 路径;治理层 SET/SKL 共用)。 基础设施工具 / Infrastructure utilities(治理层 SET/SKL 共用)。
version
协议版本解析与兼容性判定 / Protocol version parse & compatibility。 协议版本语义与兼容性判定 / Protocol version semantics & compatibility。

Structs§

A2CResource
A2C 协议层 Resource,snake_case mirror MCP Resource / A2C protocol-level Resource。
A2CSkillRef
SKILL 引用对象 / Skill reference object —— client:get_skills 返回列表元素。
AgentCallData
代理调用数据(基类)
BlobSideband
content item 的二进制旁路三元组 / The binary-sideband triple on a content item。
EnterOfficeNotification
进入办公室通知
EnterOfficeReq
进入办公室请求
ErrorPayload
A2C-SMCP flat 错误负载 / A2C-SMCP flat error payload
GetBlobReq
通用二进制拉取请求 / Generic binary pull request(client:get_blob)。
GetBlobRet
通用二进制拉取响应 / Generic binary pull response(GetBlobRet)。
GetComputerConfigReq
获取计算机配置请求
GetComputerConfigRet
获取计算机配置返回
GetDesktopReq
获取桌面请求
GetDesktopRet
获取桌面返回
GetResourcesReq
资源发现请求 / Resource discovery request(client:get_resources)。
GetResourcesRet
资源发现响应 / Resource discovery response(GetResourcesRet)。
GetSkillReq
获取 SKILL 包内单个资源请求 / Get a single in-package SKILL resource(client:get_skill)。
GetSkillRet
获取 SKILL 包内单个资源响应 / Get-skill response(GetSkillRet)。
GetSkillsReq
获取 SKILL 清单请求 / Get SKILL inventory request(client:get_skills)。
GetSkillsRet
获取 SKILL 清单响应 / Get SKILL inventory response(GetSkillsRet)。
GetToolsReq
获取工具请求
GetToolsRet
获取工具返回
LeaveOfficeNotification
离开办公室通知
LeaveOfficeReq
离开办公室请求
ListRoomReq
列出房间请求
ListRoomRet
列出房间返回
ParsedSkillName
lexer 解析结果 / Result of the name lexer。
ProtocolVersion
语义化版本三元组 / Semantic version triple (MAJOR.MINOR.PATCH)。
ProtocolVersionError
版本握手被拒错误 / Protocol-version handshake rejection error。
ProtocolVersionParseError
版本号解析错误 / Version parse error。
ReqId
请求ID,使用UUID确保全局唯一性
ResourceAnnotations
MCP Resource 标准 annotations(snake_case mirror)/ MCP standard Resource annotations。
SMCPTool
SMCP工具定义
SessionInfo
会话信息
SkillNameError
SKILL name 格式非法 / SKILL name is malformed。
ToolCallReq
工具调用请求
ToolCallRet
工具调用返回(符合 MCP CallToolResult 标准)
UpdateComputerConfigReq
更新计算机配置请求
UpdateMCPConfigNotification
更新MCP配置通知
UpdateToolListNotification
更新工具列表通知
UserInfo
用户信息

Enums§

ErrorCode
A2C-SMCP 协议错误码(v0.2.0 起;v0.2.1 加性追加 4016 / 4017 / 4018)。
Notification
通知类型枚举
ResourceAudience
MCP Resource 标准 annotations 的目标受众 / target audience of a resource。
Role
角色类型
SkillNameKind
SKILL name 的 source 形态 / The source shape of a SKILL name。
SkillResource
SKILL 资源载体 / SKILL resource carrier —— GetSkillRetbodyblob_handle 恰一存在
SkillRetError
GetSkillRetbody / blob_handle 互斥不变式被破坏 / exclusivity invariant violated。

Constants§

GET_BLOB_EVENT
client:get_blob 事件名 / event name(顶层别名,等于 events::CLIENT_GET_BLOB)。
GET_RESOURCES_EVENT
client:get_resources 事件名 / event name(顶层别名,等于 events::CLIENT_GET_RESOURCES)。
GET_SKILLS_EVENT
client:get_skills 事件名 / event name(顶层别名,等于 events::CLIENT_GET_SKILLS)。
GET_SKILL_EVENT
client:get_skill 事件名 / event name(顶层别名,等于 events::CLIENT_GET_SKILL)。
PROTOCOL_VERSION
A2C-SMCP 协议版本号 / A2C-SMCP protocol version
SMCP_NAMESPACE
SMCP协议的命名空间
UPDATE_SKILLS_EVENT
server:update_skills 事件名 / event name(顶层别名,等于 events::SERVER_UPDATE_SKILLS)。
UPDATE_SKILLS_NOTIFICATION
notify:update_skills 通知名 / notification name(顶层别名,等于 events::NOTIFY_UPDATE_SKILLS)。
WS_VERSION_HANDSHAKE_REJECTED_CLOSE_CODE
WebSocket 握手版本拒绝的 close code(RFC 6455 私有段 4000–4999)。

Functions§

build_computer_not_found_error
构造 client:* 路由层目标 Computer 名未注册时返回的 flat ErrorPayload(404)。
is_compatible
判定 Client 是否能连接到 Server / Whether the Client may connect to the Server。
is_protocol_error_payload
判定 value 是否为协议级 flat ErrorPayload:顶层 code 属协议错误码、且无嵌套 envelope。
is_valid_skill_name
非抛出版校验 / Non-raising validity check(便于 client:get_skill 入参快速门控)。
normalize_mcp_server_segment
MCP <server> 段规范化 / Normalize the MCP <server> segment(非 [A-Za-z0-9_-]_,大小写保留)。
parse_skill_name
SKILL name lexer:段数消歧 + 逐段字符集校验 / Lexer: segment-count disambiguation + per-segment charset。
read_content_blob_sideband
读取 content item 的二进制旁路 / Read the binary sideband off a content item。
set_content_blob_sideband
在 content item 上写入二进制旁路 / Write the binary sideband onto a content item。
synthesize_marketplace_name
合成 marketplace 源裸名 / Synthesize a marketplace name:<plugin>:<skill>(2 段)。
synthesize_mcp_name
合成 mcp 源 name / Synthesize an mcp-source name:mcp:<normalized-server>:<skill>(3 段)。
synthesize_user_name
合成 user 源裸名 / Synthesize a bare user-source name:<skill>(1 段)。

Type Aliases§

BlobHandle
不透明、Computer 铸造、无状态可重解析的 blob 句柄(类型别名)。 Opaque, Computer-minted, stateless-reparseable blob handle (type alias)。
Desktop
桌面类型别名