connect_discord_bot
Authenticate a Discord bot or account by creating a Composio Connect link. Use this when the user asks to connect or another tool reports missing authentication.
Instructions
Create a Composio Connect Link for authenticating the Discord bot/account connection. Use this whenever the user asks to connect Discord, or whenever another Discord tool reports that authentication is required.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- index.ts:566-575 (handler)Handler function for the connect_discord_bot MCP tool. Creates a Composio Connect Link for Discord bot/account authentication, attempts to open it in a browser, and returns a formatted message to the user.
server.tool( "connect_discord_bot", "Create a Composio Connect Link for authenticating the Discord bot/account connection. Use this whenever the user asks to connect Discord, or whenever another Discord tool reports that authentication is required.", {}, async () => { const redirectUrl = await createDiscordConnectLink(); const openedBrowser = openUrlInBrowser(redirectUrl); return textResponse(formatConnectLinkMessage(redirectUrl, openedBrowser)); } ); - index.ts:566-575 (registration)Registration of the 'connect_discord_bot' tool on the McpServer instance using server.tool(). The tool has no input parameters (empty schema object).
server.tool( "connect_discord_bot", "Create a Composio Connect Link for authenticating the Discord bot/account connection. Use this whenever the user asks to connect Discord, or whenever another Discord tool reports that authentication is required.", {}, async () => { const redirectUrl = await createDiscordConnectLink(); const openedBrowser = openUrlInBrowser(redirectUrl); return textResponse(formatConnectLinkMessage(redirectUrl, openedBrowser)); } ); - index.ts:569-569 (schema)The tool's input schema is an empty object (no parameters required).
{}, - index.ts:333-352 (helper)Helper function that creates a Composio authorization link for the DISCORDBOT toolkit. Uses either a configured auth config or the session's default authorization.
async function createDiscordConnectLink(): Promise<string> { const connectionRequest = COMPOSIO_AUTH_CONFIG_ID ? await composio.toolkits.authorize( composioUserId, COMPOSIO_TOOLKIT_SLUG, COMPOSIO_AUTH_CONFIG_ID ) : await (await getSession()).authorize(COMPOSIO_TOOLKIT_SLUG); const redirectUrl = connectionRequest.redirectUrl ? normalizeComposioConnectUrl(connectionRequest.redirectUrl) : null; if (!redirectUrl) { throw new Error( "Composio did not return a Discord connect link. Check the DISCORDBOT auth configuration in Composio." ); } return redirectUrl; } - index.ts:264-276 (helper)Helper function that formats the user-facing message when the connect link is generated, indicating whether the browser was opened successfully.
function formatConnectLinkMessage(redirectUrl: string, openedBrowser: boolean): string { return [ "Discord is connected to VoiceOS, but your Discord bot/account connection is not authenticated in Composio yet.", "", openedBrowser ? "I opened the Composio Discord connection page in your browser." : "I could not open the Composio Discord connection page automatically.", "", "I am intentionally not printing the Composio URL because VoiceOS link handling has been corrupting Composio hostnames in chat.", "", "After completing authentication, retry your Discord request.", ].join("\n"); }