Skip to main content

Protocol & Host Capabilities

This document is the complete reference for the App Plugin (MCP Apps 2026-01-26) protocol and Qoder host extensions, covering server-to-UI messaging, agent and thread collaboration, files/downloads/network CSP, and settings, @ mentions, and deep links.
Code conventions: Examples below show both raw JSON-RPC messages and standard MCP Apps SDK–style app.* helpers (such as app.callServerTool and app.sendMessage). Qoder-specific qoder/* host extensions do not have a standardized SDK wrapper and are shown using their underlying protocol method names and parameter objects.

1. Server & UI Protocol

1. Two Independent Channels and Version Negotiation

1) MCP Client (Qoder) ◀──▶ MCP Server
   initialize / tools/list / tools/call / resources/read

2) App UI Page ◀──▶ Qoder Host Bridge
   ui/initialize / ui/message / ui/update-model-context
   tools/call / resources/read / host notifications
  • Protocol versions are negotiated independently on each channel: the server negotiates the MCP protocol version (e.g., 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25), while the UI page negotiates MCP Apps version 2026-01-26 with the host. Do not mix them.

2. Protocol Metadata Placement Reference (Most Common Pitfall)

Metadata placed at the wrong protocol level is silently ignored by the host—for example, placing display mode preferences on a tool definition or putting entrypoints inside HTML:
Protocol LocationFieldsPurpose
tools/list tool top levelname, title, icons, inputSchema, annotationsTool ID, menu title, entry icon, argument schema, and behavior hints
Tool _meta.uiresourceUri, visibilityBound HTML resource URI and model/app invocation permissions
Tool _meta["qoder/ui"]entrypointsStatic navigation entrypoints (global / thread / settings)
resources/read.result.contents[] item _meta["qoder/ui"]availableDisplayModes, preferredDisplayModeContainer preferences when mounting the page (inline / fullscreen)
Same resource item _meta.ui.cspframeDomains, resourceDomains, connectDomains, baseUriDomainsCSP allowlist for embedded remote pages, static assets, and API requests
ui/message request _meta["qoder/message"]target, send, background, permissionModeMessage target thread, immediate send vs. draft, and new-thread permissions
ui/update-model-context content block _metaqoder/title, qoder/group, qoder/thumbnailDisplay title, grouping, and thumbnail for context chips in the chat input
Chat SDK Query tools/call.params._metacom.qoder/*Originating chat session ID, working directory, and workspace resource scope

3. Tool Definitions (tools/list) & Visibility

{
  "name": "open_records",
  "title": "Records",
  "description": "Read records accessible to the current user and open the list view without modifying data.",
  "inputSchema": { "type": "object", "properties": {}, "additionalProperties": false },
  "annotations": { "readOnlyHint": true },
  "_meta": {
    "ui": {
      "resourceUri": "ui://record-workbench/main.html",
      "visibility": ["app", "model"]
    },
    "qoder/ui": { "entrypoints": [{ "type": "global" }] }
  }
}
  • Read-only entrypoint rule: Static entrypoint tools must be read-only (annotations.readOnlyHint: true matching actual behavior). Opening an entrypoint must never trigger writes, billing events, or irreversible side effects.
  • resourceUri rules: Must use the ui:// scheme with a hostname, total length <= 8,192 characters, no control characters or embedded credentials, and must match the URI returned by resources/read exactly.
  • Tool visibility (_meta.ui.visibility):
ValueCallable by ModelCallable by App UI
Omitted / ["app", "model"]YesYes
["app"]NoYes
["model"]YesNo
Non-array (e.g., "app")NoNo
Array containing unknown entriesOnly if "model" is includedNo
If a server paginates tools/list and the host cannot verify model visibility due to an incomplete catalog, model invocation is denied. Neither visibility nor annotations replaces server-side authorization checks.

4. HTML Resource Responses (resources/read) & Tool Results

{
  "contents": [{
    "uri": "ui://record-workbench/main.html",
    "mimeType": "text/html;profile=mcp-app",
    "text": "<!doctype html><html><body><main id=\"app\"></main></body></html>",
    "_meta": {
      "qoder/ui": {
        "availableDisplayModes": ["inline", "fullscreen"],
        "preferredDisplayMode": "fullscreen"
      }
    }
  }]
}
  • Exact MIME type required: Must be text/html;profile=mcp-app (plain text/html or a raw remote URL is rejected). Decoded UTF-8 HTML size must not exceed 20,000,000 bytes.
  • Serve both humans and UI in tool results: Put a concise human-readable summary in content (so non-UI clients stay useful) and machine-readable state + revision numbers in structuredContent. Never place secrets or unauthorized fields in either. Return business errors with isError: true and protocol failures as JSON-RPC error; your UI must handle both paths.

5. Page Handshake, Host Notifications & Same-Server Tool Calls

Register the message listener first, send ui/initialize (protocolVersion: "2026-01-26"), and after receiving hostCapabilities and hostContext, send ui/notifications/initialized. Host messages your UI should handle:
  • ui/notifications/tool-input: Arguments passed to the tool that opened the page (not the final result).
  • ui/notifications/tool-result: Validate isError and structuredContent, then render the initial view.
  • ui/notifications/tool-cancelled: Exit loading states and offer a safe read-only refresh action.
  • ui/notifications/host-context-changed: Incrementally apply theme, locale, container size, deep-link route, or model context status updates.
  • ui/resource-teardown (request): Clean up listeners, timers, and pending requests, then reply promptly with {}.
Pages invoke App-visible tools on the same server via tools/call (app.callServerTool({ name, arguments })) using the server's local tool name. Custom messaging layers must verify event.source on postMessage, maintain unique request id values, and bound in-memory caches. Stdio servers must output only JSON-RPC lines to stdout and write all diagnostics to stderr.

2. Collaborating with the Agent & Chat Threads

Choose the right collaboration channel for the user's intent—don't turn a routine form save into a chat message:
MechanismBest ForTriggers a New Agent Turn?
Call server tool (tools/call)Querying records, saving forms, fetching chart dataNo
Update model context (ui/update-model-context)Telling the model "which items I selected or which page I'm viewing"No (attached to the next message)
Send message / prefill draft (ui/message)Requesting "Compare these three sources" or prefilling a prompt draftYes when sent immediately; No for drafts

1. Sending Messages, New-Thread Drafts & Deduplication

Check hostCapabilities.message first. Only role: "user" is supported, and every send must be triggered by an explicit user action—never fire messages silently on page load. _meta["qoder/message"] options:
FieldAllowed ValuesMeaning & Prerequisites
targetactive (default), newSend to the active thread or open a new thread
sendtrue (default), falseSend immediately, or prefill the chat composer as a draft for user confirmation
backgroundfalse (default), trueStart a new thread in the background without leaving the current view (requires target: "new", send: true, and experimental["qoder/message"].background)
permissionModeauto (default), acceptEditsPermission mode for a new thread (requires target: "new" and declared support in permissionModes)
// Example: safely prefill a new-thread draft without sending immediately
await app.sendMessage({
  role: "user",
  content: [{ type: "text", text: "Generate a comparison report from the three sources I selected." }],
  _meta: { "qoder/message": { target: "new", send: false } }
});
  • Success semantics & timeout deduplication: Standard success returns only {} (no internal receipt fields like sessionId). Within a single App instance, the host deduplicates by JSON-RPC request ID, but calling SDK sendMessage again generates a brand-new ID. On timeout, inform the user ("Send status is unconfirmed—please check the chat thread before trying again") and never auto-resend.

2. Explicit & Background Model Context (ui/update-model-context)

Check hostCapabilities.updateModelContext first. The model never reads the DOM automatically—each call submits a complete current context snapshot:
  • Put explicit user selections in content (rendered as visible, individually removable chips in the composer; supports text, image, resource_link, resource):
    await app.updateModelContext({
      content: [{
        type: "text",
        text: "Key facts from Source A...",
        _meta: { "qoder/title": "Source A", "qoder/group": { title: "Comparison Sources" } }
      }]
    });
    
    • qoder/title and group titles longer than 512 characters are truncated. qoder/thumbnail.src supports data:image/* and https: (never embed tokens).
  • Put background view state in structuredContent (body stays collapsed; composer shows a removable source badge passed to the model on the next turn): include only essential IDs, filters, and pagination—never dump your entire frontend store or credentials.
  • Updates vs. clearing: {} or { "content": [] } without structuredContent clears context; { "structuredContent": {} } is a valid update, not a clear. Accepted updates return _meta["qoder/modelContext"].updateId and sync into hostContext["qoder/modelContext"] (null after clearing).

3. Reading the Current Chat Session & Working Directory

Page hostContext does not expose chat sessionId, cwd, or workspaceId. Only when a chat SDK Query invokes a server tool can your server inspect tools/call.params._meta:
KeyMeaning
com.qoder/turnContext.sessionIdOriginating chat session ID
com.qoder/request-context-v1cwd and additionalDirectories (paths on the execution host)
com.qoder/chatResourceScopeWorkspace scope (including workspaceId); { kind: "user" } when unbound
Global entrypoint initialization and direct UI tool calls do not automatically carry chat metadata. The first chat started from a global entrypoint runs in a managed local directory with no workspace binding. When the UI needs session metadata, filter it server-side and return only safe fields via structuredContent without leaking private host paths.

3. Local Files, Downloads & Network Access

1. Five File Capability Boundaries

User ActionProtocol Method / MechanismRequired Capability CheckKey Limits
Preview a local fileqoder/files/open ({ path })experimental["qoder/files"] (local sessions + stdio/inProcess only)Must be an absolute local path; global entrypoints require a readable regular file
Pick local filesqoder/files/pick ({ extensions })experimental["qoder/files"].pick (global entrypoint)Extensions must be 1–16 lowercase alphanumeric chars without dots; max 16 files per call; cancel returns { files: [] }
Drag-and-drop local filesqoder/files/subscribe-drop + listen to qoder/files/notifications/selectedexperimental["qoder/files"].drop (global entrypoint)A new subscription replaces the previous one; delivers path metadata, not file contents
Attach local file to new-thread draftresource_link in ui/message + _meta: { "qoder/localFile": true }experimental["qoder/files"].draftAttachmentsNew-thread drafts only (target: "new", send: false); must be a percent-encoded absolute file:// URI
Export / download filesui/download-file / app.downloadFile({ contents }, { timeout })hostCapabilities.downloadFileOpens native Save-As dialog so the user chooses destination; host does not return the saved path; max 8 files / 16 MiB total decoded per batch (single-resource response cap 4 MiB / standalone view envelope cap 5 MiB still apply); cancel returns { isError: true }

2. Remote Pages, CSP Allowlists & Navigation

Top-level MCP Apps must return local HTML. To embed a hosted web page or call remote APIs, declare least-privilege domains under _meta.ui.csp on the resources/read item (omitted categories default to 'none'):
{
  "_meta": {
    "ui": {
      "csp": {
        "frameDomains": ["https://app.example.com"],
        "resourceDomains": ["https://cdn.example.com"],
        "connectDomains": ["https://api.example.com"],
        "baseUriDomains": ["https://app.example.com"]
      }
    }
  }
}
  • Cross-origin child iframes cannot call host APIs directly: Maintain the host bridge in your local HTML shell. Validate event.source === iframe.contentWindow, event.origin, and an explicit allowlist of action types on every message event. Never expose a generic RPC passthrough or pass plaintext tokens over postMessage. If authentication redirects across domains, add every login origin to frameDomains.
  • Prevent native form navigation: Attach a submit listener with event.preventDefault() on forms in the top-level page so a standard form submission never replaces the App container.
  • Open external links and existing chats: Always use app.openLink({ url }) (check openLinks, isError, and rejected promises). HTTPS links open in the external browser; jump to an existing chat using <scheme>://chat/open?sessionId=... (use qoder for Global or qoder-cn for China—do not mix schemes).

1. Host Settings Form (qoder/settings) & Custom Settings View

ApproachRendered ByHow to WireKey Constraints
qoder/settingsQoder auto-renders from schemaDeclare readTool and updateTool in server capabilities.extensions["qoder/settings"]readTool is read-only, takes {}, returns schema + all current values; updateTool receives only changed fields { set: { ... } } and returns all current values after partial update. Supports boolean/string/number/integer; max 64 fields, 128 layout items, 16 groups
Custom settings view (settings entrypoint)Your Plugin's HTML pageSeparate App-only read-only tool with entrypoints: [{ type: "settings" }]Must support fullscreen; has no chat messaging, model context, or thread file permissions; binds only to the host's existing Configure button and does not create new buttons; do not combine with global/thread on the same tool

2. Composer @ Mentions (qoder/mentions)

  1. Declare { "searchTool": "docs_search" } under server capabilities.extensions["qoder/mentions"].
  2. Mark the search tool annotations.readOnlyHint: true, accept { query: "..." }, return quickly, and place candidates inside structuredContent.items (returning only content will not work):
    {
      "content": [],
      "structuredContent": {
        "items": [{
          "type": "resource_link",
          "uri": "docs://guide/intro",
          "name": "intro",
          "title": "Getting Started",
          "mimeType": "text/plain"
        }]
      }
    }
    
  3. When the user sends the message, the host calls resources/read to resolve the body—return a single text resource matching the exact URI, and enforce authorization during both search and read steps.
Navigate directly from host surfaces to a specific in-app route:
<qoder-scheme>://plugins/<pluginId>/app/<toolName>?path=/your/in-app/route
// Use scheme "qoder" (Global) or "qoder-cn" (China); pluginId must be the actual installed ID (not manifest name)
const link = `${scheme}://plugins/${encodeURIComponent(pluginId)}`
  + `/app/${encodeURIComponent(toolName)}?`
  + new URLSearchParams({ path: "/record/r-27" }).toString();
  • Receiving routes: Read hostContext["qoder/deepLink"]?.url (an object { url: string }, not a bare string) during both initial hostContext setup and host-context-changed. If the app is already open, Qoder reuses the existing instance and pushes the new route without re-running the entrypoint tool.
  • Prerequisites & validation: The Plugin must be installed and enabled with a valid global entrypoint on the target tool. The path must have exactly 4 segments (3rd segment app), allow only a single path query param (starting with a single /, forbidding //, \, #), forbid userinfo/port/fragment/control chars, and stay <= 32,768 characters overall. Your page must still verify record existence and user access.
  • Two distinct URL families: …://plugins/…/app/… opens an App from the host; …://chat/open?sessionId=… jumps to an existing chat via app.openLink. Standard ui/open-link does not expose arbitrary internal routes.
For the full protocol method support matrix, size/concurrency budgets, and error codes, see Configuration & API Reference.
Next steps: UI & Interaction Guidelines · Debug & Verify App Plugins