Skip to main content
Glama

check_auth_status

Verify session authentication status for Bluesky API. Uses predefined environment variables for handle, app password, and service URL. Returns the current authentication state.

Instructions

Check if the current session is authenticated.

Authentication happens automatically using environment variables: - BLUESKY_IDENTIFIER: Required - your Bluesky handle - BLUESKY_APP_PASSWORD: Required - your app password - BLUESKY_SERVICE_URL: Optional - defaults to https://bsky.social Returns: Authentication status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function implementing the 'check_auth_status' tool. It retrieves an authenticated Bluesky client and returns the authentication status as a string.
    @mcp.tool() def check_auth_status(ctx: Context) -> str: """Check if the current session is authenticated. Authentication happens automatically using environment variables: - BLUESKY_IDENTIFIER: Required - your Bluesky handle - BLUESKY_APP_PASSWORD: Required - your app password - BLUESKY_SERVICE_URL: Optional - defaults to https://bsky.social Returns: Authentication status """ try: bluesky_client = get_authenticated_client(ctx) return f"Authenticated to {bluesky_client._base_url}" except ValueError as e: return f"Not authenticated: {str(e)}"
  • Helper function to lazily obtain an authenticated Bluesky client from the application context, called by check_auth_status.
    def get_authenticated_client(ctx: Context) -> Client: """Get an authenticated client, creating it lazily if needed. Args: ctx: MCP context Returns: Authenticated Client instance Raises: ValueError: If credentials are not available """ app_context = ctx.request_context.lifespan_context # If we already have a client, return it if app_context.bluesky_client is not None: return app_context.bluesky_client # Try to create a new client by calling login again client = login() if client is None: raise ValueError( "Authentication required but credentials not available. " "Please set BLUESKY_IDENTIFIER and BLUESKY_APP_PASSWORD environment variables." ) # Store it in the context for future use app_context.bluesky_client = client return client
  • Utility function to login to Bluesky using environment variables, used by get_authenticated_client.
    def login() -> Optional[Client]: """Login to Bluesky API and return the client. Authenticates using environment variables: - BLUESKY_IDENTIFIER: The handle (username) - BLUESKY_APP_PASSWORD: The app password - BLUESKY_SERVICE_URL: The service URL (defaults to "https://bsky.social") Returns: Authenticated Client instance or None if credentials are not available """ handle = os.environ.get("BLUESKY_IDENTIFIER") password = os.environ.get("BLUESKY_APP_PASSWORD") service_url = os.environ.get("BLUESKY_SERVICE_URL", "https://bsky.social") if not handle or not password: return None # This is helpful for debugging. # print(f"LOGIN {handle=} {service_url=}", file=sys.stderr) # Create and authenticate client client = Client(service_url) client.login(handle, password) return client

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/gwbischof/bluesky-social-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server