MCPcopy Index your code
hub / github.com/coder/coder / writeMCPConfig

Function writeMCPConfig

agent/x/agentmcp/reload_internal_test.go:24–38  ·  view source on GitHub ↗

writeMCPConfig writes a .mcp.json file with the given server entries. Each entry maps a server name to its config.

(t *testing.T, dir string, servers map[string]mcpServerEntry)

Source from the content-addressed store, hash-verified

22// writeMCPConfig writes a .mcp.json file with the given server
23// entries. Each entry maps a server name to its config.
24func writeMCPConfig(t *testing.T, dir string, servers map[string]mcpServerEntry) string {
25 t.Helper()
26 path := filepath.Join(dir, ".mcp.json")
27 cfg := mcpConfigFile{MCPServers: make(map[string]json.RawMessage)}
28 for name, entry := range servers {
29 raw, err := json.Marshal(entry)
30 require.NoError(t, err)
31 cfg.MCPServers[name] = raw
32 }
33 data, err := json.Marshal(cfg)
34 require.NoError(t, err)
35 err = os.WriteFile(path, data, 0o600)
36 require.NoError(t, err)
37 return path
38}
39
40// fakeMCPServerConfig returns a ServerConfig that launches a fake
41// MCP server using the test binary re-exec pattern.

Calls 3

HelperMethod · 0.65
WriteFileMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected