mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-14 08:17:34 +00:00
Validate configs on the existing-connection path; MCP policy fails closed
- Creating a tool from an existing connection validates its config too; the connection supplies the secrets the request leaves out. - When the connector policies cannot be read, the MCP test and save routes answer 503 instead of contacting the server.
This commit is contained in:
1 parent
473e8ec15c
commit
324d54ea67
5 files changed
+48
-8
No files matched your search
@@ -158,9 +158,12 @@ def _mcp_policy_error(config: dict):
|
||||
403,
|
||||
)
|
||||
except Exception:
|
||||
# The switch is an admin preference; when the policy table cannot be
|
||||
# read, saving the tool (which needs the database) fails on its own.
|
||||
# Fail closed: a server whose admin switch cannot be read is not contacted.
|
||||
current_app.logger.warning("Could not read connector policies", exc_info=True)
|
||||
return make_response(
|
||||
jsonify({"success": False, "error": "Could not check whether this MCP server is allowed"}),
|
||||
503,
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
|
||||
@@ -445,12 +445,14 @@ def _create_connected_tool(user, data, definition, tool_instance):
|
||||
config_requirements = tool_instance.get_config_requirements()
|
||||
public, secrets = connection_service.split_secrets(data.get("config") or {}, config_requirements)
|
||||
connection_id = data.get("connection_id")
|
||||
if not connection_id:
|
||||
validation_errors = _validate_config(data.get("config") or {}, config_requirements)
|
||||
if validation_errors:
|
||||
return make_response(
|
||||
jsonify({"success": False, "message": "Validation failed", "errors": validation_errors}), 400,
|
||||
)
|
||||
# An existing connection supplies the secrets the request leaves out.
|
||||
validation_errors = _validate_config(
|
||||
data.get("config") or {}, config_requirements, has_existing_secrets=bool(connection_id),
|
||||
)
|
||||
if validation_errors:
|
||||
return make_response(
|
||||
jsonify({"success": False, "message": "Validation failed", "errors": validation_errors}), 400,
|
||||
)
|
||||
try:
|
||||
with db_session() as conn:
|
||||
if connection_id:
|
||||
|
||||
Reference in new issue
Block a user