11package acpio
22
33import (
4+ "slices"
5+
46 "github.com/coder/acp-go-sdk"
57 "golang.org/x/xerrors"
68)
@@ -13,31 +15,23 @@ type AgentapiMcpConfig struct {
1315
1416// AgentapiMcpServer represents a single MCP server in Claude's format.
1517type AgentapiMcpServer struct {
16- // Type can be "stdio" or "http". Defaults to "stdio" if not specified.
17- Type string `json:"type,omitempty "`
18+ // Type can be "stdio", "sse" or "http"
19+ Type string `json:"type"`
1820 // Stdio transport fields
1921 Command string `json:"command,omitempty"`
2022 Args []string `json:"args,omitempty"`
2123 Env map [string ]string `json:"env,omitempty"`
22- // HTTP transport fields
24+ // HTTP | SSE transport fields
2325 URL string `json:"url,omitempty"`
2426 Headers map [string ]string `json:"headers,omitempty"`
2527}
2628
2729// convertAgentapiMcpToAcp converts a Claude MCP server config to the ACP format.
2830func (a * AgentapiMcpServer ) convertAgentapiMcpToAcp (name string ) (acp.McpServer , error ) {
2931 serverType := a .Type
30- if serverType == "" {
31- // Default to stdio if no type specified and command is present
32- if a .Command != "" {
33- serverType = "stdio"
34- } else if a .URL != "" {
35- serverType = "http"
36- }
37- }
32+ acpMCPServer := acp.McpServer {}
3833
39- switch serverType {
40- case "stdio" , "" :
34+ if serverType == "stdio" {
4135 if a .Command == "" {
4236 return acp.McpServer {}, xerrors .Errorf ("stdio server %q missing command" , name )
4337 }
@@ -49,16 +43,14 @@ func (a *AgentapiMcpServer) convertAgentapiMcpToAcp(name string) (acp.McpServer,
4943 Value : value ,
5044 })
5145 }
52- return acp.McpServer {
53- Stdio : & acp.McpServerStdio {
54- Name : name ,
55- Command : a .Command ,
56- Args : a .Args ,
57- Env : envVars ,
58- },
59- }, nil
6046
61- case "http" :
47+ acpMCPServer .Stdio = & acp.McpServerStdio {
48+ Name : name ,
49+ Command : a .Command ,
50+ Args : a .Args ,
51+ Env : envVars ,
52+ }
53+ } else if slices .Contains ([]string {"http" , "sse" }, serverType ) {
6254 if a .URL == "" {
6355 return acp.McpServer {}, xerrors .Errorf ("http server %q missing url" , name )
6456 }
@@ -70,16 +62,24 @@ func (a *AgentapiMcpServer) convertAgentapiMcpToAcp(name string) (acp.McpServer,
7062 Value : value ,
7163 })
7264 }
73- return acp.McpServer {
74- Http : & acp.McpServerHttp {
65+
66+ if serverType == "sse" {
67+ acpMCPServer .Sse = & acp.McpServerSse {
68+ Name : name ,
69+ Type : "sse" ,
70+ Url : a .URL ,
71+ Headers : headers ,
72+ }
73+ } else {
74+ acpMCPServer .Http = & acp.McpServerHttp {
7575 Name : name ,
7676 Type : "http" ,
7777 Url : a .URL ,
7878 Headers : headers ,
79- },
80- }, nil
81-
82- default :
79+ }
80+ }
81+ } else {
8382 return acp.McpServer {}, xerrors .Errorf ("unsupported server type %q for server %q" , serverType , name )
8483 }
84+ return acpMCPServer , nil
8585}
0 commit comments