MCP Integration (Model Context Protocol)
-
Embedded MCP HTTP
Optional stateless HTTP transport for tools and clients.
-
Access Control
Allowed hosts/origins, optional API key, DNS rebinding protection.
-
Defaults
Per-endpoint defaults for retrieval mode and Top-K.
Stateless Mode
Keep the embedded MCP HTTP endpoint stateless for easier scaling and isolation.
Path and CORS
Align mount_path, allowed_hosts, and allowed_origins with your reverse proxy and UI origin to avoid CORS issues.
Auth
Use require_api_key=true in multi-tenant or exposed deployments.
The advertised URL comes from config
GET /api/mcp/status reports the connect URL as mcp.public_base_url plus the mount path; behind a proxy, set public_base_url to the public origin and add its host to mcp.allowed_hosts. See MCP for the full field list.
Configuration (Selected)
| Field | Default | Description |
|---|---|---|
mcp.enabled | true | Enable embedded MCP HTTP endpoint |
mcp.mount_path | /mcp | URL path for MCP endpoint |
mcp.public_base_url | http://127.0.0.1:58012 | Public origin the status endpoint advertises; the server appends the mount path |
mcp.stateless_http | true | Stateless mode |
mcp.json_response | true | Prefer JSON responses |
mcp.enable_dns_rebinding_protection | true | Defense in depth |
mcp.allowed_hosts | localhost:* | Allowed Host headers |
mcp.allowed_origins | http://localhost:* | Allowed Origin values |
mcp.require_api_key | false | Require Authorization: Bearer $MCP_API_KEY at the mount (fails closed without the key) |
mcp.default_top_k | 20 | Default Top-K when omitted |
mcp.default_mode | tribrid | Default retrieval mode |
flowchart LR
Client["MCP Client"] --> HTTP["HTTP /mcp"]
HTTP --> RAG["ragweld tools"]
RAG --> Search["Search / Answer"] Status Endpoint
async function mcpStatus() {
const s = await (await fetch('/api/mcp/status')).json();
console.log(s);
}
- Set allowed hosts/origins
- Enable API key when exposing outside localhost
- Choose default retrieval mode/Top-K for tools
Search failures are structured, never partial
The MCP search tool fails closed: when retrieval cannot complete it returns isError=true with a typed error detail — dependency_unavailable, required_retrieval_leg_failed, or an index-contract mismatch (embedding_contract_mismatch / sparse_contract_mismatch) — instead of partial rows, and POST /api/mcp/probe surfaces the same details as typed 503/409 HTTP errors. See MCP for the payload shape.