The MCP page (builtin.mcp) connects the app to Model Context Protocol
builtin.mcp
servers so agents can use their tools. Declare servers once in the config;
they connect when the app starts. Users can add more from the page only where
you allow it. Install the client once: pip install "aiui[mcp]".
pip install "aiui[mcp]"
Put the block in the config the app starts with (`aiui run app.py --config
aiui.yaml) or in the data-dir config.yaml (AIUI_DATA_DIR`, default
) or in the data-dir
(
~/.praisonaiui). aiui validate checks it. Each server has a url or a
~/.praisonaiui
aiui validate
url
command, not both:
command
| Key | Meaning |
|---|---|
| url | Remote server (Streamable HTTP or SSE) |
| command, args | Local server started as a subprocess (stdio) |
args
| env | stdio: extra environment variables for the subprocess |
env
| headers | Remote: HTTP headers, for example Authorization |
headers
Authorization
| transport | streamable-http, sse or stdio (type works too). Usually not needed, see below |
transport
streamable-http
sse
stdio
type
${NAME} in url, args, env and headers reads the environment variable
${NAME}
NAME, so tokens stay out of the file. A list with a name per server
NAME
name
(servers: [{name: github, url: ...}]) works too; names must be unique.
servers: [{name: github, url: ...}]
The servers connect in the background at startup, all at once, so a slow
server never delays the app. One that fails shows its error on the page, with
a Connect button to try again. They disconnect when the app stops.
| Server | What the app uses |
| command | stdio |
| url | Streamable HTTP; if the server does not answer it, SSE |
| url whose path ends in /sse | SSE |
/sse
| transport: sse or transport: streamable-http | Exactly that one, no fallback |
transport: sse
transport: streamable-http
By default users can reconnect the declared servers but add nothing new. Open
it up with allow:
allow
| allow.urls entry | Admits |
allow.urls
| mcp.example.com | That host on its default port, http or https |
mcp.example.com
http
https
| *.example.com | Any subdomain of example.com |
*.example.com
example.com
| https://h.example.com/mcp/ | That scheme and host, paths under /mcp/ |
https://h.example.com/mcp/
/mcp/
| https://h.example.com:8443 | That port |
https://h.example.com:8443
| * | Any public host |
*
A wildcard (*, *.example.com) never reaches a private, loopback or
link-local address, so users cannot reach your internal network or a cloud
metadata endpoint through the app. To allow an internal server, name its host:
http://localhost:9000.
http://localhost:9000
allow.commands lists the executables users may start, matched exactly:
allow.commands
npx does not admit /tmp/npx. A user-added stdio server cannot set env.
npx
/tmp/npx
Allowing npx or uvx lets users run any package they name, so list them
uvx
only for people you trust; * admits any command (the older
PRAISONAIUI_ALLOW_REMOTE_MCP_STDIO=true does the same). A user cannot reuse
PRAISONAIUI_ALLOW_REMOTE_MCP_STDIO=true
a declared server's name for another target.
mcp: {enabled: false}: nothing connects at startup and the page cannot add
mcp: {enabled: false}
servers. To remove the page and its routes: extensions: {disabled: [builtin.mcp]}.
extensions: {disabled: [builtin.mcp]}
GET /api/mcp/servers
with *** values, drop user and password from URLs, and mask query values
***
(?api_key=***).
?api_key=***
Bearer
redacted from the app's logs, tracebacks included.
Every route needs the same credentials as the rest of the API in each auth mode.
| Route | Does |
| GET /api/mcp/servers | Servers with status, transport, tools, last_error, source (config or user) and masked connection_data; plus enabled and allow |
status
tools
last_error
source
config
user
connection_data
enabled
| POST /api/mcp/connect | {name} connects a declared server. {name, url, headers?, transport?} or {name, command, args?} adds one that allow admits (403 otherwise, 409 for a declared name) |
POST /api/mcp/connect
{name}
{name, url, headers?, transport?}
{name, command, args?}
| POST /api/mcp/disconnect/{name} | Disconnects a server |
POST /api/mcp/disconnect/{name}
From Python, aiui.on_mcp_connect and aiui.on_mcp_disconnect run when a
aiui.on_mcp_connect
aiui.on_mcp_disconnect
server's state changes. App code may call
praisonaiui.features.mcp.connect_mcp_server({...}) directly; the allow
praisonaiui.features.mcp.connect_mcp_server({...})
lists apply to users, not to your code.