MCPcopy
hub / github.com/anomalyco/opencode / resolveServerList

Function resolveServerList

packages/app/src/context/server.tsx:114–145  ·  view source on GitHub ↗
(input: {
  props?: Array<ServerConnection.Any>
  stored: StoredServer[]
})

Source from the content-addressed store, hash-verified

112}
113
114export function resolveServerList(input: {
115 props?: Array<ServerConnection.Any>
116 stored: StoredServer[]
117}): Array<ServerConnection.Any> {
118 const deduped = new Map<ServerConnection.Key, ServerConnection.Any>(
119 input.props?.map((v) => [ServerConnection.key(v), v]) ?? [],
120 )
121
122 for (const value of input.stored) {
123 const conn: ServerConnection.Http =
124 typeof value === "string"
125 ? {
126 type: "http" as const,
127 http: { url: value },
128 }
129 : "http" in value
130 ? value
131 : { type: "http", http: value }
132 const key = ServerConnection.key(conn)
133
134 const existing = deduped.get(key)
135 if (existing)
136 deduped.set(key, {
137 ...existing,
138 ...conn,
139 http: { ...existing.http, ...conn.http },
140 })
141 else deduped.set(key, conn)
142 }
143
144 return [...deduped.values()]
145}
146
147export namespace ServerConnection {
148 type Base = { displayName?: string; label?: string }

Callers 2

server.test.tsFile · 0.90
server.tsxFile · 0.85

Calls 4

getMethod · 0.65
keyMethod · 0.45
setMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected