INNER CODE UNIT · Python

_execute_tool

existence-master/Sentient · src/server/mcp_hub/discord/main.py:31

async def _execute_tool(ctx: Context, method_name: str, *args, **kwargs) -> Dict[str, Any]:
    try:
        user_id = auth.get_user_id_from_context(ctx)
        creds = await auth.get_discord_creds(user_id)
        client = utils.DiscordApiClient(bot_token=creds['bot_token'])
        
        method_to_call = getattr(client, method_name)
        result = await method_to_call(*args, **kwargs)
        
        return {"status": "success", "result": result}
    except Exception as e:
        logger.error(f"Tool execution failed for method '{method_name}': {e}", exc_info=True)
        return {"status": "failure", "error": str(e)}

@mcp.tool
async def list_guilds(ctx: Context) -> Dict:
    """
    Lists the Discord servers (guilds) that the authenticated user's bot is a member of, returning their names and IDs.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…