MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / addServerToConfig

Function addServerToConfig

src/mcp/config-writer.ts:106–118  ·  view source on GitHub ↗
(
  spec: McpServerSpec,
  opts: AddServerOptions = {},
)

Source from the content-addressed store, hash-verified

104
105/** Add (or overwrite) a server entry under mcp.servers.<id> in user config. */
106export async function addServerToConfig(
107 spec: McpServerSpec,
108 opts: AddServerOptions = {},
109): Promise<{ id: string; entry: BuiltServerEntry }> {
110 const id = opts.asId ?? spec.id;
111 const cfg = await readRawUserConfig();
112 cfg.mcp = cfg.mcp ?? {};
113 cfg.mcp.servers = cfg.mcp.servers ?? {};
114 const entry = buildServerEntry(spec, opts);
115 cfg.mcp.servers[id] = entry;
116 await writeRawUserConfig(cfg);
117 return { id, entry };
118}
119
120/** Remove a server entry. Returns true if it existed. */
121export async function removeServerFromConfig(id: string): Promise<boolean> {

Callers 2

index.tsFile · 0.85
executeMethod · 0.85

Calls 3

readRawUserConfigFunction · 0.85
buildServerEntryFunction · 0.85
writeRawUserConfigFunction · 0.85

Tested by

no test coverage detected