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。 - A2CSkill
Ref - SKILL 引用对象 / Skill reference object ——
client:get_skills返回列表元素。 - Agent
Call Data - 代理调用数据(基类)
- Blob
Sideband - content item 的二进制旁路三元组 / The binary-sideband triple on a content item。
- Enter
Office Notification - 进入办公室通知
- Enter
Office Req - 进入办公室请求
- Error
Payload - A2C-SMCP flat 错误负载 / A2C-SMCP flat error payload
- GetBlob
Req - 通用二进制拉取请求 / Generic binary pull request(
client:get_blob)。 - GetBlob
Ret - 通用二进制拉取响应 / Generic binary pull response(
GetBlobRet)。 - GetComputer
Config Req - 获取计算机配置请求
- GetComputer
Config Ret - 获取计算机配置返回
- GetDesktop
Req - 获取桌面请求
- GetDesktop
Ret - 获取桌面返回
- GetResources
Req - 资源发现请求 / Resource discovery request(
client:get_resources)。 - GetResources
Ret - 资源发现响应 / Resource discovery response(
GetResourcesRet)。 - GetSkill
Req - 获取 SKILL 包内单个资源请求 / Get a single in-package SKILL resource(
client:get_skill)。 - GetSkill
Ret - 获取 SKILL 包内单个资源响应 / Get-skill response(
GetSkillRet)。 - GetSkills
Req - 获取 SKILL 清单请求 / Get SKILL inventory request(
client:get_skills)。 - GetSkills
Ret - 获取 SKILL 清单响应 / Get SKILL inventory response(
GetSkillsRet)。 - GetTools
Req - 获取工具请求
- GetTools
Ret - 获取工具返回
- Leave
Office Notification - 离开办公室通知
- Leave
Office Req - 离开办公室请求
- List
Room Req - 列出房间请求
- List
Room Ret - 列出房间返回
- Parsed
Skill Name - lexer 解析结果 / Result of the name lexer。
- Protocol
Version - 语义化版本三元组 / Semantic version triple (
MAJOR.MINOR.PATCH)。 - Protocol
Version Error - 版本握手被拒错误 / Protocol-version handshake rejection error。
- Protocol
Version Parse Error - 版本号解析错误 / Version parse error。
- ReqId
- 请求ID,使用UUID确保全局唯一性
- Resource
Annotations - MCP Resource 标准 annotations(snake_case mirror)/ MCP standard Resource annotations。
- SMCP
Tool - SMCP工具定义
- Session
Info - 会话信息
- Skill
Name Error - SKILL name 格式非法 / SKILL name is malformed。
- Tool
Call Req - 工具调用请求
- Tool
Call Ret - 工具调用返回(符合 MCP CallToolResult 标准)
- Update
Computer Config Req - 更新计算机配置请求
- UpdateMCP
Config Notification - 更新MCP配置通知
- Update
Tool List Notification - 更新工具列表通知
- User
Info - 用户信息
Enums§
- Error
Code - A2C-SMCP 协议错误码(v0.2.0 起;v0.2.1 加性追加
4016/4017/4018)。 - Notification
- 通知类型枚举
- Resource
Audience - MCP Resource 标准 annotations 的目标受众 / target audience of a resource。
- Role
- 角色类型
- Skill
Name Kind - SKILL name 的 source 形态 / The source shape of a SKILL name。
- Skill
Resource - SKILL 资源载体 / SKILL resource carrier ——
GetSkillRet的body与blob_handle恰一存在。 - Skill
RetError GetSkillRet的body/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§
- Blob
Handle - 不透明、Computer 铸造、无状态可重解析的 blob 句柄(类型别名)。 Opaque, Computer-minted, stateless-reparseable blob handle (type alias)。
- Desktop
- 桌面类型别名