feat(plugin): admin-configurable marketplace URL as the install default
CI & Build / Python lint (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Successful in 46s
CI & Build / Build & push image (push) Successful in 59s

The Settings install command had a <your-scribe-repo> placeholder — not
copyable. Add an instance-global 'plugin_marketplace_url' setting (admin sets
it to the app's own repo) that every user's MCP Access reads, so the
/plugin marketplace add command is copyable out of the box. Keeps it universal
(each deployment configures its own repo) rather than hardcoding one.

- services/settings.get_admin_setting(key): admin-scoped global read.
- routes/plugin: GET /api/plugin/marketplace-url (any user) + PUT (admin).
- SettingsView: Admin → 'Plugin marketplace' field to set it; MCP Access
  marketplace field falls back to the configured value.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-10 00:17:05 -04:00
parent b1674169a0
commit 1d82e81527
3 changed files with 112 additions and 2 deletions
+65 -1
View File
@@ -144,8 +144,16 @@ const claudeCodeCommand = computed(() => {
const _MKT_KEY = 'plugin_marketplace_url';
const pluginMarketplaceUrl = ref<string>(localStorage.getItem(_MKT_KEY) || '');
watch(pluginMarketplaceUrl, (v) => localStorage.setItem(_MKT_KEY, (v || '').trim()));
// Instance default, set by an admin (Admin tab) and loaded on mount. Used when
// the per-browser field is blank so the install command is copyable out of the box.
const serverMarketplaceUrl = ref('');
const adminMarketplaceUrl = ref('');
const savingMarketplaceUrl = ref(false);
const marketplaceUrlSaved = ref(false);
const pluginInstallCommands = computed(() => {
const mkt = (pluginMarketplaceUrl.value || '').trim() || '<your-scribe-repo>.git';
const mkt = (pluginMarketplaceUrl.value || '').trim()
|| serverMarketplaceUrl.value
|| '<your-scribe-repo>.git';
return `/plugin marketplace add ${mkt}\n/plugin install scribe@scribe-plugin`;
});
@@ -429,6 +437,17 @@ onMounted(async () => {
searxngConfigured.value = false;
}
// Plugin marketplace URL (instance default; readable by all users so the
// install command in MCP Access is copyable).
try {
const mk = await apiGet<{ marketplace_url: string }>("/api/plugin/marketplace-url");
serverMarketplaceUrl.value = mk.marketplace_url || "";
adminMarketplaceUrl.value = mk.marketplace_url || "";
if (!pluginMarketplaceUrl.value) pluginMarketplaceUrl.value = mk.marketplace_url || "";
} catch {
// not configured yet
}
// Load admin settings
if (authStore.isAdmin) {
try {
@@ -658,6 +677,26 @@ async function saveBaseUrl() {
}
}
async function saveMarketplaceUrl() {
savingMarketplaceUrl.value = true;
marketplaceUrlSaved.value = false;
try {
const url = adminMarketplaceUrl.value.trim();
await apiPut("/api/plugin/marketplace-url", { marketplace_url: url });
serverMarketplaceUrl.value = url;
// Reflect the new instance default in the copyable field unless the user
// set their own per-browser override.
if (!localStorage.getItem(_MKT_KEY)) pluginMarketplaceUrl.value = url;
marketplaceUrlSaved.value = true;
setTimeout(() => (marketplaceUrlSaved.value = false), 2000);
} catch (e) {
const body = (e as { body?: { error?: string } }).body;
toastStore.show(body?.error || "Failed to save marketplace URL", "error");
} finally {
savingMarketplaceUrl.value = false;
}
}
async function handleRestoreFile(event: Event) {
const file = (event.target as HTMLInputElement).files?.[0];
if (!file) return;
@@ -1663,6 +1702,31 @@ function formatUserDate(iso: string): string {
</div>
</section>
<section class="settings-section full-width">
<h2>Plugin marketplace</h2>
<p class="section-desc">
Git URL of the repo that ships this Scribe plugin (usually this app's own repo).
Shown to every user in <strong>MCP Access</strong> so the install command is
copyable. Example: https://git.example.com/you/Scribe.git
</p>
<div class="field url-field">
<label for="marketplace-url">Marketplace git URL</label>
<input
id="marketplace-url"
v-model="adminMarketplaceUrl"
type="url"
placeholder="https://git.example.com/you/Scribe.git"
class="input"
/>
</div>
<div class="actions">
<button class="btn-save" @click="saveMarketplaceUrl" :disabled="savingMarketplaceUrl">
{{ savingMarketplaceUrl ? "Saving..." : "Save" }}
</button>
<span v-if="marketplaceUrlSaved" class="saved-msg">Saved!</span>
</div>
</section>
<section class="settings-section full-width">
<h2>Email / SMTP</h2>
<p class="section-desc">Configure SMTP to enable email notifications for all users.</p>
+29 -1
View File
@@ -10,11 +10,17 @@ from __future__ import annotations
from quart import Blueprint, g, jsonify, request
from scribe.auth import login_required
from scribe.auth import admin_required, get_current_user_id, login_required
from scribe.services import plugin_context as plugin_ctx_svc
from scribe.services.settings import get_admin_setting, set_setting
plugin_bp = Blueprint("plugin", __name__, url_prefix="/api/plugin")
# Setting key for the git URL of the marketplace that serves this plugin (the
# Scribe app's own repo). Instance-global (stored on an admin account) so every
# user's Settings page shows the real, copyable install command.
_MARKETPLACE_KEY = "plugin_marketplace_url"
@plugin_bp.get("/context")
@login_required
@@ -30,3 +36,25 @@ async def session_context():
project_id = 0
result = await plugin_ctx_svc.build_session_context(g.user.id, project_id)
return jsonify(result)
@plugin_bp.get("/marketplace-url")
@login_required
async def get_marketplace_url():
"""The plugin marketplace git URL, readable by any logged-in user so their
Settings page can show a copyable install command."""
return jsonify({"marketplace_url": await get_admin_setting(_MARKETPLACE_KEY)})
@plugin_bp.put("/marketplace-url")
@admin_required
async def set_marketplace_url():
"""Admin-set the marketplace git URL (e.g. this app's own repo)."""
data = await request.get_json() or {}
url = (data.get("marketplace_url") or "").strip()
if url:
scheme = url.split("://")[0].lower() if "://" in url else ""
if scheme not in ("http", "https"):
return jsonify({"error": "Marketplace URL must use http or https"}), 400
await set_setting(get_current_user_id(), _MARKETPLACE_KEY, url)
return jsonify({"status": "ok"})
+18
View File
@@ -4,10 +4,28 @@ from sqlalchemy import delete as sa_delete, select
from scribe.models import async_session
from scribe.models.setting import Setting
from scribe.models.user import User
logger = logging.getLogger(__name__)
async def get_admin_setting(key: str, default: str = "") -> str:
"""Read an instance-global setting (one stored on an admin account).
Used for settings that aren't per-user — e.g. the plugin marketplace URL
shown to everyone in Settings. Mirrors the admin-scoped lookup used for
the application base URL.
"""
async with async_session() as session:
result = await session.execute(
select(Setting)
.join(User, Setting.user_id == User.id)
.where(User.role == "admin", Setting.key == key)
)
setting = result.scalars().first()
return setting.value if setting and setting.value else default
async def get_setting(user_id: int, key: str, default: str = "") -> str:
async with async_session() as session:
result = await session.execute(