feat(mcp): connector marketplace + split the Connectors surface (§7/§14/§15)
Fills a gap the blueprint names: the admin had to hand-author every
`mcp_catalog` entry. A remote feed of vetted connectors now proposes them
and the admin installs — the feed is *consultative*, so §14's risk axis is
untouched and the trust anchor stays on the box.
Marketplace client (`src/frontend/api/marketplace.rs`):
- Fetches the feed server-side (it sends no CORS headers) and caches it;
icons are proxied for the same reason.
- Verifies every declared SHA-256 before writing, fail-closed and
all-or-nothing. Feed-supplied paths are refused if they escape
`./scripts/<id>/`. Importing an `mcp_local` entry still demands the
admin-only `mcp.register_local_script`.
- Translates the feed's vocabulary into Skald's: `user`→`per_user`,
`mcp_local`→`local_script`. Scope is read, never inferred from transport
(a remote connector can be per-user — that is what `mcp.register_remote`
is for), and an unreadable `type` fails closed to the answer needing more
authority. The feed's `llm_short_description` maps to `description`, the
column `render_mcp_list` puts in front of the LLM for `activate_tools()`.
- Feed URL is config (`marketplace.url`), not a constant: an on-premise
product must not hard-require reaching one vendor's host.
Two silent failures found while wiring it:
- `transport_of` maps anything unknown to Stdio, so the feed's
`streamable-http` would have tried to spawn a command. Normalised on import.
- Some servers want their key as a query param, not a bearer header, and say
so with a `{key}` placeholder. Substituted at connect time in
`global_row_spec`/`user_row_spec` — never at rest, so the key stays in its
own column and the stored URL stays a template.
Pages, split by the question each answers:
- Connectors — what runs (`UserMcpView` = global ∪ per-user) and what I can
add. Same page for everyone; the admin just has more verbs. One Available
list with the verb per row: `per_user`→Activate, `global`→Enable globally.
Enabling a global is the admin's counterpart to activating a per-user one,
so the catalog picker dropdown is gone — the entry comes from the row.
- Connector Catalog (admin) — what this box offers. One `Add connector`
with two sources: marketplace first (vetted, hashed), manual second
(unvetted by nature) — the order mirrors the trust model.
- Marketplace (admin) — reached from the catalog, not the sidebar: it is a
destination of an action, not a place.
`available()` no longer returns `McpGlobalServerRow`: that row carries
`api_key` and this view now reaches every logged-in user. A slim `GlobalView`
crosses instead, and an admin sees every global (with `can_use` marking their
own) so one enabled for someone else stays manageable.
Also fixes `connectors-page` having no CSS rule at all — every sibling page
has one, so it never got `flex: 1` and left an empty column beside it.
This commit is contained in:
+60
-5
@@ -244,20 +244,75 @@ pub async fn global_set_access(
|
||||
|
||||
// ── user: available catalog + activation ──────────────────────────────────────
|
||||
|
||||
/// What a user can activate or already reaches: the per-user catalog entries their
|
||||
/// role may activate, plus the global connectors they've been granted.
|
||||
/// A globally-active connector as the Connectors page renders it.
|
||||
///
|
||||
/// Deliberately **not** [`mcp_global_servers::McpGlobalServerRow`]: that row carries
|
||||
/// `api_key`, and this view reaches every logged-in user, not just the admin. The
|
||||
/// browser has no use for the key, the url or the env here — so they never cross.
|
||||
#[derive(serde::Serialize)]
|
||||
pub struct GlobalView {
|
||||
pub id: i64,
|
||||
pub name: String,
|
||||
/// The catalog entry this instance came from. The UI needs it to tell which
|
||||
/// catalog rows are already enabled — the runtime name can be overridden, so
|
||||
/// matching on `name` alone would miss a renamed one.
|
||||
pub catalog_name: Option<String>,
|
||||
pub friendly_name: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub transport: String,
|
||||
pub enabled: bool,
|
||||
/// Whether the caller is actually granted this connector. An admin sees every
|
||||
/// global — including one they enabled for someone else and never granted
|
||||
/// themselves — so this is what separates "I can manage it" from "I can use it".
|
||||
pub can_use: bool,
|
||||
}
|
||||
|
||||
/// What the caller can reach or add on the Connectors page: the catalog entries they
|
||||
/// may act on, plus the globally-active connectors.
|
||||
///
|
||||
/// The catalog list mixes both scopes on purpose — enabling a `global` entry is the
|
||||
/// admin's counterpart to activating a `per_user` one (§7: one template, two runtimes),
|
||||
/// so it is one list with a different verb per row rather than two sections.
|
||||
pub async fn available(
|
||||
State(skald): State<Arc<Skald>>,
|
||||
Extension(auth): Extension<AuthUser>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let user = skald_core::db::users::get(skald.db(), &auth.user_id).await?
|
||||
.ok_or_else(|| ApiError::unauthorized("unknown user"))?;
|
||||
let catalog: Vec<_> = mcp_catalog::list_for_scope(skald.db(), "per_user").await?
|
||||
let manages_catalog =
|
||||
role_capabilities::has(skald.db(), &user.role_id, role_capabilities::MANAGE_CATALOG).await?;
|
||||
|
||||
let mut catalog: Vec<_> = mcp_catalog::list_for_scope(skald.db(), "per_user").await?
|
||||
.into_iter()
|
||||
.filter(|e| e.allowed_for_role(&user.role_id))
|
||||
.collect();
|
||||
let global_names = mcp_global_access::server_names_for_user(skald.db(), &auth.user_id).await?;
|
||||
Ok(Json(json!({ "catalog": catalog, "global": global_names })))
|
||||
if manages_catalog {
|
||||
catalog.extend(mcp_catalog::list_for_scope(skald.db(), "global").await?);
|
||||
}
|
||||
|
||||
let granted: std::collections::HashSet<String> =
|
||||
mcp_global_access::server_names_for_user(skald.db(), &auth.user_id).await?
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let globals: Vec<GlobalView> = mcp_global_servers::all(skald.db()).await?
|
||||
.into_iter()
|
||||
// A catalog manager needs to see globals they cannot themselves use, or an
|
||||
// entry enabled for someone else becomes invisible and unmanageable.
|
||||
.filter(|r| manages_catalog || granted.contains(&r.name))
|
||||
.map(|r| GlobalView {
|
||||
can_use: granted.contains(&r.name),
|
||||
id: r.id,
|
||||
name: r.name,
|
||||
catalog_name: r.catalog_name,
|
||||
friendly_name: r.friendly_name,
|
||||
description: r.description,
|
||||
transport: r.transport,
|
||||
enabled: r.enabled,
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(Json(json!({ "catalog": catalog, "globals": globals })))
|
||||
}
|
||||
|
||||
/// The connectors this user has already activated (per-user runtime).
|
||||
|
||||
Reference in New Issue
Block a user