agent-mcp-adapter
v0.1.1
Published
MCP adapter that exposes XAgent HTTP APIs as non-invasive MCP tools.
Readme
agent-mcp-adapter
Non-invasive MCP adapter for XAgent HTTP APIs.
The adapter runs as a separate MCP stdio server and calls XAgent through its public HTTP API. It does not import XAgent internals, read the database, or bypass auth/owner scope.
Configuration
$env:XAGENT_BASE_URL = "http://127.0.0.1:3000"
# Optional. Forward auth exactly like a normal HTTP client.
$env:XAGENT_AUTHORIZATION = "Bearer <token>"
# Optional JSON object for extra headers.
$env:XAGENT_HEADERS_JSON = '{"x-tenant-id":"tenant-1"}'
# Optional request timeout.
$env:XAGENT_TIMEOUT_MS = "30000"
# Safety default: only read-only tools are exposed unless this is set to false.
$env:XAGENT_MCP_READONLY = "true"
# Optional comma-separated allowlist. Applied together with read-only filtering.
$env:XAGENT_MCP_ALLOWED_TOOLS = "xagent_health,xagent_list_sessions"
# Optional comma-separated response header allowlist. Headers are hidden by default.
$env:XAGENT_RESPONSE_HEADER_ALLOWLIST = "x-request-id"Run
From npm:
npx agent-mcp-adapterFor local development:
npm install
npm run build
npm startDrift Check
Set XAGENT_ROUTES_FILE to the target agent route source file, then verify that the adapter still covers the current public routes:
$env:XAGENT_ROUTES_FILE = "C:\path\to\agent-repo\packages\agent-channel-web\src\routes\requests.ts"
npm run check:xagent-routesDesign
- Every tool maps to a public XAgent route.
- Tool input is converted into HTTP path/query/body.
- Tool input is validated by the adapter before any upstream HTTP call.
- Tool output includes
structuredContentwith status, ok, body, and request metadata. - Response headers are hidden unless explicitly allowlisted.
- The default exposure mode is read-only; mutation tools require
XAGENT_MCP_READONLY=false. - SSE/WebSocket streaming is represented by a polling tool,
xagent_wait_for_session_idle. - Multipart submit/edit routes are exposed through explicit base64 file upload tools.
Included API Tools
xagent_healthxagent_health_deepxagent_runtime_bootstrapxagent_list_sessionsxagent_create_sessionxagent_update_session_titlexagent_list_skillsxagent_generate_suggested_questionsxagent_get_conversation_previewxagent_get_conversationxagent_submit_requestxagent_submit_request_multipartxagent_submit_session_requestxagent_submit_session_request_multipartxagent_cancel_sessionxagent_retry_sessionxagent_edit_latest_requestxagent_edit_latest_request_multipartxagent_answer_pending_inputxagent_upsert_run_annotationxagent_list_favoritesxagent_list_session_annotationsxagent_create_sharexagent_get_shared_conversationxagent_wait_for_session_idle
Multipart Input
Multipart tools accept base64 file content:
{
"body": {
"inputText": "Inspect this alarm file.",
"idempotencyKey": "idem-1",
"files": [
{
"fileName": "alarm.txt",
"declaredMimeType": "text/plain",
"base64": "YWxhcm0="
}
]
}
}Exposing Write Tools
To expose all built-in tools:
$env:XAGENT_MCP_READONLY = "false"To expose only a narrow set:
$env:XAGENT_MCP_READONLY = "false"
$env:XAGENT_MCP_ALLOWED_TOOLS = "xagent_submit_request,xagent_get_conversation,xagent_wait_for_session_idle"