feat: Add MCP services support and enhance migration scripts

- Introduced new MCP services functionality, including management routes and integration with the agent service.
- Updated Docker Compose configuration to include a new SQL migration for MCP services.
- Enhanced Makefile with new migration commands for versioning and creating migrations.
- Improved chat component to handle selected MCP services in message processing.
- Updated migration documentation to reflect new strategies and added MCP services migration files.
This commit is contained in:
wizardchen
2025-11-09 03:27:24 +08:00
parent 83721f98d4
commit 77b6133e2a
34 changed files with 3577 additions and 1063 deletions
+98
View File
@@ -0,0 +1,98 @@
import { get, post, put, del } from '@/utils/request'
export interface MCPService {
id: string
tenant_id?: number
name: string
description: string
enabled: boolean
transport_type: 'sse' | 'http-streamable'
url: string
headers?: Record<string, string>
auth_config?: {
api_key?: string
token?: string
custom_headers?: Record<string, string>
}
advanced_config?: {
timeout?: number
retry_count?: number
retry_delay?: number
}
created_at?: string
updated_at?: string
}
export interface MCPTool {
name: string
description: string
inputSchema: Record<string, any>
}
export interface MCPResource {
uri: string
name: string
description?: string
mimeType?: string
}
export interface MCPTestResult {
success: boolean
message?: string
tools?: MCPTool[]
resources?: MCPResource[]
}
// List all MCP services
export async function listMCPServices(): Promise<MCPService[]> {
const response: any = await get('/api/v1/mcp-services')
return response.data || []
}
// Get a single MCP service by ID
export async function getMCPService(id: string): Promise<MCPService> {
const response: any = await get(`/api/v1/mcp-services/${id}`)
return response.data
}
// Create a new MCP service
export async function createMCPService(data: Partial<MCPService>): Promise<MCPService> {
const response: any = await post('/api/v1/mcp-services', data)
return response.data
}
// Update an existing MCP service
export async function updateMCPService(id: string, data: Partial<MCPService>): Promise<MCPService> {
const response: any = await put(`/api/v1/mcp-services/${id}`, data)
return response.data
}
// Delete an MCP service
export async function deleteMCPService(id: string): Promise<void> {
await del(`/api/v1/mcp-services/${id}`)
}
// Test MCP service connection
export async function testMCPService(id: string): Promise<MCPTestResult> {
const response: any = await post(`/api/v1/mcp-services/${id}/test`, {})
// 后端返回格式: { success: true, data: MCPTestResult }
// response interceptor 已经返回了 data,所以 response 就是 { success: true, data: {...} }
if (response && response.data) {
return response.data
}
// 如果格式不对,尝试直接返回 response(可能是直接返回的数据)
return response
}
// Get tools from an MCP service
export async function getMCPServiceTools(id: string): Promise<MCPTool[]> {
const response: any = await get(`/api/v1/mcp-services/${id}/tools`)
return response.data || []
}
// Get resources from an MCP service
export async function getMCPServiceResources(id: string): Promise<MCPResource[]> {
const response: any = await get(`/api/v1/mcp-services/${id}/resources`)
return response.data || []
}
+4
View File
@@ -287,11 +287,15 @@ const sendMsg = async (value, modelId = '') => {
// Use agent-chat endpoint when agent is enabled, otherwise use knowledge-chat
const endpoint = agentEnabled ? '/api/v1/agent-chat' : '/api/v1/knowledge-chat';
// Get selected MCP services from settings store (if available)
const mcpServiceIds = useSettingsStoreInstance.settings.selectedMCPServices || [];
await startStream({
session_id: session_id.value,
knowledge_base_ids: kbIds,
agent_enabled: agentEnabled,
summary_model_id: modelId,
mcp_service_ids: mcpServiceIds,
query: value,
method: 'POST',
url: endpoint
+439
View File
@@ -0,0 +1,439 @@
<template>
<div class="mcp-settings">
<div class="section-header">
<h2>MCP 服务管理</h2>
<p class="section-description">
管理外部 MCP (Model Context Protocol) 服务,在 Agent 模式下调用外部工具和资源
</p>
</div>
<div v-if="loading" class="loading-container">
<t-loading text="加载中..." />
</div>
<div v-else class="services-container">
<div class="services-header">
<div class="header-info">
<h3>已配置的服务</h3>
<p>管理和测试 MCP 服务连接</p>
</div>
<t-button size="small" theme="primary" @click="handleAdd">
<template #icon><t-icon name="add" /></template>
添加服务
</t-button>
</div>
<div v-if="services.length === 0" class="empty-state">
<t-empty description="暂无 MCP 服务">
<t-button theme="primary" @click="handleAdd">添加第一个 MCP 服务</t-button>
</t-empty>
</div>
<div v-else class="services-list">
<div v-for="service in services" :key="service.id" class="service-card">
<div class="service-info">
<div class="service-header">
<div class="service-name">
{{ service.name }}
<t-tag
:theme="service.transport_type === 'sse' ? 'success' : 'primary'"
size="small"
variant="light"
>
{{ service.transport_type === 'sse' ? 'SSE' : 'HTTP Streamable' }}
</t-tag>
</div>
<div class="service-controls">
<t-switch
v-model="service.enabled"
@change="() => handleToggleEnabled(service)"
size="large"
/>
<t-dropdown
:options="getServiceOptions(service)"
@click="(data: any) => handleMenuAction(data, service)"
placement="bottom-right"
:disabled="testing"
>
<t-button variant="text" shape="square" size="small" class="more-btn" :disabled="testing">
<t-icon name="more" />
</t-button>
</t-dropdown>
</div>
</div>
<div v-if="service.description" class="service-description">
{{ service.description }}
</div>
</div>
</div>
</div>
</div>
<!-- Add/Edit Dialog -->
<McpServiceDialog
v-model:visible="dialogVisible"
:service="currentService"
:mode="dialogMode"
@success="handleDialogSuccess"
/>
<!-- Test Result Dialog -->
<McpTestResult
v-model:visible="testDialogVisible"
:result="testResult"
:service-name="testingServiceName"
/>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
import {
listMCPServices,
updateMCPService,
deleteMCPService,
testMCPService,
type MCPService,
type MCPTestResult
} from '@/api/mcp-service'
import McpServiceDialog from './components/McpServiceDialog.vue'
import McpTestResult from './components/McpTestResult.vue'
const services = ref<MCPService[]>([])
const loading = ref(false)
const dialogVisible = ref(false)
const dialogMode = ref<'add' | 'edit'>('add')
const currentService = ref<MCPService | null>(null)
const testDialogVisible = ref(false)
const testResult = ref<MCPTestResult | null>(null)
const testingServiceName = ref('')
const testing = ref(false)
// Load MCP services
const loadServices = async () => {
loading.value = true
try {
services.value = await listMCPServices()
} catch (error) {
MessagePlugin.error('加载 MCP 服务列表失败')
console.error('Failed to load MCP services:', error)
} finally {
loading.value = false
}
}
// Handle add button click
const handleAdd = () => {
currentService.value = null
dialogMode.value = 'add'
dialogVisible.value = true
}
// Handle edit button click
const handleEdit = (service: MCPService) => {
currentService.value = { ...service }
dialogMode.value = 'edit'
dialogVisible.value = true
}
// Handle dialog success
const handleDialogSuccess = () => {
dialogVisible.value = false
loadServices()
}
// Handle toggle enabled/disabled
const handleToggleEnabled = async (service: MCPService) => {
if (!service || !service.id) return
const originalState = service.enabled
try {
await updateMCPService(service.id, { enabled: service.enabled })
MessagePlugin.success(`已${service.enabled ? '启用' : '禁用'} MCP 服务`)
} catch (error) {
// Revert on error
service.enabled = originalState
MessagePlugin.error('更新 MCP 服务状态失败')
console.error('Failed to update MCP service:', error)
}
}
// Handle test button click
const handleTest = async (service: MCPService) => {
if (!service || !service.id) return
testingServiceName.value = service.name || 'MCP 服务'
testing.value = true
// 显示测试开始提示
MessagePlugin.info({
content: `正在测试 ${service.name}...`,
duration: 0, // 不自动关闭
closeBtn: false
})
try {
const result = await testMCPService(service.id)
console.log('Test result received:', result)
// 关闭所有消息提示
MessagePlugin.closeAll()
// 检查结果是否存在
if (!result) {
// 即使没有结果,也显示错误对话框
testResult.value = {
success: false,
message: '测试失败:未收到服务器响应'
}
testDialogVisible.value = true
return
}
// 设置测试结果
testResult.value = result
// 显示详细结果对话框
console.log('Opening test dialog, result:', testResult.value)
testDialogVisible.value = true
} catch (error: any) {
// 关闭所有消息提示
MessagePlugin.closeAll()
// 显示错误信息
const errorMessage = error?.response?.data?.error?.message || error?.message || '测试 MCP 服务失败'
console.error('Failed to test MCP service:', error)
// 即使出错也显示结果对话框,显示错误信息
testResult.value = {
success: false,
message: errorMessage
}
testDialogVisible.value = true
} finally {
// 确保关闭 loading
testing.value = false
}
}
// Handle delete button click
const handleDelete = async (service: MCPService) => {
if (!service || !service.id) return
const confirmDialog = DialogPlugin.confirm({
header: '确认删除',
body: `确定要删除 MCP 服务"${service.name || '未命名'}"吗?此操作无法撤销。`,
confirmBtn: '删除',
cancelBtn: '取消',
theme: 'warning',
onConfirm: async () => {
try {
await deleteMCPService(service.id)
MessagePlugin.success('MCP 服务已删除')
confirmDialog.hide()
loadServices()
} catch (error) {
MessagePlugin.error('删除 MCP 服务失败')
console.error('Failed to delete MCP service:', error)
}
}
})
}
// Get service options for dropdown menu
const getServiceOptions = (service: MCPService) => {
return [
{
content: '测试连接',
value: `test-${service.id}`
},
{
content: '编辑',
value: `edit-${service.id}`
},
{
content: '删除',
value: `delete-${service.id}`,
theme: 'error'
}
]
}
// Handle menu action
const handleMenuAction = (data: { value: string }, service: MCPService) => {
const value = data.value
if (value.startsWith('test-')) {
handleTest(service)
} else if (value.startsWith('edit-')) {
handleEdit(service)
} else if (value.startsWith('delete-')) {
handleDelete(service)
}
}
onMounted(() => {
loadServices()
})
</script>
<style scoped lang="less">
.mcp-settings {
width: 100%;
}
.section-header {
margin-bottom: 32px;
h2 {
font-size: 20px;
font-weight: 600;
color: #333333;
margin: 0 0 8px 0;
}
.section-description {
font-size: 14px;
color: #666666;
margin: 0;
line-height: 1.5;
}
}
.loading-container {
padding: 40px 0;
text-align: center;
}
.services-container {
margin-top: 16px;
}
.services-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
margin-bottom: 16px;
padding-bottom: 16px;
border-bottom: 1px solid #e5e7eb;
.header-info {
flex: 1;
h3 {
font-size: 15px;
font-weight: 500;
color: #333333;
margin: 0 0 4px 0;
}
p {
font-size: 13px;
color: #999999;
margin: 0;
line-height: 1.5;
}
}
}
.empty-state {
padding: 80px 0;
text-align: center;
:deep(.t-empty__description) {
font-size: 14px;
color: #999999;
margin-bottom: 16px;
}
}
.services-list {
display: flex;
flex-direction: column;
gap: 0;
border: 1px solid #e5e7eb;
border-radius: 6px;
padding: 16px;
background: #fafafa;
}
.service-card {
padding: 12px 0;
border-bottom: 1px solid #e5e7eb;
transition: all 0.2s;
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
&:first-child {
padding-top: 0;
}
}
.service-info {
.service-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 8px;
.service-name {
font-size: 15px;
font-weight: 500;
color: #333333;
display: flex;
align-items: center;
gap: 8px;
flex: 1;
}
.service-controls {
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
.more-btn {
color: #999999;
padding: 4px;
transition: all 0.2s;
&:hover {
background: #f5f7fa;
color: #333333;
}
}
}
}
.service-description {
font-size: 13px;
color: #666666;
margin-bottom: 8px;
line-height: 1.5;
}
.service-meta {
display: flex;
align-items: center;
gap: 12px;
font-size: 12px;
color: #999999;
.meta-item {
display: flex;
align-items: center;
gap: 4px;
.meta-icon {
font-size: 12px;
}
}
}
}
</style>
+7
View File
@@ -92,6 +92,11 @@
<div v-if="currentSection === 'api'" class="section">
<ApiInfo />
</div>
<!-- MCP 服务 -->
<div v-if="currentSection === 'mcp'" class="section">
<McpSettings />
</div>
</div>
</div>
</div>
@@ -112,6 +117,7 @@ import ApiInfo from './ApiInfo.vue'
import GeneralSettings from './GeneralSettings.vue'
import ModelSettings from './ModelSettings.vue'
import OllamaSettings from './OllamaSettings.vue'
import McpSettings from './McpSettings.vue'
const route = useRoute()
const router = useRouter()
@@ -136,6 +142,7 @@ const navItems = [
},
{ key: 'ollama', icon: 'server', label: 'Ollama' },
{ key: 'agent', icon: 'chat', label: 'Agent 配置' },
{ key: 'mcp', icon: 'link', label: 'MCP 服务' },
{ key: 'system', icon: 'info-circle', label: '系统信息' },
{ key: 'tenant', icon: 'user-circle', label: '租户信息' },
{ key: 'api', icon: 'secured', label: 'API 信息' }
@@ -0,0 +1,245 @@
<template>
<t-dialog
v-model:visible="dialogVisible"
:header="mode === 'add' ? '添加 MCP 服务' : '编辑 MCP 服务'"
width="700px"
:on-confirm="handleSubmit"
:on-cancel="handleClose"
:confirm-btn="{ content: '保存', loading: submitting }"
>
<t-form
ref="formRef"
:data="formData"
:rules="rules"
label-width="120px"
>
<t-form-item label="服务名称" name="name">
<t-input v-model="formData.name" placeholder="请输入服务名称" />
</t-form-item>
<t-form-item label="描述" name="description">
<t-textarea
v-model="formData.description"
:autosize="{ minRows: 3, maxRows: 5 }"
placeholder="请输入服务描述"
/>
</t-form-item>
<t-form-item label="传输类型" name="transport_type">
<t-radio-group v-model="formData.transport_type">
<t-radio value="sse">SSE (Server-Sent Events)</t-radio>
<t-radio value="http-streamable">HTTP Streamable</t-radio>
</t-radio-group>
</t-form-item>
<t-form-item label="服务 URL" name="url">
<t-input v-model="formData.url" placeholder="https://example.com/mcp" />
</t-form-item>
<t-form-item label="启用服务" name="enabled">
<t-switch v-model="formData.enabled" />
</t-form-item>
<!-- Authentication Config -->
<t-collapse :default-value="[]">
<t-collapse-panel header="认证配置" value="auth">
<t-form-item label="API Key">
<t-input
v-model="formData.auth_config.api_key"
type="password"
placeholder="可选"
/>
</t-form-item>
<t-form-item label="Bearer Token">
<t-input
v-model="formData.auth_config.token"
type="password"
placeholder="可选"
/>
</t-form-item>
</t-collapse-panel>
<!-- Advanced Config -->
<t-collapse-panel header="高级配置" value="advanced">
<t-form-item label="超时时间(秒)">
<t-input-number
v-model="formData.advanced_config.timeout"
:min="1"
:max="300"
placeholder="30"
/>
</t-form-item>
<t-form-item label="重试次数">
<t-input-number
v-model="formData.advanced_config.retry_count"
:min="0"
:max="10"
placeholder="3"
/>
</t-form-item>
<t-form-item label="重试延迟(秒)">
<t-input-number
v-model="formData.advanced_config.retry_delay"
:min="0"
:max="60"
placeholder="1"
/>
</t-form-item>
</t-collapse-panel>
</t-collapse>
</t-form>
</t-dialog>
</template>
<script setup lang="ts">
import { ref, watch, computed } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import type { FormInstanceFunctions, FormRule } from 'tdesign-vue-next'
import {
createMCPService,
updateMCPService,
type MCPService
} from '@/api/mcp-service'
interface Props {
visible: boolean
service: MCPService | null
mode: 'add' | 'edit'
}
interface Emits {
(e: 'update:visible', value: boolean): void
(e: 'success'): void
}
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
const formRef = ref<FormInstanceFunctions>()
const submitting = ref(false)
const formData = ref({
name: '',
description: '',
enabled: true,
transport_type: 'sse' as 'sse' | 'http-streamable',
url: '',
auth_config: {
api_key: '',
token: ''
},
advanced_config: {
timeout: 30,
retry_count: 3,
retry_delay: 1
}
})
const rules: Record<string, FormRule[]> = {
name: [{ required: true, message: '请输入服务名称', type: 'error' }],
transport_type: [{ required: true, message: '请选择传输类型', type: 'error' }],
url: [
{ required: true, message: '请输入服务 URL', type: 'error' },
{ url: true, message: '请输入有效的 URL', type: 'error' }
]
}
const dialogVisible = computed({
get: () => props.visible,
set: (value) => emit('update:visible', value)
})
// Reset form function - defined before watch to avoid hoisting issues
const resetForm = () => {
formData.value = {
name: '',
description: '',
enabled: true,
transport_type: 'sse',
url: '',
auth_config: {
api_key: '',
token: ''
},
advanced_config: {
timeout: 30,
retry_count: 3,
retry_delay: 1
}
}
formRef.value?.clearValidate()
}
// Watch service prop to initialize form
watch(
() => props.service,
(service) => {
if (service) {
formData.value = {
name: service.name || '',
description: service.description || '',
enabled: service.enabled ?? true,
transport_type: service.transport_type || 'sse',
url: service.url || '',
auth_config: {
api_key: service.auth_config?.api_key || '',
token: service.auth_config?.token || ''
},
advanced_config: {
timeout: service.advanced_config?.timeout || 30,
retry_count: service.advanced_config?.retry_count || 3,
retry_delay: service.advanced_config?.retry_delay || 1
}
}
} else {
resetForm()
}
},
{ immediate: true }
)
// Handle submit
const handleSubmit = async () => {
const valid = await formRef.value?.validate()
if (!valid) return
submitting.value = true
try {
const data: Partial<MCPService> = {
name: formData.value.name,
description: formData.value.description,
enabled: formData.value.enabled,
transport_type: formData.value.transport_type,
url: formData.value.url,
auth_config: {
api_key: formData.value.auth_config.api_key || undefined,
token: formData.value.auth_config.token || undefined
},
advanced_config: formData.value.advanced_config
}
if (props.mode === 'add') {
await createMCPService(data)
MessagePlugin.success('MCP 服务已创建')
} else {
await updateMCPService(props.service!.id, data)
MessagePlugin.success('MCP 服务已更新')
}
emit('success')
} catch (error) {
MessagePlugin.error(
props.mode === 'add' ? '创建 MCP 服务失败' : '更新 MCP 服务失败'
)
console.error('Failed to save MCP service:', error)
} finally {
submitting.value = false
}
}
// Handle close
const handleClose = () => {
dialogVisible.value = false
}
</script>
@@ -0,0 +1,471 @@
<template>
<t-dialog
v-model:visible="dialogVisible"
:header="`测试结果: ${serviceName}`"
width="600px"
:footer="false"
>
<div v-if="result" class="test-result">
<!-- Success/Error Status -->
<div class="status-section">
<div v-if="result.success" class="status-success">
<t-icon name="check-circle-filled" size="20px" />
<span class="status-text">连接成功</span>
</div>
<div v-else class="status-error">
<t-icon name="close-circle-filled" size="20px" />
<span class="status-text">连接失败</span>
</div>
<p v-if="result.message" class="status-message">{{ result.message }}</p>
</div>
<!-- Details Section -->
<div v-if="result.success" class="details-section">
<!-- Tools List -->
<div v-if="result.tools && result.tools.length > 0" class="section">
<div class="section-header">
<h3>可用工具</h3>
<t-tag theme="primary" variant="light" size="small">{{ result.tools.length }}</t-tag>
</div>
<div class="tools-grid">
<div
v-for="(tool, index) in result.tools"
:key="index"
class="tool-card"
:class="{ 'tool-card-expanded': expandedToolIndex === index }"
>
<div class="tool-card-header" @click="toggleTool(index)">
<div class="tool-header-left">
<t-icon name="tools" class="tool-icon" />
<div class="tool-info">
<div class="tool-name">{{ tool.name }}</div>
<div v-if="tool.description" class="tool-desc-preview">
{{ tool.description }}
</div>
</div>
</div>
<t-icon
:name="expandedToolIndex === index ? 'chevron-up' : 'chevron-down'"
class="expand-icon"
/>
</div>
<div v-if="expandedToolIndex === index" class="tool-card-content">
<div v-if="tool.description" class="tool-description">
<div class="label">描述</div>
<div class="value">{{ tool.description }}</div>
</div>
<div v-if="tool.inputSchema" class="tool-schema">
<div class="label">参数结构</div>
<div class="schema-content">
<pre>{{ formatSchema(tool.inputSchema) }}</pre>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Resources List -->
<div v-if="result.resources && result.resources.length > 0" class="section">
<div class="section-header">
<h3>可用资源</h3>
<t-tag theme="primary" variant="light" size="small">{{ result.resources.length }}</t-tag>
</div>
<div class="resources-grid">
<div
v-for="(resource, index) in result.resources"
:key="index"
class="resource-card"
>
<div class="resource-header">
<t-icon name="file" class="resource-icon" />
<div class="resource-info">
<div class="resource-name">{{ resource.name || resource.uri }}</div>
<div v-if="resource.description" class="resource-desc">
{{ resource.description }}
</div>
</div>
</div>
<div class="resource-meta">
<div v-if="resource.uri" class="resource-uri">
<t-icon name="link" size="14px" />
<span>{{ resource.uri }}</span>
</div>
<t-tag v-if="resource.mimeType" theme="default" variant="light-outline" size="small">
{{ resource.mimeType }}
</t-tag>
</div>
</div>
</div>
</div>
<!-- Empty State -->
<div
v-if="
(!result.tools || result.tools.length === 0) &&
(!result.resources || result.resources.length === 0)
"
class="empty-state"
>
<t-empty description="该服务未提供工具或资源" />
</div>
</div>
</div>
<template #footer>
<t-button @click="handleClose">关闭</t-button>
</template>
</t-dialog>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
import type { MCPTestResult } from '@/api/mcp-service'
interface Props {
visible: boolean
result: MCPTestResult | null
serviceName: string
}
interface Emits {
(e: 'update:visible', value: boolean): void
}
const props = defineProps<Props>()
const emit = defineEmits<Emits>()
const expandedToolIndex = ref<number | null>(null)
const dialogVisible = computed({
get: () => props.visible,
set: (value) => emit('update:visible', value)
})
const toggleTool = (index: number) => {
if (expandedToolIndex.value === index) {
expandedToolIndex.value = null
} else {
expandedToolIndex.value = index
}
}
const formatSchema = (schema: any): string => {
if (!schema) return ''
return JSON.stringify(schema, null, 2)
}
const handleClose = () => {
dialogVisible.value = false
expandedToolIndex.value = null
}
</script>
<style scoped lang="less">
.test-result {
padding: 20px 0;
.status-section {
margin-bottom: 24px;
.status-success,
.status-error {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 12px;
padding: 12px 16px;
border-radius: 6px;
background: #f5f7fa;
:deep(.t-icon) {
font-size: 20px;
}
.status-text {
font-size: 15px;
font-weight: 500;
}
}
.status-success {
:deep(.t-icon) {
color: #00a870;
}
.status-text {
color: #00a870;
}
}
.status-error {
:deep(.t-icon) {
color: #e34d59;
}
.status-text {
color: #e34d59;
}
}
.status-message {
margin: 0;
padding: 12px 16px;
background: #f5f7fa;
border-radius: 6px;
font-size: 13px;
color: #666666;
line-height: 1.6;
word-break: break-word;
}
}
.details-section {
.section {
margin-bottom: 30px;
.section-header {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 16px;
h3 {
font-size: 16px;
font-weight: 600;
margin: 0;
color: #303133;
}
}
.tools-grid {
display: flex;
flex-direction: column;
gap: 12px;
}
.tool-card {
border: 1px solid #e4e7ed;
border-radius: 8px;
background: #ffffff;
transition: all 0.2s ease;
overflow: hidden;
&:hover {
border-color: var(--td-brand-color);
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.1);
}
&.tool-card-expanded {
border-color: var(--td-brand-color);
box-shadow: 0 2px 12px rgba(7, 192, 95, 0.15);
}
.tool-card-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 16px;
cursor: pointer;
user-select: none;
.tool-header-left {
display: flex;
align-items: flex-start;
gap: 12px;
flex: 1;
min-width: 0;
.tool-icon {
color: var(--td-brand-color);
font-size: 18px;
margin-top: 2px;
flex-shrink: 0;
}
.tool-info {
flex: 1;
min-width: 0;
.tool-name {
font-size: 15px;
font-weight: 600;
color: #303133;
margin-bottom: 4px;
word-break: break-word;
}
.tool-desc-preview {
font-size: 13px;
color: #909399;
line-height: 1.5;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
.expand-icon {
color: #909399;
font-size: 16px;
flex-shrink: 0;
transition: transform 0.2s ease;
}
}
.tool-card-content {
padding: 0 16px 16px 16px;
border-top: 1px solid #f0f0f0;
margin-top: 12px;
padding-top: 16px;
animation: slideDown 0.2s ease;
.tool-description,
.tool-schema {
margin-bottom: 16px;
&:last-child {
margin-bottom: 0;
}
.label {
font-size: 12px;
font-weight: 600;
color: #909399;
text-transform: uppercase;
letter-spacing: 0.5px;
margin-bottom: 8px;
}
.value {
font-size: 14px;
color: #606266;
line-height: 1.6;
}
.schema-content {
background: #f5f7fa;
border: 1px solid #e4e7ed;
border-radius: 6px;
overflow: hidden;
pre {
margin: 0;
padding: 12px;
overflow-x: auto;
font-size: 12px;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
color: #303133;
line-height: 1.6;
background: transparent;
border: none;
}
}
}
}
}
.resources-grid {
display: flex;
flex-direction: column;
gap: 12px;
}
.resource-card {
border: 1px solid #e4e7ed;
border-radius: 8px;
background: #ffffff;
padding: 14px 16px;
transition: all 0.2s ease;
&:hover {
border-color: var(--td-brand-color);
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.1);
}
.resource-header {
display: flex;
align-items: flex-start;
gap: 12px;
margin-bottom: 12px;
.resource-icon {
color: var(--td-brand-color);
font-size: 18px;
margin-top: 2px;
flex-shrink: 0;
}
.resource-info {
flex: 1;
min-width: 0;
.resource-name {
font-size: 15px;
font-weight: 600;
color: #303133;
margin-bottom: 4px;
word-break: break-word;
}
.resource-desc {
font-size: 13px;
color: #909399;
line-height: 1.5;
}
}
}
.resource-meta {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding-top: 12px;
border-top: 1px solid #f0f0f0;
.resource-uri {
display: flex;
align-items: center;
gap: 6px;
flex: 1;
min-width: 0;
font-size: 12px;
color: #909399;
:deep(.t-icon) {
color: #909399;
}
span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
}
}
.empty-state {
padding: 40px 0;
}
}
}
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>