Skip to main content
Glama

resolve_handle

Convert Bluesky Social handles to DIDs (Decentralized Identifiers) to identify users across the network.

Instructions

Resolve a handle to a DID.

Args:
    ctx: MCP context
    handle: User handle to resolve (e.g. "user.bsky.social")

Returns:
    Resolved DID information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
handleYes

Implementation Reference

  • The primary handler function for the 'resolve_handle' MCP tool. It uses the authenticated Bluesky client to resolve the given handle to a DID and returns the result in a standardized dictionary format.
    @mcp.tool()
    def resolve_handle(
        ctx: Context,
        handle: str,
    ) -> Dict:
        """Resolve a handle to a DID.
    
        Args:
            ctx: MCP context
            handle: User handle to resolve (e.g. "user.bsky.social")
    
        Returns:
            Resolved DID information
        """
        try:
            bluesky_client = get_authenticated_client(ctx)
    
            resolved = bluesky_client.resolve_handle(handle)
    
            # Convert the response to a dictionary
            if hasattr(resolved, "model_dump"):
                resolved_data = resolved.model_dump()
            else:
                resolved_data = resolved
    
            return {
                "status": "success",
                "handle": handle,
                "did": resolved_data.get("did"),
            }
        except Exception as e:
            error_msg = f"Failed to resolve handle: {str(e)}"
            return {"status": "error", "message": error_msg}
  • Helper function used by the resolve_handle tool (and others) to obtain an authenticated Bluesky Client instance from environment variables via the login() function.
    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
  • Supporting login function that authenticates the Bluesky Client using environment variables, 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
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states the tool resolves a handle to DID information but lacks behavioral details: it doesn't specify error handling (e.g., invalid handles), rate limits, authentication requirements, or what 'DID information' includes (e.g., format, additional metadata). This is a significant gap for a tool with no annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with the core purpose stated first. The Args and Returns sections are structured but slightly verbose for a single parameter; the example is helpful but could be integrated more seamlessly. Overall, it's efficient with minimal waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (resolving identifiers in a social media context), no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on authentication, error cases, return format, and how it fits among sibling tools (e.g., vs. 'get_profile'). The agent would need to guess or test to use it effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds value by explaining the 'handle' parameter as a 'User handle to resolve' with an example ('user.bsky.social'), which clarifies semantics beyond the schema's basic string type. However, it doesn't cover constraints (e.g., format rules) or other potential parameters, leaving some gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'resolve' and the resource 'handle to a DID', making the purpose understandable. It distinguishes from siblings by focusing on handle resolution rather than social media actions like posting or following. However, it doesn't explicitly differentiate from potential similar tools like 'get_profile' which might also handle user identification.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication status), compare to sibling tools like 'get_profile' that might retrieve similar information, or specify use cases (e.g., converting handles for API calls). The agent must infer usage from context alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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