MCPcopy
hub / github.com/21st-dev/1code / load

Method load

src/main/lib/credential-manager.ts:110–128  ·  view source on GitHub ↗

* Load credential for a source * * For MCP sources, tries both OAuth and bearer credentials as fallback * (credentials may have been stored via different auth modes)

(source: LoadedSource)

Source from the content-addressed store, hash-verified

108 * (credentials may have been stored via different auth modes)
109 */
110 async load(source: LoadedSource): Promise<StoredCredential | null> {
111 const manager = getCredentialManager();
112
113 // For MCP sources, try both OAuth and bearer credentials
114 // (stdio transport doesn't need credentials)
115 if (source.config.type === 'mcp' && source.config.mcp?.transport !== 'stdio' && source.config.mcp?.authType !== 'none') {
116 return this.loadMcpCredential(source);
117 }
118
119 // For other sources, use the credential ID based on authType
120 const credentialId = this.getCredentialId(source);
121 const cred = await manager.get(credentialId);
122
123 if (cred) {
124 debug(`[SourceCredentialManager] Found ${credentialId.type} for ${source.config.slug}`);
125 }
126
127 return cred;
128 }
129
130 /**
131 * Load MCP credential with fallback (OAuth -> bearer)

Callers 3

getTokenMethod · 0.95
getApiCredentialMethod · 0.95
refreshMethod · 0.95

Calls 3

loadMcpCredentialMethod · 0.95
getCredentialIdMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected