Skip to content

Commit 6e32417

Browse files
authored
fix: hide MCP server credentials from non-owners (cgoinglove#317) (cgoinglove#319)
1 parent c0a8b5b commit 6e32417

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/app/api/mcp/list/route.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ export async function GET() {
4242
const result = servers.map((server) => {
4343
const mem = memoryMap.get(server.id);
4444
const info = mem?.getInfo();
45+
const isOwner = server.userId === currentUser.id;
4546
const mcpInfo: MCPServerInfo = {
4647
...server,
48+
// Hide config from non-owners to prevent credential exposure
49+
config: isOwner ? server.config : undefined,
4750
enabled: info?.enabled ?? true,
4851
status: info?.status ?? "connected",
4952
error: info?.error,

src/components/mcp-card.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -303,19 +303,24 @@ export const MCPCard = memo(function MCPCard({
303303

304304
<div className="relative hidden sm:flex w-full">
305305
<CardContent className="flex min-w-0 w-full flex-row text-sm max-h-[320px] overflow-hidden border-r-0">
306-
<div className="w-1/2 min-w-0 flex flex-col pr-2 border-r border-border">
307-
<div className="flex items-center gap-2 mb-2 pt-2 pb-1 z-10">
308-
<Settings size={14} className="text-muted-foreground" />
309-
<h5 className="text-muted-foreground text-sm font-medium">
310-
{t("configuration")}
311-
</h5>
312-
</div>
313-
<div className="flex-1 overflow-y-auto">
314-
<JsonView data={config} />
306+
{/* Only show config to owners to prevent credential exposure */}
307+
{isOwner && config && (
308+
<div className="w-1/2 min-w-0 flex flex-col pr-2 border-r border-border">
309+
<div className="flex items-center gap-2 mb-2 pt-2 pb-1 z-10">
310+
<Settings size={14} className="text-muted-foreground" />
311+
<h5 className="text-muted-foreground text-sm font-medium">
312+
{t("configuration")}
313+
</h5>
314+
</div>
315+
<div className="flex-1 overflow-y-auto">
316+
<JsonView data={config} />
317+
</div>
315318
</div>
316-
</div>
319+
)}
317320

318-
<div className="w-1/2 min-w-0 flex flex-col pl-4">
321+
<div
322+
className={`${isOwner && config ? "w-1/2" : "w-full"} min-w-0 flex flex-col ${isOwner && config ? "pl-4" : ""}`}
323+
>
319324
<div className="flex items-center gap-2 mb-4 pt-2 pb-1 z-10">
320325
<Wrench size={14} className="text-muted-foreground" />
321326
<h5 className="text-muted-foreground text-sm font-medium">

src/types/mcp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export type MCPToolInfo = {
4242
export type MCPServerInfo = {
4343
id: string;
4444
name: string;
45-
config: MCPServerConfig;
45+
config?: MCPServerConfig; // Optional - hidden from non-owners for security
4646
visibility: "public" | "private";
4747
error?: unknown;
4848
enabled: boolean;

0 commit comments

Comments
 (0)