|
16 | 16 | import uuid |
17 | 17 | from functools import reduce |
18 | 18 | from typing import Dict, List |
| 19 | + |
19 | 20 | from django.contrib.postgres.fields import ArrayField |
20 | 21 | from django.core import cache, validators |
21 | 22 | from django.core import signing |
|
24 | 25 | from django.db.models.expressions import RawSQL |
25 | 26 | from django.http import HttpResponse |
26 | 27 | from django.template import Template, Context |
| 28 | +from django.utils.translation import gettext_lazy as _, get_language, to_locale |
27 | 29 | from langchain_mcp_adapters.client import MultiServerMCPClient |
28 | | -from mcp.client.sse import sse_client |
29 | 30 | from rest_framework import serializers, status |
30 | 31 | from rest_framework.utils.formatting import lazy_format |
31 | 32 |
|
|
38 | 39 | from common.constants.authentication_type import AuthenticationType |
39 | 40 | from common.db.search import get_dynamics_model, native_search, native_page_search |
40 | 41 | from common.db.sql_execute import select_list |
41 | | -from common.exception.app_exception import AppApiException, NotFound404, AppUnauthorizedFailed, ChatException |
| 42 | +from common.exception.app_exception import AppApiException, NotFound404, AppUnauthorizedFailed |
42 | 43 | from common.field.common import UploadedImageField, UploadedFileField |
43 | 44 | from common.models.db_model_manage import DBModelManage |
44 | 45 | from common.response import result |
|
57 | 58 | from setting.serializers.provider_serializers import ModelSerializer |
58 | 59 | from smartdoc.conf import PROJECT_DIR |
59 | 60 | from users.models import User |
60 | | -from django.utils.translation import gettext_lazy as _, get_language, to_locale |
61 | 61 |
|
62 | 62 | chat_cache = cache.caches['chat_cache'] |
63 | 63 |
|
@@ -1328,6 +1328,9 @@ def get_mcp_servers(self, with_valid=True): |
1328 | 1328 | if '"stdio"' in self.data.get('mcp_servers'): |
1329 | 1329 | raise AppApiException(500, _('stdio is not supported')) |
1330 | 1330 | servers = json.loads(self.data.get('mcp_servers')) |
| 1331 | + for server, config in servers.items(): |
| 1332 | + if config.get('transport') not in ['sse', 'streamable_http']: |
| 1333 | + raise AppApiException(500, _('Only support transport=sse or transport=streamable_http')) |
1331 | 1334 |
|
1332 | 1335 | async def get_mcp_tools(servers): |
1333 | 1336 | async with MultiServerMCPClient(servers) as client: |
|
0 commit comments