Spaces:
Running
Running
minimize the diff
Browse files- components/mcp-server-manager.tsx +13 -13
- lib/context/mcp-context.tsx +4 -4
- lib/mcp-client.ts +2 -1
components/mcp-server-manager.tsx
CHANGED
@@ -48,7 +48,7 @@ import {
|
|
48 |
const INITIAL_NEW_SERVER: Omit<MCPServer, 'id'> = {
|
49 |
name: '',
|
50 |
url: '',
|
51 |
-
type: '
|
52 |
command: 'node',
|
53 |
args: [],
|
54 |
env: [],
|
@@ -189,7 +189,7 @@ export const MCPServerManager = ({
|
|
189 |
return;
|
190 |
}
|
191 |
|
192 |
-
if (newServer.type === '
|
193 |
toast.error("Server URL is required for HTTP or SSE transport");
|
194 |
return;
|
195 |
}
|
@@ -432,7 +432,7 @@ export const MCPServerManager = ({
|
|
432 |
toast.error("Server name is required");
|
433 |
return;
|
434 |
}
|
435 |
-
if (newServer.type === '
|
436 |
toast.error("Server URL is required for HTTP or SSE transport");
|
437 |
return;
|
438 |
}
|
@@ -516,7 +516,7 @@ export const MCPServerManager = ({
|
|
516 |
// UI element to display the correct server URL
|
517 |
const getServerDisplayUrl = (server: MCPServer): string => {
|
518 |
// Always show the configured URL or command, not the sandbox URL
|
519 |
-
return server.type === '
|
520 |
? server.url
|
521 |
: `${server.command} ${server.args?.join(' ')}`;
|
522 |
};
|
@@ -591,7 +591,7 @@ export const MCPServerManager = ({
|
|
591 |
{/* Server Header with Type Badge and Actions */}
|
592 |
<div className="flex items-center justify-between mb-2">
|
593 |
<div className="flex items-center gap-2">
|
594 |
-
{server.type === '
|
595 |
<Globe className={`h-4 w-4 ${isActive ? 'text-primary' : 'text-muted-foreground'} flex-shrink-0`} />
|
596 |
) : (
|
597 |
<Terminal className={`h-4 w-4 ${isActive ? 'text-primary' : 'text-muted-foreground'} flex-shrink-0`} />
|
@@ -729,14 +729,14 @@ export const MCPServerManager = ({
|
|
729 |
<div className="grid gap-2 grid-cols-2">
|
730 |
<button
|
731 |
type="button"
|
732 |
-
onClick={() => setNewServer({ ...newServer, type: '
|
733 |
className={`flex items-center gap-2 p-3 rounded-md text-left border transition-all ${
|
734 |
-
newServer.type === '
|
735 |
? 'border-primary bg-primary/10 ring-1 ring-primary'
|
736 |
: 'border-border hover:border-border/80 hover:bg-muted/50'
|
737 |
}`}
|
738 |
>
|
739 |
-
<Globe className={`h-5 w-5 shrink-0 ${newServer.type === '
|
740 |
<div>
|
741 |
<p className="font-medium">HTTP / SSE</p>
|
742 |
<p className="text-xs text-muted-foreground">Server-Sent Events</p>
|
@@ -762,7 +762,7 @@ export const MCPServerManager = ({
|
|
762 |
</div>
|
763 |
</div>
|
764 |
|
765 |
-
{newServer.type === '
|
766 |
<div className="grid gap-1.5">
|
767 |
<Label htmlFor="url">
|
768 |
Server URL
|
@@ -940,7 +940,7 @@ export const MCPServerManager = ({
|
|
940 |
|
941 |
<AccordionItem value="headers">
|
942 |
<AccordionTrigger className="text-sm py-2">
|
943 |
-
{newServer.type === '
|
944 |
</AccordionTrigger>
|
945 |
<AccordionContent>
|
946 |
<div className="space-y-3">
|
@@ -1050,11 +1050,11 @@ export const MCPServerManager = ({
|
|
1050 |
</div>
|
1051 |
) : (
|
1052 |
<p className="text-xs text-muted-foreground text-center py-2">
|
1053 |
-
No {newServer.type === '
|
1054 |
</p>
|
1055 |
)}
|
1056 |
<p className="text-xs text-muted-foreground">
|
1057 |
-
{newServer.type === '
|
1058 |
? 'HTTP headers will be sent with requests to the HTTP or SSE endpoint.'
|
1059 |
: 'Additional configuration parameters for the stdio transport.'}
|
1060 |
</p>
|
@@ -1098,7 +1098,7 @@ export const MCPServerManager = ({
|
|
1098 |
onClick={editingServerId ? updateServer : addServer}
|
1099 |
disabled={
|
1100 |
!newServer.name ||
|
1101 |
-
(newServer.type === '
|
1102 |
(newServer.type === 'stdio' && (!newServer.command || !newServer.args?.length))
|
1103 |
}
|
1104 |
>
|
|
|
48 |
const INITIAL_NEW_SERVER: Omit<MCPServer, 'id'> = {
|
49 |
name: '',
|
50 |
url: '',
|
51 |
+
type: 'sse',
|
52 |
command: 'node',
|
53 |
args: [],
|
54 |
env: [],
|
|
|
189 |
return;
|
190 |
}
|
191 |
|
192 |
+
if (newServer.type === 'sse' && !newServer.url) {
|
193 |
toast.error("Server URL is required for HTTP or SSE transport");
|
194 |
return;
|
195 |
}
|
|
|
432 |
toast.error("Server name is required");
|
433 |
return;
|
434 |
}
|
435 |
+
if (newServer.type === 'sse' && !newServer.url) {
|
436 |
toast.error("Server URL is required for HTTP or SSE transport");
|
437 |
return;
|
438 |
}
|
|
|
516 |
// UI element to display the correct server URL
|
517 |
const getServerDisplayUrl = (server: MCPServer): string => {
|
518 |
// Always show the configured URL or command, not the sandbox URL
|
519 |
+
return server.type === 'sse'
|
520 |
? server.url
|
521 |
: `${server.command} ${server.args?.join(' ')}`;
|
522 |
};
|
|
|
591 |
{/* Server Header with Type Badge and Actions */}
|
592 |
<div className="flex items-center justify-between mb-2">
|
593 |
<div className="flex items-center gap-2">
|
594 |
+
{server.type === 'sse' ? (
|
595 |
<Globe className={`h-4 w-4 ${isActive ? 'text-primary' : 'text-muted-foreground'} flex-shrink-0`} />
|
596 |
) : (
|
597 |
<Terminal className={`h-4 w-4 ${isActive ? 'text-primary' : 'text-muted-foreground'} flex-shrink-0`} />
|
|
|
729 |
<div className="grid gap-2 grid-cols-2">
|
730 |
<button
|
731 |
type="button"
|
732 |
+
onClick={() => setNewServer({ ...newServer, type: 'sse' })}
|
733 |
className={`flex items-center gap-2 p-3 rounded-md text-left border transition-all ${
|
734 |
+
newServer.type === 'sse'
|
735 |
? 'border-primary bg-primary/10 ring-1 ring-primary'
|
736 |
: 'border-border hover:border-border/80 hover:bg-muted/50'
|
737 |
}`}
|
738 |
>
|
739 |
+
<Globe className={`h-5 w-5 shrink-0 ${newServer.type === 'sse' ? 'text-primary' : ''}`} />
|
740 |
<div>
|
741 |
<p className="font-medium">HTTP / SSE</p>
|
742 |
<p className="text-xs text-muted-foreground">Server-Sent Events</p>
|
|
|
762 |
</div>
|
763 |
</div>
|
764 |
|
765 |
+
{newServer.type === 'sse' ? (
|
766 |
<div className="grid gap-1.5">
|
767 |
<Label htmlFor="url">
|
768 |
Server URL
|
|
|
940 |
|
941 |
<AccordionItem value="headers">
|
942 |
<AccordionTrigger className="text-sm py-2">
|
943 |
+
{newServer.type === 'sse' ? 'HTTP Headers' : 'Additional Configuration'}
|
944 |
</AccordionTrigger>
|
945 |
<AccordionContent>
|
946 |
<div className="space-y-3">
|
|
|
1050 |
</div>
|
1051 |
) : (
|
1052 |
<p className="text-xs text-muted-foreground text-center py-2">
|
1053 |
+
No {newServer.type === 'sse' ? 'headers' : 'additional configuration'} added
|
1054 |
</p>
|
1055 |
)}
|
1056 |
<p className="text-xs text-muted-foreground">
|
1057 |
+
{newServer.type === 'sse'
|
1058 |
? 'HTTP headers will be sent with requests to the HTTP or SSE endpoint.'
|
1059 |
: 'Additional configuration parameters for the stdio transport.'}
|
1060 |
</p>
|
|
|
1098 |
onClick={editingServerId ? updateServer : addServer}
|
1099 |
disabled={
|
1100 |
!newServer.name ||
|
1101 |
+
(newServer.type === 'sse' && !newServer.url) ||
|
1102 |
(newServer.type === 'stdio' && (!newServer.command || !newServer.args?.length))
|
1103 |
}
|
1104 |
>
|
lib/context/mcp-context.tsx
CHANGED
@@ -17,7 +17,7 @@ export interface MCPServer {
|
|
17 |
id: string;
|
18 |
name: string;
|
19 |
url: string;
|
20 |
-
type: '
|
21 |
command?: string;
|
22 |
args?: string[];
|
23 |
env?: KeyValuePair[];
|
@@ -30,7 +30,7 @@ export interface MCPServer {
|
|
30 |
|
31 |
// Type for processed MCP server config for API
|
32 |
export interface MCPServerApi {
|
33 |
-
type: '
|
34 |
url: string;
|
35 |
headers?: KeyValuePair[];
|
36 |
}
|
@@ -135,7 +135,7 @@ export function MCPProvider({ children }: { children: React.ReactNode }) {
|
|
135 |
.map(id => getServerById(id))
|
136 |
.filter((server): server is MCPServer => !!server && server.status === 'connected')
|
137 |
.map(server => ({
|
138 |
-
type: '
|
139 |
url: server.type === 'stdio' && server.sandboxUrl ? server.sandboxUrl : server.url,
|
140 |
headers: server.headers
|
141 |
}));
|
@@ -151,7 +151,7 @@ export function MCPProvider({ children }: { children: React.ReactNode }) {
|
|
151 |
|
152 |
try {
|
153 |
// For HTTP or SSE servers, just check if the endpoint is available
|
154 |
-
if (server.type === '
|
155 |
const isReady = await waitForServerReady(server.url);
|
156 |
updateServerStatus(serverId, isReady ? 'connected' : 'error',
|
157 |
isReady ? undefined : 'Could not connect to server');
|
|
|
17 |
id: string;
|
18 |
name: string;
|
19 |
url: string;
|
20 |
+
type: 'sse' | 'stdio';
|
21 |
command?: string;
|
22 |
args?: string[];
|
23 |
env?: KeyValuePair[];
|
|
|
30 |
|
31 |
// Type for processed MCP server config for API
|
32 |
export interface MCPServerApi {
|
33 |
+
type: 'sse';
|
34 |
url: string;
|
35 |
headers?: KeyValuePair[];
|
36 |
}
|
|
|
135 |
.map(id => getServerById(id))
|
136 |
.filter((server): server is MCPServer => !!server && server.status === 'connected')
|
137 |
.map(server => ({
|
138 |
+
type: 'sse',
|
139 |
url: server.type === 'stdio' && server.sandboxUrl ? server.sandboxUrl : server.url,
|
140 |
headers: server.headers
|
141 |
}));
|
|
|
151 |
|
152 |
try {
|
153 |
// For HTTP or SSE servers, just check if the endpoint is available
|
154 |
+
if (server.type === 'sse') {
|
155 |
const isReady = await waitForServerReady(server.url);
|
156 |
updateServerStatus(serverId, isReady ? 'connected' : 'error',
|
157 |
isReady ? undefined : 'Could not connect to server');
|
lib/mcp-client.ts
CHANGED
@@ -8,7 +8,7 @@ export interface KeyValuePair {
|
|
8 |
|
9 |
export interface MCPServerConfig {
|
10 |
url: string;
|
11 |
-
type: '
|
12 |
command?: string;
|
13 |
args?: string[];
|
14 |
env?: KeyValuePair[];
|
@@ -44,6 +44,7 @@ export async function initializeMCPClients(
|
|
44 |
// All servers are handled as HTTP or SSE
|
45 |
// SSE is only when URL ends with /sse
|
46 |
// which is the heuristic used by other clients
|
|
|
47 |
const transport = mcpServer.url.endsWith('/sse')
|
48 |
? {
|
49 |
type: 'sse' as const,
|
|
|
8 |
|
9 |
export interface MCPServerConfig {
|
10 |
url: string;
|
11 |
+
type: 'sse' | 'stdio';
|
12 |
command?: string;
|
13 |
args?: string[];
|
14 |
env?: KeyValuePair[];
|
|
|
44 |
// All servers are handled as HTTP or SSE
|
45 |
// SSE is only when URL ends with /sse
|
46 |
// which is the heuristic used by other clients
|
47 |
+
|
48 |
const transport = mcpServer.url.endsWith('/sse')
|
49 |
? {
|
50 |
type: 'sse' as const,
|