@tryvira/mcp 0.1.55 → 0.1.57
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.
- package/README.md +10 -0
- package/dist/cli.js +84 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -59,6 +59,16 @@ in the host. Effectful tools require approval from
|
|
|
59
59
|
the configured authority endpoint and can be denied by scope, role, release state,
|
|
60
60
|
or policy.
|
|
61
61
|
|
|
62
|
+
The agent-first operations also include `get_scope`, `list_inbox`/
|
|
63
|
+
`mark_inbox_read`, `inspect_conflicts`/`get_conflict_inspection`/
|
|
64
|
+
`resolve_conflict`, and provider-backed `start_optimization`,
|
|
65
|
+
`get_optimization_run`, and `cancel_optimization_run`. Optimization calls use
|
|
66
|
+
the authenticated Control API, which forwards to the server-owned optimizer
|
|
67
|
+
service; optimizer credentials never belong in the MCP client environment.
|
|
68
|
+
They remain scoped and fail closed when the optimizer service is not
|
|
69
|
+
configured. These operations do not require Studio, but release and approval
|
|
70
|
+
gates still apply.
|
|
71
|
+
|
|
62
72
|
## Minimal MCP client configuration
|
|
63
73
|
|
|
64
74
|
```json
|
package/dist/cli.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/cli.ts
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
5
5
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
6
|
-
import { ViraClient } from "@tryvira/sdk";
|
|
6
|
+
import { ViraClient, viraHttpRequest } from "@tryvira/sdk";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
|
|
9
9
|
// src/tool-registry.ts
|
|
@@ -13,7 +13,11 @@ var registry = {};
|
|
|
13
13
|
var add = (names, authority) => names.forEach((name) => {
|
|
14
14
|
registry[name] = authority;
|
|
15
15
|
});
|
|
16
|
-
add(["list_capabilities", "list_semantic_tasks", "list_behavior_points", "list_behavior_programs", "list_behavior_strategies", "get_behavior_strategy", "get_behavior_program", "get_task_run", "list_task_run_events", "get_strategy_execution", "get_strategy_execution_trace", "list_ai_systems", "get_ai_system", "list_system_connections", "get_connection", "connection_health", "inventory", "connection_inventory", "list_discovery_candidates", "get_signal_mapping", "get_pack_revision", "get_pack_revision_diff", "list_packs", "diagnose_pack", "get_teach_analysis", "get_teach_run_recommendation", "get_evaluation", "get_evaluation_comparison", "get_evaluation_plan", "get_improvement_proposal", "search_runtime_traces"], read());
|
|
16
|
+
add(["get_scope", "list_capabilities", "get_job", "list_inbox", "get_conflict_inspection", "get_optimization_run", "list_semantic_tasks", "list_behavior_points", "list_behavior_programs", "list_behavior_strategies", "get_behavior_strategy", "get_behavior_program", "get_task_run", "list_task_run_events", "get_strategy_execution", "get_strategy_execution_trace", "list_ai_systems", "get_ai_system", "list_system_connections", "get_connection", "connection_health", "inventory", "connection_inventory", "list_discovery_candidates", "get_signal_mapping", "get_pack_revision", "get_pack_revision_diff", "list_packs", "diagnose_pack", "get_teach_analysis", "get_teach_run_recommendation", "get_evaluation", "get_evaluation_comparison", "get_evaluation_plan", "get_improvement_proposal", "search_runtime_traces"], read());
|
|
17
|
+
add(["connect_once", "observe", "feedback", "outcome"], effectful("integration.write", "server", ["studio.write", "admin"]));
|
|
18
|
+
add(["mark_inbox_read"], effectful("teach.write", "server", ["studio.write", "admin"]));
|
|
19
|
+
add(["inspect_conflicts", "resolve_conflict"], effectful("behavior.write", "server", ["studio.write", "admin", "release.approve"]));
|
|
20
|
+
add(["start_optimization", "cancel_optimization_run"], effectful("evaluation.write", "server", ["studio.write", "admin", "optimizer.execute"]));
|
|
17
21
|
add(["list_host_tools"], read("integration.read"));
|
|
18
22
|
add(["test_connection"], effectful("integration.write", "server", ["studio.write", "admin"]));
|
|
19
23
|
add(["resolve_semantic", "resolve_task_run", "simulate_behavior_strategy"], read("runtime.execute"));
|
|
@@ -87,16 +91,76 @@ var scopeFields = {
|
|
|
87
91
|
environmentId: z.string().optional()
|
|
88
92
|
};
|
|
89
93
|
var input = (shape = {}) => z.object({ ...scopeFields, ...shape }).strict();
|
|
94
|
+
var pageFields = { limit: z.number().int().positive().max(100).optional(), cursor: z.string().min(1).optional() };
|
|
95
|
+
var packVariableSchema = z.object({ key: z.string().min(1), label: z.string().min(1), type: z.enum(["text", "boolean", "multi_select"]).optional(), required: z.boolean().optional(), default: z.unknown().optional() }).strict();
|
|
96
|
+
var packManifestSchema = z.object({ id: z.string().min(1), name: z.string().min(1), version: z.string().min(1), schemaVersion: z.string().regex(/^vira\.pack\.v[0-9]+$/).optional(), requires: z.object({ vira: z.string().min(1).optional() }).strict().optional(), variables: z.array(packVariableSchema).optional() }).passthrough();
|
|
97
|
+
var importPackSchema = input({ manifest: packManifestSchema.optional(), objects: z.record(z.string(), z.unknown()).optional(), archiveBase64: z.string().min(1).optional(), fileName: z.string().min(1).optional(), idempotencyKey: z.string().min(1).optional() }).superRefine((raw, ctx) => {
|
|
98
|
+
const value = raw;
|
|
99
|
+
if (!value.manifest && !value.archiveBase64) ctx.addIssue({ code: z.ZodIssueCode.custom, message: "MCP_PACK_MANIFEST_OR_ARCHIVE_REQUIRED", path: ["manifest"] });
|
|
100
|
+
if (value.archiveBase64 && !value.fileName) ctx.addIssue({ code: z.ZodIssueCode.custom, message: "MCP_PACK_FILE_NAME_REQUIRED", path: ["fileName"] });
|
|
101
|
+
});
|
|
90
102
|
var scopeQuery = (args) => {
|
|
91
103
|
for (const key of Object.keys(scope)) {
|
|
92
104
|
const supplied = args[key];
|
|
93
105
|
if (supplied !== void 0 && supplied !== scope[key]) throw new Error("MCP_SCOPE_MISMATCH");
|
|
94
106
|
}
|
|
95
107
|
};
|
|
108
|
+
var decodePageCursor = (cursor) => {
|
|
109
|
+
if (!cursor) return 0;
|
|
110
|
+
try {
|
|
111
|
+
const value = Number(Buffer.from(cursor, "base64url").toString("utf8"));
|
|
112
|
+
return Number.isSafeInteger(value) && value >= 0 ? value : -1;
|
|
113
|
+
} catch {
|
|
114
|
+
return -1;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var encodePageCursor = (offset) => Buffer.from(String(offset), "utf8").toString("base64url");
|
|
118
|
+
var listFromApi = async (path, args) => {
|
|
119
|
+
const url = new URL(`${baseUrl}${path}`);
|
|
120
|
+
for (const [key, value] of Object.entries(scope)) url.searchParams.set(key, value);
|
|
121
|
+
if (typeof args.limit === "number") url.searchParams.set("limit", String(args.limit));
|
|
122
|
+
if (typeof args.cursor === "string") url.searchParams.set("cursor", args.cursor);
|
|
123
|
+
const response = await viraHttpRequest(url, { method: "GET", apiKey });
|
|
124
|
+
const body = response.body;
|
|
125
|
+
const requestedLimit = typeof args.limit === "number" ? args.limit : 100;
|
|
126
|
+
const offset = decodePageCursor(typeof args.cursor === "string" ? args.cursor : void 0);
|
|
127
|
+
if (offset < 0) throw new Error("MCP_PAGE_CURSOR_INVALID");
|
|
128
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) return body;
|
|
129
|
+
const record = body;
|
|
130
|
+
const collectionKey = Object.keys(record).find((key) => Array.isArray(record[key]));
|
|
131
|
+
if (!collectionKey) return body;
|
|
132
|
+
if (Object.prototype.hasOwnProperty.call(record, "nextCursor")) return body;
|
|
133
|
+
const collection = record[collectionKey];
|
|
134
|
+
const page = collection.slice(offset, offset + requestedLimit);
|
|
135
|
+
const nextCursor = offset + requestedLimit < collection.length ? encodePageCursor(offset + requestedLimit) : void 0;
|
|
136
|
+
return { ...record, [collectionKey]: page, nextCursor };
|
|
137
|
+
};
|
|
138
|
+
var readFromApi = async (path) => {
|
|
139
|
+
const url = new URL(`${baseUrl}${path}`);
|
|
140
|
+
for (const [key, value] of Object.entries(scope)) url.searchParams.set(key, value);
|
|
141
|
+
return (await viraHttpRequest(url, { method: "GET", apiKey })).body;
|
|
142
|
+
};
|
|
143
|
+
var optimizerRequest = async (path, method, body) => {
|
|
144
|
+
const controlPath = path === "/v1/optimize" ? "/v1/optimization/execute" : path;
|
|
145
|
+
const url = new URL(`${baseUrl}${controlPath}`);
|
|
146
|
+
if (method === "GET") for (const [key, value] of Object.entries(scope)) url.searchParams.set(key, value);
|
|
147
|
+
return (await viraHttpRequest(url, { method, apiKey, body: body ? { ...body, scope } : void 0, idempotencyKey: method === "POST" ? `mcp:optimizer:${path}` : void 0 })).body;
|
|
148
|
+
};
|
|
96
149
|
var tools = [
|
|
150
|
+
{ name: "get_scope", description: "Read the immutable organization/project/environment scope configured for this MCP session.", inputSchema: input(), run: async () => ({ scope, apiUrl: baseUrl }) },
|
|
97
151
|
{ name: "list_capabilities", description: "List capabilities available to this API key.", inputSchema: input(), run: () => client.listCapabilities({ surface: "mcp" }) },
|
|
98
|
-
{ name: "
|
|
99
|
-
{ name: "
|
|
152
|
+
{ name: "list_inbox", description: "List the authenticated actor\u2019s scoped review notifications.", inputSchema: input({ limit: z.number().int().positive().max(100).optional() }), run: async (args) => readFromApi(`/v1/notifications/inbox?limit=${encodeURIComponent(String(args.limit ?? 100))}`) },
|
|
153
|
+
{ 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 },
|
|
154
|
+
{ 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 },
|
|
155
|
+
{ 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))}`) },
|
|
156
|
+
{ 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 },
|
|
157
|
+
{ 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) },
|
|
158
|
+
{ 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") },
|
|
159
|
+
{ 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", {}) },
|
|
160
|
+
{ name: "connect_once", description: "Create or reuse a scoped AI System connection and return its capability handshake.", 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.connectOnce({ 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 }) },
|
|
161
|
+
{ 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))}`) },
|
|
162
|
+
{ name: "list_semantic_tasks", description: "List Semantic Tasks with bounded cursor pagination.", inputSchema: input(pageFields), run: (args) => listFromApi("/v1/semantic-tasks", args) },
|
|
163
|
+
{ name: "list_behavior_points", description: "List BehaviorPoints with bounded cursor pagination.", inputSchema: input(pageFields), run: (args) => listFromApi("/v1/behavior-points", args) },
|
|
100
164
|
{ name: "list_behavior_programs", description: "List behavior programs in the API key scope.", inputSchema: input(), run: () => client.listBehaviorPrograms() },
|
|
101
165
|
{ name: "list_behavior_strategies", description: "List behavior strategies in the API key scope.", inputSchema: input(), run: () => client.listBehaviorStrategies() },
|
|
102
166
|
{ name: "resolve_semantic", description: "Resolve text using Vira semantic routing.", 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) },
|
|
@@ -125,8 +189,8 @@ var tools = [
|
|
|
125
189
|
const { idempotencyKey, ...proposal } = args;
|
|
126
190
|
return client.createTeachProposal(proposal, { idempotencyKey });
|
|
127
191
|
} },
|
|
128
|
-
{ name: "list_packs", description: "List Behavior Packs
|
|
129
|
-
{ name: "import_pack", description: "Import a Pack draft; release remains separately governed.", inputSchema:
|
|
192
|
+
{ name: "list_packs", description: "List Behavior Packs with bounded cursor pagination.", inputSchema: input(pageFields), run: (args) => listFromApi("/v1/packs", args) },
|
|
193
|
+
{ name: "import_pack", description: "Import a versioned Pack draft; release remains separately governed.", inputSchema: importPackSchema, effectful: true, run: (args) => client.importPack(args) },
|
|
130
194
|
{ 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 ?? {}) },
|
|
131
195
|
{ 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)) },
|
|
132
196
|
{ 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) },
|
|
@@ -139,7 +203,7 @@ var tools = [
|
|
|
139
203
|
if (String(proposalRecord.tool_key ?? "") !== registered.name) throw new Error("MCP_HOST_TOOL_DEFINITION_MISMATCH");
|
|
140
204
|
return client.authorizeHostAction({ executionId: String(executionId), sessionId: String(sessionId), dataVersion: String(dataVersion), scope, context: contextRecord, proposal: proposalRecord, ...approval ? { approval } : {} });
|
|
141
205
|
} },
|
|
142
|
-
{ name: "list_ai_systems", description: "List connected AI systems
|
|
206
|
+
{ name: "list_ai_systems", description: "List connected AI systems with bounded cursor pagination.", inputSchema: input(pageFields), run: (args) => listFromApi("/v1/ai-systems", args) },
|
|
143
207
|
{ name: "get_ai_system", description: "Read one connected AI system.", inputSchema: input({ systemId: z.string().min(1) }), run: (args) => client.getAISystem(String(args.systemId)) },
|
|
144
208
|
{ name: "list_system_connections", description: "List connections for an AI system.", inputSchema: input({ systemId: z.string().min(1) }), run: (args) => client.listSystemConnections(String(args.systemId)) },
|
|
145
209
|
{ name: "get_connection", description: "Read one connection.", inputSchema: input({ connectionId: z.string().min(1) }), run: (args) => client.getConnection(String(args.connectionId)) },
|
|
@@ -155,6 +219,8 @@ var tools = [
|
|
|
155
219
|
{ name: "get_task_run", description: "Read TaskRun state and final result.", inputSchema: input({ taskRunId: z.string().min(1) }), run: (args) => client.getTaskRun(String(args.taskRunId)) },
|
|
156
220
|
{ name: "list_task_run_events", description: "Read TaskRun lifecycle events and child lineage.", inputSchema: input({ taskRunId: z.string().min(1) }), run: (args) => client.listTaskRunEvents(String(args.taskRunId)) },
|
|
157
221
|
{ name: "observe", description: "Ingest a scoped observation.", inputSchema: input({ event: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.observe(args.event) },
|
|
222
|
+
{ name: "feedback", description: "Record scoped user feedback for an observed AI interaction.", inputSchema: input({ event: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.feedback(args.event) },
|
|
223
|
+
{ name: "outcome", description: "Record a scoped business outcome for an observed AI interaction.", inputSchema: input({ event: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.outcome(args.event) },
|
|
158
224
|
{ name: "search_runtime_traces", description: "Search scoped runtime traces and receipts.", inputSchema: input({ limit: z.number().int().positive().optional(), cursor: z.string().optional(), query: z.string().optional(), event: z.string().optional() }), run: (args) => client.searchRuntimeTraces(args) },
|
|
159
225
|
{ name: "create_signal_discovery_proposal", description: "Create an evidence-backed signal discovery proposal.", inputSchema: input({ proposal: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.createSignalDiscoveryProposal(args.proposal) },
|
|
160
226
|
{ name: "review_signal_discovery_proposal", description: "Approve or reject a signal discovery proposal.", inputSchema: input({ proposalId: z.string().min(1), decision: z.enum(["APPROVE", "REJECT"]) }), effectful: true, run: (args) => client.reviewSignalDiscoveryProposal(String(args.proposalId), args.decision) },
|
|
@@ -165,6 +231,7 @@ var tools = [
|
|
|
165
231
|
{ name: "create_teach_analysis", description: "Start a Teach analysis from admitted evidence.", inputSchema: input({ evidenceIds: z.array(z.string()).min(1), controlPointId: z.string().optional(), summary: z.string().optional() }), effectful: true, run: (args) => client.createTeachAnalysis(args.evidenceIds, { controlPointId: args.controlPointId, summary: args.summary }) },
|
|
166
232
|
{ name: "get_teach_analysis", description: "Read Teach analysis status and result.", inputSchema: input({ analysisId: z.string().min(1) }), run: (args) => client.getTeachAnalysis(String(args.analysisId)) },
|
|
167
233
|
{ name: "get_teach_run_recommendation", description: "Read a Teach recommendation.", inputSchema: input({ teachRunId: z.string().min(1) }), run: (args) => client.getTeachRunRecommendation(String(args.teachRunId)) },
|
|
234
|
+
{ name: "get_teach_behavior_set", description: "Read the complete provider-backed Teach behavior set before review.", inputSchema: input({ teachRunId: z.string().min(1) }), run: (args) => readFromApi(`/v1/teach/runs/${encodeURIComponent(String(args.teachRunId))}/behavior-set`) },
|
|
168
235
|
{ name: "accept_teach_recommendation", description: "Accept a Teach recommendation for evaluation.", inputSchema: input({ teachRunId: z.string().min(1), actorId: z.string().min(1) }), effectful: true, run: (args) => client.acceptTeachRecommendation(String(args.teachRunId), String(args.actorId)) },
|
|
169
236
|
{ name: "reject_teach_recommendation", description: "Reject a Teach recommendation with a reason.", inputSchema: input({ teachRunId: z.string().min(1), reason: z.string().min(1) }), effectful: true, run: (args) => client.rejectTeachRecommendation(String(args.teachRunId), String(args.reason)) },
|
|
170
237
|
{ name: "edit_teach_recommendation", description: "Edit a Teach recommendation as a new immutable revision.", inputSchema: input({ teachRunId: z.string().min(1), revisionId: z.string().min(1), reason: z.string().min(1), behaviorSet: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.editTeachRecommendation(String(args.teachRunId), { revisionId: String(args.revisionId), reason: String(args.reason), behaviorSet: args.behaviorSet }) },
|
|
@@ -191,20 +258,21 @@ var tools = [
|
|
|
191
258
|
{ name: "evaluate_pack", description: "Evaluate a Pack using server-owned execution.", inputSchema: input({ packId: z.string().min(1), evaluation: z.record(z.string(), z.unknown()) }), effectful: true, run: (args) => client.evaluatePack(String(args.packId), args.evaluation) },
|
|
192
259
|
{ name: "approve_pack", description: "Approve a passed Pack evaluation.", inputSchema: input({ packId: z.string().min(1), reason: z.string().optional() }), effectful: true, run: (args) => client.approvePack(String(args.packId), { manualApproval: true, reason: args.reason }) },
|
|
193
260
|
{ name: "compile_behavior_capsule", description: "Compile a Behavior Program capsule.", inputSchema: input({ programId: z.string().min(1), input: z.string().min(1), selection: z.record(z.string(), z.unknown()).optional(), candidates: z.array(z.unknown()).optional() }), effectful: true, run: (args) => client.compileBehaviorCapsule(args) },
|
|
194
|
-
{ name: "serve_behavior_projection", description: "Serve the active behavior projection for verification.", inputSchema: input({ input: z.string().min(1), provider: z.string().min(1), programId: z.string().optional() }), effectful: true, run: (args) => client.serveBehaviorProjection(args) }
|
|
261
|
+
{ name: "serve_behavior_projection", description: "Serve the active behavior projection for verification.", inputSchema: input({ input: z.string().min(1), provider: z.string().min(1), programId: z.string().optional() }), effectful: true, run: (args) => client.serveBehaviorProjection(args) },
|
|
262
|
+
{ 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) }
|
|
195
263
|
];
|
|
196
264
|
if (tools.some((tool) => !isKnownMcpTool(tool.name) || Boolean(tool.effectful) !== (getMcpToolAuthority(tool.name)?.effectType === "effectful"))) throw new Error("MCP_TOOL_REGISTRY_DRIFT");
|
|
197
265
|
var authorize = async (tool, args) => {
|
|
198
266
|
if (!tool.effectful) return;
|
|
199
|
-
const
|
|
267
|
+
const decision = (await viraHttpRequest(authorityUrl, {
|
|
200
268
|
method: "POST",
|
|
201
|
-
|
|
202
|
-
body:
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (
|
|
269
|
+
apiKey,
|
|
270
|
+
body: { tool: tool.name, arguments: args, scope },
|
|
271
|
+
idempotencyKey: `mcp:authorize:${tool.name}`
|
|
272
|
+
})).body;
|
|
273
|
+
if (decision?.allowed !== true) throw new Error(decision?.reason ?? "MCP_AUTHORITY_DENIED");
|
|
206
274
|
};
|
|
207
|
-
var server = new McpServer({ name: process.env.VIRA_MCP_SERVER_NAME ?? "vira-behavior-control", version: "0.1.
|
|
275
|
+
var server = new McpServer({ name: process.env.VIRA_MCP_SERVER_NAME ?? "vira-behavior-control", version: "0.1.57" }, { capabilities: { tools: {} } });
|
|
208
276
|
for (const tool of tools) {
|
|
209
277
|
server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema }, async (raw) => {
|
|
210
278
|
const args = raw;
|
|
@@ -219,4 +287,4 @@ for (const tool of tools) {
|
|
|
219
287
|
}
|
|
220
288
|
});
|
|
221
289
|
}
|
|
222
|
-
serveStdio(() => server
|
|
290
|
+
serveStdio(() => server);
|