mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-09-19 21:32:20 +03:00
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host. Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean. Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
88 lines
3.2 KiB
TypeScript
88 lines
3.2 KiB
TypeScript
/**
|
|
* MCP Authorization Scopes — Defines permission scopes for each MCP tool.
|
|
*
|
|
* Each tool requires specific scopes to execute. API keys can be configured
|
|
* with a subset of scopes to limit tool access (least-privilege).
|
|
*/
|
|
|
|
// ============ Scope Definitions ============
|
|
|
|
/** All available MCP scopes */
|
|
export const MCP_SCOPE_LIST = [
|
|
"read:health",
|
|
"read:combos",
|
|
"write:combos",
|
|
"read:quota",
|
|
"read:usage",
|
|
"read:models",
|
|
"read:radar",
|
|
"execute:completions",
|
|
"execute:search",
|
|
"write:budget",
|
|
"write:resilience",
|
|
"pricing:write",
|
|
"read:cache",
|
|
"write:cache",
|
|
"read:compression",
|
|
"write:compression",
|
|
"read:proxies",
|
|
] as const;
|
|
|
|
export type McpScope = (typeof MCP_SCOPE_LIST)[number];
|
|
|
|
// ============ Tool → Scope Mapping ============
|
|
|
|
/** Maps each MCP tool to its required scopes */
|
|
export const MCP_TOOL_SCOPES: Record<string, readonly McpScope[]> = {
|
|
// Phase 1: Essential Tools
|
|
omniroute_get_health: ["read:health"],
|
|
omniroute_list_combos: ["read:combos"],
|
|
omniroute_get_combo_metrics: ["read:combos"],
|
|
omniroute_switch_combo: ["write:combos"],
|
|
omniroute_check_quota: ["read:quota"],
|
|
omniroute_route_request: ["execute:completions"],
|
|
omniroute_web_search: ["execute:search"],
|
|
omniroute_x_search: ["execute:search"],
|
|
omniroute_web_fetch: ["execute:search"],
|
|
omniroute_cost_report: ["read:usage"],
|
|
omniroute_list_models_catalog: ["read:models"],
|
|
omniroute_radar_catalog: ["read:radar"],
|
|
|
|
// Phase 2: Advanced Tools
|
|
omniroute_simulate_route: ["read:health", "read:combos"],
|
|
omniroute_set_budget_guard: ["write:budget"],
|
|
omniroute_set_resilience_profile: ["write:resilience"],
|
|
omniroute_test_combo: ["execute:completions", "read:combos"],
|
|
omniroute_get_provider_metrics: ["read:health"],
|
|
omniroute_best_combo_for_task: ["read:combos", "read:health"],
|
|
omniroute_explain_route: ["read:health", "read:usage"],
|
|
omniroute_get_session_snapshot: ["read:usage"],
|
|
omniroute_db_health_check: ["read:health", "write:resilience"],
|
|
omniroute_sync_pricing: ["pricing:write"],
|
|
omniroute_cache_stats: ["read:cache"],
|
|
omniroute_cache_flush: ["write:cache"],
|
|
omniroute_compression_status: ["read:compression"],
|
|
omniroute_compression_configure: ["write:compression"],
|
|
omniroute_set_compression_engine: ["write:compression"],
|
|
omniroute_list_compression_combos: ["read:compression"],
|
|
omniroute_compression_combo_stats: ["read:compression"],
|
|
omniroute_ccr_store: ["write:compression"],
|
|
omniroute_ccr_retrieve: ["read:compression"],
|
|
omniroute_ccr_inspect: ["read:compression"],
|
|
omniroute_ccr_list: ["read:compression"],
|
|
omniroute_ccr_delete: ["write:compression"],
|
|
omniroute_ccr_stats: ["read:compression"],
|
|
omniroute_oneproxy_fetch: ["read:proxies"],
|
|
omniroute_oneproxy_rotate: ["read:proxies"],
|
|
omniroute_oneproxy_stats: ["read:proxies"],
|
|
|
|
// Web-session pool observability (read) + lifecycle (write)
|
|
omniroute_pool_status: ["read:health"],
|
|
omniroute_pool_sessions: ["read:health"],
|
|
omniroute_pool_health: ["read:health"],
|
|
omniroute_pool_reset: ["write:resilience"],
|
|
omniroute_pool_warm: ["write:resilience"],
|
|
// Stealth browser pool observability (#3368 PR7)
|
|
omniroute_browser_pool_status: ["read:health"],
|
|
} as const;
|