Repository navigation
feat: add enable_agent_mcp_service field to portal model and update related components #7725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Generated by Django 6.1.2 on 2026-11-06 09:23 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
| dependencies = [ | ||
| ("portal", "0001_initial"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="portal", | ||
| name="enable_agent_mcp_service", | ||
| field=models.BooleanField(default=True, verbose_name="是否开启智能体MCP服务"), | ||
| ), | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,9 @@ class PortalSerializer(serializers.Serializer): | |
| required=False, label=_("enable public access"), help_text=_("enable public access") | ||
| ) | ||
| enable_api = serializers.BooleanField(required=False, label=_("enable api"), help_text=_("enable api")) | ||
| enable_agent_mcp_service = serializers.BooleanField( | ||
| required=False, label=_("enable agent mcp service"), help_text=_("enable agent mcp service") | ||
| ) | ||
| enable_knowledge_base_api = serializers.BooleanField( | ||
| required=False, label=_("enable knowledge base api"), help_text=_("enable knowledge base api") | ||
| ) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The added field is syntactically valid and consistent with the surrounding
Overall: the field addition itself looks fine, but the main risks are persistence wiring, default behavior, and security/authorization around enabling the MCP service. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ import ButtonPortalAuthSetting from './components/ButtonPortalAuthSetting.vue' | |
| import ButtonPortalCorsSetting from './components/ButtonPortalCorsSetting.vue' | ||
| import { useStore } from '@/stores' | ||
|
|
||
| type AccessField = 'enable_public_access' | 'enable_api' | 'enable_knowledge_base_api' | 'enable_auth' | 'enable_cors' | ||
| type AccessField = 'enable_public_access' | 'enable_api' | 'enable_agent_mcp_service' | 'enable_knowledge_base_api' | 'enable_auth' | 'enable_cors' | ||
|
|
||
| const portalSetting = reactive<PortalSetting>({ | ||
| id: '', | ||
|
|
@@ -21,6 +21,7 @@ const portalSetting = reactive<PortalSetting>({ | |
| logo: '', | ||
| enable_public_access: true, | ||
| enable_api: true, | ||
| enable_agent_mcp_service: true, | ||
| enable_knowledge_base_api: true, | ||
| enable_auth: false, | ||
| auth_config: { | ||
|
|
@@ -173,9 +174,9 @@ const canEditPortal = computed(() => perm.system.portal.edit()) | |
| </span> | ||
| <el-switch | ||
| :disabled="!canEditPortal || saving" | ||
| :model-value="portalSetting.enable_knowledge_base_api" | ||
| :model-value="portalSetting.enable_agent_mcp_service" | ||
| size="small" | ||
| @change="handleAccessChange('enable_knowledge_base_api', $event)" | ||
| @change="handleAccessChange('enable_agent_mcp_service', $event)" | ||
| /> | ||
| </div> | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review of the diff🔴 Critical / likely bugs
🟡 Potential issues
🟢 Optimization suggestions
Bottom lineThe type + default additions are fine, but the template change almost certainly drops an existing feature and the associated label/i18n text was not updated. Confirm whether the new switch was meant to be added alongside |
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blocking syntax or Django-migration irregularities are visible. The migration is a standard
AddFieldoperation and should work as generated.Potential issues / things to verify:
default=Trueaffects all existing rowsPortalrow will getenable_agent_mcp_service=True.default=Falseand opt-in explicitly.Trueis only meant to populate existing rows but new rows should have no/defaultFalse, usepreserve_default=Falseand then adjust the model field appropriately.Dependency ordering
("portal", "0001_initial")is fine only if0001_initialis the correct latest dependency.portalapp has later migrations, this migration should usually depend on the latest relevant migration to avoid ordering problems.Django version header
Generated by Django 6.1.2. Confirm the project/CI actually uses Django 6.1.2.Large-table migration performance
BooleanFieldwith a default can lock or rewrite the table on some databases, especially older MySQL/SQLite setups.AlterField, withatomic = Falseif needed.Model/migration consistency
No index needed
BooleanFieldgenerally does not need an index due to low selectivity. Only add a partial index if you frequently query enabled portals and profiling justifies it.Generated migration hygiene
Overall: No correctness bug in the migration itself. The main decision is whether
default=Trueis intentional for all existing and new portals.