Overview
Chatto's Model Context Protocol (MCP) integration lets an agent host inspect a Chatto server through a standard, user-scoped tool interface. MCP tools adapt the existing public Chatto operations. They do not replace the public API or give an agent operator authority. The first catalog has bounded reads and a small set of user actions for practical agent-host tests.
MCP has three main server primitives. Tools let a model request an operation. Resources let a host load identified content. Prompts provide reusable interaction templates. Chatto starts with tools because they provide bounded arguments, normal authorization checks, and structured results for the first use cases.
An MCP client runs inside an agent host. The client reads Chatto's tool
definitions, the host decides which calls it permits, and Chatto authorizes
each received call. The model's choice to request a tool never bypasses the
host or Chatto checks. In OAuth text, the MCP "resource" means the audience
identifier for the /mcp endpoint. It is different from an MCP Resource
primitive.
Behavior
- The MCP integration is disabled by default while it is experimental.
- When enabled, Chatto serves MCP over stateless Streamable HTTP at
/mcpon the existing public HTTP server. It serves the canonicalwebserver.urlorigin and each exact non-wildcardwebserver.allowed_originsentry. - The implementation supports MCP
2026-07-28. The olderinitializehandshake is not supported. See ADR-085 and the tested host matrix. - The server advertises only tools. Resource, prompt, and completion methods return method-not-found errors. Logging and catalog-change subscriptions are not advertised.
- A human grants an MCP client access through Chatto OAuth. The flow uses Authorization Code with PKCE and the client's CIMD identity.
- A native MCP client can receive the OAuth result on a literal loopback IP,
localhost, or one concrete.localhosthostname. Chatto shows the local callback origin and requires consent for each authorization. - Human MCP access tokens are valid only for the exact MCP resource that the
user approved. A token for one configured origin is not valid for another
origin. A grant can contain any nonempty subset of
chatto:rooms:read,chatto:rooms:write,chatto:messages:read,chatto:messages:write, andchatto:profile:read. These scopes are an additional ceiling on the user's normal Chatto authority. Writes do not imply reads. Empty sets and unknown scopes are rejected. The consent screen states only the approved capabilities and identifies server and account identity access. Message reads and writes have separate consent text. - Resource-bound access and refresh credentials use a separate credential class. A validator that supports only general bearer credentials rejects them instead of ignoring their resource and scope boundary.
- A bot can use its existing Bot API key. Calls act as that bot and remain limited by its explicit permissions and its owner's current authority.
- The MCP endpoint does not accept browser cookies. It does not accept a human bearer session that has no MCP resource and scope grant.
- The tool catalog contains
get_server_info,get_current_user,list_rooms,list_room_messages,post_message,join_room, andleave_room,get_user,add_reaction,remove_reaction,get_message,update_message,delete_message, andsend_direct_message. - Any valid MCP grant permits discovery and the two identity tools.
list_roomsrequires room-read scope;list_room_messagesrequires message-read scope, as doesget_message; sends, edits, deletions, and reactions require message-write scope;get_userrequires the separatechatto:profile:readscope;join_roomandleave_roomrequire room-write scope.tools/listshows only tools covered by the grant. Its result has private cache scope and a zero TTL. Bot keys have the complete catalog but retain their normal authority ceiling. - Protected-resource metadata requests only
chatto:rooms:readfor initial discovery. Issuer metadata lists all five scopes. A host can request more scopes through fresh consent. Existing complete grants remain valid. - A call without its tool scope returns HTTP
403with an OAuthinsufficient_scopechallenge that names only the required scope and the protected-resource metadata URL. This check precedes domain operations. A scope-present RBAC denial remains an MCP tool error. - Consent records identify the exact resource and normalized scope set.
Authorization-code exchange and refresh preserve that grant. The token
response reports the granted
scope. A token request cannot widen it. - Identity tools return the effective server identity or the authenticated
account identity. Server identity includes the canonical server URL and the
connected MCP URL. Room and message list tools return bounded pages. The
room-list result also returns the exact number of rooms that the account can
see, independent of the page size.
post_messagecreates one room or thread message and can mark a reply to another message. Thread selection and reply markers have separate arguments; omitted thread selection retains the canonical reply-target inheritance behavior. Profile lookup returns public fields only; reaction tools change only the caller’s reaction. Cross-room actions use current server permissions. The room membership tools join or leave one channel room. get_messagereturns the current body, thread references, and reaction counts after canonical message-read authorization. Edits replace only the body; deletions use normal author and moderation rules. Uncertain edits and deletions require inspection before another mutation.send_direct_messagetakes a recipient ID and body, resolves or creates the canonical DM, and posts through the normal message operation. Its receipt includes the message and room IDs for later thread replies. Exact keyed sends use the existing 30-minute retry contract. DM creation and posting are separate operations; a failed send can leave an empty DM. Error fieldsconversationCreatedandroomIddescribe this separately from the message deliveryoutcome. Message-write consent covers this complete sending action, including destination creation. Existing message-write grants also permit edits and deletions subject to account rights.- Authenticated tool calls can supply
Chatto-Realtime-Minimum-Cursor. The canonical viewer-bound content wait runs before tool dispatch. Invalid cursors and wait timeouts have no tool effects. An expired cursor needs no wait, so the tool runs at once. - MCP server metadata uses
Chattoas its stable implementation name and the effective Chatto server name as its display title. - Static MCP instructions identify the tools as the source of truth for rooms,
messages, room membership, and account identity on the connected server.
They tell an agent host to use the advertised server title to distinguish
the connection from other Chatto connections, to call
get_server_infowhen the target server is not clear, to complete pagination when needed, and not to infer Chatto application data from deployment configuration. Configured values never enter these instructions. - Tool descriptions state that operations apply to the connected Chatto server. Identity and list descriptions also explain server matching, exact room counts, and continuation fields.
- Tool arguments use stable Chatto resource IDs and explicit bounded page limits. Tool results do not contain raw broker coordinates or internal storage identifiers.
- The endpoint requires a configured public server Host and rejects wildcard or unknown hosts. It rejects cross-origin browser writes and gives each request 15 seconds. Admission limits are separate for each caller; see decision 12.
- A listed tool can reject a specific target even when its scope is granted.
- Every tool call applies current Chatto RBAC, room membership, message access, search visibility, and absence rules. A successful earlier call does not grant authority to a later call.
- A failed tool call returns structured failure details and a short text explanation. Hosts can distinguish invalid input, missing consent, membership, confirmed missing RBAC permissions, generic policy denial, hidden or absent resources, conflict, rate limits, timeout, and temporary failure without parsing the explanation. Suggested actions do not grant authority. Permission names appear only after visibility and permission checks confirm that they are missing. Policy details and backend diagnostics remain private.
- Room tools check visibility before they run. A hidden channel or a nonparticipant direct-message room has the same failure as an absent room. Joined rooms remain visible to their members.
- Failure details state whether a write did not occur, completed, or has an unknown outcome. A host can retry a post with its original optional UUID and exact arguments within 30 minutes. Without a key, a completed or uncertain result needs a result check, also when the connection closes without a result. Known input, access, and policy rejections need a change before retry.
- A tool returns only the data needed for its declared operation. It does not add related private resources for agent convenience.
- User-controlled Chatto content is untrusted data. It cannot change tool descriptions, server instructions, authorization, or the available tool catalog.
- OAuth consent, session revocation, blocked-client policy, account lifecycle, and bot-key rotation affect MCP access in the same way that they affect the underlying credential.
- The network MCP server has no Operator API, bootstrap, password-reset, credential-enrolment, account-deletion, role-management, server-management, raw diagnostics, or event-log tools in its first release.
- Disabling MCP removes its routes from the public HTTP server. It does not disable ConnectRPC, realtime, OAuth, the CLI, or the local Operator API.
Design Decisions
1. MCP adapts canonical Chatto operations
Decision: Implement each MCP tool as an adapter over the same application operation used by the public API. Do not call Chatto through loopback HTTP and do not put domain behavior in MCP handlers. Why: ADR-042 and ADR-044 require transports to share authorization, validation, consistency, and response behavior. A thin adapter prevents MCP from becoming a second product API with different rules. Tradeoff: MCP result shapes need explicit mapping, and not every public RPC should become a tool.
2. Keep the tester catalog small
Decision: Expose identity, bounded room and message reads, room/thread and direct posting, message corrections, reactions, and channel membership changes. Admit later tools only through the tool-admission checklist. Prefer a bounded agent task over a tool for each public API method. Keep registration as an explicit allowlist; do not generate tools from protobuf services. The current catalog does not expose attachment management, dedicated moderation commands, administration, resources, or prompts. Why: This catalog is sufficient to test discovery, OAuth, schemas, pagination, RBAC, membership, reads, and writes in a real agent host. API completeness and CRUD symmetry are not MCP goals. A public ConnectRPC method alone is not a reason to add a tool. Tradeoff: The key is optional, so the message tool's idempotent hint stays false. Without a key, an agent must check an uncertain result. Read access can disclose sensitive content and needs full authorization. Some agent workflows must use ConnectRPC until there is evidence for a suitable MCP tool.
3. Use explicit human consent and existing bot identity
Decision: Human clients use OAuth with a resource-bound MCP scope. Bots use their existing API key and explicit bot permission model. Ambient browser cookies and unrelated human bearer sessions are not accepted. Why: A user must know when an agent host receives access. Unattended agents also need a non-human identity with least privilege. Chatto already provides CIMD consent for humans and explicit permission allowlists for bots. Tradeoff: MCP hosts must complete OAuth or let an operator configure a bot credential. A normal signed-in browser session cannot silently become MCP authority.
4. Keep MCP scopes separate from RBAC
Decision: MCP OAuth scopes limit the classes of MCP operations that a human client can request. Normal Chatto permissions and resource visibility still decide what the user can do and see. Accept independent scope subsets, filter discovery, and require fresh consent to add authority. Keep the exact grant through code exchange, refresh, and multi-replica credential validation. Why: A user can grant an agent less authority than the user's complete account. RBAC remains the canonical product authorization model. Tradeoff: A call can fail because of either the OAuth ceiling or the current product authority. Errors and consent text must make this distinction clear without disclosing hidden resources. Hosts that need more than the initial room-read grant must request the additional scopes.
5. Target the dated stateless MCP specification
Decision: Prefer MCP specification 2026-07-28 over stateless Streamable
HTTP. Use MCP's own discovery and capability rules after a client reaches the
endpoint. Let the official SDK negotiate its older supported versions during
their compatibility window. Do not describe the protocol as "MCP 2.0."
Why: The dated version is unambiguous. Its stateless request model fits the
existing public HTTP server and does not require MCP session affinity or a
shared MCP session store.
Tradeoff: An older agent host can connect only while the official SDK
supports its version. Chatto can make an older version an explicit product
contract only after a compatibility and resource cost review.
6. Use standard MCP and OAuth discovery
Decision: An operator gives the configured MCP URL to an agent host. The host uses MCP and OAuth metadata for discovery. Do not add MCP details to Chatto's ConnectRPC discovery service. Why: A general MCP host does not use Chatto's protobuf API. MCP already reports its protocol capabilities and tool catalog. Tradeoff: Chatto cannot automatically suggest the MCP URL to a Chatto-specific client until that product use case has a separate design.
7. Treat all Chatto content as untrusted data
Decision: Tool descriptions and protocol instructions are static Chatto text. The configured server name is display metadata and a structured tool result field. Other user-controlled content also stays in structured result fields. No user-controlled value can add tools or change server instructions. Why: Messages and profiles can contain text that tries to control an agent. The server must not present that text as trusted protocol guidance. Tradeoff: The MCP host and model must still handle prompt injection in returned data. Server-side structure reduces confusion but cannot make hostile content safe.
8. Preserve the local Operator API boundary
Decision: Do not expose chatto.operator.v1 through the network MCP server.
A future operator MCP integration must be a separate local stdio bridge that
uses the configured Operator socket.
Why: The Operator API is root-equivalent and uses local filesystem access
as its security boundary. Combining it with user tools would create remote
root authority and make tool selection a critical privilege boundary.
Tradeoff: Remote operator automation cannot use the public MCP endpoint. A
trusted operator must use the CLI, the Unix socket, or a future local bridge.
9. Keep bootstrap outside MCP
Decision: Keep recovery in configuration and the local Operator API. First-run web setup is a separate public flow described in FDR-047. Do not add initial-owner or recovery tools to the network MCP server. Why: A normal user cannot approve OAuth access before the server has a usable identity and recovery path. MCP transport does not solve this circular authority problem. Tradeoff: A remote-only deployment can use the first-run wizard, but recovery still requires operator access.
10. Treat each configured origin as a separate resource
Decision: Serve MCP on the canonical server origin and each exact public alias. Bind human OAuth credentials to the exact origin that the client uses. Keep the canonical server origin as the authorization-server issuer. Why: Operators can expose one Chatto server through more than one public host. Exact resource binding prevents a credential for one host from becoming authority on a different host. Tradeoff: A human must approve a new grant when the client changes to a different configured origin. Wildcard CORS entries cannot expose MCP.
11. Give safe failure guidance
Decision: Give hosts stable failure categories, suggested actions, retry rules, and write outcomes. Confirm visibility before an operation and before disclosing missing RBAC identifiers. Preserve standard OAuth scope challenges. Why: An agent must be able to ask its human driver for the right next action without parsing prose, disclosing a hidden room, or repeating an uncertain message post. Tradeoff: Generic policy errors need human investigation. A completed write can still have a failed response. A keyed retry keeps the same message identity; an unkeyed post needs a result check. See FDR-052 and ADR-117.
12. Separate admission limits for each caller
Decision: Admit MCP requests in stages, so that one caller cannot use the allowance of another caller:
- A request without a bearer token gets only an authentication challenge. Each client network has 5 such requests per second with a burst of 20. All of them together have 20 per second with a burst of 40.
- Each request with a bearer token that does not authenticate is a failure. A backend error during verification is not a failure; a cancelled or expired request is. At most 10 requests with new credentials from one client network can wait for verification at the same time. A client network can have 10 failures, plus one more each 5 seconds. After that, the network cannot present tokens until the allowance refills. Chatto does not read the credential store for a blocked request.
- After a credential authenticates, the replica keeps a bounded index from the credential hash to its account. A later request with that credential uses the allowance of its account before verification. Verification still decides each request, and a failure removes the credential from the index.
- A credential that is not in the index has 20 requests per second with a burst of 40 before verification. All such credentials together have 200 requests per second with a burst of 400.
- Each authenticated account has 20 requests per second with a burst of 40 across all of its credentials, and at most 8 requests that run at the same time.
- Cross-origin browser writes are rejected before these stages and use no allowance.
A client network is an IPv4 address or an IPv6 /64 prefix. Chatto gets it
through webserver.trusted_proxies. A rejection returns HTTP 429,
Retry-After, and retryAfterMs. It does not identify the stage, network,
credential, or account. Chatto keeps the keys only in memory and does not log
them.
Why: One shared limit in front of authentication let anonymous callers or
one flooding bot block all authenticated callers (#2243). A caller-specific
stage runs before each shared ceiling, so a flood from one caller does not use
the shared ceilings. The credential index keeps an account with many
credentials out of the shared ceiling. Bounded failure checks protect the
credential store.
Tradeoff: Each replica enforces the limits in its own memory, so N replicas
admit up to N times the values. A caller on the same client network as a
source of failed tokens cannot present tokens while the failure allowance is
empty. A caller that uses many new valid credentials can still use the shared
ceiling for their first requests. When a keyed limit holds 10,000 entries
that all have requests in progress, it rejects new keys. Without correct
webserver.trusted_proxies, all callers behind a proxy share one client
network. A distributed flood with many networks can still reach the shared
ceilings.
Tool Admission Policy
A new tool must serve a demonstrated agent workflow that the current catalog cannot express safely. The proposal must answer every item below before a maintainer admits it:
- Workflow: State the user's task, the agent's steps, and the result that the user needs. Explain why existing tools cannot complete it safely. Prefer a bounded task over separate tools for each CRUD operation.
- Cost and output: Set limits for arguments, work, duration, result items, and result bytes. Cover pagination, scans, and related-resource reads. A page limit or request timeout alone does not prove bounded backend work.
- Human effect: State what the call reads or changes, who can observe the change, and whether it is destructive or reversible. Make the effect clear in the tool description and annotations. Host approval does not grant Chatto authority.
- Canonical operation: Use existing Chatto application reads or commands with their validation and consistency rules. A composed task must state its partial-success behavior. Do not add MCP-only domain rules or state.
- Authorization and privacy: Define the OAuth scope, current RBAC, membership, visibility, and bot authority checks for each target. Explain hidden/absent behavior, returned private data, untrusted content, external connections, and safe diagnostics. Check authority on every call.
- Retry: State idempotency, failure categories, cancellation, concurrent changes, and write outcomes after a lost response or acknowledgement. A host must not automatically repeat a non-idempotent write with an unknown outcome. Tool hints do not replace the outcome contract.
- Compatibility: Review names, arguments, results, errors, and authority as public contracts under ADR-045 and ADR-085. State client impact, discovery behavior, and any migration or consent change.
- Primitive: Explain why a tool fits better than existing tools, ConnectRPC, an MCP resource, or an MCP prompt. A new primitive needs its own capability, authorization, cost, and compatibility review.
- Evidence: Supply a repeatable workflow in a real agent host with synthetic accounts and content. Record the host version, limits tested, user-visible result, and remaining gaps. Add automated success, denial, invalid-input, cost-boundary, and retry/outcome checks where applicable. Schema checks or SDK fixture calls alone are insufficient. A new tool class, such as search or content changes, requires this evidence before admission; an existing class does not waive the checklist.
Evaluate an MCP resource when a host needs to load identified content as context, with no requested action. Evaluate a prompt when a host needs a reusable interaction template rather than a new application operation. These choices do not justify broader read access or trusted instructions from user-controlled content. Chatto currently advertises neither primitive.
The public catalog excludes Operator API authority, bootstrap and recovery, credential issuance or management, raw diagnostics, event logs, and storage internals. Protocol conformance fixtures must not enter the product catalog. Administrative, moderation, destructive-content, and account-lifecycle tools are outside the current scope. They need a separate product and authority decision as well as the checklist. Any future Operator MCP integration must use a separate local bridge under ADR-085.
There is no numeric catalog budget. The MCP maintainer reviews the complete catalog with each catalog change and before each stable Chatto release that includes MCP. The review must check overlapping tools, selection ambiguity, retained workflow evidence, and recorded exceptions. A small count alone does not make a tool useful or safe. Record each tool's disposition in the catalog review. An exception must state its reason, affected checklist items, evidence gaps, and the condition for review. Existing tester exceptions do not admit new tools or tool classes.
Permissions
The MCP integration adds no RBAC permissions.
chatto:rooms:read,chatto:rooms:write,chatto:messages:read, andchatto:messages:writeare OAuth grant ceilings for a human MCP client. They are not RBAC permissions.room.listcontrols room-directory visibility where applicable.room.joincontrols channel joins where applicable.message.postcontrols root message posting.message.readcontrols broad message access in channel rooms and DMs.message.read-interactionscontrols relationship-scoped message access.- DM membership is an additional requirement for DM reads.
- Bot calls also require the bot's explicit permission and sufficient current authority from its owner.
Each underlying operation can require other existing permissions or resource relationships. The operation remains the source of truth.
Related
- ADRs: ADR-024 (opaque bearer tokens), ADR-042 (protobuf-first public API), ADR-044 (ConnectRPC service conventions), ADR-045 (public API stability tiers), ADR-071 (CIMD-identified OAuth clients), ADR-079 (renewable bearer sessions), ADR-080 (message-read permission), ADR-085 (user-scoped MCP integration), ADR-117 (message-post idempotency)
- FDRs: FDR-001 (Roles & Permissions), FDR-023 (Authentication & Sessions), FDR-028 (Operator API & CLI), FDR-031 (Client–Server Compatibility Discovery), FDR-033 (Message Search), FDR-038 (Bot Accounts), FDR-039 (Message Access & Interactions), FDR-050 (Message Send Retries)
Open Questions
- Which product scopes should cover later thread, search, and other write tools?
- Which demonstrated workflows meet the admission policy for MCP resources or prompts?
- When should the tested host matrix justify an older MCP protocol version?
- Should Chatto ship a separate local operator MCP bridge after the public endpoint has operational experience?
- Which audit events and safe usage metrics should identify MCP calls without recording message content or other PII?