({
export function onconnectionmethodchange() {
console.log();
+}
+
+// 定义连接类型
+type ConnectionType = 'STDIO' | 'SSE';
+
+// 定义命令行参数接口
+export interface MCPOptions {
+ connectionType: ConnectionType;
+ // STDIO 特定选项
+ command?: string;
+ args?: string[];
+ // SSE 特定选项
+ url?: string;
+ // 通用客户端选项
+ clientName?: string;
+ clientVersion?: string;
+}
+
+
+
+export function doConnect() {
+ let connectOption: MCPOptions;
+
+ if (connectionMethods.current === 'STDIO') {
+ const commandComponents = connectionArgs.commandString.split(/\s+/g);
+ const command = commandComponents[0];
+ commandComponents.shift();
+
+ connectOption = {
+ connectionType: 'STDIO',
+ command: command,
+ args: commandComponents,
+ clientName: 'openmcp.connect.stdio.' + command,
+ clientVersion: '0.0.1'
+ }
+
+ } else {
+ const url = connectionArgs.urlString;
+
+ connectOption = {
+ connectionType: 'SSE',
+ url: url,
+ clientName: 'openmcp.connect.sse',
+ clientVersion: '0.0.1'
+ }
+ }
+
+ const bridge = useMessageBridge();
+ bridge.postMessage({
+ command: 'connect',
+ data: connectOption
+ });
}
\ No newline at end of file
diff --git a/app/src/views/connect/index.vue b/app/src/views/connect/index.vue
index de76785..61332dc 100644
--- a/app/src/views/connect/index.vue
+++ b/app/src/views/connect/index.vue
@@ -11,12 +11,9 @@
-
- {{ t('command') }}
-
-
-
-
+
+
+
{{ t('env-var') }}
@@ -50,7 +47,9 @@
-
+
Connect
@@ -60,12 +59,23 @@