Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 37 additions & 18 deletions agent/app/service/mcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,14 @@ func (m McpServerService) Update(req request.McpServerUpdate) error {
mcpServer.Port = req.Port
mcpServer.Command = req.Command
mcpServer.BaseURL = req.BaseURL
mcpServer.SsePath = req.SsePath
mcpServer.HostIP = req.HostIP
mcpServer.StreamableHttpPath = req.StreamableHttpPath
mcpServer.OutputTransport = req.OutputTransport
mcpServer.Type = req.Type
if req.OutputTransport == "sse" {
mcpServer.SsePath = req.SsePath
} else {
mcpServer.StreamableHttpPath = req.StreamableHttpPath
}
if err := handleCreateParams(mcpServer, req.Environments, req.Volumes); err != nil {
return err
}
Expand Down Expand Up @@ -163,19 +166,23 @@ func (m McpServerService) Create(create request.McpServerCreate) error {
}
mcpDir := path.Join(global.Dir.McpDir, create.Name)
mcpServer := &model.McpServer{
Name: create.Name,
ContainerName: create.ContainerName,
Port: create.Port,
Command: create.Command,
Status: constant.StatusStarting,
BaseURL: create.BaseURL,
SsePath: create.SsePath,
Dir: mcpDir,
HostIP: create.HostIP,
StreamableHttpPath: create.StreamableHttpPath,
OutputTransport: create.OutputTransport,
Type: create.Type,
Name: create.Name,
ContainerName: create.ContainerName,
Port: create.Port,
Command: create.Command,
Status: constant.StatusStarting,
BaseURL: create.BaseURL,
Dir: mcpDir,
HostIP: create.HostIP,
OutputTransport: create.OutputTransport,
Type: create.Type,
}
if create.OutputTransport == "sse" {
mcpServer.SsePath = create.SsePath
} else {
mcpServer.StreamableHttpPath = create.StreamableHttpPath
}

if err := handleCreateParams(mcpServer, create.Environments, create.Volumes); err != nil {
return err
}
Expand Down Expand Up @@ -445,8 +452,14 @@ func addProxy(server *model.McpServer) {
if !ok {
return
}
location.UpdateDirective("proxy_pass", []string{fmt.Sprintf("http://127.0.0.1:%d%s", server.Port, server.SsePath)})
location.ChangePath("^~", server.SsePath)
var proxyPath string
if server.OutputTransport == "sse" {
proxyPath = server.SsePath
} else {
proxyPath = server.StreamableHttpPath
}
location.UpdateDirective("proxy_pass", []string{fmt.Sprintf("http://127.0.0.1:%d%s", server.Port, proxyPath)})
location.ChangePath("^~", proxyPath)
if err = nginx.WriteConfig(config, nginx.IndentedStyle); err != nil {
global.LOG.Errorf("write config failed, err: %v", buserr.WithErr("ErrUpdateBuWebsite", err))
return
Expand Down Expand Up @@ -497,8 +510,14 @@ func addMCPProxy(websiteID uint) error {
err = errors.New("error")
return err
}
location.UpdateDirective("proxy_pass", []string{fmt.Sprintf("http://127.0.0.1:%d%s", server.Port, server.SsePath)})
location.ChangePath("^~", server.SsePath)
var proxyPath string
if server.OutputTransport == "sse" {
proxyPath = server.SsePath
} else {
proxyPath = server.StreamableHttpPath
}
location.UpdateDirective("proxy_pass", []string{fmt.Sprintf("http://127.0.0.1:%d%s", server.Port, proxyPath)})
location.ChangePath("^~", proxyPath)
if err = nginx.WriteConfig(config, nginx.IndentedStyle); err != nil {
return buserr.WithErr("ErrUpdateBuWebsite", err)
}
Expand Down
17 changes: 14 additions & 3 deletions frontend/src/views/ai/mcp/server/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div>
<RouterMenu />
<LayoutContent :title="'Servers'" v-loading="loading">
<template #toolbar>
<template #leftToolBar>
<div class="flex flex-wrap gap-3">
<el-button type="primary" @click="openCreate">
{{ $t('aiTools.mcp.create') }}
Expand All @@ -12,6 +12,9 @@
</el-button>
</div>
</template>
<template #rightToolBar>
<TableRefresh @search="search()" />
</template>
<template #main>
<ComplexTable :pagination-config="paginationConfig" :data="items" @search="search()">
<el-table-column
Expand All @@ -29,8 +32,8 @@
</el-table-column>
<el-table-column :label="$t('aiTools.mcp.externalUrl')" prop="baseUrl" min-width="200px">
<template #default="{ row }">
{{ row.baseUrl + row.ssePath }}
<CopyButton :content="row.baseUrl + row.ssePath" />
{{ getUrl(row) }}
<CopyButton :content="getUrl(row)" />
</template>
</el-table-column>
<el-table-column :label="$t('commons.table.status')" prop="status" width="120px">
Expand Down Expand Up @@ -125,6 +128,14 @@ const mobile = computed(() => {
return globalStore.isMobile();
});

const getUrl = (row: AI.McpServer) => {
if (row.outputTransport == 'sse') {
return row.baseUrl + row.ssePath;
} else {
return row.baseUrl + row.streamableHttpPath;
}
};

const buttons = [
{
label: i18n.global.t('menu.config'),
Expand Down
Loading