CEP-35 has been drafted (contextvm-docs PR ContextVM/contextvm-docs#39) and standardizes the runtime discovery exchange already present in the TS SDK.
Right now the rs-sdk can send and receive encrypted MCP messages and publish static announcements, but it never attaches capability tags to outbound messages, never reads capability tags from inbound messages, and never adapts its behavior based on what the peer supports.
This issue tracks porting the TS SDK's capability learning and discovery tag exchange behavior to the Rust SDK, following the CEP-35 spec as the implementation guide.
1. Discovery tags module (foundation)
2. Session store enhancement
3. Tag composition architecture
4. Client-side discovery tag emission
5. Server-side discovery tag emission
6. Client-side capability learning
7. Server-side capability learning
8. Announcement Manager refactor (deferred, last)
Reference
CEP-35 has been drafted (contextvm-docs PR ContextVM/contextvm-docs#39) and standardizes the runtime discovery exchange already present in the TS SDK.
Right now the rs-sdk can send and receive encrypted MCP messages and publish static announcements, but it never attaches capability tags to outbound messages, never reads capability tags from inbound messages, and never adapts its behavior based on what the peer supports.
This issue tracks porting the TS SDK's capability learning and discovery tag exchange behavior to the Rust SDK, following the CEP-35 spec as the implementation guide.
1. Discovery tags module (foundation)
get_discovery_tags(tags): filters out routing tags (p, e), preserves everything else (feat: add discovery tags module and server config foundation for CEP-35 #51)learn_peer_capabilities(tags) -> PeerCapabilities: checks for support_encryption, support_encryption_ephemeral, support_oversized_transfer (feat: add discovery tags module and server config foundation for CEP-35 #51)parse_discovered_peer_capabilities(tags): uses get_discovery_tags internally (feat: add discovery tags module and server config foundation for CEP-35 #51): removed from TS SDK per CEP-35 spec update. Later tags must NOT merge into session baseline.merge_discovery_tags(existing, new)SUPPORT_OVERSIZED_TRANSFERtosrc/core/constants.rs(feat: add discovery tags module and server config foundation for CEP-35 #51)gift_wrap_mode: GiftWrapModetoNostrServerTransportConfig(feat: add discovery tags module and server config foundation for CEP-35 #51)wrap_kind: Option<u16>toRouteEntryinsrc/transport/server/correlation_store.rs(feat: add discovery tags module and server config foundation for CEP-35 #51)2. Session store enhancement
has_sent_common_tags: booltoClientSession(feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )supports_encryption: booltoClientSession(feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )supports_ephemeral_encryption: booltoClientSession(feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )supports_oversized_transfer: booltoClientSession(feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )HashMapwith LRU-bounded session store (max_sessions default 1000)3. Tag composition architecture
compose_outbound_tags(base, discovery, negotiation)toBaseTransport. Canonical tag ordering: routing, then discovery, then negotiation. (feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )4. Client-side discovery tag emission
get_client_capability_tags(): constructs tags based on encryption mode and gift wrap modeget_pending_client_discovery_tags()with one-shot flag (has_sent_discovery_tags)build_outbound_client_tags(): composes routing + discovery tagssend(): attach discovery tags on first request, flip flag after send5. Server-side discovery tag emission
get_common_tags()helper: builds server info + capability tags from config (feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )take_pending_server_discovery_tags(session): returns common tags on first response per client, empty after (feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )build_server_outbound_tags(): composes routing + discovery + negotiation tags (feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )send_response(): include discovery tags on first response to each client (feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )send_notification()-- include discovery tags on first notification to each client (feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57)6. Client-side capability learning
discovered_server_capabilities: PeerCapabilitiestoNostrClientTransportserver_initialize_event: Option<Event>: stores first event carrying discovery tagslearn_server_discovery(event): parses tags, OR-assigns capabilities, stores baseline eventget_server_initialize_event(),discovered_server_capabilities()7. Server-side capability learning
learn_peer_capabilities()on inner event tags (feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )ClientSessionfields (feat: add tag composition, server discovery tag emission and capability learning for CEP-35 #57 )8. Announcement Manager refactor (deferred, last)
get_common_tags()into dedicatedAnnouncementManagerstruct (refactor: extract AnnouncementManager from NostrServerTransport (CEP-35) #74 )get_server_info_tags(),get_capability_tags(),get_common_tags()with caching (refactor: extract AnnouncementManager from NostrServerTransport (CEP-35) #74 )set_extra_common_tags(),set_internal_common_tags(),set_pricing_tags()(refactor: extract AnnouncementManager from NostrServerTransport (CEP-35) #74 )announce(),publish_tools()etc. to delegate toAnnouncementManager(refactor: extract AnnouncementManager from NostrServerTransport (CEP-35) #74 )Reference
src/transport/discovery-tags.tssrc/transport/nostr-client-transport.ts:227-281, 853-909src/transport/nostr-server-transport.ts:441-469, 985-992