This document is the complete reference for the App Plugin (MCP Apps
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:
Register the
Choose the right collaboration channel for the user's intent—don't turn a routine form save into a chat message:
Check
Check
Page
Top-level MCP Apps must return local HTML. To embed a hosted web page or call remote APIs, declare least-privilege domains under
Navigate directly from host surfaces to a specific in-app route:
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–styleapp.*helpers (such asapp.callServerToolandapp.sendMessage). Qoder-specificqoder/*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
- 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 version2026-01-26with 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 Location | Fields | Purpose |
|---|---|---|
tools/list tool top level | name, title, icons, inputSchema, annotations | Tool ID, menu title, entry icon, argument schema, and behavior hints |
Tool _meta.ui | resourceUri, visibility | Bound HTML resource URI and model/app invocation permissions |
Tool _meta["qoder/ui"] | entrypoints | Static navigation entrypoints (global / thread / settings) |
resources/read.result.contents[] item _meta["qoder/ui"] | availableDisplayModes, preferredDisplayMode | Container preferences when mounting the page (inline / fullscreen) |
Same resource item _meta.ui.csp | frameDomains, resourceDomains, connectDomains, baseUriDomains | CSP allowlist for embedded remote pages, static assets, and API requests |
ui/message request _meta["qoder/message"] | target, send, background, permissionMode | Message target thread, immediate send vs. draft, and new-thread permissions |
ui/update-model-context content block _meta | qoder/title, qoder/group, qoder/thumbnail | Display title, grouping, and thumbnail for context chips in the chat input |
Chat SDK Query tools/call.params._meta | com.qoder/* | Originating chat session ID, working directory, and workspace resource scope |
3. Tool Definitions (tools/list) & Visibility
- Read-only entrypoint rule: Static entrypoint tools must be read-only (
annotations.readOnlyHint: truematching actual behavior). Opening an entrypoint must never trigger writes, billing events, or irreversible side effects. resourceUrirules: Must use theui://scheme with a hostname, total length<= 8,192characters, no control characters or embedded credentials, and must match the URI returned byresources/readexactly.- Tool visibility (
_meta.ui.visibility):
| Value | Callable by Model | Callable by App UI |
|---|---|---|
Omitted / ["app", "model"] | Yes | Yes |
["app"] | No | Yes |
["model"] | Yes | No |
Non-array (e.g., "app") | No | No |
| Array containing unknown entries | Only if "model" is included | No |
If a server paginatestools/listand the host cannot verify model visibility due to an incomplete catalog, model invocation is denied. Neithervisibilitynorannotationsreplaces server-side authorization checks.
4. HTML Resource Responses (resources/read) & Tool Results
- Exact MIME type required: Must be
text/html;profile=mcp-app(plaintext/htmlor 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 instructuredContent. Never place secrets or unauthorized fields in either. Return business errors withisError: trueand protocol failures as JSON-RPCerror; 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: ValidateisErrorandstructuredContent, 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{}.
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:
| Mechanism | Best For | Triggers a New Agent Turn? |
|---|---|---|
Call server tool (tools/call) | Querying records, saving forms, fetching chart data | No |
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 draft | Yes 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:
| Field | Allowed Values | Meaning & Prerequisites |
|---|---|---|
target | active (default), new | Send to the active thread or open a new thread |
send | true (default), false | Send immediately, or prefill the chat composer as a draft for user confirmation |
background | false (default), true | Start a new thread in the background without leaving the current view (requires target: "new", send: true, and experimental["qoder/message"].background) |
permissionMode | auto (default), acceptEdits | Permission mode for a new thread (requires target: "new" and declared support in permissionModes) |
- Success semantics & timeout deduplication: Standard success returns only
{}(no internal receipt fields likesessionId). Within a single App instance, the host deduplicates by JSON-RPC request ID, but calling SDKsendMessageagain 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; supportstext,image,resource_link,resource):qoder/titleand group titles longer than 512 characters are truncated.qoder/thumbnail.srcsupportsdata:image/*andhttps:(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": [] }withoutstructuredContentclears context;{ "structuredContent": {} }is a valid update, not a clear. Accepted updates return_meta["qoder/modelContext"].updateIdand sync intohostContext["qoder/modelContext"](nullafter 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:
| Key | Meaning |
|---|---|
com.qoder/turnContext.sessionId | Originating chat session ID |
com.qoder/request-context-v1 | cwd and additionalDirectories (paths on the execution host) |
com.qoder/chatResourceScope | Workspace 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 Action | Protocol Method / Mechanism | Required Capability Check | Key Limits |
|---|---|---|---|
| Preview a local file | qoder/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 files | qoder/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 files | qoder/files/subscribe-drop + listen to qoder/files/notifications/selected | experimental["qoder/files"].drop (global entrypoint) | A new subscription replaces the previous one; delivers path metadata, not file contents |
| Attach local file to new-thread draft | resource_link in ui/message + _meta: { "qoder/localFile": true } | experimental["qoder/files"].draftAttachments | New-thread drafts only (target: "new", send: false); must be a percent-encoded absolute file:// URI |
| Export / download files | ui/download-file / app.downloadFile({ contents }, { timeout }) | hostCapabilities.downloadFile | Opens 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'):
- 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 everymessageevent. Never expose a generic RPC passthrough or pass plaintext tokens overpostMessage. If authentication redirects across domains, add every login origin toframeDomains. - Prevent native form navigation: Attach a
submitlistener withevent.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 })(checkopenLinks,isError, and rejected promises). HTTPS links open in the external browser; jump to an existing chat using<scheme>://chat/open?sessionId=...(useqoderfor Global orqoder-cnfor China—do not mix schemes).
4. Host Settings, @ Mentions & App Deep Links
1. Host Settings Form (qoder/settings) & Custom Settings View
| Approach | Rendered By | How to Wire | Key Constraints |
|---|---|---|---|
qoder/settings | Qoder auto-renders from schema | Declare 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 page | Separate 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)
- Declare
{ "searchTool": "docs_search" }under servercapabilities.extensions["qoder/mentions"]. - Mark the search tool
annotations.readOnlyHint: true, accept{ query: "..." }, return quickly, and place candidates insidestructuredContent.items(returning onlycontentwill not work): - When the user sends the message, the host calls
resources/readto resolve the body—return a single text resource matching the exact URI, and enforce authorization during both search and read steps.
3. App Deep Links
Navigate directly from host surfaces to a specific in-app route:
- Receiving routes: Read
hostContext["qoder/deepLink"]?.url(an object{ url: string }, not a bare string) during both initialhostContextsetup andhost-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
globalentrypoint on the target tool. The path must have exactly 4 segments (3rd segmentapp), allow only a singlepathquery param (starting with a single/, forbidding//,\,#), forbid userinfo/port/fragment/control chars, and stay<= 32,768characters 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 viaapp.openLink. Standardui/open-linkdoes 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