add tab to modify mcp_config.json in front end
This commit is contained in:
@@ -4,10 +4,12 @@ import {
|
|||||||
deleteGraphConfig,
|
deleteGraphConfig,
|
||||||
getGraphConfig,
|
getGraphConfig,
|
||||||
getGraphDefaultConfig,
|
getGraphDefaultConfig,
|
||||||
|
getMcpToolConfig,
|
||||||
listAvailableGraphs,
|
listAvailableGraphs,
|
||||||
listGraphConfigs,
|
listGraphConfigs,
|
||||||
listPipelines,
|
listPipelines,
|
||||||
stopPipeline,
|
stopPipeline,
|
||||||
|
updateMcpToolConfig,
|
||||||
upsertGraphConfig,
|
upsertGraphConfig,
|
||||||
} from "./api/frontApis";
|
} from "./api/frontApis";
|
||||||
import type {
|
import type {
|
||||||
@@ -37,6 +39,8 @@ type LaunchCredentials = {
|
|||||||
authKeyMasked: string;
|
authKeyMasked: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type ActiveTab = "agents" | "mcp";
|
||||||
|
|
||||||
const DEFAULT_ENTRY_POINT = "fastapi_server/server_dashscope.py";
|
const DEFAULT_ENTRY_POINT = "fastapi_server/server_dashscope.py";
|
||||||
const DEFAULT_LLM_NAME = "qwen-plus";
|
const DEFAULT_LLM_NAME = "qwen-plus";
|
||||||
const DEFAULT_PORT = 8100;
|
const DEFAULT_PORT = 8100;
|
||||||
@@ -118,6 +122,7 @@ function toEditable(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
|
const [activeTab, setActiveTab] = useState<ActiveTab>("agents");
|
||||||
const [graphs, setGraphs] = useState<string[]>([]);
|
const [graphs, setGraphs] = useState<string[]>([]);
|
||||||
const [configItems, setConfigItems] = useState<GraphConfigListItem[]>([]);
|
const [configItems, setConfigItems] = useState<GraphConfigListItem[]>([]);
|
||||||
const [running, setRunning] = useState<PipelineRunInfo[]>([]);
|
const [running, setRunning] = useState<PipelineRunInfo[]>([]);
|
||||||
@@ -126,6 +131,9 @@ export default function App() {
|
|||||||
const [editor, setEditor] = useState<EditableAgent | null>(null);
|
const [editor, setEditor] = useState<EditableAgent | null>(null);
|
||||||
const [statusMessage, setStatusMessage] = useState<string>("");
|
const [statusMessage, setStatusMessage] = useState<string>("");
|
||||||
const [launchCredentials, setLaunchCredentials] = useState<LaunchCredentials | null>(null);
|
const [launchCredentials, setLaunchCredentials] = useState<LaunchCredentials | null>(null);
|
||||||
|
const [mcpConfigPath, setMcpConfigPath] = useState<string>("");
|
||||||
|
const [mcpConfigRaw, setMcpConfigRaw] = useState<string>("");
|
||||||
|
const [mcpToolKeys, setMcpToolKeys] = useState<string[]>([]);
|
||||||
const [busy, setBusy] = useState(false);
|
const [busy, setBusy] = useState(false);
|
||||||
|
|
||||||
const configKeySet = useMemo(
|
const configKeySet = useMemo(
|
||||||
@@ -208,6 +216,16 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
}, [selectedId, configKeySet]);
|
}, [selectedId, configKeySet]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (activeTab !== "mcp") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mcpConfigRaw) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
reloadMcpConfig().catch(() => undefined);
|
||||||
|
}, [activeTab]);
|
||||||
|
|
||||||
async function selectExisting(item: GraphConfigListItem): Promise<void> {
|
async function selectExisting(item: GraphConfigListItem): Promise<void> {
|
||||||
const id = makeAgentKey(item.pipeline_id, item.prompt_set_id);
|
const id = makeAgentKey(item.pipeline_id, item.prompt_set_id);
|
||||||
setSelectedId(id);
|
setSelectedId(id);
|
||||||
@@ -321,6 +339,37 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function reloadMcpConfig(): Promise<void> {
|
||||||
|
setBusy(true);
|
||||||
|
setStatusMessage("Loading MCP config...");
|
||||||
|
try {
|
||||||
|
const resp = await getMcpToolConfig();
|
||||||
|
setMcpConfigPath(resp.path || "");
|
||||||
|
setMcpConfigRaw(resp.raw_content || "");
|
||||||
|
setMcpToolKeys(resp.tool_keys || []);
|
||||||
|
setStatusMessage("MCP config loaded.");
|
||||||
|
} catch (error) {
|
||||||
|
setStatusMessage((error as Error).message);
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveMcpConfig(): Promise<void> {
|
||||||
|
setBusy(true);
|
||||||
|
setStatusMessage("Saving MCP config...");
|
||||||
|
try {
|
||||||
|
const resp = await updateMcpToolConfig({ raw_content: mcpConfigRaw });
|
||||||
|
setMcpConfigPath(resp.path || "");
|
||||||
|
setMcpToolKeys(resp.tool_keys || []);
|
||||||
|
setStatusMessage("MCP config saved.");
|
||||||
|
} catch (error) {
|
||||||
|
setStatusMessage((error as Error).message);
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function saveConfig(): Promise<void> {
|
async function saveConfig(): Promise<void> {
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
return;
|
return;
|
||||||
@@ -507,8 +556,11 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showSidebar = activeTab === "agents";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="app">
|
<div className={`app ${showSidebar ? "" : "full-width"}`}>
|
||||||
|
{showSidebar ? (
|
||||||
<aside className="sidebar">
|
<aside className="sidebar">
|
||||||
<div className="sidebar-header">
|
<div className="sidebar-header">
|
||||||
<h2>Agents</h2>
|
<h2>Agents</h2>
|
||||||
@@ -543,10 +595,34 @@ export default function App() {
|
|||||||
{rows.length === 0 ? <p className="empty">No agents configured yet.</p> : null}
|
{rows.length === 0 ? <p className="empty">No agents configured yet.</p> : null}
|
||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
) : null}
|
||||||
|
|
||||||
<main className="content">
|
<main className="content">
|
||||||
<header className="content-header">
|
<header className="content-header">
|
||||||
<h1>Agent Configuration</h1>
|
<h1>Agent Manager</h1>
|
||||||
|
<div className="tabs">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={`tab-button ${activeTab === "agents" ? "active" : ""}`}
|
||||||
|
onClick={() => setActiveTab("agents")}
|
||||||
|
disabled={busy}
|
||||||
|
>
|
||||||
|
Agents
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={`tab-button ${activeTab === "mcp" ? "active" : ""}`}
|
||||||
|
onClick={() => setActiveTab("mcp")}
|
||||||
|
disabled={busy}
|
||||||
|
>
|
||||||
|
MCP Config
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
{statusMessage ? <p className="status">{statusMessage}</p> : null}
|
||||||
|
{activeTab === "agents" ? (
|
||||||
|
<div className="tab-pane">
|
||||||
<div className="header-actions">
|
<div className="header-actions">
|
||||||
<button onClick={saveConfig} disabled={busy || !editor}>
|
<button onClick={saveConfig} disabled={busy || !editor}>
|
||||||
Save
|
Save
|
||||||
@@ -561,9 +637,7 @@ export default function App() {
|
|||||||
Delete
|
Delete
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
|
||||||
|
|
||||||
{statusMessage ? <p className="status">{statusMessage}</p> : null}
|
|
||||||
{launchCredentials ? (
|
{launchCredentials ? (
|
||||||
<div className="launch-credentials">
|
<div className="launch-credentials">
|
||||||
<h3>Access Credentials (shown once)</h3>
|
<h3>Access Credentials (shown once)</h3>
|
||||||
@@ -746,6 +820,41 @@ export default function App() {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<section className="mcp-config-section tab-pane">
|
||||||
|
<div className="mcp-config-header">
|
||||||
|
<h3>Edit MCP Tool Options</h3>
|
||||||
|
<div className="header-actions">
|
||||||
|
<button type="button" onClick={reloadMcpConfig} disabled={busy}>
|
||||||
|
Reload
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={saveMcpConfig} disabled={busy}>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p className="empty">
|
||||||
|
This tab edits <code>configs/mcp_config.json</code> directly (comments supported).
|
||||||
|
</p>
|
||||||
|
{mcpConfigPath ? (
|
||||||
|
<p className="empty">
|
||||||
|
File: <code>{mcpConfigPath}</code>
|
||||||
|
</p>
|
||||||
|
) : null}
|
||||||
|
<p className="empty">
|
||||||
|
Tool options detected: {mcpToolKeys.length ? mcpToolKeys.join(", ") : "(none)"}
|
||||||
|
</p>
|
||||||
|
<textarea
|
||||||
|
className="mcp-config-editor"
|
||||||
|
value={mcpConfigRaw}
|
||||||
|
onChange={(e) => setMcpConfigRaw(e.target.value)}
|
||||||
|
rows={18}
|
||||||
|
spellCheck={false}
|
||||||
|
disabled={busy}
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import type {
|
|||||||
GraphConfigReadResponse,
|
GraphConfigReadResponse,
|
||||||
GraphConfigUpsertRequest,
|
GraphConfigUpsertRequest,
|
||||||
GraphConfigUpsertResponse,
|
GraphConfigUpsertResponse,
|
||||||
|
McpToolConfigResponse,
|
||||||
|
McpToolConfigUpdateRequest,
|
||||||
|
McpToolConfigUpdateResponse,
|
||||||
PipelineCreateRequest,
|
PipelineCreateRequest,
|
||||||
PipelineCreateResponse,
|
PipelineCreateResponse,
|
||||||
PipelineListResponse,
|
PipelineListResponse,
|
||||||
@@ -85,6 +88,19 @@ export function deleteGraphConfig(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMcpToolConfig(): Promise<McpToolConfigResponse> {
|
||||||
|
return fetchJson("/v1/tool-configs/mcp");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateMcpToolConfig(
|
||||||
|
payload: McpToolConfigUpdateRequest
|
||||||
|
): Promise<McpToolConfigUpdateResponse> {
|
||||||
|
return fetchJson("/v1/tool-configs/mcp", {
|
||||||
|
method: "PUT",
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function createPipeline(
|
export function createPipeline(
|
||||||
payload: PipelineCreateRequest
|
payload: PipelineCreateRequest
|
||||||
): Promise<PipelineCreateResponse> {
|
): Promise<PipelineCreateResponse> {
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ body {
|
|||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app.full-width {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
border-right: 1px solid #dbe2ea;
|
border-right: 1px solid #dbe2ea;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
@@ -94,6 +98,21 @@ button:disabled {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tabs {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-button {
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-button.active {
|
||||||
|
background: #edf3ff;
|
||||||
|
border-color: #4d7ef3;
|
||||||
|
color: #1a4fc5;
|
||||||
|
}
|
||||||
|
|
||||||
.header-actions {
|
.header-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@@ -139,6 +158,10 @@ button:disabled {
|
|||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tab-pane {
|
||||||
|
margin-top: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.form-grid {
|
.form-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
@@ -206,6 +229,35 @@ button:disabled {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mcp-config-section {
|
||||||
|
background: #f7fbff;
|
||||||
|
border: 1px solid #d7e6f6;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mcp-config-header {
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mcp-config-header h3 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mcp-config-editor {
|
||||||
|
border: 1px solid #c9d4e2;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||||
|
font-size: 13px;
|
||||||
|
margin-top: 8px;
|
||||||
|
padding: 10px;
|
||||||
|
resize: vertical;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
color: #687788;
|
color: #687788;
|
||||||
margin: 6px 0;
|
margin: 6px 0;
|
||||||
|
|||||||
@@ -85,3 +85,19 @@ export type PipelineStopResponse = {
|
|||||||
status: string;
|
status: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type McpToolConfigResponse = {
|
||||||
|
path: string;
|
||||||
|
raw_content: string;
|
||||||
|
tool_keys: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type McpToolConfigUpdateRequest = {
|
||||||
|
raw_content: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type McpToolConfigUpdateResponse = {
|
||||||
|
status: string;
|
||||||
|
path: string;
|
||||||
|
tool_keys: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user