swit-oauth-start
Initiate OAuth authentication and return a URL to open in a browser for authorizing access to Swit workspaces.
Instructions
Start OAuth authentication. Returns authentication URL that can be opened in browser.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/oauth.handlers.ts:17-45 (handler)The `handleOAuthStart` function that executes the 'swit-oauth-start' tool logic. It checks if OAuth web server is initialized, verifies if already authenticated, then generates an authorization URL and returns instructions for browser-based authentication.
export const handleOAuthStart = async (oauthWebServer: OAuthWebServer | null) => { if (!oauthWebServer) { return { error: 'OAuth web server is not initialized. Please check SWIT_CLIENT_ID and SWIT_CLIENT_SECRET environment variables.', }; } if (oauthWebServer.isAuthenticated()) { return { error: 'OAuth authentication already completed.', note: 'To re-authenticate, please logout first.', }; } const authUrl = oauthWebServer.getAuthorizationUrl(); const port = process.env.OAUTH_PORT || '3000'; return { authorizationUrl: authUrl, webServerUrl: `http://localhost:${port}`, instructions: [ '1. Open the authorizationUrl above in your browser.', '2. Login with your Swit account and authorize the application.', '3. The token will be automatically saved upon completion.', '4. Use swit-oauth-status to check authentication status.', ], }; }; - src/tools/oauth.tools.ts:4-4 (schema)Empty schema (EmptySchema) used as the input schema for 'swit-oauth-start', meaning the tool accepts no input parameters.
const EmptySchema = z.object({}); - src/tools/oauth.tools.ts:12-16 (registration)Tool definition/registration for 'swit-oauth-start' in the oauthTools array, defining its name, description, and input schema.
{ name: 'swit-oauth-start', description: 'Start OAuth authentication. Returns authentication URL that can be opened in browser.', inputSchema: zodToJsonSchema(EmptySchema), }, - src/handlers/oauth.handlers.ts:62-66 (registration)The oauthHandlers record mapping the tool name 'swit-oauth-start' to its handler function `handleOAuthStart`, wired up with the OAuthWebServer dependency.
export const oauthHandlers = (oauthWebServer: OAuthWebServer | null) => ({ 'swit-oauth-status': () => handleOAuthStatus(oauthWebServer), 'swit-oauth-start': () => handleOAuthStart(oauthWebServer), 'swit-oauth-logout': () => handleOAuthLogout(oauthWebServer), }); - src/index.ts:109-109 (registration)Final wiring where oauthHandlers are spread into the global toolHandlers record used by the MCP server's CallToolRequestSchema handler.
toolHandlers = { ...oauthHandlers(oauthWebServer), ...coreHandlers(switClient) };