Skip to main content
Glama

get_profile

Retrieve user profile information using a handle or the authenticated user's data. Returns detailed profile data for Bluesky Social MCP users.

Instructions

Get a user profile.

Args: ctx: MCP context handle: Optional handle to get profile for. If None, gets the authenticated user Returns: Profile data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
handleNo

Implementation Reference

  • The primary handler function for the 'get_profile' tool. Decorated with @mcp.tool() which also registers it with the MCP server. Retrieves the profile of a specified handle or the authenticated user's profile using the Bluesky client.
    @mcp.tool() def get_profile(ctx: Context, handle: Optional[str] = None) -> Dict: """Get a user profile. Args: ctx: MCP context handle: Optional handle to get profile for. If None, gets the authenticated user Returns: Profile data """ try: bluesky_client = get_authenticated_client(ctx) # If no handle provided, get authenticated user's profile if not handle: handle = bluesky_client.me.handle profile_response = bluesky_client.get_profile(handle) profile = profile_response.dict() return {"status": "success", "profile": profile} except Exception as e: error_msg = f"Failed to get profile: {str(e)}" return {"status": "error", "message": error_msg}
  • Helper function used by get_profile (and other tools) to obtain an authenticated Bluesky Client instance.
    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
  • Underlying helper function that performs the actual login to create the Bluesky Client, called 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