Files
FastapiAdmin/backend/app/api/v1/module_application/ai/model.py
T
zhangtao c0d32a7eec refactor: 统一将creator_id重命名为created_id并优化模型关系
feat: 新增系统租户和用户初始化数据

style: 优化代码注释和格式

fix: 修复数据权限检查逻辑中的created_id字段判断

perf: 移除不必要的模型关系以提升性能

docs: 更新初始化数据的描述信息

chore: 清理废弃文件和冗余代码
2025-11-24 01:02:27 +08:00

33 lines
1.4 KiB
Python

# -*- coding: utf-8 -*-
from sqlalchemy import JSON, String, Integer
from sqlalchemy.orm import Mapped, mapped_column
from app.core.base_model import ModelMixin, UserMixin, TenantMixin, CustomerMixin
class McpModel(ModelMixin, UserMixin, TenantMixin, CustomerMixin):
"""
MCP 服务器表
数据隔离策略:
===========
- 系统级MCP: tenant_id=1, customer_id=NULL (平台预置MCP,所有租户可用)
- 租户级MCP: tenant_id>1, customer_id=NULL (租户自定义MCP,仅本租户可用)
- 客户级MCP: tenant_id>1, customer_id>0 (客户专属MCP,仅该客户可用)
MCP类型:
- 0: stdio (标准输入输出)
- 1: sse (Server-Sent Events)
"""
__tablename__: str = 'app_ai_mcp'
__table_args__: dict[str, str] = ({'comment': 'MCP 服务器表'})
__loader_options__: list[str] = ["created_by", "updated_by", "tenant", "customer"]
name: Mapped[str] = mapped_column(String(50), comment='MCP 名称')
type: Mapped[int] = mapped_column(Integer, default=0, comment='MCP 类型(0:stdio 1:sse)')
url: Mapped[str | None] = mapped_column(String(255), default=None, comment='远程 SSE 地址')
command: Mapped[str | None] = mapped_column(String(255), default=None, comment='MCP 命令')
args: Mapped[str | None] = mapped_column(String(255), default=None, comment='MCP 命令参数')
env: Mapped[dict[str, str] | None] = mapped_column(JSON(), default=None, comment='MCP 环境变量')