atpmcp
An AT Protocol MCP server, speaking Model Context Protocol 2026-07-28 over stdio.
This server requires a client that speaks MCP 2026-07-28. That revision removed the
initializehandshake and made the protocol stateless: every request carries its own protocol version and client capabilities in_meta, andserver/discoverreplaces the handshake. A client speaking an earlier revision cannot use this server — it is answered with an error naming the version required rather than left to guess. Clients that have not migrated should stay onatpmcp0.14.5 — the last 0.14 release, and the last that answers an earlier revision. Not "0.15 or earlier":"0.15"is a caret requirement and resolves to 0.15.0, the first modern-only release, which is precisely the version such a client cannot use.
Tools
| Tool | Writes | Network | Purpose |
|---|---|---|---|
create_record_cid |
no | no | DAG-CBOR CID for a JSON record |
validate_lexicon_schema |
no | no | Validate a lexicon schema document |
generate_tid |
no | no | Generate AT Protocol Timestamp Identifiers |
resolve_handle_to_did |
no | yes | Resolve a handle to its DID, and check the DID claims it back |
resolve_identity |
no | yes | Fetch a full DID document |
parse_facets |
no | yes | Extract mentions, links and hashtags with byte offsets |
get_record |
no | yes | Fetch a record by AT-URI |
get_lexicon |
no | yes | Fetch a lexicon schema by NSID |
validate_xrpc |
no | yes | Validate XRPC params and body against a lexicon |
invoke_xrpc |
yes, destructive | yes | Call an XRPC method (JSON in, JSON out) |
upload_blob |
yes | yes | Upload bytes to an account's PDS |
download_blob |
no | yes | Fetch and verify a blob by DID and CID |
generate_bsky_post |
yes, a thumbnail blob only | yes | Build and validate an app.bsky.feed.post record, with an optional link card; never publishes it |
Every tool carries annotations, so a host can tell which three of them write — and which
can destroy. upload_blob only adds a blob, and so does generate_bsky_post, which writes no
record but uploads a link card's thumbnail when given an account; invoke_xrpc calls whatever
NSID it is given, so
com.atproto.repo.deleteRecord, applyWrites and an overwriting putRecord all go through it.
It is the one tool marked destructiveHint: true.
destructiveHint defaults to true in the MCP schema, so a false is an explicit claim that a
tool makes only additive changes, not an omission. The specification is also clear that these are
hints, and that a client "MUST consider tool annotations to be untrusted unless they come from
trusted servers" — it does not itself require anything of a host that reads them.
Resources
Blobs are addressable as resources:
atpmcp://public/blob/{did}/{cid}
resources/templates/list advertises the template
atpmcp://public/blob/{+did}/{cid}; resources/list is empty, because the
blob namespace is unbounded and the specification forbids a resource list that
varies with what earlier requests on the connection happened to do.
Reading a blob resolves the DID to a PDS, fetches the bytes, verifies them
against the CID, caches them, and returns them as base64. The verification is
not a nicety: the endpoint comes from a serviceEndpoint the DID's own subject
publishes, so a hostile host can refuse or stall but cannot substitute content.
A host may serve any blob as application/octet-stream (draft-04 §11.8), so
that answer is not reported as the blob's type: a resource read reports the
type sniffed from the bytes, and download_blob the mime_type of the blob
reference the caller passes, unless the bytes are recognised as something else.
download_blob also takes the reference's size, and refuses a blob of any
other size.
public names the trust half of the namespace — no credential is used, so the
result is cacheScope: "public". It reserves atpmcp://private/... for a
future authenticated read.
Blobs and the context window
resources/read has one delivery mechanism: base64 inside a JSON-RPC response.
A 16 MiB blob is about 21.8 MB of base64, which is hundreds of thousands of
tokens if a host puts it in the model's context as text. So:
download_blobsaves the blob to atpmcp's cache and returns its path plus aresource_link. Inline is opt-in. The file is always the cache entry named for the CID, or a scratch file in the system temp directory when there is no cache, the blob is larger than its budget, or the cache cannot store it; the caller cannot choose where it goes. Either way the path exists when the call returns. Before 0.15.0 anoutput_pathargument could, which let a model write chosen bytes to any path the user can write from a tool marked read-only. A call that still passes it is refused. Move the file with a file tool instead.- Inline is capped at
ATPMCP_BLOB_MAX_INLINE_BYTES(default 256 KiB), and the same cap applies toresources/read. - An image under the cap is returned as image content, which hosts tokenise as an image rather than as a wall of text.
Bluesky posts
generate_bsky_post builds an app.bsky.feed.post record and returns it without publishing
it. Publishing is a second call, invoke_xrpc with com.atproto.repo.createRecord, so a host
can show the post before it goes anywhere.
- Text and languages. The text is used exactly as given.
langsdefaults to["en"], takes at most three BCP 47 tags, and[]leaves the field out. - Facets. Mentions, links and hashtags are parsed from the text, as
parse_facetsdoes, and mentions are resolved to DIDs.mention_facet_allow,tag_facet_allowandlink_facet_alloweach keep only the facets of their kind they name; an absent or empty list keeps them all. Handles and tags are compared without regard to case, with or without@or#, and links exactly. A mention a list leaves out is never resolved. - Link card.
embed_externalnames a page, and its Open Graph metadata becomes anapp.bsky.embed.externalcard:og:titleandog:description, falling back to the Twitter card metadata and then the page's<title>and<meta name="description">. Nothing is truncated. The card'suriis the URL as given. The page and its image are fetched like any other caller-named host: the endpoint policy on the first URL (its query and fragment set aside), a check on every redirect that the waiver does not lift, the address guard, a timeout, and the first 1 MiB of the page. - Thumbnail. A blob reference only resolves once the blob is on the PDS that holds the
record, so with
auth_handlethe page's image is uploaded to that account's own PDS, asupload_blobdoes, and the PDS's blob reference goes into the card. Publish as the same account, and soon: an uploaded blob no record references is temporary. Withoutauth_handle, or when the page names no image, the image is over the download ceiling or cannot be shrunk, or its bytes are not a recognised image, the card has no thumbnail and the result'snotessay why. - Metadata. Uploading a site's image to your PDS republishes whatever it carries, and a
photo's EXIF can hold where it was taken. So by default the thumbnail has its metadata
removed: EXIF, XMP, IPTC and comments from a JPEG,
eXIfand the text chunks from a PNG, theEXIFandXMPchunks from a WebP, and anything after the image's end. This works on the file's structure, so the pixels are exactly the ones served. The colour profile is kept, because it describes colours, not the photograph. A GIF has no place for EXIF. An image that only its EXIF says is stored rotated is re-encoded with the rotation applied, since without the EXIF it would show on its side, and another format is not used, since atpmcp cannot say what it carries. SetATPMCP_PRESERVE_EXIF=1to keep the metadata: then an image under the limit is uploaded as served, and a shrunk one gets its source's EXIF copied in. - Shrinking. The image is fetched up to the download ceiling (
ATPMCP_BLOB_MAX_DOWNLOAD_BYTES, 16 MiB by default). One over 1,000,000 bytes, the lexicon's limit, is decoded and re-encoded as a JPEG that fits: within 2000 pixels on its longer side, the aspect ratio kept, the quality stepped down and then the size until it is under the limit. Only JPEG, PNG, GIF and WebP are decoded, by pure-Rust decoders, under limits of 8192 pixels a side and 320 MiB of allocation, and off the server's async runtime. Transparency goes onto white, an animated GIF gives its first frame, and EXIF orientation is applied to the pixels. The new JPEG keeps the source's colour profile, and its EXIF only underATPMCP_PRESERVE_EXIF, with the orientation reset. The result'snotesgive the sizes before and after. - Images.
galleryattaches up to 10 images as anapp.bsky.embed.gallery, andimagesup to 4 as the olderapp.bsky.embed.images, which more clients show. Each item is{ "path": "/absolute/file.png" }or{ "url": "https://…" }, with an optionalaltthat defaults to"".auth_handleis required, and every image is uploaded to that account's PDS with its aspect ratio. Each goes through the thumbnail's handling, with the lexicons' 2,000,000-byte limit: judged by its bytes, its metadata removed unlessATPMCP_PRESERVE_EXIFis set, and shrunk to a JPEG that fits when it is over. An image that cannot be used fails the call, and every image is prepared before any is uploaded, so nothing is uploaded then. HEIC is not decoded; convert it first (sips -s format jpeg in.heic --out out.jpg).gallery,imagesandembed_externalcannot be combined, since a post has one embed. - Shortened links. With
shorten_links: true, each linked URL in the text is shown as the Bluesky app shows it:https://tangled.org/ngerakines.me/wow-break-timerbecomestangled.org/ngerakines.m..., and the link still goes to the full URL. - Validation. The record is checked against the
app.bsky.feed.post, embed andapp.bsky.richtext.facetlexicons bundled with the binary, before anything is fetched or uploaded and again with its embed, so a text over 300 graphemes, a malformed language tag or a gallery item without its aspect ratio is refused here rather than by the PDS.
The result's structuredContent is { record, notes, thumbnail?, uploaded? }; record is
ready to pass as createRecord's record.
Configuration
| Variable | Default | Meaning |
|---|---|---|
PLC_HOSTNAME |
plc.directory |
PLC directory for every did:plc resolution, in any tool, resources/read and login. A bare hostname means HTTPS; a value with a scheme is used as written, so http://localhost:2582 reaches a local directory. Operator configuration, so the host policy does not apply to it (see Caller-named hosts). It must still be well formed: an empty value, or one that is not a URL with a host once https:// is put in front of a bare hostname, is refused at startup |
DNS_NAMESERVERS |
the system's | Nameservers to resolve a handle with, separated by ; (1.1.1.1;8.8.8.8). Without it and without a readable system DNS configuration, as in a scratch container, the server still starts: a tool that has to resolve a handle answers with error-atproto-identity-resolve-11, saying to set this, and every other tool works. An entry that is not an IP address is refused at startup |
ATPMCP_BLOB_CACHE_DIR |
platform cache dir | Where verified blobs are stored |
ATPMCP_BLOB_CACHE_MAX_BYTES |
536870912 (512 MiB) |
Cache ceiling over atpmcp's own entries; oldest evicted, never the one just written. A blob larger than it is kept as a scratch file instead. 0 turns the cache off, and startup then removes what an earlier ceiling cached. Startup prunes the cache to any other ceiling |
ATPMCP_BLOB_MAX_UPLOAD_BYTES |
16777216 (16 MiB) |
Largest blob sent to a PDS. At least 1 |
ATPMCP_BLOB_MAX_DOWNLOAD_BYTES |
16777216 (16 MiB) |
Largest blob fetched from a repository. At least 1 |
ATPMCP_BLOB_MAX_INLINE_BYTES |
262144 (256 KiB) |
Largest blob returned as base64. 0 means never inline |
ATPMCP_ALLOW_INSECURE_ENDPOINTS |
off | Waive the host policy for the endpoint and plc_directory_hostname arguments and for atpmcp login, never for an endpoint read from a DID document during a tool call, and turn off the address check for every client (see Caller-named hosts): 1, true, yes or on. 0, false, no, off or empty keep it |
ATPMCP_PRESERVE_EXIF |
off | Keep a link card thumbnail's metadata (EXIF, XMP and the like) rather than remove it (see Bluesky posts): 1, true, yes or on. 0, false, no, off or empty remove it |
ATPMCP_MAX_MESSAGE_BYTES |
33554432 (32 MiB) |
Largest inbound message. At least 1024 |
ATPMCP_MAX_CONCURRENT_REQUESTS |
16 |
Handlers doing work at once. At least 1 |
ATPMCP_MAX_QUEUED_REQUESTS |
1024 |
Accepted-but-unanswered ceiling. At least 1 |
ATPXRPC_CONFIG |
<config dir>/atpxrpc/config.json |
Stored accounts, shared with atpxrpc |
Sizes and counts are whole numbers written as digits alone: 1048576, not 1M,
1MiB or 1_048_576. An unset or empty variable keeps its default, except
PLC_HOSTNAME: its default is another host rather than a limit, so an empty
value is refused. Anything else — a value that is not digits alone, one below
its minimum, a waiver that is neither on nor off, a PLC_HOSTNAME no
request URL can be built from, or a DNS_NAMESERVERS entry that is not an
address — stops the server at startup with an error-atpmcp-config-* error
naming the variable, and login refuses a bad waiver, PLC_HOSTNAME or
DNS_NAMESERVERS the same way. An MCP host usually keeps a
server's stderr out of sight, so the alternative, running on a default you did
not choose, would be silent.
ATPMCP_BLOB_MAX_UPLOAD_BYTES and ATPMCP_BLOB_MAX_DOWNLOAD_BYTES are
ceilings, not defaults: the max_bytes argument of upload_blob and
download_blob can ask for less and cannot ask for more. It used to replace
the configured value, so a caller naming a large enough number had the
operator's limit removed — and upload_blob reads a path into memory before
it looks up the account, so that needed no stored credential. The argument must
be a whole number of at least 1; anything else is refused rather than read as
absent.
resolve_identity and get_record also take their own plc_directory_hostname argument, in
either form. Precedence, highest first: the tool call's own argument, then PLC_HOSTNAME, then the
built-in plc.directory. login has no per-call argument, so only the last two apply to it.
The cache needs no expiry: a blob CID is a hash of its bytes, so a cached entry cannot go stale, and every read re-hashes what it finds before serving it.
A download streams into the cache directory as <cid>.partial-<pid>-<n> and is
renamed to <cid> once verified, with its content type in <cid>.type. The
ceiling counts those two as one entry and evicts them together, oldest first;
no other file in the directory is counted or evicted. A partial file is never
counted against the ceiling or evicted either, since it may still be being
written, so at startup atpmcp removes its own that are more than a day old,
left by a process that stopped mid-write. With
ATPMCP_BLOB_CACHE_MAX_BYTES=0, startup also removes every <cid> and
<cid>.type, so turning the cache off gives its space back. Under any other
ceiling startup prunes the cache to it, so a lowered ceiling takes effect
before the first request rather than at the next download. Only those names,
with <cid> a blob CID, are removed: anything else in the directory, and the
directory itself, stays.
Caller-named hosts
download_blob and invoke_xrpc take an endpoint, and the identity tools take
a plc_directory_hostname. Each names a host this process then connects to, and
the caller is a model — so an unchecked one is an SSRF primitive reachable from a
prompt. They go through the same service-endpoint policy this crate already
applies to endpoints read from a DID document: HTTPS only, no address literals
(including 169.254.169.254), no single-label hosts such as localhost, no
embedded credentials, and no non-default ports.
That also refuses http://127.0.0.1:4800, where this workspace's own pds
listens by default, so ATPMCP_ALLOW_INSECURE_ENDPOINTS=1 waives it for local
development. It is an environment variable and not a tool argument on purpose:
an operator can widen the policy, a prompt cannot.
PLC_HOSTNAME is not a caller-named host. It is configuration, set by whoever
sets the waiver, and every tool uses it as given, so a local directory needs no
waiver — which would also open every endpoint argument to it. A
plc_directory_hostname is checked only when it names a directory other than
that one.
The waiver covers those arguments and atpmcp login, and nothing else. An
endpoint read from a DID document during a tool call is checked whether or not
it is set — the PDS behind get_record, behind download_blob or
resources/read given only a DID, behind invoke_xrpc given an identity,
and behind get_lexicon and validate_xrpc. For those two the DID is the
repo argument when given, and otherwise the authority an NSID's _lexicon
record names, which includes every NSID a schema being validated refs. Their
check is atproto-lexicon's own, since 0.15.0. Whoever controls a DID chooses that endpoint, and the call that
reaches it names no host: get_record on an attacker's DID is read-only, so a
host may run it without asking. The waiver is a standing variable in a host's
configuration, still set while the same server talks to the real network, and
then that check is the protection left. login is a command you run, not a
tool, so the waiver costs nothing there.
The policy reads URLs. What a name resolves to is checked when the connection
is made: unless the waiver is set, every client refuses a name that resolves only
to loopback, private or link-local addresses (error-atproto-identity-egress-1),
so pds.example.com pointing at 127.0.0.1 is refused as https://127.0.0.1/
is. The operator's PLC_HOSTNAME is admitted wherever it resolves. Unlike the
policy, this check has one switch: the waiver turns it off for every client,
endpoints read from a DID document included. A proxy from the environment or the
system settings resolves the target itself, so behind one this check sees only
the proxy's name.
Against a local pds, then: log in with the waiver set, and pass endpoint to
download_blob and invoke_xrpc. A refusal names the endpoint, the policy's
reason, and — where the tool has one — the argument to use instead.
Each of those checks is on the first URL. Where that host redirects is its own
choice, and a checked https:// host answering 307 Location: http://127.0.0.1:2375/containers/create would otherwise take the request past
the policy — on a 307, with its body. So invoke_xrpc, get_record, the record
fetch behind get_lexicon and validate_xrpc, blob transfers and atpmcp login follow no redirects, and one fails the call; invoke_xrpc reports it as
error following redirect. Identity resolution does follow them, because the
handle specification allows redirects on /.well-known/atproto-did, but at most
five, each held to the same policy whether or not the waiver is set: that is
atproto-identity's redirect::validated_policy, which atpdid uses too. A JSON
request times out after 30 seconds, and a connection that has not opened after
10.
The policy reads the URL, not the address its name resolves to. A public name
whose DNS answers 127.0.0.1 passes it, on the first hop as on any other.
Authentication
invoke_xrpc and upload_blob use app-password accounts stored in the shared
atpxrpc config.
The account store holds credentials in plaintext — each account's app
password, access token and refresh token. On Unix it is written with mode
0600, and a failure to set that mode is an error rather than a warning;
elsewhere, Windows included, no permission is applied and the file is as
private as the directory holding it. Delete the file to revoke a machine's
copy.
It lives at ATPXRPC_CONFIG when that is set, and otherwise at
<config dir>/atpxrpc/config.json, which is not the same place on every
platform:
| Platform | Default location |
|---|---|
| Linux | ~/.config/atpxrpc/config.json |
| macOS | ~/Library/Application Support/atpxrpc/config.json |
| Windows | %APPDATA%\atpxrpc\config.json |
atpmcp login prints the resolved path when it finishes, which is the reliable
way to find it — this table is a convenience, and it is the kind of thing that
goes stale.
An authenticated request goes to that account's own PDS and
nowhere else: upload_blob takes no endpoint override, and invoke_xrpc
refuses endpoint or identity alongside auth_handle. A credential that can
be aimed at a host the caller names is a credential-forwarding gadget, which is
what a prompt injection needs. Reach another service with proxy, which sets
the atproto-proxy header on a request to the user's own PDS.
Add an account with:
For an account on a local development server, whose DID document names an
endpoint such as http://localhost:4800, set the waiver for the login:
ATPMCP_ALLOW_INSECURE_ENDPOINTS=1
Sessions are refreshed automatically, and refreshed tokens are written back to
the config. upload_blob accepts no endpoint override: an upload carries a
credential and always goes to the account's own PDS.
Building
Claude Code integration
Trying it by hand
Every request needs _meta. There is no handshake, so any method can be the
first one sent:
META='"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientCapabilities":{}}'
|
Notes
- Requests are handled concurrently, and responses may arrive in any order;
correlate them by JSON-RPC
id. This is required rather than optional: cancellation arrives as a notification while a request is running, andsubscriptions/listendoes not return until it is cancelled. notifications/cancelledstops a request and suppresses its response.notifications/progressis emitted for blob transfers when the request carries aprogressToken.- Logging goes to stderr. The MCP Logging feature is deprecated in this revision and stderr is the migration it names for stdio servers.
subscriptions/listenis answered and acknowledged with an empty filter: nothing this server exposes changes, so there is nothing to notify about.