MCPcopy Create free account
hub / github.com/arctic-cli/interface / create

Function create

packages/arctic/src/mcp/index.ts:152–329  ·  view source on GitHub ↗
(key: string, mcp: Config.Mcp)

Source from the content-addressed store, hash-verified

150 }
151
152 async function create(key: string, mcp: Config.Mcp) {
153 if (mcp.enabled === false) {
154 log.info("mcp server disabled", { key })
155 return {
156 mcpClient: undefined,
157 status: { status: "disabled" as const },
158 }
159 }
160 log.info("found", { key, type: mcp.type })
161 let mcpClient: MCPClient | undefined
162 let status: Status | undefined = undefined
163
164 if (mcp.type === "remote") {
165 // OAuth is enabled by default for remote servers unless explicitly disabled with oauth: false
166 const oauthDisabled = mcp.oauth === false
167 const oauthConfig = typeof mcp.oauth === "object" ? mcp.oauth : undefined
168 let authProvider: McpOAuthProvider | undefined
169
170 if (!oauthDisabled) {
171 authProvider = new McpOAuthProvider(
172 key,
173 mcp.url,
174 {
175 clientId: oauthConfig?.clientId,
176 clientSecret: oauthConfig?.clientSecret,
177 scope: oauthConfig?.scope,
178 },
179 {
180 onRedirect: async (url) => {
181 log.info("oauth redirect requested", { key, url: url.toString() })
182 // Store the URL - actual browser opening is handled by startAuth
183 },
184 },
185 )
186 }
187
188 const transports: Array<{ name: string; transport: TransportWithAuth }> = [
189 {
190 name: "StreamableHTTP",
191 transport: new StreamableHTTPClientTransport(new URL(mcp.url), {
192 authProvider,
193 requestInit: mcp.headers ? { headers: mcp.headers } : undefined,
194 }),
195 },
196 {
197 name: "SSE",
198 transport: new SSEClientTransport(new URL(mcp.url), {
199 authProvider,
200 requestInit: mcp.headers ? { headers: mcp.headers } : undefined,
201 }),
202 },
203 ]
204
205 let lastError: Error | undefined
206 for (const { name, transport } of transports) {
207 try {
208 mcpClient = await experimental_createMCPClient({
209 name: "arctic",

Callers 3

index.tsFile · 0.70
addFunction · 0.70
connectFunction · 0.70

Calls 2

withTimeoutFunction · 0.90
setMethod · 0.45

Tested by

no test coverage detected