Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

minor fix: remove duplicates, fix typo, and add restriction for get mcp server (#22170)

NeatGuyCodingf929bfb94c24
diff --git a/api/controllers/console/app/mcp_server.py b/api/controllers/console/app/mcp_server.py
index 4f9e75c0d30..ccda97d80c8 100644
--- a/api/controllers/console/app/mcp_server.py
+++ b/api/controllers/console/app/mcp_server.py
@@ -90,7 +90,11 @@ class AppMCPServerRefreshController(Resource):
def get(self, server_id):
if not current_user.is_editor:
raise NotFound()
- server = db.session.query(AppMCPServer).filter(AppMCPServer.id == server_id).first()
+ server = (
+ db.session.query(AppMCPServer)
+ .filter(AppMCPServer.id == server_id and AppMCPServer.tenant_id == current_user.current_tenant_id)
+ .first()
+ )
if not server:
raise NotFound()
server.server_code = AppMCPServer.generate_server_code(16)
diff --git a/api/core/mcp/server/streamable_http.py b/api/core/mcp/server/streamable_http.py
index 37eec3cd9c6..1c2cf570e2a 100644
--- a/api/core/mcp/server/streamable_http.py
+++ b/api/core/mcp/server/streamable_http.py
@@ -112,13 +112,13 @@ class MCPServerStreamableHTTPRequestHandler:
def initialize(self):
request = cast(types.InitializeRequest, self.request.root)
client_info = request.params.clientInfo
- clinet_name = f"{client_info.name}@{client_info.version}"
+ client_name = f"{client_info.name}@{client_info.version}"
if not self.end_user:
end_user = EndUser(
tenant_id=self.app.tenant_id,
app_id=self.app.id,
type="mcp",
- name=clinet_name,
+ name=client_name,
session_id=generate_session_id(),
external_user_id=self.mcp_server.id,
)
diff --git a/api/services/tools/mcp_tools_mange_service.py b/api/services/tools/mcp_tools_mange_service.py
index 3b1592230ae..7c23abda4b5 100644
--- a/api/services/tools/mcp_tools_mange_service.py
+++ b/api/services/tools/mcp_tools_mange_service.py
@@ -69,7 +69,6 @@ class MCPToolManageService:
MCPToolProvider.server_url_hash == server_url_hash,
MCPToolProvider.server_identifier == server_identifier,
),
- MCPToolProvider.tenant_id == tenant_id,
)
.first()
)