@tryvira/mcp 0.1.78 → 0.1.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +8 -3
  2. package/dist/cli.js +324 -100
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @tryvira/mcp 0.1.58
1
+ # @tryvira/mcp 0.1.79
2
2
 
3
3
  An MCP server for connecting MCP-compatible applications to Vira's governed AI
4
4
  behavior and runtime APIs. The package is MIT licensed.
@@ -8,7 +8,7 @@ An npx-ready MCP server for Vira's existing scoped authority boundary.
8
8
  ## Run it
9
9
 
10
10
  ```bash
11
- npx -y @tryvira/mcp@0.1.62
11
+ npx -y @tryvira/mcp@latest
12
12
  ```
13
13
 
14
14
  The package is a thin stdio MCP adapter over the public Vira API. It uses the
@@ -28,6 +28,11 @@ VIRA_PROJECT_ID=local-project
28
28
  VIRA_ENVIRONMENT_ID=local
29
29
  ```
30
30
 
31
+ MCP API calls allow up to 30 seconds per request by default. Set
32
+ `VIRA_MCP_API_TIMEOUT_MS` to a value from `1000` to `120000` when the connected
33
+ Control API needs a different request budget. The MCP adapter retries once for
34
+ safe reads and idempotency-keyed operations.
35
+
31
36
  For example, an MCP client configuration uses the same names:
32
37
 
33
38
  ```json
@@ -45,7 +50,7 @@ policy, evaluation, and release eligibility. The server does not bypass those ch
45
50
 
46
51
  ## What a client can discover
47
52
 
48
- Version `0.1.62` exposes a compact, task-oriented public catalog. The first-class
53
+ Version `0.1.79` exposes a compact, task-oriented public catalog. The first-class
49
54
  workflow tools cover connection, semantic resolution, TaskRuns, Teach, evaluation,
50
55
  pack release and runtime projection. The remaining registered Control API operations
51
56
  are available through `read_control_api` and `write_control_api`, so the catalog
package/dist/cli.js CHANGED
@@ -49,6 +49,274 @@ var MCP_TOOL_REGISTRY = Object.freeze(registry);
49
49
  var getMcpToolAuthority = (tool) => Object.hasOwn(MCP_TOOL_REGISTRY, tool) ? MCP_TOOL_REGISTRY[tool] : void 0;
50
50
  var isKnownMcpTool = (tool) => Boolean(getMcpToolAuthority(tool));
51
51
 
