Skip to content
Merged
4 changes: 3 additions & 1 deletion cmd/generate-types/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const HealthActionApprove = 'approve' as const;
export const HealthActionViewLogs = 'view_logs' as const;
export const HealthActionSetSecret = 'set_secret' as const;
export const HealthActionConfigure = 'configure' as const;
export const HealthActionEditURL = 'edit_url' as const;
export type HealthAction =
| typeof HealthActionNone
| typeof HealthActionLogin
Expand All @@ -82,7 +83,8 @@ export type HealthAction =
| typeof HealthActionApprove
| typeof HealthActionViewLogs
| typeof HealthActionSetSecret
| typeof HealthActionConfigure;
| typeof HealthActionConfigure
| typeof HealthActionEditURL;

export interface HealthStatus {
level: HealthLevel;
Expand Down
10 changes: 10 additions & 0 deletions docs/api/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -842,13 +842,23 @@ additive-compatible and gains two fields:
| `connected` | bool | mcpproxy registered in the config. Authoritative **only** when `access_state == "accessible"`; `false`/unresolved in the overall listing. |
| `access_state` | string | `"unknown"` in the overall listing (not content-checked); resolved to `"accessible"`, `"absent"`, `"malformed"`, or `"denied"` by an on-demand single-client read. |
| `remediation` | string | Present only when `access_state == "denied"`; carries the actionable fix text (App Data toggle + `tccutil reset` command). |
| `proxy_url` | string | **This** instance's MCP endpoint. Config-derived (no file read), so it is present on the overall listing too. |
| `registered_url` | string | The endpoint the client's existing entry actually points at, projected through the same sanitizer as a connect preview's `existing_entry_summary.endpoint`: **scheme, host and path only** — query (the `?apikey=` carrier), userinfo and fragment are dropped, and a value that is not an absolute URL is not echoed at all. Resolved only by an on-demand read. |
| `endpoint_match` | string | How `registered_url` relates to `proxy_url`: `"this"` (the entry addresses this instance), `"other"` (it addresses a different one), `"unknown"` (the entry has no comparable endpoint, e.g. a stdio command). Empty when `connected` is false or nothing was read. |

A client that is installed but not yet content-checked reads as
`exists=true, connected=false, access_state="unknown"`. Resolving `connected`
requires an explicit per-client read (the per-client status route below,
connect/disconnect, or the CLI `mcpproxy connect` command), which is where a
privacy prompt may legitimately appear.

**`connected` alone is not "connected to this instance."** It means an
mcpproxy-shaped entry is present in that client's config — and an entry merely
*named* `mcpproxy` counts, even when its URL addresses another instance on
another port. Consumers that need the stronger claim must check
`endpoint_match == "this"`; a UI showing a bare "Connected" on
`endpoint_match == "other"` is reporting someone else's link as its own.

#### GET /api/v1/connect/{client}

On-demand single-client status. Reads the one client's config **at request
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ let removeAPIListener: (() => void) | null = null
function handleAuthModalClose() {
authModal.show = false
authModal.lastError = ''
systemStore.setAuthRequired(false)
}

function handleAuthModalAuthenticated() {
authModal.show = false
authModal.lastError = ''
systemStore.setAuthRequired(false)

// Refresh data now that we're authenticated
systemStore.connectEventSource()
Expand All @@ -87,6 +89,7 @@ function handleAuthModalAuthenticated() {
function handleAuthModalRefresh() {
authModal.show = false
authModal.lastError = ''
systemStore.setAuthRequired(false)

// Reconnect with potentially new API key
systemStore.connectEventSource()
Expand All @@ -98,6 +101,9 @@ function handleAuthError(event: APIAuthEvent) {
console.log('Global auth error received:', event)
authModal.lastError = event.error
authModal.show = true
// Audit F28: one cause, one message. The modal now suppresses the reconnect
// toast and the inline load errors it would otherwise compete with.
systemStore.setAuthRequired(true)
}

onMounted(async () => {
Expand Down
27 changes: 20 additions & 7 deletions frontend/src/components/AuthErrorModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
<div class="alert alert-info mb-4">
<div class="flex-1">
<h4 class="font-semibold mb-2">How to get the API key:</h4>
<!-- Audit F28: headless and server installs have no tray, so the
tray route can't be the only one. The config file and the CLI
work everywhere. -->
<ol class="list-decimal list-inside space-y-1 text-sm">
<li><strong>Using Tray:</strong> Right-click the MCPProxy tray icon and select "Open Web UI"</li>
<li><strong>From Logs:</strong> Check mcpproxy startup logs for the API key, then add <code class="bg-base-200 px-1 rounded">?apikey=YOUR_KEY</code> to the URL</li>
<li><strong>Manual Entry:</strong> Enter your API key below if you have it</li>
<li><strong>From the CLI:</strong> run <code class="bg-base-200 px-1 rounded">mcpproxy doctor</code>, or read <code class="bg-base-200 px-1 rounded">api_key</code> in <code class="bg-base-200 px-1 rounded">~/.mcpproxy/mcp_config.json</code></li>
<li><strong>From logs:</strong> the key is printed in the mcpproxy startup log</li>
<li><strong>Using the tray</strong> (desktop installs): right-click the MCPProxy tray icon and select "Open Web UI" — it opens an already-authenticated window</li>
</ol>
</div>
</div>
</div>

<!-- Manual API Key Entry -->
<!-- Manual API Key Entry. Audit F28: the field was labelled "(optional)"
while being the only way in. -->
<div class="form-control mb-6">
<label class="label">
<span class="label-text font-semibold">Enter API Key (optional)</span>
<span class="label-text font-semibold">API key <span class="text-error">(required)</span></span>
</label>
<div class="input-group">
<input
Expand Down Expand Up @@ -72,8 +76,17 @@
</svg>
Refresh & Retry
</button>
<button v-if="canClose" class="btn btn-outline" @click="handleClose">
Continue Without Auth
<!-- Audit F28: "Continue Without Auth" led to a shell of zero-valued
tiles, so it must not sit at equal weight beside the real way in.
Demoted to a link, and honest about where it goes. -->
<button
v-if="canClose"
class="btn btn-ghost btn-sm text-base-content/60"
data-test="auth-dismiss"
title="The UI cannot load data without a key — pages will render empty"
@click="handleClose"
>
Dismiss (pages stay empty)
</button>
</div>
</div>
Expand Down
155 changes: 141 additions & 14 deletions frontend/src/components/ConnectModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@
<div class="min-w-0 flex-1">
<div class="font-medium text-sm truncate">{{ client.name }}</div>
<div class="text-xs opacity-50 truncate" :title="client.config_path">{{ client.config_path }}</div>
<!-- Audit F18: "which endpoint am I registered to?" was
unanswerable — a config merely holding an entry NAMED
mcpproxy read as connected, even pointing at another
instance on another port. Say where it points. -->
<div
v-if="client.connected && client.registered_url"
class="text-xs mt-0.5 truncate"
:class="client.endpoint_match === 'other' ? 'text-warning' : 'opacity-60'"
:title="endpointTitle(client)"
:data-test="`connect-endpoint-${client.id}`"
>
→ {{ client.registered_url }}
</div>
<div v-if="client.note" class="text-xs opacity-60 italic mt-0.5" :title="client.note">{{ client.note }}</div>
</div>
</div>
Expand All @@ -57,11 +70,31 @@
class="badge badge-warning badge-sm"
title="Config exists but could not be parsed"
>Unreadable config</span>
<span v-else-if="!client.exists && !client.bridge" class="text-xs opacity-40">Config not found</span>
<!-- Audit F18: one action pattern for every actionable row — a
button in one of three states — instead of a bare red text
link on some rows and a primary button on others. -->
<span
v-else-if="!client.exists && !client.bridge"
class="badge badge-ghost badge-sm"
:title="notFoundTitle(client)"
:data-test="`connect-not-found-${client.id}`"
>Not installed</span>
<button
v-else-if="client.connected && client.endpoint_match === 'other'"
:data-test="`connect-repoint-${client.id}`"
@click="startConnect(client.id)"
class="btn btn-warning btn-xs"
:disabled="loading.clients[client.id] || previewLoading[client.id]"
title="This client points at a different MCPProxy instance — review the change to repoint it here"
>
<span v-if="loading.clients[client.id] || previewLoading[client.id]" class="loading loading-spinner loading-xs"></span>
<span v-else>Point here</span>
</button>
<button
v-else-if="client.connected"
@click="disconnect(client.id)"
class="btn btn-ghost btn-xs text-error"
:data-test="`connect-disconnect-${client.id}`"
@click="askDisconnect(client)"
class="btn btn-outline btn-error btn-xs"
:disabled="loading.clients[client.id]"
>
<span v-if="loading.clients[client.id]" class="loading loading-spinner loading-xs"></span>
Expand All @@ -75,21 +108,32 @@
:disabled="loading.clients[client.id] || previewLoading[client.id]"
>
<span v-if="loading.clients[client.id] || previewLoading[client.id]" class="loading loading-spinner loading-xs"></span>
<span v-else>Review & connect</span>
<span v-else>Review &amp; connect</span>
</button>
<span
v-if="client.connected && client.endpoint_match === 'other'"
class="text-[0.7rem] text-warning"
:data-test="`connect-other-instance-${client.id}`"
>Connected to another instance</span>
<!-- Spec 075 US1: explicit, no-eager-read access check. The stat-only
listing leaves installed clients 'unknown'; this is the only
action that reads the config (the sole macOS privacy-prompt site). -->
<!-- Also offered for a row whose `connected` came from the merged
onboarding ids rather than a content read: that path knows the
entry exists but not which endpoint it names, and the read
stays an explicit user action (audit F18 + Spec 075). -->
<button
v-if="client.exists && accessState(client) === 'unknown' && !client.connected"
v-if="client.exists && accessState(client) === 'unknown' && !client.endpoint_match"
data-test="connect-check-access"
@click="checkAccess(client.id)"
class="btn btn-ghost btn-2xs h-auto min-h-0 py-0.5 text-[0.7rem] opacity-60 hover:opacity-100"
:disabled="checking[client.id]"
title="Read this client's config now to verify access (may prompt on macOS)"
:title="client.connected
? `Read this client's config now to see which MCPProxy endpoint it points at (may prompt on macOS)`
: `Read this client's config now to verify access (may prompt on macOS)`"
>
<span v-if="checking[client.id]" class="loading loading-spinner loading-xs"></span>
<span v-else>Check access</span>
<span v-else>{{ client.connected ? 'Verify endpoint' : 'Check access' }}</span>
</button>
</div>
</div>
Expand Down Expand Up @@ -336,16 +380,59 @@
</div>
</div>

<div class="modal-action">
<!-- Audit F18: the footer's primary said a bare "Connect All" while every
actionable row already said Disconnect, and went disabled with no
explanation. It now names the count it would change, and says why it
is off when it is. -->
<div class="modal-action items-center">
<span
v-if="connectableClients.length === 0 && !loading.initial"
class="text-xs opacity-60 mr-auto"
data-test="connect-all-hint"
>{{ connectAllDisabledReason }}</span>
<button
@click="connectAll"
class="btn btn-primary btn-sm"
:disabled="allConnected || connectableClients.length === 0"
data-test="connect-all"
:disabled="connectableClients.length === 0"
:title="connectableClients.length === 0 ? connectAllDisabledReason : ''"
>
Connect All
{{ connectableClients.length === 0
? 'Connect All'
: `Connect ${connectableClients.length} client${connectableClients.length === 1 ? '' : 's'}` }}
</button>
<button @click="close" class="btn btn-ghost btn-sm">Close</button>
</div>

<!-- Audit F18: disconnecting rewrites a user-owned config file. That is
never a one-click, unconfirmed text link. -->
<div v-if="disconnectTarget" class="modal modal-open" data-test="connect-disconnect-confirm">
<div class="modal-box max-w-md">
<h3 class="font-bold text-lg">Disconnect {{ disconnectTarget.name }}?</h3>
<p class="text-sm mt-2">
This removes the
<code class="font-mono">{{ disconnectTarget.server_name || 'mcpproxy' }}</code>
entry from
<code class="font-mono break-all">{{ disconnectTarget.config_path }}</code>.
</p>
<p class="text-sm text-base-content/70 mt-2">
A timestamped backup of the file is written first, and the path is shown afterwards
so you can restore it.
</p>
<div class="modal-action">
<button class="btn btn-ghost btn-sm" data-test="connect-disconnect-cancel" @click="disconnectTarget = null">Cancel</button>
<button
class="btn btn-error btn-sm"
data-test="connect-disconnect-confirm-button"
:disabled="loading.clients[disconnectTarget.id]"
@click="confirmDisconnect"
>
<span v-if="loading.clients[disconnectTarget.id]" class="loading loading-spinner loading-xs"></span>
Disconnect
</button>
</div>
</div>
</div>
</div>
<form method="dialog" class="modal-backdrop" @click.prevent="close"><button>close</button></form>
</dialog>
Expand Down Expand Up @@ -445,14 +532,54 @@ const connectableClients = computed(() =>
// Bridge clients (e.g. Claude Desktop) can be connected even without an
// existing config file — Connect creates it. A client macOS has blocked
// ('denied') is excluded: the write would fail with the same privacy error.
// A row pointing at ANOTHER instance is excluded too: repointing someone
// else's config is a deliberate per-row decision, not a bulk side effect.
mergedClients.value.filter(
c => c.supported && (c.exists || c.bridge) && !c.connected && accessState(c) !== 'denied'
c =>
c.supported &&
(c.exists || c.bridge) &&
!c.connected &&
accessState(c) !== 'denied'
)
)

const allConnected = computed(() =>
connectableClients.value.length === 0
)
// Audit F18: a disabled primary must say what would enable it. The reasons are
// mutually exclusive in practice, so the most specific one wins.
const connectAllDisabledReason = computed(() => {
const supported = mergedClients.value.filter(c => c.supported)
if (supported.length === 0) return 'No supported MCP clients found on this machine.'
if (supported.every(c => c.connected)) return 'Every supported client is already connected.'
if (supported.some(c => accessState(c) === 'denied')) {
return 'The remaining clients are blocked by macOS — fix access above first.'
}
return 'No client on this machine is ready to connect.'
})

function endpointTitle(client: ClientStatus): string {
if (client.endpoint_match === 'other') {
return `This client is registered to ${client.registered_url}, not to this instance (${client.proxy_url ?? 'unknown'}).`
}
return `Registered to ${client.registered_url}`
}

function notFoundTitle(client: ClientStatus): string {
const paths = client.checked_paths?.length ? client.checked_paths : [client.config_path]
return `No config file found. Looked in:\n${paths.join('\n')}`
}

// --- Disconnect confirmation (audit F18) ---
const disconnectTarget = ref<ClientStatus | null>(null)

function askDisconnect(client: ClientStatus) {
disconnectTarget.value = client
}

async function confirmDisconnect() {
const target = disconnectTarget.value
if (!target) return
await disconnect(target.id)
disconnectTarget.value = null
}

function clientIcon(client: ClientStatus): string {
// Map client icons based on id/name
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/ConnectionStatus.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<template>
<!-- Audit F28: while the Authentication Required modal is up, the SSE stream
is down *because* there is no key. Repeating that as a second, vaguer
message ("Connection Lost — Reconnecting…") only competes with the one
screen that can actually fix it. -->
<div
v-if="!systemStore.connected"
v-if="!systemStore.connected && !systemStore.authRequired"
class="fixed bottom-4 left-4 alert alert-warning shadow-lg max-w-sm z-40"
data-test="connection-lost-toast"
>
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.732-.833-2.5 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z" />
Expand All @@ -17,4 +22,4 @@
import { useSystemStore } from '@/stores/system'

const systemStore = useSystemStore()
</script>
</script>
Loading
Loading