use std::sync::Arc;
use serde_json::Value;
use crate::context::ServerContext;
use crate::proto::PROTOCOL_VERSION;
const INSTRUCTIONS: &str = "AT Protocol tools: identity and handle resolution, DAG-CBOR CIDs, \
TIDs, lexicon fetch and validation, XRPC invocation, and blob upload/download. Blobs are also \
exposed as resources under atpmcp://public/blob/{did}/{cid}; reading one fetches it from the \
repository's PDS, verifies the bytes against the CID, and caches them locally. Blobs are \
returned as a file path and a resource link by default; ask for them inline only when they are \
small, because inline bytes are base64 and consume the context window quickly.";
#[must_use]
pub fn capabilities() -> Value {
serde_json::json!({
"tools": { "listChanged": false },
"resources": { "listChanged": false, "subscribe": false },
})
}
#[must_use]
pub fn payload(ctx: &Arc<ServerContext>) -> Value {
let _ = ctx;
serde_json::json!({
"supportedVersions": [PROTOCOL_VERSION],
"capabilities": capabilities(),
"instructions": INSTRUCTIONS,
})
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn advertises_exactly_the_version_this_server_implements() {
let capabilities = capabilities();
assert_eq!(capabilities["tools"]["listChanged"], false);
assert_eq!(capabilities["resources"]["subscribe"], false);
}
#[test]
fn instructions_name_the_blob_uri_scheme() {
assert!(INSTRUCTIONS.contains("atpmcp://public/blob/"));
}
}