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

Signed-off-by: neatguycoding <15627489+NeatGuyCoding@users.noreply.github.com>
This commit is contained in:
NeatGuyCoding
2025-07-11 09:40:17 +08:00
committed by GitHub
parent f4df80e093
commit f929bfb94c
3 changed files with 7 additions and 4 deletions

View File

@@ -90,7 +90,11 @@ class AppMCPServerRefreshController(Resource):
def get(self, server_id): def get(self, server_id):
if not current_user.is_editor: if not current_user.is_editor:
raise NotFound() 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: if not server:
raise NotFound() raise NotFound()
server.server_code = AppMCPServer.generate_server_code(16) server.server_code = AppMCPServer.generate_server_code(16)

View File

@@ -112,13 +112,13 @@ class MCPServerStreamableHTTPRequestHandler:
def initialize(self): def initialize(self):
request = cast(types.InitializeRequest, self.request.root) request = cast(types.InitializeRequest, self.request.root)
client_info = request.params.clientInfo 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: if not self.end_user:
end_user = EndUser( end_user = EndUser(
tenant_id=self.app.tenant_id, tenant_id=self.app.tenant_id,
app_id=self.app.id, app_id=self.app.id,
type="mcp", type="mcp",
name=clinet_name, name=client_name,
session_id=generate_session_id(), session_id=generate_session_id(),
external_user_id=self.mcp_server.id, external_user_id=self.mcp_server.id,
) )

View File

@@ -69,7 +69,6 @@ class MCPToolManageService:
MCPToolProvider.server_url_hash == server_url_hash, MCPToolProvider.server_url_hash == server_url_hash,
MCPToolProvider.server_identifier == server_identifier, MCPToolProvider.server_identifier == server_identifier,
), ),
MCPToolProvider.tenant_id == tenant_id,
) )
.first() .first()
) )