Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions docs/features/sensitive-data-detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,32 @@ When sensitive data is detected, it is recorded in the activity log metadata:
```

:::caution Redaction
Detected sensitive values are automatically redacted in the activity log to prevent secondary exposure. Only the type, category, and partial context are stored.
A detection record itself never carries the value that triggered it — only the type, category, severity and location are stored.
:::

### Masked payloads

A detection is stored alongside the call it came from, and that call's arguments and response are kept for debugging. Serving those verbatim would mean the screen that warns you about a credential also prints it, in cleartext, next to a Copy button — into every screenshot, screen-share and exported page.

So MCPProxy masks them **server-side**, in the REST layer, before the record leaves the process:

- `GET /api/v1/activity` and `GET /api/v1/activity/{id}` replace every detected value inside `arguments`, `response` and `error_message` with a recognisable preview — `AKIAIOSFODNN7EXAMPLE` becomes `AKIA…****`. Enough to tell you *which* credential to rotate, not enough to use. A private key is replaced whole, envelope and body: its pattern matches only the `-----BEGIN …-----` line, and masking that alone would leave the key readable.
- Masking applies to records the detector flagged (`has_sensitive_data: true`); an unflagged payload is served unchanged. Detection runs asynchronously just after the call is recorded, so a record read in that sub-second window is not yet flagged and is served unmasked.
- The live event stream (`GET /events`, and therefore the tray and `mcpproxy activity watch`) masks **unconditionally**: those events are emitted at completion time, before the detector has a verdict to gate on.
- `GET /api/v1/tool-calls` and friends — a separate store with no detection metadata — mask unconditionally too.
- Internal `_auth_*` arguments (the server-edition identity MCPProxy injects into a call) are stripped from every browsing response.
- The Web UI's activity drawer and `mcpproxy activity show` both read the activity endpoints, so both are masked.

Full values remain reachable through one deliberate, separately-flagged surface for incident response and compliance:

```bash
mcpproxy activity export --include-bodies
```

That export deliberately keeps `_auth_*` as well: attributing a call to a user is the point of a compliance export.

Masking follows the same `sensitive_data_detection` categories as detection — a category you exclude is neither flagged nor masked. It does **not** follow the `enabled` flag: records flagged while detection was on stay masked after you turn it off, so disabling the feature never starts serving old credentials.

## Web UI Usage

The Activity Log page in the web UI provides filtering and visualization for sensitive data detections.
Expand All @@ -214,8 +237,8 @@ Clicking on an activity with detections shows:

- List of all detected sensitive data types
- Location (arguments or response)
- Redacted context for verification
- Timestamp and duration
- The request arguments and response body, with every detected value masked (`AKIA…****`) and both panels badged **Masked** — see [Masked payloads](#masked-payloads)

## CLI Usage

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/SidebarNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,8 @@ const teamsUserMenu = [
{ name: 'My Activity', path: '/my/activity' },
{ name: 'Agent Tokens', path: '/my/tokens' },
{ name: 'Diagnostics', path: '/my/diagnostics' },
{ name: 'Search', path: '/search' },
// Tools is the canonical search surface since /search folded into it (F20).
{ name: 'Tools', path: '/tools' },
]

const teamsAdminMenu = [
Expand Down
36 changes: 19 additions & 17 deletions frontend/src/components/TopHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
@keydown.enter="handleSearch"
/>
</div>
<!-- Always enabled: greyed out next to an empty box read as broken
(audit F20/F32). With nothing typed it simply opens Tools. -->
<button
@click="handleSearch"
class="btn btn-primary"
:disabled="!searchQuery.trim()"
data-test="header-search-button"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
Expand Down Expand Up @@ -67,8 +69,14 @@
<span class="text-xs opacity-60">Tools</span>
</div>

<!-- Routing Mode -->
<div class="flex items-center space-x-2 px-3 py-2 bg-base-200 rounded-lg text-sm">
<!-- Routing Mode. The label alone is jargon (audit F31), so the badge
carries what the mode actually does to a connecting agent. -->
<div
class="flex items-center space-x-2 px-3 py-2 bg-base-200 rounded-lg text-sm cursor-help"
:title="routingMode.description"
:aria-label="`Routing mode: ${routingMode.description}`"
data-test="routing-mode-badge"
>
<span class="text-xs opacity-60">Mode:</span>
<span class="font-medium">{{ routingModeLabel }}</span>
</div>
Expand Down Expand Up @@ -141,6 +149,7 @@ import { useServersStore } from '@/stores/servers'
import { useAuthStore } from '@/stores/auth'
import AddServerModal from './AddServerModal.vue'
import ProfileSwitcher from './ProfileSwitcher.vue'
import { routingModeMeta } from '@/utils/routingMode'

const router = useRouter()
const systemStore = useSystemStore()
Expand All @@ -149,17 +158,8 @@ const authStore = useAuthStore()

const addServerLabel = computed(() => authStore.isTeamsEdition ? 'Add Personal Server' : 'Add Server')

const routingModeLabel = computed(() => {
const mode = systemStore.routingMode
switch (mode) {
case 'direct':
return 'Direct'
case 'code_execution':
return 'Code Exec'
default:
return 'Retrieve'
}
})
const routingMode = computed(() => routingModeMeta(systemStore.routingMode))
const routingModeLabel = computed(() => routingMode.value.label)

const searchQuery = ref('')
const showAddServerModal = ref(false)
Expand Down Expand Up @@ -222,10 +222,12 @@ async function copyEndpoint(ep: McpEndpoint) {
}
}

// One canonical search surface (audit F20): the header box hands its query to
// the Tools page instead of the retired /search view. An empty box is not an
// error — it opens Tools unfiltered rather than leaving the button dead.
function handleSearch() {
if (searchQuery.value.trim()) {
router.push({ path: '/search', query: { q: searchQuery.value } })
}
const q = searchQuery.value.trim()
router.push(q ? { path: '/tools', query: { q } } : { path: '/tools' })
}

function handleServerAdded() {
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ const router = createRouter({
title: 'Repositories',
},
},
// `/search` used to be a third, sidebar-less search surface duplicating the
// header box and the Tools page (audit F20). Tools is the canonical one —
// it is in the sidebar, it lists what it searches, and it can act on the
// results — so the orphan route now folds into it, carrying `?q=` across so
// old links and bookmarks still land on their query.
{
path: '/search',
name: 'search',
component: () => import('@/views/Search.vue'),
meta: {
title: 'Search',
},
redirect: (to) => ({ path: '/tools', query: to.query, hash: to.hash }),
},
{
path: '/settings',
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/stores/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,15 @@ export const useSystemStore = defineStore('system', () => {
}
})

// Listen for activity events (tool calls, policy decisions, etc.)
// Listen for activity events (tool calls, policy decisions, etc.).
//
// These payloads carry the call's raw arguments and response, so they are
// NOT logged: `console.log(data)` printed whatever secret the call carried
// straight into the DevTools console, which is the same leak the activity
// drawer was fixed for (audit F13). Only parse failures are logged.
es.addEventListener('activity.tool_call.started', (event) => {
try {
const data = JSON.parse(event.data)
console.log('SSE activity.tool_call.started event received:', data)
// Extract payload - SSE wraps activity data in {payload: ..., timestamp: ...}
const payload = data.payload || data
window.dispatchEvent(new CustomEvent('mcpproxy:activity-started', { detail: payload }))
Expand All @@ -224,7 +228,6 @@ export const useSystemStore = defineStore('system', () => {
es.addEventListener('activity.tool_call.completed', (event) => {
try {
const data = JSON.parse(event.data)
console.log('SSE activity.tool_call.completed event received:', data)
// Extract payload - SSE wraps activity data in {payload: ..., timestamp: ...}
const payload = data.payload || data
window.dispatchEvent(new CustomEvent('mcpproxy:activity-completed', { detail: payload }))
Expand All @@ -236,7 +239,6 @@ export const useSystemStore = defineStore('system', () => {
es.addEventListener('activity.policy_decision', (event) => {
try {
const data = JSON.parse(event.data)
console.log('SSE activity.policy_decision event received:', data)
// Extract payload - SSE wraps activity data in {payload: ..., timestamp: ...}
const payload = data.payload || data
window.dispatchEvent(new CustomEvent('mcpproxy:activity-policy', { detail: payload }))
Expand All @@ -248,7 +250,6 @@ export const useSystemStore = defineStore('system', () => {
es.addEventListener('activity', (event) => {
try {
const data = JSON.parse(event.data)
console.log('SSE activity event received:', data)
// Extract payload - SSE wraps activity data in {payload: ..., timestamp: ...}
const payload = data.payload || data
window.dispatchEvent(new CustomEvent('mcpproxy:activity', { detail: payload }))
Expand All @@ -261,7 +262,6 @@ export const useSystemStore = defineStore('system', () => {
es.addEventListener('activity.internal_tool_call.completed', (event) => {
try {
const data = JSON.parse(event.data)
console.log('SSE activity.internal_tool_call.completed event received:', data)
const payload = data.payload || data
window.dispatchEvent(new CustomEvent('mcpproxy:activity-completed', { detail: payload }))
} catch (error) {
Expand Down
42 changes: 42 additions & 0 deletions frontend/src/utils/routingMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Routing-mode vocabulary for the header badge.
*
* `Mode: Retrieve` sat in the header with nothing to explain it (audit F31) —
* it is the single most consequential setting on the page (it decides what an
* agent sees when it connects) and it was rendered as a bare word. Label and
* explanation live together here so the badge, its tooltip and any future
* surface cannot drift apart.
*/

export interface RoutingModeMeta {
/** Compact label rendered in the header badge. */
label: string
/** One-sentence explanation, shown as the badge's tooltip. */
description: string
}

const RETRIEVE: RoutingModeMeta = {
label: 'Retrieve',
description:
'Retrieve mode: agents search for the tools they need with retrieve_tools, then call them — only matching tools enter the agent’s context.',
}

const ROUTING_MODES: Record<string, RoutingModeMeta> = {
direct: {
label: 'Direct',
description:
'Direct mode: every enabled tool from every server is listed to the agent up front — no search step, but the full tool list costs context.',
},
code_execution: {
label: 'Code Exec',
description:
'Code execution mode: agents orchestrate several upstream tools from one sandboxed JavaScript call, discovering them with retrieve_tools.',
},
retrieve_tools: RETRIEVE,
}

/** Metadata for a routing mode, falling back to Retrieve — the default. */
export function routingModeMeta(mode: string | undefined | null): RoutingModeMeta {
if (!mode) return RETRIEVE
return ROUTING_MODES[mode] ?? RETRIEVE
}
26 changes: 26 additions & 0 deletions frontend/src/views/Activity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,16 @@
</div>
</div>
</div>
<!-- The payloads below are masked by the SERVER before this
drawer ever sees them (audit F13): a drawer that prints
the credential it just flagged leaks it into every
screenshot and screen-share. Say so, so the mask does not
read as a rendering glitch. -->
<div class="text-xs text-inherit/80" data-test="sensitive-mask-note">
Detected values are masked below (e.g. <code class="font-mono">AKIA…****</code>). Full values are
only available from the explicit export:
<code class="font-mono">mcpproxy activity export --include-bodies</code>.
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -869,6 +879,14 @@
<h4 class="font-semibold mb-2 flex items-center gap-2">
Request Arguments
<span class="badge badge-sm badge-info">JSON</span>
<span
v-if="selectedActivity.has_sensitive_data"
class="badge badge-sm badge-warning"
title="Detected secrets are masked by the server before this view receives them"
data-test="arguments-masked-badge"
>
Masked
</span>
</h4>
<JsonViewer :data="selectedActivity.arguments" max-height="12rem" />
</div>
Expand All @@ -879,6 +897,14 @@
Response Body
<span class="badge badge-sm badge-info">JSON</span>
<span v-if="selectedActivity.response_truncated" class="badge badge-sm badge-warning">Truncated</span>
<span
v-if="selectedActivity.has_sensitive_data"
class="badge badge-sm badge-warning"
title="Detected secrets are masked by the server before this view receives them"
data-test="response-masked-badge"
>
Masked
</span>
</h4>
<JsonViewer :data="parseResponseData(selectedActivity.response)" max-height="16rem" />
</div>
Expand Down
Loading
Loading