Handle MCP sse and URL-based server mapping
This commit is contained in:
parent
5de68cb803
commit
4fcb826b0b
3 changed files with 13 additions and 7 deletions
|
|
@ -291,16 +291,16 @@ export function ConfigPage() {
|
|||
.map((name) => [name, null] as const)
|
||||
|
||||
const upsertServerEntries = normalizedServers.map((server) => {
|
||||
if (server.type === "http") {
|
||||
if (server.type !== "stdio") {
|
||||
if (server.url === "") {
|
||||
throw new Error(`MCP server ${server.name} requires an HTTP URL.`)
|
||||
throw new Error(`MCP server ${server.name} requires a URL.`)
|
||||
}
|
||||
|
||||
return [
|
||||
server.name,
|
||||
{
|
||||
enabled: server.enabled,
|
||||
type: "http",
|
||||
type: server.type,
|
||||
url: server.url,
|
||||
headers: parseJSONObjectField(
|
||||
server.headersText,
|
||||
|
|
|
|||
|
|
@ -380,6 +380,7 @@ export function MCPSection({
|
|||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="stdio">stdio</SelectItem>
|
||||
<SelectItem value="sse">sse</SelectItem>
|
||||
<SelectItem value="http">http</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ export interface CoreConfigForm {
|
|||
mcpServers: MCPServerForm[]
|
||||
}
|
||||
|
||||
export type MCPServerType = "http" | "stdio"
|
||||
export type MCPServerType = "http" | "sse" | "stdio"
|
||||
|
||||
export interface MCPServerForm {
|
||||
id: string
|
||||
|
|
@ -155,7 +155,10 @@ function asNumberString(value: unknown, fallback: string): string {
|
|||
}
|
||||
|
||||
function toMCPServerType(value: unknown): MCPServerType {
|
||||
return value === "http" ? "http" : "stdio"
|
||||
if (value === "http" || value === "sse") {
|
||||
return value
|
||||
}
|
||||
return "stdio"
|
||||
}
|
||||
|
||||
function makeMCPServerID(name: string): string {
|
||||
|
|
@ -176,6 +179,8 @@ function mapMCPServers(value: unknown): MCPServerForm[] {
|
|||
const argsList = Array.isArray(cfg.args)
|
||||
? cfg.args.filter((item): item is string => typeof item === "string")
|
||||
: []
|
||||
const url = asString(cfg.url)
|
||||
const type = cfg.type === undefined ? (url ? "sse" : "stdio") : toMCPServerType(cfg.type)
|
||||
const env = asRecord(cfg.env)
|
||||
const headers = asRecord(cfg.headers)
|
||||
|
||||
|
|
@ -183,8 +188,8 @@ function mapMCPServers(value: unknown): MCPServerForm[] {
|
|||
id: makeMCPServerID(name),
|
||||
name,
|
||||
enabled: cfg.enabled !== false,
|
||||
type: toMCPServerType(cfg.type),
|
||||
url: asString(cfg.url),
|
||||
type,
|
||||
url,
|
||||
command: asString(cfg.command),
|
||||
argsText: argsList.join("\n"),
|
||||
envText: JSON.stringify(env, null, 2),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue