Repository navigation
Expand file tree
/
Copy pathindex.mts
More file actions
executable file
·64 lines (61 loc) · 1.78 KB
/
Copy pathindex.mts
File metadata and controls
executable file
·64 lines (61 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
import {
createSocketMcpCliDeps,
reportSocketMcpStartupFailure,
runSocketMcpCli,
} from './lib/cli.mts'
import { loginWithBrowserOAuth, logoutLocalOAuth } from './lib/local-oauth.mts'
import { logger } from './lib/logger.mts'
// Re-export the module's public surface so existing consumers (tests,
// downstream importers) continue to work after the split.
export {
buildSocketHeaders,
getApiKeyInteractively,
getForwardedHeaderValue,
getRequestBaseUrl,
getRequestHeaderValue,
parseJsonObject,
writeJson,
writeOAuthError,
} from './lib/http.mts'
export { createConfiguredServer } from './lib/server.mts'
export {
authenticateRequest,
buildProtectedResourceMetadata,
getProtectedResourceMetadataUrl,
loadOAuthMetadata,
splitScopes,
verifyAccessToken,
} from './lib/oauth.mts'
// Wrap CLI startup in an async main() so rolldown can bundle to CJS
// (top-level await isn't supported in CJS output).
async function main(): Promise<void> {
const [command, ...args] = process.argv.slice(2)
if (command === 'login') {
if (args.length > 0) {
logger.error('Usage: socket-mcp login')
process.exitCode = 1
return
}
await loginWithBrowserOAuth()
return
}
if (command === 'logout') {
if (args.length > 0) {
logger.error('Usage: socket-mcp logout')
process.exitCode = 1
return
}
await logoutLocalOAuth()
return
}
if (command === '--help' || command === '-h') {
logger.info(
'Usage: socket-mcp [--http] | socket-mcp login | socket-mcp logout\n' +
'Local stdio: run `socket-mcp login` for browser OAuth. A raw API token is a discouraged fallback.',
)
return
}
process.exitCode = await runSocketMcpCli(createSocketMcpCliDeps())
}
main().catch(reportSocketMcpStartupFailure)