swit-oauth-start
Initiate OAuth authentication to access Swit workspaces, channels, and messages by generating a secure URL for browser-based login.
Instructions
Start OAuth authentication. Returns authentication URL that can be opened in browser.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/handlers/oauth.handlers.ts:17-45 (handler)The handleOAuthStart function implements the core logic of the 'swit-oauth-start' tool, handling OAuth initialization checks and returning the authorization URL with instructions.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:12-16 (schema)Schema definition for the 'swit-oauth-start' tool, specifying name, description, and empty 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)Factory function oauthHandlers that maps 'swit-oauth-start' to the handleOAuthStart execution wrapper.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)Top-level integration of oauthHandlers into the global toolHandlers map used by the MCP CallToolRequest handler.toolHandlers = { ...oauthHandlers(oauthWebServer), ...coreHandlers(switClient) };
- src/index.ts:61-63 (registration)MCP server request handler for listing tools, which includes the schema definitions from oauthTools containing 'swit-oauth-start'.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [...oauthTools, ...coreTools] }; });