MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / start

Method start

src/mcp/manager.ts:36–72  ·  view source on GitHub ↗

Load config and connect to all approved, non-disabled servers.

()

Source from the content-addressed store, hash-verified

34
35 /** Load config and connect to all approved, non-disabled servers. */
36 async start(): Promise<McpSnapshot> {
37 if (this.started) return this.snapshot()
38 this.started = true
39 const { servers } = loadMcpConfig(this.cwd)
40 this.configs.clear()
41 this.states.clear()
42 for (const [name, cfg] of Object.entries(servers)) {
43 this.configs.set(name, cfg)
44 this.states.set(name, {
45 name,
46 scope: cfg.scope,
47 status: "disabled",
48 toolCount: 0,
49 disabled: this.disabled.has(name),
50 detail: undefined,
51 })
52 }
53
54 // Project-scope servers need explicit approval (they ship in the repo).
55 // User/local-scope servers are trusted (the user wrote them).
56 const toConnect: string[] = []
57 for (const [name, cfg] of this.configs) {
58 if (this.disabled.has(name)) continue
59 if (cfg.scope === "project" && !this.enabled.has(name)) {
60 this.pendingApproval.add(name)
61 this.states.get(name)!.status = "disabled"
62 this.states.get(name)!.detail = "awaiting approval"
63 continue
64 }
65 toConnect.push(name)
66 }
67
68 // At startup, skip the OAuth browser flow for servers with no stored
69 // tokens — mark them needs-auth so the user can auth explicitly from /mcp.
70 await Promise.all(toConnect.map((name) => this.connectOne(name, { skipUnauthOAuth: true })))
71 return this.snapshot()
72 }
73
74 /** Connect (or reconnect) a single server by name.
75 * When `skipUnauthOAuth` is set, OAuth servers with no stored tokens are

Callers 2

runHeadlessFunction · 0.95
AppFunction · 0.95

Calls 4

snapshotMethod · 0.95
connectOneMethod · 0.95
loadMcpConfigFunction · 0.85
clearMethod · 0.80

Tested by

no test coverage detected