@tryvira/mcp 0.1.94 → 0.1.95
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 +1 -1
- package/dist/cli.js +44 -4
- package/package.json +2 -2
package/README.md
CHANGED
package/dist/cli.js
CHANGED
|
@@ -6,6 +6,41 @@ import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
|
6
6
|
import { ViraClient, viraHttpRequest } from "@tryvira/sdk";
|
|
7
7
|
import { z } from "zod";
|
|
8
8
|
|
|
9
|
+
// src/local-observability.ts
|
|
10
|
+
async function observeMcpStdioCall(observer, run) {
|
|
11
|
+
if (!observer) return run();
|
|
12
|
+
const started = performance.now();
|
|
13
|
+
let outcome = "exception";
|
|
14
|
+
try {
|
|
15
|
+
const result = await run();
|
|
16
|
+
outcome = result.isError === true ? "tool_error" : "success";
|
|
17
|
+
return result;
|
|
18
|
+
} finally {
|
|
19
|
+
try {
|
|
20
|
+
const event = Object.freeze({ outcome, durationMs: Math.max(0, performance.now() - started) });
|
|
21
|
+
void Promise.resolve(observer(event)).catch(() => {
|
|
22
|
+
});
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
var stderrFailed = false;
|
|
28
|
+
var stderrGuardInstalled = false;
|
|
29
|
+
function createMcpStderrObserver(enabled) {
|
|
30
|
+
if (!enabled) return void 0;
|
|
31
|
+
if (!stderrGuardInstalled) {
|
|
32
|
+
stderrGuardInstalled = true;
|
|
33
|
+
process.stderr.on("error", () => {
|
|
34
|
+
stderrFailed = true;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return (event) => {
|
|
38
|
+
if (stderrFailed || process.stderr.destroyed || !process.stderr.writable || process.stderr.writableNeedDrain) return;
|
|
39
|
+
process.stderr.write(JSON.stringify({ schema: "vira.mcp.stdio.diagnostic.v1", outcome: event.outcome, durationMs: event.durationMs }) + "\n", () => {
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
9
44
|
// src/tool-registry.ts
|
|
10
45
|
var read = (permissionClass = "integration.read") => ({ permissionClass, requiredRoles: [permissionClass], effectType: "read", scopePolicy: "environment", approvalRequirement: "none" });
|
|
11
46
|
var effectful = (permissionClass, approvalRequirement = "server", aliases = []) => ({ permissionClass, requiredRoles: [permissionClass, ...aliases], effectType: "effectful", scopePolicy: "environment", approvalRequirement });
|
|
@@ -15,7 +50,7 @@ var add = (names, authority) => names.forEach((name) => {
|
|
|
15
50
|
});
|
|
16
51
|
var generatedReadTools = ["list_strategy_executions", "search_runtime_traces", "get_ai_system", "list_system_connections", "list_inventory", "get_connection", "get_connection_health", "list_teach_analyses", "get_teach_analysis", "get_evaluation", "list_conversation_archive", "list_teach_runs", "get_teach_run_recommendation", "get_task_run_evidence", "get_improvement_proposal", "list_compound_task_plans", "get_compound_task_plan", "get_behavior_program"];
|
|
17
52
|
add(generatedReadTools, read());
|
|
18
|
-
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", "get_ai_usage_reconciliation", "list_ai_systems", "get_ai_system", "list_system_connections", "get_connection", "get_connection_health", "list_inventory", "list_connection_inventory", "list_discovery_candidates", "get_signal_mapping", "get_pack_revision", "get_pack_revision_diff", "list_packs", "get_pack", "diagnose_pack", "list_evaluations", "get_teach_analysis", "get_teach_run_recommendation", "get_evaluation", "get_evaluation_comparison", "get_evaluation_plan", "get_improvement_proposal", "search_runtime_traces"], read());
|
|
53
|
+
add(["get_scope", "list_capabilities", "get_job", "list_inbox", "read_notification_updates", "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", "get_ai_usage_reconciliation", "list_ai_systems", "get_ai_system", "list_system_connections", "get_connection", "get_connection_health", "list_inventory", "list_connection_inventory", "list_discovery_candidates", "get_signal_mapping", "get_pack_revision", "get_pack_revision_diff", "list_packs", "get_pack", "diagnose_pack", "list_evaluations", "get_teach_analysis", "get_teach_run_recommendation", "get_evaluation", "get_evaluation_comparison", "get_evaluation_plan", "get_improvement_proposal", "search_runtime_traces"], read());
|
|
19
54
|
add(["list_organization_units", "list_organization_unit_members", "list_project_organization_units", "list_organization_billing_admins", "list_ai_system_unit_grants", "get_ai_credit_wallet", "list_ai_credit_budgets", "list_ai_usage_receipts", "get_ai_usage_summary", "list_notification_destinations"], read());
|
|
20
55
|
registry.preview_organization_unit_archive = { permissionClass: "integration.read", requiredRoles: ["workspace.owner"], effectType: "read", scopePolicy: "environment", approvalRequirement: "none" };
|
|
21
56
|
add(["reserve_ai_credits", "release_ai_credit_reservation"], effectful("billing.write", "human", ["admin.billing.write", "workspace.owner"]));
|
|
@@ -84,6 +119,7 @@ var coreTools = Object.freeze([
|
|
|
84
119
|
{ name: "list_project_organization_units", description: "List organization unit bindings for the current project.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, targetProjectId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId", "targetProjectId"] } },
|
|
85
120
|
{ name: "bind_project_organization_unit", description: "Bind an organization unit to a project. Workspace owners may bind units and assign primary ownership; Department Admins may bind only their active unit as a non-primary owner.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, targetProjectId: { type: "string" }, unitId: { type: "string" }, primaryOwner: { type: "boolean" } }, required: ["organizationId", "projectId", "environmentId", "targetProjectId", "unitId"] } },
|
|
86
121
|
{ 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"] } },
|
|
122
|
+
{ name: "read_notification_updates", description: "Read opaque scoped notification invalidations for live inbox refresh.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, afterId: { type: "string", default: "latest" }, count: { type: "integer", minimum: 1, maximum: 100, default: 32 } }, required: ["organizationId", "projectId", "environmentId"] } },
|
|
87
123
|
{ name: "list_notification_destinations", description: "List authorized notification destinations in the current organization, project, and environment scope. Endpoint secrets are never returned.", inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" } }, required: ["organizationId", "projectId", "environmentId"] } },
|
|
88
124
|
{ name: "create_notification_destination", description: "Register an encrypted Slack or Microsoft Teams Workflows destination. The endpoint is a secret and is never returned; owner or integration.write permission is required.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, label: { type: "string", minLength: 1 }, provider: { type: "string", enum: ["slack", "microsoft_teams"] }, endpoint: { type: "string", minLength: 1, writeOnly: true }, idempotencyKey: { type: "string", minLength: 1 } }, required: ["organizationId", "projectId", "environmentId", "label", "provider", "endpoint"] } },
|
|
89
125
|
{ name: "revoke_notification_destination", description: "Revoke a scoped notification destination. Pending deliveries are suppressed after revocation; owner or integration.write permission is required.", effectful: true, inputSchema: { type: "object", properties: { organizationId: { type: "string" }, projectId: { type: "string" }, environmentId: { type: "string" }, destinationId: { type: "string", minLength: 1 } }, required: ["organizationId", "projectId", "environmentId", "destinationId"] } },
|
|
@@ -266,6 +302,7 @@ var MCP_PUBLIC_CORE_TOOL_NAMES = Object.freeze([
|
|
|
266
302
|
"get_ai_usage_reconciliation",
|
|
267
303
|
"continue_strategy_execution",
|
|
268
304
|
"list_inbox",
|
|
305
|
+
"read_notification_updates",
|
|
269
306
|
"list_notification_destinations",
|
|
270
307
|
"create_notification_destination",
|
|
271
308
|
"revoke_notification_destination",
|
|
@@ -570,6 +607,7 @@ var REGISTERED_MCP_CONTROL_OPERATIONS = Object.freeze([
|
|
|
570
607
|
"GET /v1/jobs/{jobId}",
|
|
571
608
|
"GET /v1/notification-destinations",
|
|
572
609
|
"GET /v1/notifications/inbox",
|
|
610
|
+
"GET /v1/notifications/updates",
|
|
573
611
|
"GET /v1/observations/backfills/{backfillId}/history",
|
|
574
612
|
"GET /v1/observations/backfills/{backfillId}/readiness",
|
|
575
613
|
"GET /v1/observations/trajectories/{trajectoryKey}/runtime-evidence",
|
|
@@ -941,6 +979,7 @@ var fullTools = [
|
|
|
941
979
|
{ name: "list_project_organization_units", description: "List organization unit bindings for a project in this MCP scope.", inputSchema: input({ targetProjectId: z.string().min(1) }), run: (args) => readFromApi(`/v1/projects/${encodeURIComponent(String(args.targetProjectId))}/organization-units`) },
|
|
942
980
|
{ name: "bind_project_organization_unit", description: "Bind a unit to a project as a workspace owner, or let a Department Admin bind only their active unit as a non-primary owner.", inputSchema: input({ targetProjectId: z.string().min(1), unitId: z.string().min(1), primaryOwner: z.boolean().optional() }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/projects/${encodeURIComponent(String(args.targetProjectId))}/organization-units/${encodeURIComponent(String(args.unitId))}`, { ...mcpHttpOptions, method: "POST", body: { ...scope, primaryOwner: args.primaryOwner }, idempotencyKey: newMcpMutationKey("bind_project_organization_unit") })).body },
|
|
943
981
|
{ 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()}`) },
|
|
982
|
+
{ name: "read_notification_updates", description: "Read opaque scoped notification invalidations for live inbox refresh.", inputSchema: input({ afterId: z.string().default("latest"), count: z.number().int().min(1).max(100).default(32) }), run: async (args) => readFromApi(`/v1/notifications/updates?${new URLSearchParams({ afterId: String(args.afterId), count: String(args.count) }).toString()}`) },
|
|
944
983
|
{ name: "list_notification_destinations", description: "List scoped notification destinations. Endpoint secrets are never returned.", inputSchema: input(), run: () => readFromApi("/v1/notification-destinations") },
|
|
945
984
|
{ name: "create_notification_destination", description: "Register an encrypted Slack or Microsoft Teams Workflows destination. The endpoint is a secret and is never returned; owner or integration.write permission is required.", inputSchema: input({ label: z.string().min(1), provider: z.enum(["slack", "microsoft_teams"]), endpoint: z.string().min(1), idempotencyKey: z.string().min(1).optional() }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/notification-destinations`, { ...mcpHttpOptions, method: "POST", body: { ...scope, label: String(args.label), provider: args.provider, endpoint: String(args.endpoint) }, idempotencyKey: String(args.idempotencyKey ?? `mcp:notification-destination:${String(args.label)}`) })).body },
|
|
946
985
|
{ name: "revoke_notification_destination", description: "Revoke a scoped destination so queued deliveries are suppressed. Owner or integration.write permission is required.", inputSchema: input({ destinationId: z.string().min(1) }), effectful: true, run: async (args) => (await viraHttpRequest(`${baseUrl}/v1/notification-destinations/${encodeURIComponent(String(args.destinationId))}/revoke`, { ...mcpHttpOptions, method: "POST", body: scope, idempotencyKey: `mcp:notification-destination-revoke:${String(args.destinationId)}` })).body },
|
|
@@ -1116,9 +1155,10 @@ var authorize = async (tool, args) => {
|
|
|
1116
1155
|
})).body;
|
|
1117
1156
|
assertMcpAuthorityDecisionReceipt(decision);
|
|
1118
1157
|
};
|
|
1119
|
-
var server = new McpServer({ name: process.env.VIRA_MCP_SERVER_NAME ?? "vira", version: "0.1.
|
|
1158
|
+
var server = new McpServer({ name: process.env.VIRA_MCP_SERVER_NAME ?? "vira", version: "0.1.95" }, { capabilities: { tools: {} } });
|
|
1159
|
+
var stdioObserver = createMcpStderrObserver(process.env.VIRA_MCP_LOCAL_DIAGNOSTICS === "true");
|
|
1120
1160
|
for (const tool of tools) {
|
|
1121
|
-
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) => {
|
|
1161
|
+
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) => observeMcpStdioCall(stdioObserver, async () => {
|
|
1122
1162
|
const args = raw;
|
|
1123
1163
|
scopeQuery(args, ["list_ai_usage_receipts", "get_ai_usage_summary"].includes(tool.name));
|
|
1124
1164
|
try {
|
|
@@ -1130,7 +1170,7 @@ for (const tool of tools) {
|
|
|
1130
1170
|
const message = error instanceof Error ? error.message : "VIRA_MCP_REQUEST_FAILED";
|
|
1131
1171
|
return { isError: true, content: [{ type: "text", text: message }], structuredContent: { result: message } };
|
|
1132
1172
|
}
|
|
1133
|
-
});
|
|
1173
|
+
}));
|
|
1134
1174
|
}
|
|
1135
1175
|
process.once("SIGTERM", () => process.exit(0));
|
|
1136
1176
|
process.once("SIGINT", () => process.exit(0));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryvira/mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.95",
|
|
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.
|
|
41
|
+
"@tryvira/sdk": "^0.1.98",
|
|
42
42
|
"zod": "^4.2.0"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|