MCPcopy Index your code
hub / github.com/simstudioai/sim / constructor

Method constructor

apps/sim/lib/mcp/client.ts:49–85  ·  view source on GitHub ↗
(options: McpClientOptions)

Source from the content-addressed store, hash-verified

47 private isConnected = false
48
49 constructor(options: McpClientOptions) {
50 this.config = options.config
51 this.securityPolicy = options.securityPolicy ?? {
52 requireConsent: true,
53 auditLevel: 'basic',
54 maxToolExecutionsPerHour: 1000,
55 }
56 this.onToolsChanged = options.onToolsChanged
57 this.authProvider = options.authProvider
58 const resolvedIP = options.resolvedIP
59
60 this.connectionStatus = { connected: false }
61
62 if (!this.config.url) {
63 throw new McpError('URL required for Streamable HTTP transport')
64 }
65
66 if (this.config.authType === 'oauth' && this.authProvider == null) {
67 throw new McpError('OAuth MCP server requires an authProvider')
68 }
69 const useOauth = this.config.authType === 'oauth'
70 this.transport = new StreamableHTTPClientTransport(new URL(this.config.url), {
71 authProvider: useOauth ? this.authProvider : undefined,
72 requestInit: { headers: this.config.headers },
73 ...(resolvedIP ? { fetch: createPinnedFetch(resolvedIP) } : {}),
74 })
75
76 this.client = new Client(
77 {
78 name: 'sim-platform',
79 version: '1.0.0',
80 },
81 {
82 capabilities: {},
83 }
84 )
85 }
86
87 /**
88 * Initialize connection to MCP server.

Callers

nothing calls this directly

Calls 1

createPinnedFetchFunction · 0.90

Tested by

no test coverage detected