Skip to content

Commit 6725e5a

Browse files
committed
Add server description and instructions support
Introduces support for displaying server instructions and implementation details in configuration cards and metadata. Updates types and components to handle and render these new fields, including Markdown rendering for instructions and improved localization handling.
1 parent e0620c0 commit 6725e5a

File tree

12 files changed

+108
-60
lines changed

12 files changed

+108
-60
lines changed

src/main/IPCs.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,5 +361,15 @@ export function registerIpcHandlers({
361361
}
362362
}
363363

364-
return feature
364+
const instructions = connection.client.getInstructions()
365+
366+
const implementation = connection.client.getServerVersion()
367+
368+
return {
369+
...feature,
370+
description: {
371+
instructions,
372+
implementation
373+
}
374+
}
365375
}

src/main/mcp/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
StdioServerParameters
1616
} from '@modelcontextprotocol/sdk/client/stdio.js'
1717

18-
import { McpMetadata } from '@/types/mcp'
18+
import { McpMetadata, McpServerDescription } from '@/types/mcp'
1919

2020
export const McpServerCapabilitySchemas = {
2121
tools: {
@@ -67,4 +67,5 @@ export type McpClientObject = {
6767
export type McpFeatureObject = {
6868
name: string
6969
config: McpClientObject['configJson']
70+
description?: McpServerDescription
7071
}

src/preload/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,18 @@ const api = {
178178
}
179179

180180
function buildClientAPI(client: ClientProfile): MCPAPI[string] {
181-
const { name, tools, prompts, resources, config } = client
181+
const { name, tools, prompts, resources, config, description } = client
182182
const apiItem: MCPAPI[string] = {}
183183

184184
if (tools) apiItem.tools = createAPIMethods(tools)
185185
if (prompts) apiItem.prompts = createAPIMethods(prompts)
186186
if (resources) apiItem.resources = createAPIMethods(resources)
187187

188188
const metadata = {
189-
name: name,
189+
name,
190190
type: 'metadata__stdio_config' as const,
191-
config: config
191+
config,
192+
description
192193
}
193194

194195
apiItem.metadata = metadata

src/renderer/components/common/ConfigDxtCard.vue

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getDxtUrl, openDxtFilePath } from '@/renderer/utils'
55
import { useDxtStore, validateNumberRange } from '@/renderer/store/dxt'
66
import type { McpMetadataDxt, userConfigValue, McpbManifest, McpDxtErrors } from '@/types/mcp'
77
import { useI18n } from 'vue-i18n'
8+
import MarkdownCard from '@/renderer/components/common/MarkdownCard.vue'
89
const { t } = useI18n()
910
1011
const dxtStore = useDxtStore()
@@ -114,24 +115,13 @@ function hasErrors(config: McpbManifest | McpDxtErrors): config is McpDxtErrors
114115
</v-card>
115116
</div>
116117
<div v-else>
117-
<v-card>
118-
<template #title>
119-
<div class="d-flex">
120-
{{ $t('dxt.title') + ' - ' + metadata.name }}
121-
<v-chip size="small" class="ml-2 mt-1 font-weight-bold" color="primary">
122-
{{ manifest.version }}
123-
</v-chip>
124-
</div>
125-
</template>
118+
<v-card :title="$t('dxt.title')" :subtitle="metadata.name">
126119
<template #append>
127-
<v-btn
128-
color="primary"
129-
variant="text"
130-
rounded="lg"
131-
icon="mdi-folder-open"
132-
@click="openDxtFilePath(metadata.name)"
133-
></v-btn>
120+
<v-chip size="small" class="font-weight-bold" color="primary">
121+
{{ manifest.version }}
122+
</v-chip>
134123
</template>
124+
135125
<v-divider></v-divider>
136126
<v-card
137127
class="mx-auto"
@@ -144,8 +134,17 @@ function hasErrors(config: McpbManifest | McpDxtErrors): config is McpDxtErrors
144134
<v-img :src="getIcon(metadata)"></v-img>
145135
</v-avatar>
146136
</template>
147-
<v-card-text class="wrap-text">
148-
{{ manifest.long_description }}
137+
<template #append>
138+
<v-btn
139+
color="primary"
140+
variant="text"
141+
rounded="lg"
142+
icon="mdi-folder-open"
143+
@click="openDxtFilePath(metadata.name)"
144+
></v-btn>
145+
</template>
146+
<v-card-text v-if="manifest.long_description">
147+
<MarkdownCard :model-value="manifest.long_description"></MarkdownCard>
149148
</v-card-text>
150149
</v-card>
151150
</v-card>

src/renderer/components/common/ConfigStdioCard.vue

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import { McpMetadataStdio } from '@/types/mcp'
33
import { reactive, ref } from 'vue'
44
import { useStdioStore } from '@/renderer/store/stdio'
55
import { getRawServers } from '@/renderer/store/mcp'
6+
67
import McpEditPage from '@/renderer/components/pages/McpEditPage.vue'
8+
9+
import MarkdownCard from '@/renderer/components/common/MarkdownCard.vue'
10+
711
const stdioStore = useStdioStore()
812
913
const editDialog = ref(false)
1014
15+
const show = ref(false)
16+
1117
const showPassword = reactive<Record<string, boolean>>({})
1218
1319
const props = defineProps({
@@ -33,7 +39,15 @@ const editConfig = () => {
3339
</script>
3440

3541
<template>
36-
<v-card title="Stdio Config">
42+
<v-card :title="$t('mcp.stdio')">
43+
<template v-if="metadata.description?.implementation" #subtitle>
44+
{{ metadata.description?.implementation.title ?? metadata.description?.implementation.name }}
45+
</template>
46+
<template v-if="metadata.description?.implementation.version" #append>
47+
<v-chip size="small" class="font-weight-bold" color="primary">{{
48+
metadata.description.implementation.version
49+
}}</v-chip>
50+
</template>
3751
<v-divider></v-divider>
3852
<v-card-text>
3953
<div v-for="(value, key) in metadata.config" :key="key" class="ma-2">
@@ -104,6 +118,11 @@ const editConfig = () => {
104118
</v-card-text>
105119
<v-divider></v-divider>
106120
<v-card-actions>
121+
<v-btn
122+
v-if="metadata.description?.instructions"
123+
:icon="show ? 'mdi-chevron-up' : 'mdi-chevron-down'"
124+
@click="show = !show"
125+
></v-btn>
107126
<v-spacer> </v-spacer>
108127
<v-btn
109128
v-if="metadata.name in (getRawServers() ?? {})"
@@ -133,6 +152,15 @@ const editConfig = () => {
133152
>
134153
</v-btn>
135154
</v-card-actions>
155+
<v-expand-transition v-if="metadata.description?.instructions">
156+
<div v-show="show">
157+
<v-divider></v-divider>
158+
159+
<v-card-text class="ma-2">
160+
<MarkdownCard :model-value="metadata.description.instructions"></MarkdownCard
161+
></v-card-text>
162+
</div>
163+
</v-expand-transition>
136164
</v-card>
137165
<McpEditPage v-model="editDialog" v-model:name="metadata.name"></McpEditPage>
138166
</template>

src/renderer/components/common/MarkdownCard.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<script setup lang="ts">
22
import { MdPreview, config } from 'md-editor-v3'
3+
import { useI18n } from 'vue-i18n'
4+
const { locale } = useI18n()
5+
36
import 'md-editor-v3/lib/style.css'
47
58
import katex from 'katex'
@@ -39,7 +42,6 @@ config({
3942
interface Props {
4043
modelValue: string
4144
codeFoldable?: boolean
42-
language?: string
4345
autoFoldThreshold?: number
4446
}
4547
@@ -54,7 +56,7 @@ withDefaults(defineProps<Props>(), {
5456
<md-preview
5557
:model-value="modelValue"
5658
:code-foldable="codeFoldable"
57-
:language="language"
59+
:language="locale === 'zh' ? 'zh-CN' : 'en-US'"
5860
:auto-fold-threshold="autoFoldThreshold"
5961
/>
6062
</template>

src/renderer/components/pages/ChatPage.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ const { smAndUp } = useDisplay()
3030
3131
const props = defineProps<{
3232
messages: Message[]
33-
language: string
3433
}>()
3534
3635
const emit = defineEmits<{
@@ -185,10 +184,7 @@ const groupMessages = computed<Group[]>(() => {
185184
/>
186185
</v-card-text>
187186
<v-card-text v-else class="md-preview pt-3">
188-
<MarkdownCard
189-
:model-value="group.message!.content"
190-
:language="language === 'zh' ? 'zh-CN' : 'en-US'"
191-
></MarkdownCard>
187+
<MarkdownCard :model-value="group.message!.content"></MarkdownCard>
192188
</v-card-text>
193189
</template>
194190
</chat-card>

src/renderer/locales/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
},
4343
"mcp": {
4444
"config": "Server Config",
45+
"stdio": "Stdio Config",
4546
"file": "Archive File",
4647
"add": "Add MCP Server",
4748
"init": "Start MCP Servers",

src/renderer/locales/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"desc": {},
33
"dxt": {
4-
"title": "MCP扩展包",
4+
"title": "MCP 扩展包",
55
"name": "名称",
66
"version": "版本",
77
"description": "介绍",
@@ -42,6 +42,7 @@
4242
},
4343
"mcp": {
4444
"config": "服务端配置",
45+
"stdio": "Stdio 配置",
4546
"file": "文件压缩包",
4647
"add": "新增 MCP 服务端",
4748
"init": "启动 MCP 服务端",

src/renderer/screens/chat/ChatScreen.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
<script setup lang="ts">
2-
import { useI18n } from 'vue-i18n'
32
import ChatPage from '@/renderer/components/pages/ChatPage.vue'
43
import CommandCard from '@/renderer/components/common/CommandCard.vue'
54
import { useMessageStore } from '@/renderer/store/message'
65
import RobotJSON from '@/public/lotties/robot.json'
76
87
const messageStore = useMessageStore()
9-
10-
const { locale } = useI18n()
118
</script>
129

1310
<template>
1411
<CommandCard></CommandCard>
1512
<ChatPage
1613
v-if="messageStore.conversation.messages.length > 0"
1714
:messages="messageStore.conversation.messages"
18-
:language="locale"
1915
@request-delete="messageStore.deleteMessage"
2016
>
2117
</ChatPage>

0 commit comments

Comments
 (0)