Building MCP Servers with MCP Apps
MCP Apps is an official MCP extension that lets your server return interactive UIs rendered directly inside ajan and other MCP hosts.
What is MCP Apps?
MCP Apps is an official extension to the Model Context Protocol that lets MCP servers return interactive HTML/JavaScript interfaces β rendered directly in the host application (ajan, Claude Desktop, VS Code, etc.) β instead of plain text.
How It Works
Tool declares a UI resource
Your tool definition includes a _meta.ui.resourceUri pointing to a ui:// resource served by your MCP server. This tells compatible hosts that the tool has a UI component.
Host fetches and renders the UI
When the LLM calls the tool, the host fetches the HTML from your server and renders it in a sandboxed iframe. In ajan, the iframe appears as a standalone output in the chat after the tool call. On desktop, you can open it in the side panel or show it in the chat.
Bidirectional communication
The UI and host communicate via JSON-RPC over postMessage. Your app can request tool calls, update the model's context, and receive results β all without leaving the conversation.
View MCP Apps in Chat
When an MCP tool declares a UI resource, ajan displays the MCP App as a standalone output in the chat after the tool finishes. The app appears outside the tool call details. Standard MCP tools without a UI resource continue to show their regular output.
On desktop, select Open in side panel to move the app to a resizable side panel while you continue the conversation. Select Show in chat to return it to the chat.
Security Model
MCP Apps runs in a sandboxed environment. The host controls what your app can access:
| Layer | What it does |
|---|---|
| Iframe sandbox | Isolates the app from the parent page and other tabs |
| App HTML | ajan renders the HTML returned by your MCP server directly in the sandbox without inspecting or sanitizing it |
| Enabled resources | Apps can read only resources enabled for the integration |
| Auditable JSON-RPC | All app-to-host communication is loggable |
| Confirmation gate | Apps cannot call tools or read resources that require confirmation |
Building Your Own
The official SDK is @modelcontextprotocol/ext-apps. It works with React, Vue, Svelte, Solid, Preact, and vanilla JavaScript.
The core pattern: a tool definition declares _meta.ui.resourceUri, which points to a ui:// resource your server serves as HTML. ajan fetches and renders it in a sandboxed iframe as a standalone output in the chat. On desktop, you can also open it in the side panel.
import {
registerAppResource,
registerAppTool,
RESOURCE_MIME_TYPE,
} from "@modelcontextprotocol/ext-apps/server";
const resourceUri = "ui://my-form";
registerAppTool(
server,
"render_form",
{
inputSchema: {},
_meta: { ui: { resourceUri } },
},
async () => ({
content: [{ type: "text", text: "Opening form..." }],
}),
);
registerAppResource(
server,
resourceUri,
resourceUri,
{ mimeType: RESOURCE_MIME_TYPE },
async () => ({
contents: [
{
uri: resourceUri,
mimeType: RESOURCE_MIME_TYPE,
text: "<html>...</html>",
},
],
}),
);- MCP Apps Documentation β Official spec, SDK reference, and framework guides
- ext-apps GitHub β SDK source, examples, and issue tracker
Example: ServiceNow MCP Server
The ajan ServiceNow MCP Server is a reference implementation that shows how to combine OAuth Dynamic Client Registration (DCR) with MCP Apps forms for creating ServiceNow records from within ajan.
It exposes four tools:
| Tool | Description |
|---|---|
get_form_fields | Retrieves available fields from a ServiceNow table |
render_form | Returns an interactive MCP Apps form, optionally pre-filled from conversation context |
submit_form | Creates a record in ServiceNow from the submitted form data |
update_form | Updates fields in an existing ServiceNow form after render_form runs |
- servicenow-mcp-server β Reference implementation β OAuth DCR + MCP Apps forms for ServiceNow
Connecting to ajan
Once your MCP server is running, connect it to ajan the same way as any MCP server. See the MCP integration guide for setup instructions, including authentication options.
Related Documentation
- MCP Integration Guide β How to connect MCP servers to ajan
- MCP Server Directory β Verified remote MCP servers you can connect today
- A2A Protocol β Agent-to-agent communication