Skip to content

Commit c891ece

Browse files
committed
feat: enhance MCP server configuration with support for SSE type and update JSON structure
1 parent f31782b commit c891ece

File tree

4 files changed

+31
-29
lines changed

4 files changed

+31
-29
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ The file uses the same format as Claude's MCP configuration:
143143
```json
144144
{
145145
"mcpServers": {
146+
"type": "stdio",
146147
"filesystem": {
147148
"command": "npx",
148149
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],

e2e/echo_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ func TestServerFlagValidation(t *testing.T) {
580580
// Create a temporary MCP file
581581
tmpDir := t.TempDir()
582582
mcpFile := filepath.Join(tmpDir, "mcp.json")
583-
err := os.WriteFile(mcpFile, []byte(`{"mcpServers": []}`), 0o644)
583+
err := os.WriteFile(mcpFile, []byte(`{"mcpServers": {}}`), 0o644)
584584
require.NoError(t, err, "Failed to create temp MCP file")
585585

586586
// Run the server with --mcp-file but WITHOUT --experimental-acp

x/acpio/mcp.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package acpio
22

33
import (
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.
1517
type 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.
2830
func (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
}

x/acpio/mcp_internal_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ func TestGetSupportedMCPConfig(t *testing.T) {
252252
func TestConvertAgentapiMcpToAcp(t *testing.T) {
253253
t.Run("converts stdio server correctly", func(t *testing.T) {
254254
server := AgentapiMcpServer{
255+
Type: "stdio",
255256
Command: "/usr/bin/mcp-server",
256257
Args: []string{"--arg1", "--arg2"},
257258
Env: map[string]string{

0 commit comments

Comments
 (0)