-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
fix(mcp): stop exposing MCP server URLs on the AI Hub and public hub API #30902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import { render, screen } from "@testing-library/react"; | ||
| import { vi } from "vitest"; | ||
| import { flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table"; | ||
| import { mcpHubColumns, MCPServerData } from "./mcp_hub_table_columns"; | ||
|
|
||
| const SERVER_URL = "https://mcp.exa.ai/mcp"; | ||
|
|
||
| const mockServer: MCPServerData = { | ||
| server_id: "server-1", | ||
| server_name: "exa_test", | ||
| description: "Fast, intelligent web search and web crawling", | ||
| url: SERVER_URL, | ||
| transport: "http", | ||
| auth_type: "none", | ||
| created_at: "2026-01-01T00:00:00Z", | ||
| created_by: "admin", | ||
| updated_at: "2026-01-01T00:00:00Z", | ||
| updated_by: "admin", | ||
| teams: [], | ||
| mcp_access_groups: [], | ||
| allowed_tools: [], | ||
| extra_headers: [], | ||
| mcp_info: {}, | ||
| static_headers: {}, | ||
| status: "active", | ||
| args: [], | ||
| env: {}, | ||
| }; | ||
|
|
||
| function TestTable({ data }: { data: MCPServerData[] }) { | ||
| const columns = mcpHubColumns(vi.fn(), vi.fn(), false); | ||
| const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel() }); | ||
|
|
||
| return ( | ||
| <table> | ||
| <thead> | ||
| {table.getHeaderGroups().map((hg) => ( | ||
| <tr key={hg.id}> | ||
| {hg.headers.map((h) => ( | ||
| <th key={h.id}>{flexRender(h.column.columnDef.header, h.getContext())}</th> | ||
| ))} | ||
| </tr> | ||
| ))} | ||
| </thead> | ||
| <tbody> | ||
| {table.getRowModel().rows.map((row) => ( | ||
| <tr key={row.id}> | ||
| {row.getVisibleCells().map((cell) => ( | ||
| <td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td> | ||
| ))} | ||
| </tr> | ||
| ))} | ||
| </tbody> | ||
| </table> | ||
| ); | ||
| } | ||
|
|
||
| describe("mcpHubColumns", () => { | ||
| it("renders the server row", () => { | ||
| render(<TestTable data={[mockServer]} />); | ||
| expect(screen.getByText("exa_test")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("keeps the non-sensitive columns", () => { | ||
| render(<TestTable data={[mockServer]} />); | ||
| expect(screen.getByText("Server Name")).toBeInTheDocument(); | ||
| expect(screen.getByText("Transport")).toBeInTheDocument(); | ||
| expect(screen.getByText("Auth Type")).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it("does not expose a URL column header", () => { | ||
| render(<TestTable data={[mockServer]} />); | ||
| expect(screen.queryByText("URL")).not.toBeInTheDocument(); | ||
| expect(mcpHubColumns(vi.fn(), vi.fn(), false).some((c) => c.header === "URL")).toBe(false); | ||
| }); | ||
|
|
||
| it("does not render the server url anywhere in the table", () => { | ||
| render(<TestTable data={[mockServer]} />); | ||
| expect(screen.queryByText(SERVER_URL)).not.toBeInTheDocument(); | ||
| }); | ||
| }); | ||
|
Comment on lines
+57
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new test suite only exercises Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Comment on lines
+58
to
+81
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new test file only validates Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion
c.header === "URL"only matches a column whoseheaderproperty is the exact string"URL". If someone re-adds the column with a header like"Server URL", a React node, or even a function, the check passes even though the URL is rendered. The companionqueryByText(SERVER_URL)test at line 79 catches rendered output and is the stronger guard; consider removing the brittle static check or complementing it with anaccessorKeyassertion (e.g.,c.accessorKey !== "url") so the test actually fails if the URL data is wired back up regardless of the label used.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!