Runtime
The dzx runtime hosts your MCP server over HTTP + JSON-RPC. It loads your manifest, discovers tools/resources/prompts, and handles MCP requests.
HTTP endpoints
POST /mcp/<name>-- JSON-RPC endpoint.GET /health-- simple health check.GET /status-- counts for tools/resources/prompts.GET /-- local dev dashboard.
The <name> segment comes from mcp.json name.
Method compatibility
dzx accepts both slash and dotted method names:
tools/listandtools.listresources/listandresources.listprompts/listandprompts.list
Core MCP methods
initializenotifications/initializedtools/list,tools/callresources/list,resources/read,resources/subscribe,resources/unsubscribeprompts/list,prompts/getlogging/setLevelnotifications/cancelled,notifications/canceled
Calling tools
Request:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "user-profile",
"arguments": { "userId": "123" }
}
}
Response shape:
result.contentis always present (stringified output).result.structuredContentis included when the output is an object or a schema is defined.
Tool handlers must be async and should return a value. If you define an output schema, returning undefined is treated as an error.
Resources
resources/list returns a resource://<name> URI. resources/read accepts that URI or the resource file path.
Example request:
{
"jsonrpc": "2.0",
"id": 2,
"method": "resources/read",
"params": { "uri": "resource://getting-started" }
}
Prompts
prompts/get reads the Markdown file, strips frontmatter, and returns the body as a prompt message.
Example request:
{
"jsonrpc": "2.0",
"id": 3,
"method": "prompts/get",
"params": { "name": "summarize" }
}
Streaming (SSE)
Enable streaming with either:
?stream=1Accept: text/event-stream
SSE frames are emitted as:
event: message
data: {"jsonrpc":"2.0", ...}
Context injection
If src/context.ts (or context.ts) exists, the runtime loads it and passes the result as the second argument to every tool.
Example:
import type { IncomingMessage } from "http";
export default function createContext(req: IncomingMessage) {
return {
requestId: req.headers["x-request-id"],
userId: req.headers["x-user-id"],
};
}
Then in tools:
export default async function myTool(args, context) {
return { userId: context.userId };
}
Timeouts
Tool execution is bounded by DZX_TOOL_TIMEOUT_MS (default: 30000ms). When a tool times out, the runtime returns a tool error.
Host and port
- Port defaults to
3333(orPORTif set). - Dev mode binds to
127.0.0.1by default. - Set
DZX_HOSTto override the bind address.
In dev, if TCP listeners are blocked, the runtime falls back to a Unix socket (DZX_SOCKET or /tmp/dzx-<name>.sock).