Skip to content

Commit 09a1748

Browse files
committed
feat: add Phase 3 advanced MCP tools and A2A smart routing skill
Register 8 new advanced MCP tools (simulate_route, set_budget_guard, set_resilience_profile, test_combo, get_provider_metrics, best_combo_for_task, explain_route, get_session_snapshot) with their handler implementations. Add A2A smart routing skill that routes prompts through the OmniRoute pipeline with routing explanation, cost envelope, and resilience trace metadata.
1 parent e0ddb22 commit 09a1748

File tree

13 files changed

+1954
-0
lines changed

13 files changed

+1954
-0
lines changed

open-sse/mcp-server/server.ts

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ import {
2727

2828
import { logToolCall } from "./audit.ts";
2929

30+
import {
31+
handleSimulateRoute,
32+
handleSetBudgetGuard,
33+
handleSetResilienceProfile,
34+
handleTestCombo,
35+
handleGetProviderMetrics,
36+
handleBestComboForTask,
37+
handleExplainRoute,
38+
handleGetSessionSnapshot,
39+
} from "./tools/advancedTools.ts";
40+
3041
// ============ Configuration ============
3142

3243
const OMNIROUTE_BASE_URL = process.env.OMNIROUTE_BASE_URL || "http://localhost:20128";
@@ -407,6 +418,94 @@ export function createMcpServer(): McpServer {
407418
(args) => handleListModelsCatalog(args as any)
408419
);
409420

421+
// ── Advanced Tools (Phase 3) ──────────────────────────────
422+
423+
server.tool(
424+
"omniroute_simulate_route",
425+
"Simulates the routing path a request would take without executing it (dry-run)",
426+
{
427+
model: { type: "string", description: "Target model identifier" },
428+
promptTokenEstimate: { type: "number", description: "Estimated prompt token count" },
429+
combo: {
430+
type: "string",
431+
description: "Specific combo to simulate (optional, default: active)",
432+
},
433+
},
434+
(args) => handleSimulateRoute(args as any)
435+
);
436+
437+
server.tool(
438+
"omniroute_set_budget_guard",
439+
"Sets a session budget limit with configurable action when exceeded (degrade/block/alert)",
440+
{
441+
maxCost: { type: "number", description: "Maximum cost in USD for the session" },
442+
action: { type: "string", description: "Action on exceed: degrade, block, or alert" },
443+
degradeToTier: {
444+
type: "string",
445+
description: "If action=degrade, target tier: cheap or free (optional)",
446+
},
447+
},
448+
(args) => handleSetBudgetGuard(args as any)
449+
);
450+
451+
server.tool(
452+
"omniroute_set_resilience_profile",
453+
"Applies a resilience profile controlling circuit breakers, retries, timeouts, and fallback depth",
454+
{
455+
profile: { type: "string", description: "Profile: aggressive, balanced, or conservative" },
456+
},
457+
(args) => handleSetResilienceProfile(args as any)
458+
);
459+
460+
server.tool(
461+
"omniroute_test_combo",
462+
"Tests each provider in a combo with a real prompt, reporting latency, cost, and success per provider",
463+
{
464+
comboId: { type: "string", description: "ID or name of the combo to test" },
465+
testPrompt: { type: "string", description: "Short test prompt (max 200 chars)" },
466+
},
467+
(args) => handleTestCombo(args as any)
468+
);
469+
470+
server.tool(
471+
"omniroute_get_provider_metrics",
472+
"Returns detailed metrics for a specific provider including latency percentiles and circuit breaker state",
473+
{
474+
provider: { type: "string", description: "Provider name" },
475+
},
476+
(args) => handleGetProviderMetrics(args as any)
477+
);
478+
479+
server.tool(
480+
"omniroute_best_combo_for_task",
481+
"Recommends the best combo for a task type based on provider fitness and constraints",
482+
{
483+
taskType: {
484+
type: "string",
485+
description: "Task type: coding, review, planning, analysis, debugging, documentation",
486+
},
487+
budgetConstraint: { type: "number", description: "Max cost constraint in USD (optional)" },
488+
latencyConstraint: { type: "number", description: "Max latency constraint in ms (optional)" },
489+
},
490+
(args) => handleBestComboForTask(args as any)
491+
);
492+
493+
server.tool(
494+
"omniroute_explain_route",
495+
"Explains why a request was routed to a specific provider, showing scoring factors and fallbacks",
496+
{
497+
requestId: { type: "string", description: "Request ID from X-Request-Id header" },
498+
},
499+
(args) => handleExplainRoute(args as any)
500+
);
501+
502+
server.tool(
503+
"omniroute_get_session_snapshot",
504+
"Returns a full snapshot of the current working session: cost, tokens, top models, errors, budget status",
505+
{},
506+
handleGetSessionSnapshot
507+
);
508+
410509
return server;
411510
}
412511

0 commit comments

Comments
 (0)