这是indexloc提供的服务,不要输入任何密码
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions server/endpoints/mcpServers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { reqBody } = require("../utils/http");
const MCPCompatibilityLayer = require("../utils/MCP");
const MCPCompatibilityLayer = require("../utils/MCP"); // Logic for interacting with external MCP servers
const {
flexUserRoleValid,
ROLES,
Expand All @@ -9,13 +9,14 @@ const { validatedRequest } = require("../utils/middleware/validatedRequest");
function mcpServersEndpoints(app) {
if (!app) return;

// Endpoint to force a reload of all configured MCP servers.
app.get(
"/mcp-servers/force-reload",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
async (_request, response) => {
try {
const mcp = new MCPCompatibilityLayer();
await mcp.reloadMCPServers();
await mcp.reloadMCPServers(); // Triggers the server list reload logic
return response.status(200).json({
success: true,
error: null,
Expand All @@ -32,6 +33,7 @@ function mcpServersEndpoints(app) {
}
);

// Endpoint to list all configured MCP servers and their current status.
app.get(
"/mcp-servers/list",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
Expand All @@ -52,6 +54,10 @@ function mcpServersEndpoints(app) {
}
);

// Endpoint to toggle (start/stop) an MCP server by name.
// NOTE: The fix for the streamable server issue needs to be implemented
// inside MCPCompatibilityLayer.toggleServerStatus(name) to skip the
// initial GET request if the server is marked as 'streamable'.
app.post(
"/mcp-servers/toggle",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
Expand All @@ -75,6 +81,7 @@ function mcpServersEndpoints(app) {
}
);

// Endpoint to delete a configured MCP server by name.
app.post(
"/mcp-servers/delete",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
Expand All @@ -97,4 +104,4 @@ function mcpServersEndpoints(app) {
);
}

module.exports = { mcpServersEndpoints };
module.exports = { mcpServersEndpoints };