52
+ // src/public-tool-catalog.ts
53
+ var coreTools = Object.freeze([
54
+ { name: "get_scope", description: "Read the immutable scope configured for this MCP session.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
55
+ { name: "list_capabilities", description: "Show which Vira capabilities this scoped credential can use and on which public surfaces.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, surface: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
56
+ { name: "list_inbox", description: "List scoped review notifications for the authenticated actor.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, limit: { type: "number" } }, required: ["organizationId", "projectId", "environmentId"] } },
57
+ { name: "mark_inbox_read", description: "Mark one scoped review notification as read.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, notificationId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "notificationId"] } },
58
+ { name: "inspect_conflicts", description: "Create a scoped conflict inspection.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, proposed: { type: "array", items: { type: "object", additionalProperties: false, properties: { id: { type: "string" }, controlPointId: { type: "string" }, policyEffect: { type: "string" }, strategyKey: { type: "string" }, scope: { type: "string" } }, required: ["id", "controlPointId", "policyEffect", "strategyKey"] } }, active: { type: "array", items: { type: "object", additionalProperties: false, properties: { id: { type: "string" }, controlPointId: { type: "string" }, policyEffect: { type: "string" }, strategyKey: { type: "string" }, scope: { type: "string" } }, required: ["id", "controlPointId", "policyEffect", "strategyKey"] } }, controls: { type: "array", items: { type: "object", additionalProperties: false, properties: { id: { type: "string" }, level: { type: "string" }, autonomy: { type: "string", enum: ["MANUAL", "ASSISTED", "AUTOMATIC"] }, value: { type: "string" }, enabled: { type: "boolean" }, authorityDigest: { type: ["string", "null"] } }, required: ["id", "level", "autonomy", "value", "enabled"] } } }, required: ["organizationId", "projectId", "environmentId", "proposed", "active", "controls"] } },
59
+ { name: "get_conflict_inspection", description: "Read a persisted scoped conflict inspection.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, inspectionId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "inspectionId"] } },
60
+ { name: "resolve_conflict", description: "Approve or reject a scoped conflict inspection.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, inspectionId: { type: "string" }, status: { type: "string" }, authorityDigest: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "inspectionId", "status"] } },
61
+ { name: "start_optimization", description: "Start provider-backed scoped optimization.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, request: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "request"] } },
62
+ { name: "get_optimization_run", description: "Read a scoped durable optimization run.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, runId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "runId"] } },
63
+ { name: "cancel_optimization_run", description: "Request cancellation of a scoped optimization run.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, runId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "runId"] } },
64
+ { name: "connect_ai_system", description: "Connect the customer chatbot/agent and return its capability handshake. Use for an AI System connection; not for a raw adapter probe or behavior authoring.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, name: { type: "string" }, systemType: { type: "string" }, adapterType: { type: "string" }, adapterVersion: { type: "string" }, capabilities: { type: "array", items: { type: "string" } }, config: { type: "object" }, idempotencyKey: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "name", "systemType", "adapterType", "adapterVersion"] } },
65
+ { name: "get_job", description: "Read a scope-bound asynchronous job and completion evidence.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, jobId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "jobId"] } },
66
+ { name: "list_semantic_tasks", description: "Read scoped Semantic Tasks with optional cursor pagination and search.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, limit: { type: "number" }, cursor: { type: "string" }, search: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
67
+ { name: "create_semantic_task", description: "Create a scoped Semantic Task for later review/activation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, taskKey: { type: "string" }, description: { type: "string" }, version: { type: "number" }, aliases: { type: "array", items: { type: "string" } }, examples: { type: "array", items: { type: "string" } }, negativeExamples: { type: "array", items: { type: "string" } } }, required: ["organizationId", "projectId", "environmentId", "taskKey"] } },
68
+ { name: "list_behavior_points", description: "Read scoped canonical BehaviorPoints with optional cursor pagination and search.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, limit: { type: "number" }, cursor: { type: "string" }, search: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
69
+ { name: "list_discovery_candidates", description: "Read scoped discovery candidates with pagination and review filters.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, reviewState: { type: "string" }, limit: { type: "number" }, cursor: { type: "string" }, search: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
70
+ { name: "create_behavior_point", description: "Create a scoped BehaviorPoint bound to one or more Semantic Tasks.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, key: { type: "string" }, taskId: { type: "string" }, taskIds: { type: "array", items: { type: "string" } }, constraints: { type: "array", items: { type: "object", additionalProperties: true } } }, required: ["organizationId", "projectId", "environmentId", "key"] } },
71
+ { name: "activate_behavior_strategy", description: "Activate a validated scoped Behavior Strategy revision.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, strategyId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "strategyId"] } },
72
+ { name: "submit_teach_evidence", description: "Submit scoped evidence to the Teach lifecycle.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, source: { type: "string" }, content: { type: "string" }, consent: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "id", "content", "consent"] } },
73
+ { name: "get_teach_behavior_set", description: "Read a provider-backed Teach run behavior set and its completeness; review is required before evaluation or release.", effectful: false, inputSchema: { type: "object", properties: { teachRunId: { type: "string" } }, required: ["teachRunId"] } },
74
+ { name: "accept_teach_recommendation", description: "Accept a complete Teach behavior graph for evaluation; this never publishes directly.", effectful: true, inputSchema: { type: "object", properties: { teachRunId: { type: "string" }, actorId: { type: "string" } }, required: ["teachRunId", "actorId"] } },
75
+ { name: "create_teach_proposal", description: "Create a reviewed Teach proposal from admitted evidence.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, evidenceId: { type: "string" }, controlPointId: { type: "string" }, summary: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "evidenceId", "controlPointId", "summary"] } },
76
+ { name: "transition_teach_proposal", description: "Review, evaluate, or promote a Teach proposal.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, proposalId: { type: "string" }, transition: { type: "string" }, decision: { type: "string" }, score: { type: "number" }, evaluationId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "proposalId", "transition"] } },
77
+ { name: "create_release", description: "Create a scoped release using either provider-backed evaluation or explicit manual approval with step-up evidence.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, releaseId: { type: "string" }, artifactId: { type: "string" }, evaluationId: { type: "string" }, manualApproval: { type: "object", properties: { reason: { type: "string" } }, required: ["reason"] }, stepUp: { type: "object", properties: { id: { type: "string" }, assertion: { type: "string" }, purpose: { type: "string" } }, required: ["id", "assertion", "purpose"] } }, required: ["organizationId", "projectId", "environmentId", "artifactId"] } },
78
+ { name: "resolve_semantic", description: "Resolve input through the governed semantic runtime.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, input: { type: "string" }, sessionId: { type: "string" }, profile: { type: "object" }, selection: { type: "object" }, candidates: { type: "array", items: { type: "object", additionalProperties: true } }, timeoutMs: { type: "number" } }, required: ["organizationId", "projectId", "environmentId", "input"] } },
79
+ { name: "resolve_task_run", description: "Resolve a scoped TaskRun route without starting execution.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, input: { type: "string" }, requestedMode: { type: "string" }, intentCount: { type: "number" }, hostCapabilities: { type: "array", items: { type: "string" } } }, required: ["organizationId", "projectId", "environmentId", "input"] } },
80
+ { name: "start_task_run", description: "Start a TaskRun from a natural-language request. Server derives the actor, host capabilities, mode and released plan; requestedMode and plan fields are advanced overrides only.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, taskRunId: { type: "string" }, requestId: { type: "string" }, ownerActorRef: { type: "string" }, input: { type: "string" }, requestedMode: { type: "string" }, hostCapabilities: { type: "array", items: { type: "string" } } }, required: ["organizationId", "projectId", "environmentId", "input"] } },
81
+ { name: "get_task_run", description: "Read a scoped TaskRun state and lifecycle version.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, taskRunId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "taskRunId"] } },
82
+ { name: "list_task_run_events", description: "Read the persisted scoped TaskRun lifecycle events.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, taskRunId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "taskRunId"] } },
83
+ { name: "continue_task_run", description: "Resume a waiting scoped TaskRun using its current state version.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, taskRunId: { type: "string" }, expectedVersion: { type: "number" }, cursor: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "taskRunId", "expectedVersion"] } },
84
+ { name: "cancel_task_run", description: "Cancel a scoped TaskRun using its current state version.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, taskRunId: { type: "string" }, expectedVersion: { type: "number" } }, required: ["organizationId", "projectId", "environmentId", "taskRunId", "expectedVersion"] } },
85
+ { name: "retry_task_run", description: "Retry a failed, blocked, or partial scoped TaskRun using its immutable plan and current state version.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, taskRunId: { type: "string" }, expectedVersion: { type: "number" } }, required: ["organizationId", "projectId", "environmentId", "taskRunId", "expectedVersion"] } },
86
+ { name: "resolve_runtime", description: "Resolve a persisted BehaviorPoint through the governed runtime boundary. behaviorPoint may be omitted when semanticContext supplies the selected canonical route.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, behaviorPoint: { type: "string" }, executionBoundary: { type: "object" }, semanticContext: { type: "object" } }, required: ["organizationId", "projectId", "environmentId"] } },
87
+ { name: "create_signal_discovery_proposal", description: "Propose a discovered signal for scoped human review.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, signalStableKey: { type: "string" }, evidenceEventIds: { type: "array", items: { type: "string" } }, suggestedProducerType: { type: "string" }, suggestedProducerKey: { type: "string" }, confidence: { type: "number" } }, required: ["organizationId", "projectId", "environmentId", "signalStableKey", "evidenceEventIds"] } },
88
+ { name: "review_signal_discovery_proposal", description: "Approve or reject a discovered signal proposal.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, proposalId: { type: "string" }, decision: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "proposalId", "decision"] } },
89
+ { name: "materialize_signal_discovery", description: "Materialize an approved signal into a definition and producer mapping.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, proposalId: { type: "string" }, valueType: { type: "string" }, description: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "proposalId"] } },
90
+ { name: "create_signal_mapping", description: "Create a scoped signal producer mapping proposal.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, signalStableKey: { type: "string" }, signalVersion: { type: "number" }, producerType: { type: "string" }, producerKey: { type: "string" }, sourceEventType: { type: "string" }, evidenceEventIds: { type: "array", items: { type: "string" } } }, required: ["organizationId", "projectId", "environmentId", "signalStableKey", "signalVersion", "producerType", "producerKey"] } },
91
+ { name: "get_signal_mapping", description: "Read one scoped signal producer mapping.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, mappingId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "mappingId"] } },
92
+ { name: "review_signal_mapping", description: "Approve or reject a scoped signal producer mapping.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, mappingId: { type: "string" }, decision: { type: "string" }, eventId: { type: "string" }, definition: { type: "object" }, teachConsentRecord: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "mappingId", "decision"] } },
93
+ { name: "list_behavior_programs", description: "Read scoped canonical behavior programs with optional cursor pagination and search.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, limit: { type: "number" }, cursor: { type: "string" }, search: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
94
+ { name: "list_behavior_strategies", description: "Read persisted immutable Behavior Strategy revisions with optional cursor pagination and search.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, limit: { type: "number" }, cursor: { type: "string" }, search: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
95
+ { name: "get_behavior_strategy", description: "Read one persisted Behavior Strategy definition and artifact binding.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, strategyId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "strategyId"] } },
96
+ { name: "simulate_behavior_strategy", description: "Run the explicit structural dry-run for a persisted Behavior Strategy.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, strategyId: { type: "string" }, initialState: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "strategyId"] } },
97
+ { name: "start_strategy_execution", description: "Start a persisted Strategy execution through the governed runtime boundary.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, behaviorPoint: { type: "string" }, executionBoundary: { type: "object" }, revisionId: { type: "string" }, idempotencyKey: { type: "string" }, nonce: { type: "string" }, expiresAt: { type: "number" }, decisionPlanId: { type: "string" }, candidates: { type: "array", items: { type: "object" } }, policy: { type: "string" }, allowedIds: { type: "array", items: { type: "string" } }, calibrationId: { type: "string" }, postModelJudge: { type: "object" }, shadow: { type: "object" }, artifactDigest: { type: "string" }, traceId: { type: "string" }, executionId: { type: "string" }, state: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "revisionId", "idempotencyKey", "nonce", "expiresAt", "decisionPlanId", "candidates", "policy", "artifactDigest"] } },
98
+ { name: "get_strategy_execution", description: "Read one scoped Strategy execution.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, executionId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "executionId"] } },
99
+ { name: "get_strategy_execution_trace", description: "Read persisted Strategy step receipts and trace evidence.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, executionId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "executionId"] } },
100
+ { name: "continue_strategy_execution", description: "Continue a waiting Strategy execution with the same pinned artifact, state, and external references.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, executionId: { type: "string" }, authorityDigest: { type: "string" }, state: { type: "object", additionalProperties: true }, references: { type: "object", additionalProperties: true } }, required: ["organizationId", "projectId", "environmentId", "executionId"] } },
101
+ { name: "cancel_strategy_execution", description: "Cancel a non-terminal scoped Strategy execution.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, executionId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "executionId"] } },
102
+ { name: "list_ai_systems", description: "Read connected AI systems with optional cursor pagination and search.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, limit: { type: "number" }, cursor: { type: "string" }, search: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
103
+ { name: "delete_ai_system", description: "Delete an unused scoped AI system after explicit confirmation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, systemId: { type: "string" }, confirm: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "systemId", "confirm"] } },
104
+ { name: "delete_semantic_task", description: "Delete an unused scoped Semantic Task after explicit confirmation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, taskId: { type: "string" }, confirm: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "taskId", "confirm"] } },
105
+ { name: "delete_behavior_point", description: "Delete an unused scoped BehaviorPoint after explicit confirmation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, pointId: { type: "string" }, confirm: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "pointId", "confirm"] } },
106
+ { name: "delete_behavior_strategy", description: "Delete a non-active unused scoped Behavior Strategy after explicit confirmation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, strategyId: { type: "string" }, confirm: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "strategyId", "confirm"] } },
107
+ { name: "review_discovery_candidate", description: "Record a human review decision for a scoped discovery candidate.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, kind: { type: "string" }, key: { type: "string" }, decision: { type: "string" }, payload: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "kind", "key", "decision"] } },
108
+ { name: "create_observation", description: "Submit one scoped observation for discovery; it does not publish behavior.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, content: { type: "object" }, consent: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "id", "content", "consent"] } },
109
+ { name: "record_user_feedback", description: "Record scoped user feedback for an observed AI interaction.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, event: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "event"] } },
110
+ { name: "record_business_outcome", description: "Record a scoped business outcome for an observed AI interaction.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, event: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "event"] } },
111
+ { name: "start_evaluation", description: "Start a scoped evaluation. Use assertions for a manual evaluation, or planId + evaluationPolicy + comparisonPlan for a provider-backed execution bound to a sealed evaluation plan.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, planId: { type: "string" }, evaluationPolicy: { type: "object" }, comparisonPlan: { type: "object", properties: { arms: { type: "array", items: { type: "string" } } }, required: ["arms"] }, targetArtifact: { oneOf: [{ type: "string" }, { type: "object", additionalProperties: true }] }, dataset: { type: "array", items: { type: "object", additionalProperties: true } }, assertions: { type: "array", items: { type: "boolean" } }, threshold: { type: "number" } }, required: ["organizationId", "projectId", "environmentId", "id", "dataset"] } },
112
+ { name: "create_evaluation_plan", description: "Create an immutable OFF/current-on evaluation plan for a scoped behavior target.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, suiteId: { type: "string" }, suiteVersion: { type: "string" }, suiteDigest: { type: "string" }, datasetSnapshotDigest: { type: "string" }, evaluationPolicyDigest: { type: "string" }, arms: { type: "array" } }, required: ["organizationId", "projectId", "environmentId", "id", "suiteId", "suiteVersion", "suiteDigest", "datasetSnapshotDigest", "evaluationPolicyDigest", "arms"] } },
113
+ { name: "seal_evaluation_plan", description: "Seal an evaluation plan so its suite, dataset, and execution arms cannot drift.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, planId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "planId"] } },
114
+ { name: "create_improvement_proposal", description: "Create a Teach improvement proposal from a completed comparative evaluation.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, evaluationId: { type: "string" }, id: { type: "string" }, basePackId: { type: "string" }, basePackDigest: { type: "string" }, behaviorSet: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "evaluationId", "id", "basePackId", "basePackDigest"] } },
115
+ { name: "review_improvement_proposal", description: "Review a Teach improvement proposal without mutating canonical runtime state.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, proposalId: { type: "string" }, action: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "proposalId", "action"] } },
116
+ { name: "create_behavior_revision_candidate", description: "Create an immutable behavior revision candidate from a reviewed Teach improvement proposal.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, sourceTeachProposalId: { type: "string" }, parentRevisionId: { type: "string" }, parentRevisionDigest: { type: "string" }, changeSet: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "id", "sourceTeachProposalId", "parentRevisionId", "parentRevisionDigest", "changeSet"] } },
117
+ { name: "evaluate_behavior_revision_candidate", description: "Evaluate exactly one immutable Behavior Revision Candidate with provider-backed dataset assertions. It does not evaluate or release the parent Pack.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, candidateId: { type: "string" }, dataset: { type: "array", items: { type: "object", additionalProperties: true } }, assertions: { type: "array", items: { type: "boolean" } } }, required: ["organizationId", "projectId", "environmentId", "candidateId", "dataset"] } },
118
+ { name: "accept_behavior_revision_candidate", description: "Accept a candidate only when a passed evaluation is bound to its immutable digest.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, candidateId: { type: "string" }, candidateEvaluationId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "candidateId", "candidateEvaluationId"] } },
119
+ { name: "create_pack_revision", description: "Create a draft Pack Revision from an accepted behavior candidate.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, id: { type: "string" }, packKey: { type: "string" }, version: { type: "string" }, behaviorRevisionCandidateId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "id", "packKey", "version", "behaviorRevisionCandidateId"] } },
120
+ { name: "transition_pack_revision", description: "Validate, request approval, approve, or release a governed Pack Revision.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, revisionId: { type: "string" }, transition: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "revisionId", "transition"] } },
121
+ { name: "materialize_pack_revision", description: "Materialize an approved Pack Revision into canonical runtime state.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, revisionId: { type: "string" }, packId: { type: "string" }, variables: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "revisionId", "packId"] } },
122
+ { name: "get_pack_revision_diff", description: "Read the immutable lineage and change summary for a Pack Revision.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, revisionId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "revisionId"] } },
123
+ { name: "compile_behavior_capsule", description: "Compile a persisted scoped Behavior VM capsule and return its receipt.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, programId: { type: "string" }, input: { type: "string" }, selection: { type: "object" }, candidates: { type: "array" } }, required: ["organizationId", "projectId", "environmentId", "programId", "input"] } },
124
+ { name: "serve_behavior_projection", description: "Serve the active scoped behavior projection through the governed runtime boundary.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, programId: { type: "string" }, input: { type: "string" }, provider: { type: "string" }, protocol: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "input", "provider"] } },
125
+ { name: "list_packs", description: "Read scoped behavior packs with optional cursor pagination, status and search filters.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, limit: { type: "number" }, cursor: { type: "string" }, status: { type: "string" }, search: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
126
+ { name: "get_pack", description: "Read one scoped behavior pack, including manifest and materialization metadata.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, packId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "packId"] } },
127
+ { name: "list_evaluations", description: "Read scoped evaluations with bounded pagination and optional status filter.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, limit: { type: "number" }, cursor: { type: "string" }, status: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
128
+ { name: "diagnose_pack", description: "Run Pack Doctor without materializing or releasing a pack.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, packId: { type: "string" }, runtimeBindings: { type: "array", items: { type: "string" } }, knownVerifiers: { type: "array", items: { type: "string" } } }, required: ["organizationId", "projectId", "environmentId", "packId"] } },
129
+ { name: "import_pack", description: "Import and validate a scoped behavior pack.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, manifest: { type: "object" }, objects: { type: "object" }, archiveBase64: { type: "string" }, fileName: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "manifest"] } },
130
+ { name: "install_pack", description: "Install a scoped behavior pack.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, packId: { type: "string" }, variables: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "packId"] } },
131
+ { name: "evaluate_pack", description: "Evaluate one imported/installed Pack in its Pack lifecycle with server-owned execution. Use before Pack approval/release; it is not the candidate evaluator.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, packId: { type: "string" }, evaluation: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "packId", "evaluation"] } },
132
+ { name: "approve_pack", description: "Approve a scoped behavior pack.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, packId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "packId"] } },
133
+ { name: "release_pack", description: "Release a scoped behavior pack.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, packId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "packId"] } },
134
+ { name: "preview_pack_upgrade", description: "Preview a scoped behavior pack upgrade.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, packId: { type: "string" }, incoming: { type: "object" } }, required: ["organizationId", "projectId", "environmentId", "packId", "incoming"] } },
135
+ { name: "get_evaluation", description: "Read evaluation status, case results, receipts, and provenance.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, evaluationId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "evaluationId"] } },
136
+ { name: "get_evaluation_comparison", description: "Read the arms, findings, and comparison for one evaluation.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, evaluationId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "evaluationId"] } }
137
+ ]);
138
+ var MCP_PUBLIC_CORE_TOOL_NAMES = Object.freeze([
139
+ "get_scope",
140
+ "list_capabilities",
141
+ "connect_ai_system",
142
+ "list_ai_systems",
143
+ "get_job",
144
+ "list_semantic_tasks",
145
+ "create_semantic_task",
146
+ "list_behavior_points",
147
+ "list_discovery_candidates",
148
+ "create_behavior_point",
149
+ "resolve_semantic",
150
+ "resolve_task_run",
151
+ "start_task_run",
152
+ "get_task_run",
153
+ "list_task_run_events",
154
+ "continue_task_run",
155
+ "cancel_task_run",
156
+ "retry_task_run",
157
+ "resolve_runtime",
158
+ "create_observation",
159
+ "record_user_feedback",
160
+ "record_business_outcome",
161
+ "submit_teach_evidence",
162
+ "get_teach_behavior_set",
163
+ "create_teach_proposal",
164
+ "accept_teach_recommendation",
165
+ "start_evaluation",
166
+ "create_improvement_proposal",
167
+ "create_behavior_revision_candidate",
168
+ "evaluate_behavior_revision_candidate",
169
+ "accept_behavior_revision_candidate",
170
+ "create_pack_revision",
171
+ "transition_pack_revision",
172
+ "materialize_pack_revision",
173
+ "get_pack_revision_diff",
174
+ "import_pack",
175
+ "install_pack",
176
+ "evaluate_pack",
177
+ "approve_pack",
178
+ "release_pack",
179
+ "create_release",
180
+ "serve_behavior_projection",
181
+ "list_behavior_strategies",
182
+ "get_behavior_strategy",
183
+ "simulate_behavior_strategy",
184
+ "list_packs",
185
+ "get_pack",
186
+ "list_evaluations",
187
+ "get_strategy_execution_trace",
188
+ "continue_strategy_execution",
189
+ "list_inbox",
190
+ "mark_inbox_read",
191
+ "inspect_conflicts",
192
+ "get_conflict_inspection",
193
+ "resolve_conflict",
194
+ "review_discovery_candidate",
195
+ "diagnose_pack",
196
+ "get_evaluation",
197
+ "get_evaluation_comparison"
198
+ ]);
199
+ var controlApiRequestProperties = {
200
+ organizationId: { type: "string" },
201
+ projectId: { type: "string" },
202
+ environmentId: { type: "string" },
203
+ path: { type: "string", description: "Registered Control API path; unregistered paths and methods are rejected." },
204
+ method: { type: "string", enum: ["POST", "PUT", "PATCH", "DELETE"] },
205
+ pathParams: { type: "object", additionalProperties: { type: "string" } },
206
+ query: { type: "object", additionalProperties: true },
207
+ body: { type: "object", additionalProperties: true },
208
+ idempotencyKey: { type: "string" }
209
+ };
210
+ var genericControlTools = Object.freeze([
211
+ { name: "read_control_api", description: "Call one registered read-only Control API path not promoted to a first-class MCP tool.", inputSchema: { type: "object", additionalProperties: false, properties: controlApiRequestProperties, required: ["organizationId", "projectId", "environmentId", "path"] } },
212
+ { name: "write_control_api", description: "Call one registered effectful Control API path not promoted to a first-class MCP tool. Server authorization and receipts still apply.", effectful: true, inputSchema: { type: "object", additionalProperties: false, properties: controlApiRequestProperties, required: ["organizationId", "projectId", "environmentId", "path", "body"] } }
213
+ ]);
214
+ var parameterDescription = (toolName, name) => {
215
+ if (name === "organizationId" || name === "projectId" || name === "environmentId") return "Authenticated customer scope identifier; must match the API key scope and is never inferred from model text.";
216
+ if (name.endsWith("Id") || name.endsWith("Key") || name.endsWith("Digest")) return `Immutable ${name} reference used to bind this ${toolName} operation to the correct released or persisted resource.`;
217
+ if (name === "actorId" || name === "ownerActorRef") return "Actor identity for the authorized customer action; do not use a service or Vira-internal identity.";
218
+ if (name === "input") return "The end-user request or runtime input that Vira must resolve, execute, or evaluate.";
219
+ if (name === "expectedVersion") return "Current persisted lifecycle version; required for optimistic concurrency and must be read immediately before the transition.";
220
+ if (name === "decision" || name === "transition") return "Explicit lifecycle decision requested by the authorized reviewer; invalid or out-of-order transitions fail closed.";
221
+ if (name === "manifest" || name === "objects" || name === "evaluation") return `Structured ${name} payload validated against the published contract; caller-supplied scores or authority signals are not trusted.`;
222
+ return `Documented ${name} input for ${toolName}; use the published type and keep customer data within the authenticated scope.`;
223
+ };
224
+ var normalizeJsonSchema = (value) => {
225
+ if (Array.isArray(value)) return value.map(normalizeJsonSchema);
226
+ if (!value || typeof value !== "object") return value;
227
+ const record = value;
228
+ const normalized = Object.fromEntries(Object.entries(record).map(([key, item]) => [key, normalizeJsonSchema(item)]));
229
+ if (normalized.additionalProperties === true) normalized.additionalProperties = {};
230
+ if (normalized.type === "object" && !Object.hasOwn(normalized, "properties")) normalized.properties = {};
231
+ if (normalized.type === "object" && !Object.hasOwn(normalized, "additionalProperties")) normalized.additionalProperties = {};
232
+ return normalized;
233
+ };
234
+ var describeInput = (toolName, inputSchema) => {
235
+ const properties = inputSchema.properties && typeof inputSchema.properties === "object" ? inputSchema.properties : {};
236
+ const described = Object.fromEntries(Object.entries(properties).map(([name, property]) => [name, { ...property, description: typeof property.description === "string" && property.description.trim() ? property.description : parameterDescription(toolName, name) }]));
237
+ const required2 = Array.isArray(inputSchema.required) ? inputSchema.required.map(String).filter((name) => !["organizationId", "projectId", "environmentId"].includes(name)) : void 0;
238
+ const result = { ...inputSchema, $schema: "https://json-schema.org/draft/2020-12/schema", additionalProperties: false, properties: described };
239
+ if (required2?.length) result.required = required2;
240
+ else delete result.required;
241
+ return normalizeJsonSchema(result);
242
+ };
243
+ var requiredInputs = (tool) => Array.isArray(tool.inputSchema.required) ? (tool.inputSchema.required ?? []).map(String) : [];
244
+ var lifecycleGuidance = {
245
+ create_behavior_point: "Use after a Semantic Task exists to attach one canonical behavior authority. Provide either taskId or taskIds, not both; use create_behavior_program for executable rules.",
246
+ create_semantic_task: "Use to author a new intent definition with aliases, positive examples, and negative examples. It creates a draft; it does not classify input or publish behavior.",
247
+ list_semantic_tasks: "Use before authoring or routing to inspect the registered intent catalog. Prefer list_behavior_points when you need behavior authorities.",
248
+ list_behavior_points: "Use to inspect canonical BehaviorPoints and their task links. Prefer get_behavior_strategy for strategy details and resolve_runtime only after choosing one point.",
249
+ list_capabilities: "Use before a write or runtime call to check what this credential can access on a public surface; it never grants capability.",
250
+ import_pack: "Use to validate and create a Pack draft. It does not install or release; continue with install_pack, evaluate_pack, approve_pack, then release_pack.",
251
+ get_pack: "Use to inspect one Pack manifest, digest, status, conflicts, and materialization metadata. It is read-only.",
252
+ list_packs: "Use to find scoped Pack drafts and releases; use get_pack for one Pack\u2019s full detail.",
253
+ list_evaluations: "Use to inspect evaluation records and statuses; use start_evaluation to run one and get_evaluation for full provenance.",
254
+ get_evaluation: "Use to read one evaluation\u2019s status, provenance, score, and receipts; it never starts or approves an evaluation.",
255
+ mark_inbox_read: "Use after list_inbox returns a notificationId that the current actor has reviewed. On success the notification is marked read; repeated calls for the same notification are safe and do not create a new notification.",
256
+ serve_behavior_projection: "RUNTIME PROJECTION: use after get_scope/list_capabilities, Pack install, evaluation, approval, release, and a verified promotion pointer confirm that the requested Behavior Program is active. The response contains the projected behavior and an execution receipt. Do not use this tool for authoring, classification, candidate evaluation, model calls, or host actions; it does not call the model or execute tools. Use compile_behavior_capsule for pre-model context, resolve_runtime/executeRuntime for enforcement, and evaluate_behavior_revision_candidate for unreleased candidate testing."
257
+ };
258
+ var enrichTool = (tool) => {
259
+ const required2 = requiredInputs(tool);
260
+ const guidance = lifecycleGuidance[tool.name] ?? (tool.effectful ? "Use only after the preceding resource and authority prerequisites are satisfied; inspect the server receipt before continuing." : "Use to read the scoped resource; use its create, execute, or transition sibling for state changes.");
261
+ const contract = required2.length ? `Required fields: ${required2.join(", ")}.` : "No fields are required unless supplied by the schema.";
262
+ const scope2 = "The authenticated MCP session supplies the tenant scope; any supplied scope identifiers must match it. Unknown fields are rejected.";
263
+ const state = tool.effectful ? "This changes governed state and remains fail-closed behind server authorization and an auditable receipt." : "This is read-only and returns scope-bound data.";
264
+ return { ...tool, description: `${(tool.description ?? "Vira MCP operation").trim()} ${guidance} ${contract} ${scope2} ${state}`, annotations: { title: tool.name, readOnlyHint: !tool.effectful, destructiveHint: tool.effectful === true && /delete|revoke|cancel/.test(tool.name), idempotentHint: /^(get|list|resolve|diagnose|inspect|preview|simulate|search|test)_/.test(tool.name), openWorldHint: false }, inputSchema: describeInput(tool.name, tool.inputSchema) };
265
+ };
266
+ var descriptionOverrides = {
267
+ create_behavior_point: "AUTHORING: attach a canonical BehaviorPoint to an existing Semantic Task. Supply either taskId or taskIds; constraints define the policy boundary. Use create_behavior_program for executable rules and do not use this tool to publish a Pack.",
268
+ create_semantic_task: "AUTHORING: register a Semantic Task with aliases, positive examples, and negative examples for governed routing. It creates a draft; it does not classify input or publish behavior.",
269
+ list_semantic_tasks: "CATALOG READ: inspect registered Semantic Tasks before authoring or routing. limit, cursor, and search are optional. Use resolve_semantic to classify an actual request.",
270
+ list_ai_systems: "AI SYSTEM READ: list AI Systems connected in the authenticated scope. Use before creating a connection or to find a system to inspect; use get_connection_health and list_connection_inventory for connection diagnostics.",
271
+ list_behavior_points: "AUTHORITY READ: inspect canonical BehaviorPoints and task links. Pagination and search are optional. Use resolve_runtime only after selecting one point.",
272
+ list_capabilities: "ACCESS READ: use before a write, runtime, or lifecycle call to inspect this credential\u2019s allowed capabilities. Omit surface to receive the full scoped report; provide surface to filter it. The result lists permitted operations/roles and public surfaces, never grants authority, and get_scope is the alternative when you only need tenant identity.",
273
+ import_pack: "PACK AUTHORING: validate and create a Pack draft from a manifest or archive. Only manifest plus authenticated scope are required; objects/archiveBase64/fileName are alternatives. Continue install \u2192 evaluate \u2192 approve \u2192 release.",
274
+ list_packs: "PACK READ: find scoped Pack drafts and releases. Pagination, status, and search are optional; use get_pack for full detail and never infer release from list membership alone.",
275
+ get_pack: "PACK DETAIL READ: inspect one Pack\u2019s canonical manifest, digest, status, conflicts, and materialization metadata. Read-only; it never installs, evaluates, approves, or releases.",
276
+ list_evaluations: "EVALUATION READ: list scoped evaluation records. Pagination and status are optional; use start_evaluation to run one and get_evaluation for full provenance.",
277
+ mark_inbox_read: "REVIEW STATE: mark one notification returned by list_inbox as read after the actor has reviewed it. Required: notificationId. Success changes only that notification\u2019s read state; repeated calls are safe. Use list_inbox first to discover IDs.",
278
+ serve_behavior_projection: "RUNTIME PROJECTION: use after get_scope/list_capabilities, Pack install, evaluation, approval, release, and a verified promotion pointer confirm that the requested Behavior Program is active. Required: input and provider; programId is optional when the active pointer is unambiguous. Do not use this tool for authoring, classification, candidate evaluation, model calls, or host actions; it does not call the model or execute tools. Use compile_behavior_capsule for pre-model context, resolve_runtime/executeRuntime for enforcement, and evaluate_behavior_revision_candidate for unreleased candidate testing.",
279
+ resolve_semantic: "ROUTING 1/3: classify input into registered Semantic Tasks and intent candidates. It never resolves runtime authority or executes; follow with resolve_runtime for one BehaviorPoint or resolve_task_run for AUTO/multi-task planning.",
280
+ resolve_runtime: "ROUTING 2/3: resolve one already-selected BehaviorPoint into released runtime authority. It does not classify text or execute; use resolve_task_run/start_task_run for TaskRun execution.",
281
+ resolve_task_run: "ROUTING 2/3 FOR TASKRUN: preview server-owned AUTO mode and the SINGLE/STRATEGY/COMPOUND/HYBRID child plan. It never executes; call start_task_run after inspection.",
282
+ start_evaluation: "EVALUATION ENTRYPOINT: start a standalone dataset/evaluation-plan run, including comparative execution. Use evaluate_pack for an imported Pack and evaluate_behavior_revision_candidate for one immutable candidate.",
283
+ evaluate_pack: "PACK LIFECYCLE EVALUATION: evaluate one imported/installed Pack before approve_pack/release_pack. It is not start_evaluation and not evaluate_behavior_revision_candidate.",
284
+ evaluate_behavior_revision_candidate: "CANDIDATE EVALUATION ONLY: execute a real dataset against exactly one immutable candidate. It does not evaluate/release the parent Pack or grant human approval.",
285
+ approve_pack: "PACK APPROVAL: record human approval for a passed imported/installed Pack evaluation; use before release_pack. For a Pack Revision use transition_pack_revision approve.",
286
+ release_pack: "PACK FINAL STEP: release an already evaluated and approved imported/installed Pack. For a Pack Revision use transition_pack_revision release.",
287
+ transition_pack_revision: "PACK REVISION STATE MACHINE: validate, request approval, approve, release, or reject a Pack Revision. Do not substitute approve_pack/release_pack; those operate on imported Pack records."
288
+ };
289
+ var MCP_TOOL_OUTPUT_CONTRACT = Object.freeze({ $schema: "https://json-schema.org/draft/2020-12/schema", type: "object", additionalProperties: false, properties: { result: {} }, required: ["result"] });
290
+ var MCP_PUBLIC_TOOL_CATALOG = Object.freeze([...coreTools.filter((tool) => MCP_PUBLIC_CORE_TOOL_NAMES.includes(tool.name)), ...genericControlTools].map((tool) => {
291
+ const authority = getMcpToolAuthority(tool.name);
292
+ if (!authority) throw new Error("MCP_TOOL_AUTHORITY_MISSING");
293
+ const canonical = { ...tool, effectful: authority.effectType === "effectful", outputSchema: MCP_TOOL_OUTPUT_CONTRACT };
294
+ const enriched = enrichTool(canonical);
295
+ return descriptionOverrides[tool.name] ? { ...enriched, description: descriptionOverrides[tool.name] } : enriched;
296
+ }));
297
+ var catalogNames = MCP_PUBLIC_TOOL_CATALOG.map((tool) => tool.name);
298
+ if (new Set(catalogNames).size !== catalogNames.length || catalogNames.some((name) => !getMcpToolAuthority(name))) throw new Error("MCP_PUBLIC_TOOL_CATALOG_INVALID");
299
+ function assertMcpToolScope(input2, scope2, errorCode = "MCP_SCOPE_MISMATCH") {
300
+ const fields = ["organizationId", "projectId", "environmentId"];
301
+ const assertRecord = (value) => {
302
+ if (!value || typeof value !== "object" || Array.isArray(value)) return;
303
+ for (const key of fields) {
304
+ const supplied = value[key];
305
+ if (supplied !== void 0 && supplied !== scope2[key]) throw new Error(errorCode);
306
+ }
307
+ };
308
+ assertRecord(input2);
309
+ assertRecord(input2.query);
310
+ assertRecord(input2.body);
311
+ }
312
+ function unwrapMcpClientResponse(value) {
313
+ if (value && typeof value === "object" && !Array.isArray(value)) {
314
+ const response = value;
315
+ if (Number.isInteger(response.status) && typeof response.requestId === "string" && Object.hasOwn(response, "body")) return response.body;
316
+ }
317
+ return value;
318
+ }
319
+
52
320
  // src/cli.ts
53
321
  var required = (key) => {
54
322
  const value = process.env[key]?.trim();
@@ -64,7 +332,10 @@ var scope = {
64
332
  projectId: required("VIRA_PROJECT_ID"),
65
333
  environmentId: required("VIRA_ENVIRONMENT_ID")
66
334
  };
67
- var client = new ViraClient({ baseUrl, apiKey, allowInsecureLocalhost });
335
+ var mcpApiTimeoutMs = Number(process.env.VIRA_MCP_API_TIMEOUT_MS ?? 3e4);
336
+ if (!Number.isInteger(mcpApiTimeoutMs) || mcpApiTimeoutMs < 1e3 || mcpApiTimeoutMs > 12e4) throw new Error("VIRA_MCP_API_TIMEOUT_MS_INVALID");
337
+ var mcpHttpOptions = { apiKey, timeoutMs: mcpApiTimeoutMs, retries: 1 };
338
+ var client = new ViraClient({ baseUrl, apiKey, allowInsecureLocalhost, timeoutMs: mcpApiTimeoutMs, retries: 1 });
68
339
  var hostToolDefinitions = (() => {
69
340
  try {
70
341
  const parsed = JSON.parse(process.env.VIRA_HOST_TOOL_DEFINITIONS ?? "[]");
@@ -111,12 +382,7 @@ var importPackSchema = input({ manifest: packManifestSchema.optional(), objects:
111
382
  if (!value.manifest && !value.archiveBase64) ctx.addIssue({ code: z.ZodIssueCode.custom, message: "MCP_PACK_MANIFEST_OR_ARCHIVE_REQUIRED", path: ["manifest"] });
112
383
  if (value.archiveBase64 && !value.fileName) ctx.addIssue({ code: z.ZodIssueCode.custom, message: "MCP_PACK_FILE_NAME_REQUIRED", path: ["fileName"] });
113
384
  });
114
- var scopeQuery = (args) => {
115
- for (const key of Object.keys(scope)) {
116
- const supplied = args[key];
117
- if (supplied !== void 0 && supplied !== scope[key]) throw new Error("MCP_SCOPE_MISMATCH");
118
- }
119
- };
385
+ var scopeQuery = (args) => assertMcpToolScope(args, scope);
120
386
  var decodePageCursor = (cursor) => {
121
387
  if (!cursor) return 0;
122
388
  try {
@@ -132,7 +398,7 @@ var listFromApi = async (path, args) => {
132
398
  for (const [key, value] of Object.entries(scope)) url.searchParams.set(key, value);
133
399
  if (typeof args.limit === "number") url.searchParams.set("limit", String(args.limit));
134
400
  if (typeof args.cursor === "string") url.searchParams.set("cursor", args.cursor);
135
- const response = await viraHttpRequest(url, { method: "GET", apiKey });
401
+ const response = await viraHttpRequest(url, { ...mcpHttpOptions, method: "GET" });
136
402
  const body = response.body;
137
403
  const requestedLimit = typeof args.limit === "number" ? args.limit : 100;
138
404
  const offset = decodePageCursor(typeof args.cursor === "string" ? args.cursor : void 0);
@@ -150,7 +416,7 @@ var listFromApi = async (path, args) => {
150
416
  var readFromApi = async (path) => {
151
417
  const url = new URL(`${baseUrl}${path}`);
152
418
  for (const [key, value] of Object.entries(scope)) url.searchParams.set(key, value);
153
- return (await viraHttpRequest(url, { method: "GET", apiKey })).body;
419
+ return (await viraHttpRequest(url, { ...mcpHttpOptions, method: "GET" })).body;
154
420
  };
155
421
  var safeControlPath = (value) => {
156
422
  const path = String(value ?? "");
@@ -163,36 +429,48 @@ var controlQuery = (query) => {
163
429
  const entries = Object.entries(query).filter(([, value]) => value !== void 0);
164
430
  return entries.length ? "?" + entries.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(typeof value === "string" ? value : JSON.stringify(value))}`).join("&") : "";
165
431
  };
166
- var readControlApi = async (args) => readFromApi(`${safeControlPath(args.path)}${controlQuery(args.query)}`);
432
+ var controlPath = (args) => safeControlPath(args.path).replace(/\{([A-Za-z0-9_]+)\}/g, (_match, key) => {
433
+ const values = args.pathParams && typeof args.pathParams === "object" ? args.pathParams : {};
434
+ const value = values[key];
435
+ if (typeof value !== "string" || !value.trim()) throw new Error("MCP_CONTROL_PATH_PARAMETER_REQUIRED");
436
+ return encodeURIComponent(value);
437
+ });
438
+ var readControlApi = async (args) => readFromApi(`${controlPath(args)}${controlQuery(args.query)}`);
167
439
  var writeControlApi = async (args) => {
168
- const path = safeControlPath(args.path);
440
+ const path = controlPath(args);
169
441
  const method = String(args.method ?? "POST");
170
442
  if (!["POST", "PUT", "PATCH", "DELETE"].includes(method)) throw new Error("MCP_CONTROL_WRITE_METHOD_INVALID");
171
- return (await viraHttpRequest(`${baseUrl}${path}`, { method, apiKey, body: { ...scope, ...args.body && typeof args.body === "object" ? args.body : {} }, idempotencyKey: String(args.idempotencyKey ?? `mcp:write_control_api:${path}`) })).body;
443
+ return (await viraHttpRequest(`${baseUrl}${path}`, { ...mcpHttpOptions, method, body: { ...scope, ...args.body && typeof args.body === "object" ? args.body : {} }, idempotencyKey: String(args.idempotencyKey ?? `mcp:write_control_api:${path}`) })).body;
172
444
  };
173
445
  var optimizerRequest = async (path, method, body) => {
174
- const controlPath = path === "/v1/optimize" ? "/v1/optimization/execute" : path;
175
- const url = new URL(`${baseUrl}${controlPath}`);
446
+ const controlPath2 = path === "/v1/optimize" ? "/v1/optimization/execute" : path;
447
+ const url = new URL(`${baseUrl}${controlPath2}`);
176
448
  if (method === "GET") for (const [key, value] of Object.entries(scope)) url.searchParams.set(key, value);
177
- return (await viraHttpRequest(url, { method, apiKey, body: body ? { ...body, scope } : void 0, idempotencyKey: method === "POST" ? `mcp:optimizer:${path}` : void 0 })).body;
449
+ return (await viraHttpRequest(url, { ...mcpHttpOptions, method, body: body ? { ...body, scope } : void 0, idempotencyKey: method === "POST" ? `mcp:optimizer:${path}` : void 0 })).body;
178
450
  };
179
451
  var fullTools = [
180
452
  { name: "get_scope", description: "Read the immutable organization/project/environment scope configured for this MCP session.", inputSchema: input(), run: async () => ({ scope, apiUrl: baseUrl }) },
181
- { name: "list_capabilities", description: "List capabilities available to this API key.", inputSchema: input(), run: () => client.listCapabilities({ surface: "mcp" }) },
453
+ { name: "list_capabilities", description: "List capabilities available to this API key.", inputSchema: input(), run: () => readFromApi("/v1/capabilities?surface=mcp") },
182
454
  { name: "list_inbox", description: "List the authenticated actor\u2019s scoped review notifications.", inputSchema: input({ ...pageFields, search: z.string().min(1).optional() }), run: async (args) => readFromApi(`/v1/notifications/inbox?${new URLSearchParams(Object.entries(args).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])).toString()}`) },
183
- { name: "mark_inbox_read", description: "Mark one scoped review notification as read.", inputSchema: input({ notificationId: z.string().min(1) }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/notifications/${encodeURIComponent(String(args.notificationId))}/read`, { method: "POST", apiKey, body: scope, idempotencyKey: `mcp:inbox:${String(args.notificationId)}` })).body },
184
- { name: "inspect_conflicts", description: "Create a scoped conflict inspection for proposed versus active behavior.", inputSchema: input({ id: z.string().optional(), proposed: z.array(z.unknown()), active: z.array(z.unknown()), controls: z.array(z.unknown()) }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/conflicts/inspect`, { method: "POST", apiKey, body: { ...scope, ...args }, idempotencyKey: `mcp:conflicts:inspect:${String(args.id ?? scope.projectId)}` })).body },
455
+ { name: "mark_inbox_read", description: "Mark one scoped review notification as read.", inputSchema: input({ notificationId: z.string().min(1) }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/notifications/${encodeURIComponent(String(args.notificationId))}/read`, { ...mcpHttpOptions, method: "POST", body: scope, idempotencyKey: `mcp:inbox:${String(args.notificationId)}` })).body },
456
+ { name: "inspect_conflicts", description: "Create a scoped conflict inspection for proposed versus active behavior.", inputSchema: input({ id: z.string().optional(), proposed: z.array(z.unknown()), active: z.array(z.unknown()), controls: z.array(z.unknown()) }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/conflicts/inspect`, { ...mcpHttpOptions, method: "POST", body: { ...scope, ...args }, idempotencyKey: `mcp:conflicts:inspect:${String(args.id ?? scope.projectId)}` })).body },
185
457
  { name: "get_conflict_inspection", description: "Read a persisted scoped conflict inspection.", inputSchema: input({ inspectionId: z.string().min(1) }), run: (args) => readFromApi(`/v1/conflicts/${encodeURIComponent(String(args.inspectionId))}`) },
186
- { name: "resolve_conflict", description: "Approve or reject a previously inspected scoped conflict set.", inputSchema: input({ inspectionId: z.string().min(1), status: z.enum(["APPROVED", "REJECTED"]), authorityDigest: z.string().optional() }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/conflicts/${encodeURIComponent(String(args.inspectionId))}/resolve`, { method: "POST", apiKey, body: { ...scope, status: args.status, authorityDigest: args.authorityDigest }, idempotencyKey: `mcp:conflicts:resolve:${String(args.inspectionId)}` })).body },
458
+ { name: "resolve_conflict", description: "Approve or reject a previously inspected scoped conflict set.", inputSchema: input({ inspectionId: z.string().min(1), status: z.enum(["APPROVED", "REJECTED"]), authorityDigest: z.string().optional() }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/conflicts/${encodeURIComponent(String(args.inspectionId))}/resolve`, { ...mcpHttpOptions, method: "POST", body: { ...scope, status: args.status, authorityDigest: args.authorityDigest }, idempotencyKey: `mcp:conflicts:resolve:${String(args.inspectionId)}` })).body },
187
459
  { name: "start_optimization", description: "Start provider-backed scoped optimization with dataset and holdout governance through the authenticated Control API.", inputSchema: input({ request: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => optimizerRequest("/v1/optimize", "POST", args.request) },
188
460
  { name: "get_optimization_run", description: "Read a scoped durable optimization run.", inputSchema: input({ runId: z.string().min(1) }), run: (args) => optimizerRequest(`/v1/optimization/runs/${encodeURIComponent(String(args.runId))}`, "GET") },
189
461
  { name: "cancel_optimization_run", description: "Request cancellation of a scoped optimization run.", inputSchema: input({ runId: z.string().min(1) }), effectful: true, run: (args) => optimizerRequest(`/v1/optimization/runs/${encodeURIComponent(String(args.runId))}/cancel`, "POST", {}) },
190
462
  { name: "connect_ai_system", description: "Connect the customer chatbot/agent and return its capability handshake. Use for an AI System connection; not for a raw adapter probe or behavior authoring.", inputSchema: input({ name: z.string().min(1), systemType: z.string().min(1), adapterType: z.string().min(1), adapterVersion: z.string().min(1), capabilities: z.array(z.string()).optional(), config: z.unknown().optional(), idempotencyKey: z.string().min(1).optional() }), effectful: true, run: (args) => client.connectAiSystem({ name: String(args.name), systemType: String(args.systemType), organizationId: scope.organizationId, projectId: scope.projectId, environmentId: scope.environmentId, adapterType: String(args.adapterType), adapterVersion: String(args.adapterVersion), capabilities: args.capabilities, config: args.config, idempotencyKey: args.idempotencyKey }) },
191
463
  { name: "get_job", description: "Read a scope-bound asynchronous job and completion evidence.", inputSchema: input({ jobId: z.string().min(1) }), run: (args) => readFromApi(`/v1/jobs/${encodeURIComponent(String(args.jobId))}`) },
192
464
  { name: "list_semantic_tasks", description: "List Semantic Tasks with bounded cursor pagination.", inputSchema: input(pageFields), run: (args) => listFromApi("/v1/semantic-tasks", args) },
465
+ { name: "delete_semantic_task", description: "Delete an unused scoped Semantic Task after explicit confirmation.", inputSchema: input({ taskId: z.string().min(1), confirm: z.literal(true) }), effectful: true, run: (args) => client.deleteSemanticTask(String(args.taskId), { confirm: args.confirm === true }) },
193
466
  { name: "list_behavior_points", description: "List BehaviorPoints with bounded cursor pagination.", inputSchema: input(pageFields), run: (args) => listFromApi("/v1/behavior-points", args) },
467
+ { name: "delete_behavior_point", description: "Delete an unused scoped BehaviorPoint after explicit confirmation.", inputSchema: input({ pointId: z.string().min(1), confirm: z.literal(true) }), effectful: true, run: (args) => client.deleteBehaviorPoint(String(args.pointId), { confirm: args.confirm === true }) },
194
468
  { name: "list_behavior_programs", description: "List behavior programs with bounded cursor pagination and search.", inputSchema: input({ ...pageFields, search: z.string().min(1).optional() }), run: (args) => readFromApi(`/v1/behavior-programs?${new URLSearchParams(Object.entries(args).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])).toString()}`) },
195
469
  { name: "list_behavior_strategies", description: "List behavior strategies with bounded cursor pagination and search.", inputSchema: input({ ...pageFields, search: z.string().min(1).optional() }), run: (args) => readFromApi(`/v1/behavior-strategies?${new URLSearchParams(Object.entries(args).filter(([, v]) => v !== void 0).map(([k, v]) => [k, String(v)])).toString()}`) },
470
+ { name: "get_behavior_strategy", description: "Read one scoped Behavior Strategy and its immutable artifact binding.", inputSchema: input({ strategyId: z.string().min(1) }), run: (args) => client.getBehaviorStrategy(String(args.strategyId)) },
471
+ { name: "delete_behavior_strategy", description: "Delete a non-active scoped Behavior Strategy after explicit confirmation.", inputSchema: input({ strategyId: z.string().min(1), confirm: z.literal(true) }), effectful: true, run: (args) => client.deleteBehaviorStrategy(String(args.strategyId), { confirm: args.confirm === true }) },
472
+ { name: "get_strategy_execution", description: "Read one scoped Strategy execution.", inputSchema: input({ executionId: z.string().min(1) }), run: (args) => client.getStrategyExecution(String(args.executionId)) },
473
+ { name: "cancel_strategy_execution", description: "Cancel a non-terminal scoped Strategy execution.", inputSchema: input({ executionId: z.string().min(1) }), effectful: true, run: (args) => client.cancelStrategyExecution(String(args.executionId)) },
196
474
  { name: "resolve_semantic", description: "Classify input into registered Semantic Tasks. Use before execution when you need intent candidates; it does not run a behavior, tool, or TaskRun.", inputSchema: input({ input: z.string().min(1), profile: z.record(z.string(), z.unknown()).optional(), sessionId: z.string().optional(), selection: z.record(z.string(), z.unknown()).optional(), candidates: z.array(z.string()).optional(), timeoutMs: z.number().positive().optional(), requestId: z.string().optional(), executionBoundary: z.record(z.string(), z.unknown()).optional(), idempotencyKey: z.string().min(1).optional() }), run: (args) => client.resolveSemantic(args) },
197
475
  { name: "resolve_runtime", description: "Resolve a selected BehaviorPoint into released runtime authority. Use after canonical selection; it does not classify text or start a TaskRun.", inputSchema: input({ behaviorPoint: z.string().min(1).optional(), executionBoundary: z.record(z.string(), z.unknown()).optional(), semanticContext: z.record(z.string(), z.unknown()).optional(), idempotencyKey: z.string().min(1).optional() }), effectful: true, run: (args) => client.resolveRuntime(args) },
198
476
  { name: "resolve_task_run", description: "Preview server-owned AUTO mode selection and child plan. Use to inspect routing; it does not execute the TaskRun.", inputSchema: input({ input: z.string().min(1), requestedMode: z.enum(["AUTO", "SINGLE", "STRATEGY", "COMPOUND", "HYBRID"]).optional(), intentCount: z.number().int().positive().optional(), hostCapabilities: z.array(z.string()).optional(), hybridPlan: z.array(z.object({ semanticTaskKey: z.string().min(1), mode: z.enum(["SINGLE", "STRATEGY"]) })).optional() }), run: (args) => client.resolveTaskRun(args) },
@@ -211,6 +489,7 @@ var fullTools = [
211
489
  const { id, idempotencyKey, ...point } = args;
212
490
  return client.createBehaviorPoint(point, { id, idempotencyKey });
213
491
  } },
492
+ { name: "create_observation", description: "Submit one scoped observation for discovery without publishing behavior.", inputSchema: input({ id: z.string().min(1), content: z.record(z.string(), z.unknown()), consent: z.boolean() }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/observations`, { ...mcpHttpOptions, method: "POST", body: { ...scope, ...args }, idempotencyKey: `mcp:create_observation:${String(args.id)}` })).body },
214
493
  { name: "submit_teach_evidence", description: "Admit selected consented evidence into Teach analysis. Use after observation; it is not generic observation ingest and does not publish behavior.", inputSchema: input({ evidenceId: z.string().optional(), source: z.string().min(1), content: z.string().min(1), consent: z.literal(true), privacy: z.string().optional(), conversationId: z.string().optional(), controlPointId: z.string().optional(), summary: z.string().optional(), idempotencyKey: z.string().min(1).optional() }), effectful: true, run: (args) => {
215
494
  const { idempotencyKey, ...evidence } = args;
216
495
  return client.submitTeachEvidence(evidence, { idempotencyKey });
@@ -219,12 +498,19 @@ var fullTools = [
219
498
  const { idempotencyKey, ...proposal } = args;
220
499
  return client.createTeachProposal(proposal, { idempotencyKey });
221
500
  } },
501
+ { name: "transition_teach_proposal", description: "Review, evaluate, or promote a scoped Teach proposal.", inputSchema: input({ proposalId: z.string().min(1), transition: z.enum(["review", "evaluate", "promote"]), decision: z.string().optional(), score: z.number().optional(), evaluationId: z.string().optional() }), effectful: true, run: (args) => {
502
+ const { proposalId, transition, ...body } = args;
503
+ return client.transitionTeachProposal(String(proposalId), transition, body);
504
+ } },
222
505
  { name: "list_packs", description: "List Behavior Packs with bounded cursor pagination.", inputSchema: input(pageFields), run: (args) => listFromApi("/v1/packs", args) },
223
506
  { name: "get_pack", description: "Read one scoped Behavior Pack including its manifest and materialization metadata.", inputSchema: input({ packId: z.string().min(1) }), run: (args) => client.getPack(String(args.packId)) },
224
507
  { name: "list_evaluations", description: "List scoped evaluations with bounded pagination and optional status filter.", inputSchema: input({ ...pageFields, status: z.string().optional() }), run: (args) => client.listEvaluations(args) },
225
508
  { name: "import_pack", description: "Import a versioned Pack draft; release remains separately governed.", inputSchema: importPackSchema, effectful: true, run: (args) => client.importPack(args) },
226
509
  { name: "install_pack", description: "Install and materialize an approved Pack using direct variables.", inputSchema: input({ packId: z.string().min(1), variables: z.record(z.string(), z.unknown()).optional() }), effectful: true, run: (args) => client.installPack(String(args.packId), args.variables ?? {}) },
227
510
  { name: "release_pack", description: "Release a separately evaluated and approved Pack.", inputSchema: input({ packId: z.string().min(1) }), effectful: true, run: (args) => client.releasePack(String(args.packId)) },
511
+ { name: "preview_pack_upgrade", description: "Preview a scoped Behavior Pack upgrade without applying it.", inputSchema: input({ packId: z.string().min(1), incoming: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.previewPackUpgrade(String(args.packId), args.incoming) },
512
+ { name: "get_strategy_execution_trace", description: "Read persisted Strategy execution trace and receipts.", inputSchema: input({ executionId: z.string().min(1) }), run: (args) => client.getStrategyExecutionTrace(String(args.executionId)) },
513
+ { name: "continue_strategy_execution", description: "Continue a waiting Strategy execution under the same immutable authority.", inputSchema: input({ executionId: z.string().min(1), authorityDigest: z.string().optional(), state: z.record(z.string(), z.unknown()).optional(), references: z.record(z.string(), z.unknown()).optional() }), effectful: true, run: (args) => client.continueStrategyExecution(String(args.executionId), { authorityDigest: args.authorityDigest, state: args.state, references: args.references }) },
228
514
  { name: "start_strategy_execution", description: "Start a server-authorized immutable Strategy execution.", inputSchema: input({ artifactDigest: z.string().min(1), revisionId: z.string().min(1), idempotencyKey: z.string().min(1), nonce: z.string().min(1), expiresAt: z.number().positive(), decisionPlanId: z.string().min(1), candidates: z.array(z.record(z.string(), z.unknown())), policy: z.string().min(1), behaviorPoint: z.string().optional(), executionBoundary: z.record(z.string(), z.unknown()).optional() }), effectful: true, run: (args) => client.startStrategyExecution(args) },
229
515
  { name: "list_host_tools", description: "List host tools registered dynamically by the host with their ActionDefinition bindings; this MCP server defines no domain tools.", inputSchema: input(), run: async () => ({ tools: hostToolDefinitions }) },
230
516
  { name: "authorize_host_tool", description: "Request Vira server authorization for one dynamically registered host tool proposal matched to its ActionDefinition.", inputSchema: input({ toolName: z.string().min(1), executionId: z.string().min(1), sessionId: z.string().min(1), dataVersion: z.string().min(1), context: z.record(z.string(), z.unknown()), proposal: z.record(z.string(), z.unknown()), approval: z.record(z.string(), z.unknown()).optional() }), effectful: true, run: (args) => {
@@ -236,8 +522,11 @@ var fullTools = [
236
522
  return client.authorizeHostAction({ executionId: String(executionId), sessionId: String(sessionId), dataVersion: String(dataVersion), scope, context: contextRecord, proposal: proposalRecord, ...approval ? { approval } : {} });
237
523
  } },
238
524
  { name: "list_ai_systems", description: "List connected AI systems with bounded cursor pagination.", inputSchema: input(pageFields), run: (args) => listFromApi("/v1/ai-systems", args) },
525
+ { name: "delete_ai_system", description: "Delete an unused scoped AI System after explicit confirmation.", inputSchema: input({ systemId: z.string().min(1), confirm: z.literal(true) }), effectful: true, run: (args) => client.deleteAISystem(String(args.systemId), { confirm: args.confirm === true }) },
239
526
  { name: "get_ai_system", description: "Read one connected AI system.", inputSchema: input({ systemId: z.string().min(1) }), run: (args) => client.getAISystem(String(args.systemId)) },
240
527
  { name: "list_system_connections", description: "List connections for an AI system with bounded cursor pagination and search.", inputSchema: input({ systemId: z.string().min(1), ...pageFields, search: z.string().min(1).optional() }), run: (args) => client.listSystemConnections(String(args.systemId), { limit: args.limit, cursor: args.cursor, search: args.search }) },
528
+ { name: "list_discovery_candidates", description: "Read evidence-backed discovery candidates with bounded pagination and search.", inputSchema: input({ reviewState: z.string().optional(), ...pageFields, search: z.string().optional() }), run: (args) => client.discover({ reviewState: args.reviewState, limit: args.limit, cursor: args.cursor, search: args.search }) },
529
+ { name: "review_discovery_candidate", description: "Record a human review decision for a scoped discovery candidate.", inputSchema: input({ kind: z.string().min(1), key: z.string().min(1), decision: z.string().min(1), payload: z.record(z.string(), z.unknown()).optional() }), effectful: true, run: (args) => client.reviewDiscoveryCandidate(String(args.kind), String(args.key), { decision: String(args.decision), ...args.payload ? { payload: args.payload } : {} }) },
241
530
  { name: "get_connection", description: "Read one connection.", inputSchema: input({ connectionId: z.string().min(1) }), run: (args) => client.getConnection(String(args.connectionId)) },
242
531
  { name: "get_connection_health", description: "Read the latest health state for one AI System connection.", inputSchema: input({ connectionId: z.string().min(1) }), run: (args) => client.connectionHealth(String(args.connectionId)) },
243
532
  { name: "list_connection_inventory", description: "List capability inventory for one connected AI System.", inputSchema: input({ systemId: z.string().min(1) }), run: (args) => client.inventory(String(args.systemId)) },
@@ -283,6 +572,7 @@ var fullTools = [
283
572
  { name: "create_behavior_revision_candidate", description: "Create an immutable behavior revision candidate.", inputSchema: input({ candidate: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.createBehaviorRevisionCandidate(args.candidate) },
284
573
  { name: "evaluate_behavior_revision_candidate", description: "Evaluate exactly one immutable Behavior Revision Candidate with a real dataset. It does not evaluate or release the parent Pack.", inputSchema: input({ candidateId: z.string().min(1), evaluation: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.evaluateBehaviorRevisionCandidate(String(args.candidateId), args.evaluation) },
285
574
  { name: "transition_behavior_revision_candidate", description: "Accept, reject, or promote a candidate revision.", inputSchema: input({ candidateId: z.string().min(1), transition: z.enum(["evaluate", "accept", "reject", "pack"]), input: z.record(z.string(), z.unknown()).optional() }), effectful: true, run: (args) => client.transitionBehaviorRevisionCandidate(String(args.candidateId), args.transition, args.input ?? {}) },
575
+ { name: "accept_behavior_revision_candidate", description: "Accept a candidate only when its evaluation is bound to the immutable digest.", inputSchema: input({ candidateId: z.string().min(1), candidateEvaluationId: z.string().min(1) }), effectful: true, run: (args) => client.transitionBehaviorRevisionCandidate(String(args.candidateId), "accept", { candidateEvaluationId: String(args.candidateEvaluationId) }) },
286
576
  { name: "create_pack_revision", description: "Create a Pack Revision from an accepted candidate.", inputSchema: input({ revision: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.createPackRevision(args.revision) },
287
577
  { name: "get_pack_revision", description: "Read Pack Revision status and lineage.", inputSchema: input({ revisionId: z.string().min(1) }), run: (args) => client.getPackRevision(String(args.revisionId)) },
288
578
  { name: "get_pack_revision_diff", description: "Read Pack Revision diff.", inputSchema: input({ revisionId: z.string().min(1) }), run: (args) => client.getPackRevisionDiff(String(args.revisionId)) },
@@ -295,108 +585,42 @@ var fullTools = [
295
585
  { name: "serve_behavior_projection", description: "Serve the active behavior projection for verification. Use only after get_scope/list_capabilities, Pack install, evaluation, approval, release, and a verified promotion pointer confirm that the requested Behavior Program is active. Do not use this tool to create, install, evaluate, approve, or release a Pack, to classify input, to call the model, or to execute a host action; it does not call the model or execute tools. Use compile_behavior_capsule when you need pre-model context, resolve_runtime/executeRuntime when you need enforcement, and evaluate_behavior_revision_candidate when testing an unreleased candidate.", inputSchema: input({ input: z.string().min(1), provider: z.string().min(1), programId: z.string().optional() }), effectful: true, run: (args) => client.serveBehaviorProjection(args) },
296
586
  { name: "create_release", description: "Create a governed release for an approved immutable artifact.", inputSchema: input({ release: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.createRelease(args.release) }
297
587
  ];
298
- var promotedNames = /* @__PURE__ */ new Set([
299
- "get_scope",
300
- "list_capabilities",
301
- "connect_ai_system",
302
- "get_job",
303
- "list_semantic_tasks",
304
- "list_behavior_points",
305
- "resolve_semantic",
306
- "resolve_task_run",
307
- "start_task_run",
308
- "get_task_run",
309
- "list_task_run_events",
310
- "continue_task_run",
311
- "cancel_task_run",
312
- "retry_task_run",
313
- "resolve_runtime",
314
- "create_observation",
315
- "record_user_feedback",
316
- "record_business_outcome",
317
- "submit_teach_evidence",
318
- "get_teach_behavior_set",
319
- "create_teach_proposal",
320
- "accept_teach_recommendation",
321
- "start_evaluation",
322
- "get_evaluation",
323
- "get_evaluation_comparison",
324
- "create_behavior_revision_candidate",
325
- "evaluate_behavior_revision_candidate",
326
- "accept_behavior_revision_candidate",
327
- "create_pack_revision",
328
- "transition_pack_revision",
329
- "materialize_pack_revision",
330
- "diagnose_pack",
331
- "get_pack",
332
- "list_evaluations",
333
- "evaluate_pack",
334
- "import_pack",
335
- "install_pack",
336
- "approve_pack",
337
- "release_pack",
338
- "serve_behavior_projection",
339
- "list_behavior_strategies",
340
- "get_behavior_strategy",
341
- "simulate_behavior_strategy",
342
- "get_strategy_execution_trace",
343
- "continue_strategy_execution",
344
- "list_inbox",
345
- "mark_inbox_read",
346
- "inspect_conflicts",
347
- "get_conflict_inspection",
348
- "resolve_conflict"
349
- ]);
350
588
  var genericTools = [
351
589
  { name: "read_control_api", description: "Call one registered read-only Control API path not promoted to a first-class MCP tool.", inputSchema: input({ path: z.string().regex(/^\/v1\/[A-Za-z0-9_./{}-]+$/), query: z.record(z.string(), z.unknown()).optional() }), run: readControlApi },
352
590
  { name: "write_control_api", description: "Call one registered effectful Control API path not promoted to a first-class MCP tool. Server authorization and receipts still apply.", inputSchema: input({ path: z.string().regex(/^\/v1\/[A-Za-z0-9_./{}-]+$/), method: z.enum(["POST", "PUT", "PATCH", "DELETE"]).default("POST"), body: z.record(z.string(), z.unknown()), idempotencyKey: z.string().min(1).optional() }), effectful: true, run: writeControlApi }
353
591
  ];
354
- var descriptionOverrides = {
355
- create_semantic_task: "AUTHORING: register a Semantic Task with aliases, positive examples, and negative examples for governed routing. It creates a draft; it does not classify input or publish behavior. Required: taskKey; id, description, version, aliases, examples, and negativeExamples are optional.",
356
- create_behavior_point: "AUTHORING: attach a canonical BehaviorPoint to an existing Semantic Task. Required: key. Provide either taskId or taskIds, not both; constraints are optional policy data. Use create_behavior_program for executable rules.",
357
- list_capabilities: "ACCESS READ: use before a write, runtime, or lifecycle call to inspect this credential\u2019s allowed capabilities. Omit surface for the full scoped report or provide it to filter by public surface; the result lists permitted operations/roles and never grants authority. Use get_scope when you only need tenant identity.",
358
- list_semantic_tasks: "CATALOG READ: inspect registered Semantic Tasks before authoring or routing. Pagination and search are optional. Use resolve_semantic to classify an actual request.",
359
- list_behavior_points: "AUTHORITY READ: inspect canonical BehaviorPoints and task links. Pagination and search are optional. Use resolve_runtime only after selecting one point.",
360
- import_pack: "PACK AUTHORING: validate and create a Pack draft. Required: manifest. objects, archiveBase64, and fileName are optional alternatives; continue install \u2192 evaluate \u2192 approve \u2192 release.",
361
- list_packs: "PACK READ: find scoped Pack drafts and releases. Pagination is optional; use get_pack for one Pack\u2019s detail and never infer release from list membership alone.",
362
- get_pack: "PACK DETAIL READ: inspect one Pack\u2019s manifest, digest, status, conflicts, and materialization metadata. Required: packId. Read-only; it never releases.",
363
- list_evaluations: "EVALUATION READ: list scoped evaluation records. Pagination and status are optional; use start_evaluation to run one and get_evaluation for full provenance.",
364
- mark_inbox_read: "REVIEW STATE: mark one notification returned by list_inbox as read after reviewing it. Required: notificationId. Repeated calls are safe and change only that notification\u2019s read state; use list_inbox first to discover IDs.",
365
- serve_behavior_projection: "RUNTIME PROJECTION: use after get_scope/list_capabilities, Pack install, evaluation, approval, release, and a verified promotion pointer confirm that the requested Behavior Program is active. Required: input and provider; programId is optional when the active pointer is unambiguous. Do not use this tool for authoring, classification, candidate evaluation, model calls, or host actions. Use compile_behavior_capsule for pre-model context, resolve_runtime/executeRuntime for enforcement, and evaluate_behavior_revision_candidate for unreleased candidate testing.",
366
- resolve_semantic: "ROUTING 1/3: classify input into registered Semantic Tasks and intent candidates. It never resolves runtime authority or executes; follow with resolve_runtime for one selected BehaviorPoint or resolve_task_run for AUTO/multi-task planning.",
367
- resolve_runtime: "ROUTING 2/3: resolve one already-selected BehaviorPoint into released runtime authority. It does not classify text or execute; use resolve_task_run/start_task_run for TaskRun execution.",
368
- resolve_task_run: "ROUTING 2/3 FOR TASKRUN: preview server-owned AUTO mode and the SINGLE/STRATEGY/COMPOUND/HYBRID child plan. It never executes; call start_task_run after inspection.",
369
- start_evaluation: "EVALUATION ENTRYPOINT: start a standalone dataset/evaluation-plan run, including comparative execution. Use evaluate_pack for an imported Pack and evaluate_behavior_revision_candidate for one immutable candidate.",
370
- evaluate_pack: "PACK LIFECYCLE EVALUATION: evaluate one imported/installed Pack before approve_pack/release_pack. It is not start_evaluation and not evaluate_behavior_revision_candidate.",
371
- evaluate_behavior_revision_candidate: "CANDIDATE EVALUATION ONLY: execute a real dataset against exactly one immutable candidate. It does not evaluate/release the parent Pack or grant human approval.",
372
- approve_pack: "PACK APPROVAL: record human approval for a passed imported/installed Pack evaluation; use before release_pack. For a Pack Revision use transition_pack_revision approve.",
373
- release_pack: "PACK FINAL STEP: release an already evaluated and approved imported/installed Pack. For a Pack Revision use transition_pack_revision release.",
374
- transition_pack_revision: "PACK REVISION STATE MACHINE: validate, request approval, approve, release, or reject a Pack Revision. Do not substitute approve_pack/release_pack; those operate on imported Pack records."
375
- };
376
- var tools = Object.freeze([...fullTools.filter((tool) => promotedNames.has(tool.name)), ...genericTools].map((tool) => descriptionOverrides[tool.name] ? { ...tool, description: descriptionOverrides[tool.name] } : tool));
592
+ var handlerDefinitions = [...fullTools, ...genericTools];
593
+ if (new Set(handlerDefinitions.map((tool) => tool.name)).size !== handlerDefinitions.length) throw new Error("MCP_TOOL_HANDLER_DUPLICATE");
594
+ var handlers = new Map(handlerDefinitions.map((tool) => [tool.name, tool]));
595
+ var tools = Object.freeze(MCP_PUBLIC_TOOL_CATALOG.map((definition) => {
596
+ const handler = handlers.get(definition.name);
597
+ if (!handler) throw new Error("MCP_TOOL_HANDLER_MISSING:" + definition.name);
598
+ return { ...handler, description: definition.description ?? handler.description, effectful: definition.effectful === true, annotations: definition.annotations, inputSchema: z.fromJSONSchema(definition.inputSchema) };
599
+ }));
377
600
  if (tools.some((tool) => !isKnownMcpTool(tool.name) || Boolean(tool.effectful) !== (getMcpToolAuthority(tool.name)?.effectType === "effectful"))) throw new Error("MCP_TOOL_REGISTRY_DRIFT");
378
601
  var authorize = async (tool, args) => {
379
602
  if (!tool.effectful) return;
380
603
  const decision = (await viraHttpRequest(authorityUrl, {
604
+ ...mcpHttpOptions,
381
605
  method: "POST",
382
- apiKey,
383
606
  body: { tool: tool.name, arguments: args, scope },
384
607
  idempotencyKey: `mcp:authorize:${tool.name}`
385
608
  })).body;
386
609
  if (decision?.allowed !== true) throw new Error(decision?.reason ?? "MCP_AUTHORITY_DENIED");
387
610
  };
388
- var server = new McpServer({ name: process.env.VIRA_MCP_SERVER_NAME ?? "vira", version: "0.1.61" }, { capabilities: { tools: {} } });
611
+ var server = new McpServer({ name: process.env.VIRA_MCP_SERVER_NAME ?? "vira", version: "0.1.79" }, { capabilities: { tools: {} } });
389
612
  for (const tool of tools) {
390
- server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema }, async (raw) => {
613
+ server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema, outputSchema: z.fromJSONSchema(MCP_PUBLIC_TOOL_CATALOG.find((item) => item.name === tool.name).outputSchema), annotations: tool.annotations }, async (raw) => {
391
614
  const args = raw;
392
615
  scopeQuery(args);
393
616
  try {
394
617
  await authorize(tool, args);
395
618
  const apiArgs = Object.fromEntries(Object.entries(args).filter(([key]) => !(key in scope)));
396
- const result = await tool.run(apiArgs);
397
- return { content: [{ type: "text", text: JSON.stringify(result) }] };
619
+ const result = unwrapMcpClientResponse(await tool.run(apiArgs));
620
+ return { content: [{ type: "text", text: JSON.stringify(result) }], structuredContent: { result } };
398
621
  } catch (error) {
399
- return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : "VIRA_MCP_REQUEST_FAILED" }] };
622
+ const message = error instanceof Error ? error.message : "VIRA_MCP_REQUEST_FAILED";
623
+ return { isError: true, content: [{ type: "text", text: message }], structuredContent: { result: message } };
400
624
  }
401
625
  });
402
626
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryvira/mcp",
3
- "version": "0.1.78",
3
+ "version": "0.1.79",
4
4
  "mcpName": "io.github.hrpering/vira",
5
5
  "description": "Vira MCP client and npx-ready JSON-RPC launcher.",
6
6
  "keywords": [
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@modelcontextprotocol/server": "^2.4.0",
41
- "@tryvira/sdk": "^0.1.74",
41
+ "@tryvira/sdk": "^0.1.75",
42
42
  "zod": "^4.2.0"
43
43
  },
44
44
  "scripts": {