MCP for agents
The running Veya app serves MCP over Streamable HTTP:
http://127.0.0.1:7317/mcpThe endpoint is stateless: every request creates a fresh MCP server over the same live hub. There is no authentication and the hub listens on localhost only. Context cursors belong to the hub's evidence, not to an MCP session.
Client configuration
{
"mcpServers": {
"veya": {
"url": "http://127.0.0.1:7317/mcp"
}
}
}Some clients call the transport "http" or "streamable-http" instead of inferring it from the URL. Use the client's documented shape; the endpoint does not change.
If you change VEYA_HUB_PORT, change the URL to match.
Session selection
Every tool that reads a session accepts an optional sessionId. Without one, the tool uses the newest agent session; if there is no agent session, it uses the newest session. The human window is a session too, so pass its id to read or act on it.
Call veya_sessions first when you need to choose a session explicitly. Each session reports its mode: human for the default window and agent for the window with its own profile.
Tools
| Tool | Arguments | Returns |
|---|---|---|
veya_sessions | none | Session summaries: id, URL, route, mode, start time, event count, channels and replacement id. |
veya_context | sessionId?, since?, maxBytes? | A budgeted baseline or diff: failing signals, components with sources, state, diagnostics, events, omitted and next. |
veya_inspect | sessionId?, depth? | The full semantic snapshot: protocol version, session, URL and route, viewport, component tree, business state, diagnostics and channel status. |
veya_state | sessionId?, path? | The whole state map, or one dotted path such as dashboard.projectCount. |
veya_events | sessionId?, since?, type?, trace?, limit? | Recorded events, newest last. Default limit is 200; maximum is 1000. |
veya_trace | sessionId?, traceId | Every event sharing the trace id, ordered by sequence. |
veya_signals | sessionId?, viewport? | Evaluated R001–R008 signals. A viewport triggers a layout and accessibility probe before evaluation. |
veya_screenshot | sessionId?, fullPage? | { artifactId, url } for a PNG of the window that owns the session. |
veya_perform | sessionId?, steps, timeoutMs? | An action result: ok, action, traceId, per-step outcomes, observed events, state changes and an error naming the failing step. |
veya_navigate | sessionId?, url | An action result. The window that owns the session loads the URL; the default is the agent window. |
veya_context
veya_context is the default read. Without since it returns a baseline; with the cursor from a previous response it returns only what changed. The document carries current failing signals, a flat source-linked component outline, business state, diagnostics, recent event summaries, omitted counts and next hints.
{
"tool": "veya_context",
"arguments": { "maxBytes": 4096 }
}{
"tool": "veya_context",
"arguments": { "since": "ctx_7" }
}budget.usedBytes is the exact compact-JSON byte size; the default budget is 8192 bytes. The returned cursor is session-scoped and points at a snapshot in a bounded history (32 snapshots by default). An unknown or expired cursor returns a baseline with baselineReason: "cursor_unavailable", not an error.
veya_context never resizes or probes. It reuses the last probe; call veya_signals with a viewport for a fresh layout check. See The context brief for the full document and budget rules.
veya_inspect
The full snapshot. Prefer veya_context for the default brief; use this when you need the complete tree, bounds or props.
depth limits the component tree. A depth of 1 returns only the root components without children. Omit it for the full tree.
The snapshot is what the page says about itself, not a DOM dump. source: null is a fact: the build never annotated that component.
veya_events and veya_trace
veya_events returns the evidence stream. Filter by event type, trace id, sequence or a limit:
{
"tool": "veya_events",
"arguments": {
"type": "network.request.completed",
"limit": 50
}
}veya_trace is the focused view: one user action and everything it caused.
{
"tool": "veya_trace",
"arguments": {
"traceId": "trc_01JABCDEF"
}
}veya_signals
Without viewport, the rules evaluate the evidence already captured. With a viewport, the Electron host resizes the window that owns the session (the agent window by default), probes overflow and accessible names, captures a screenshot when the page scrolls horizontally, and then evaluates the rules.
{
"tool": "veya_signals",
"arguments": {
"viewport": { "width": 390, "height": 844 }
}
}See Signals for what each rule needs.
veya_screenshot
{
"tool": "veya_screenshot",
"arguments": { "sessionId": "ses_01JABCDEF" }
}The result contains an artifact id and a URL such as http://127.0.0.1:7317/v1/artifacts/shot_1. The bundled host captures the full page; fullPage is accepted by the schema and is reserved for finer host control.
A standalone hub has no window to capture and answers with a host error.
veya_perform
veya_perform runs an ordered list of steps and verifies the product after each click. A click that lands is not a behaviour that worked.
{ "kind": "click", "target": "project.create" }clicks a semantic id or a CSS selector.{ "kind": "expect", "expect": { "events": [...], "state": { ... } } }waits for those event types in the most recent click's trace, and for the current dotted state paths to match.
The list starts with a click, contains at least one expect and holds at most 12 steps. An expect step needs events or state.
{
"tool": "veya_perform",
"arguments": {
"steps": [
{ "kind": "click", "target": "project.create" },
{
"kind": "expect",
"expect": { "state": { "dashboard.dialogOpen": true } }
},
{ "kind": "click", "target": "dialog.confirm" },
{
"kind": "expect",
"expect": {
"events": ["network.request.completed", "state.changed"],
"state": { "dashboard.projectCount": 1 }
}
}
],
"timeoutMs": 5000
}
}A successful result:
{
"ok": true,
"action": {
"kind": "perform",
"steps": [
{ "kind": "click", "target": "project.create" },
{
"kind": "expect",
"expect": { "state": { "dashboard.dialogOpen": true } }
},
{ "kind": "click", "target": "dialog.confirm" },
{
"kind": "expect",
"expect": {
"events": ["network.request.completed", "state.changed"],
"state": { "dashboard.projectCount": 1 }
}
}
],
"timeoutMs": 5000
},
"traceId": "trc_02",
"observed": [],
"stateChanges": [
{ "path": "dashboard.dialogOpen", "previous": false, "current": true },
{ "path": "dashboard.projectCount", "previous": 0, "current": 1 }
],
"steps": [
{ "index": 0, "kind": "click", "ok": true, "traceId": "trc_01" },
{ "index": 1, "kind": "expect", "ok": true, "traceId": "trc_01" },
{ "index": 2, "kind": "click", "ok": true, "traceId": "trc_02" },
{ "index": 3, "kind": "expect", "ok": true, "traceId": "trc_02" }
]
}A failed expectation:
{
"ok": false,
"action": {
"kind": "perform",
"steps": [
{ "kind": "click", "target": "project.create" },
{
"kind": "expect",
"expect": { "state": { "dashboard.dialogOpen": true } }
},
{ "kind": "click", "target": "dialog.confirm" },
{ "kind": "expect", "expect": { "events": ["signal.raised"] } }
],
"timeoutMs": 800
},
"traceId": "trc_02",
"observed": [],
"stateChanges": [],
"steps": [
{ "index": 0, "kind": "click", "ok": true, "traceId": "trc_01" },
{ "index": 1, "kind": "expect", "ok": true, "traceId": "trc_01" },
{ "index": 2, "kind": "click", "ok": true, "traceId": "trc_02" },
{
"index": 3,
"kind": "expect",
"ok": false,
"traceId": "trc_02",
"missing": ["event:signal.raised"]
}
],
"error": {
"code": "expectation_timeout",
"message": "Step at index 3 expected event:signal.raised but never observed it",
"missing": ["event:signal.raised"],
"stepIndex": 3
}
}observed and stateChanges are shortened in these examples. observed contains the events seen while the expectation steps ran, deduplicated; stateChanges comes from the state.changed events among them. The full traces remain available through veya_trace.
The list stops at the first unmet expectation or unresolved click; later steps do not run. error.stepIndex is 0-based and points at the failing entry in steps.
timeoutMs is the wait budget for each expect step, not the whole list. The default is 5 seconds; the schema maximum is 60 seconds.
target is a semantic id such as project.create or a CSS selector such as [data-veya-id="project.create"]. The runtime clicks the semantic element in the window that owns the session first; the Electron host falls back to a CDP click. An expectation after a fallback click sees the events recorded after that click.
veya_navigate
{
"tool": "veya_navigate",
"arguments": {
"url": "http://127.0.0.1:5173/settings"
}
}This loads a URL in the window that owns the session and creates a new session. Without a sessionId, that is the agent window; the human window keeps its page.
HTTP surface
The MCP endpoint is the agent interface. The same hub also exposes its evidence over HTTP for clients that cannot speak MCP:
| Route | Method | Purpose |
|---|---|---|
/v1/health | GET | Health, protocol version and session count. |
/v1/sessions | GET | Session summaries. |
/v1/sessions/:id | GET | Session, snapshot and replacement id. |
/v1/sessions/:id/events | GET | Events; supports since, type, trace and limit. |
/v1/sessions/:id/context | GET | The context brief; supports since and maxBytes. |
/v1/sessions/:id/traces/:traceId | GET | One trace, ordered by sequence. |
/v1/sessions/:id/signals | GET, POST | Evaluate signals; POST accepts { "viewport": { "width": 390, "height": 844 } }. |
/v1/sessions/:id/commands | POST | Run a command: { "command": { ... } }. |
/v1/sessions/:id/stream | GET | Server-sent updates for a session. |
/v1/artifacts/:id | GET | PNG artefacts such as screenshots. |
/mcp | POST | MCP Streamable HTTP. |
/v1/runtime | WebSocket | The in-page runtime channel. |
Commands have the same shape as the protocol: navigate, click, resize, screenshot or perform, with optional target, value, steps and timeoutMs. perform carries an ordered steps list of click and expect, exactly as veya_perform does.
Errors
| Code | Meaning |
|---|---|
expectation_timeout | An expect step did not hold within timeoutMs; stepIndex and missing say where. |
action_unavailable | The click target at stepIndex could not be found or clicked. |
steps_required | A perform command arrived without a steps list. |
target_required | A click command needs a target. |
host_unavailable | The operation needs a window to own the session, for example navigate or screenshot, and this hub has none. |
A tool that needs a session and has none answers with a plain error: No Veya session is connected. Open the app window first.
Limits
- MCP is HTTP only in this checkout.
@veya/mcpexportsserveMcpStdiofor embedders, but no CLI wrapper ships in v0.1. - The endpoint is local and unauthenticated. Do not expose it.
- Screenshots and viewport probes need the Electron host. A standalone hub can still serve sessions, events, snapshots and signals.
- The default session is the newest agent session, else the newest session; pass
sessionIdto target the human window. - Context cursors are bounded to the last 32 snapshots per session; an older cursor returns a baseline.