feat: http logging middleware + mcp random port (#74)
This commit is contained in:
@@ -17,6 +17,7 @@ export default function RootLayout({
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
const runtimeApiBaseUrl = process.env.KANDEV_API_BASE_URL ?? "";
|
||||
const runtimeMcpServerUrl = process.env.KANDEV_MCP_SERVER_URL ?? "";
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<body className="antialiased font-sans">
|
||||
@@ -28,6 +29,13 @@ export default function RootLayout({
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
{runtimeMcpServerUrl ? (
|
||||
<script
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `window.__KANDEV_MCP_SERVER_URL = ${JSON.stringify(runtimeMcpServerUrl)};`,
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
<StateProvider>
|
||||
<ThemeProvider>
|
||||
<TooltipProvider>
|
||||
|
||||
@@ -4,7 +4,9 @@ import { Card, CardContent, CardHeader, CardTitle } from '@kandev/ui/card';
|
||||
import { Label } from '@kandev/ui/label';
|
||||
import { Switch } from '@kandev/ui/switch';
|
||||
import { Textarea } from '@kandev/ui/textarea';
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@kandev/ui/tooltip';
|
||||
import { UnsavedChangesBadge, UnsavedSaveButton } from '@/components/settings/unsaved-indicator';
|
||||
import { getBackendConfig } from '@/lib/config';
|
||||
import { useProfileMcpConfig } from './use-profile-mcp-config';
|
||||
import type { AgentProfileMcpConfig } from '@/lib/types/http';
|
||||
|
||||
@@ -62,11 +64,13 @@ export function ProfileMcpConfigCard({
|
||||
const currentServers = isDraft ? draftState?.servers ?? '' : mcpServers;
|
||||
const currentError = isDraft ? draftState?.error ?? null : mcpError;
|
||||
const currentDirty = isDraft ? draftState?.dirty ?? false : mcpDirty;
|
||||
const { mcpServerUrl } = getBackendConfig();
|
||||
const kandevTools = 'Tools: list_workspaces, list_boards, list_columns, list_tasks, create_task, update_task';
|
||||
|
||||
const popularServers: Record<string, Record<string, unknown>> = {
|
||||
kandev: {
|
||||
type: 'sse',
|
||||
url: 'http://localhost:9090/sse',
|
||||
url: mcpServerUrl,
|
||||
},
|
||||
playwright: {
|
||||
type: 'stdio',
|
||||
@@ -202,13 +206,20 @@ export function ProfileMcpConfigCard({
|
||||
MCP definitions are stored in the database and resolved per executor at runtime. This does not override your local agent config.</p>
|
||||
<p className="text-xs font-medium text-muted-foreground">Popular servers</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs rounded-full border border-muted-foreground/30 px-2 py-1 hover:bg-muted cursor-pointer"
|
||||
onClick={() => applyPopularServer('kandev')}
|
||||
>
|
||||
+ Kandev MCP
|
||||
</button>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs rounded-full border border-muted-foreground/30 px-2 py-1 hover:bg-muted cursor-pointer"
|
||||
onClick={() => applyPopularServer('kandev')}
|
||||
>
|
||||
+ Kandev MCP
|
||||
</button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom" className="max-w-[320px] text-xs">
|
||||
{kandevTools}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
<button
|
||||
type="button"
|
||||
className="text-xs rounded-full border border-muted-foreground/30 px-2 py-1 hover:bg-muted cursor-pointer"
|
||||
|
||||
Vendored
+1
@@ -3,5 +3,6 @@ export {};
|
||||
declare global {
|
||||
interface Window {
|
||||
__KANDEV_API_BASE_URL?: string;
|
||||
__KANDEV_MCP_SERVER_URL?: string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
export type AppConfig = {
|
||||
apiBaseUrl: string;
|
||||
mcpServerUrl: string;
|
||||
};
|
||||
|
||||
const DEFAULT_API_BASE_URL = 'http://localhost:8080';
|
||||
const DEFAULT_MCP_SERVER_URL = 'http://localhost:9090/sse';
|
||||
export const DEBUG_UI = process.env.NEXT_PUBLIC_KANDEV_DEBUG === 'true';
|
||||
|
||||
export function getBackendConfig(): AppConfig {
|
||||
if (typeof window === 'undefined') {
|
||||
return {
|
||||
apiBaseUrl: process.env.KANDEV_API_BASE_URL ?? DEFAULT_API_BASE_URL,
|
||||
mcpServerUrl: process.env.KANDEV_MCP_SERVER_URL ?? DEFAULT_MCP_SERVER_URL,
|
||||
};
|
||||
}
|
||||
if (window.__KANDEV_API_BASE_URL) {
|
||||
if (window.__KANDEV_API_BASE_URL || window.__KANDEV_MCP_SERVER_URL) {
|
||||
return {
|
||||
apiBaseUrl: window.__KANDEV_API_BASE_URL,
|
||||
apiBaseUrl: window.__KANDEV_API_BASE_URL ?? DEFAULT_API_BASE_URL,
|
||||
mcpServerUrl: window.__KANDEV_MCP_SERVER_URL ?? DEFAULT_MCP_SERVER_URL,
|
||||
};
|
||||
}
|
||||
return {
|
||||
apiBaseUrl: process.env.NEXT_PUBLIC_KANDEV_API_BASE_URL ?? DEFAULT_API_BASE_URL,
|
||||
mcpServerUrl: process.env.NEXT_PUBLIC_KANDEV_MCP_SERVER_URL ?? DEFAULT_MCP_SERVER_URL,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user