Skip to main content
Glama
brianellin

Bluesky MCP Server

by brianellin

convert-url-to-uri

Transform Bluesky post URLs into AT URIs for compatibility with other tools in the Bluesky MCP Server ecosystem.

Instructions

Convert a Bluesky web URL to an AT URI format that can be used with other tools

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesBluesky post URL to convert (e.g., https://bsky.app/profile/username.bsky.social/post/postid)

Implementation Reference

  • src/index.ts:387-409 (registration)
    Registration of the 'convert-url-to-uri' MCP tool, including description, input schema, and inline handler function that calls the helper.
      "convert-url-to-uri",
      "Convert a Bluesky web URL to an AT URI format that can be used with other tools",
      {
        url: z.string().describe("Bluesky post URL to convert (e.g., https://bsky.app/profile/username.bsky.social/post/postid)")
      },
      async ({ url }) => {
        if (!agent) {
          return mcpErrorResponse("Not logged in. Please check your environment variables.");
        }
    
        try {
          const atUri = await convertBskyUrlToAtUri(url, agent);
          
          if (!atUri) {
            return mcpErrorResponse(`Failed to convert URL: ${url}. Make sure it's a valid Bluesky post URL.`);
          }
          
          return mcpSuccessResponse(`Successfully converted to AT URI: ${atUri}`);
        } catch (error) {
          return mcpErrorResponse(`Error converting URL: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );
  • Inline handler function for the 'convert-url-to-uri' tool that validates agent, calls convertBskyUrlToAtUri, and formats response.
    async ({ url }) => {
      if (!agent) {
        return mcpErrorResponse("Not logged in. Please check your environment variables.");
      }
    
      try {
        const atUri = await convertBskyUrlToAtUri(url, agent);
        
        if (!atUri) {
          return mcpErrorResponse(`Failed to convert URL: ${url}. Make sure it's a valid Bluesky post URL.`);
        }
        
        return mcpSuccessResponse(`Successfully converted to AT URI: ${atUri}`);
      } catch (error) {
        return mcpErrorResponse(`Error converting URL: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema for the tool using Zod: requires a 'url' string parameter.
    {
      url: z.string().describe("Bluesky post URL to convert (e.g., https://bsky.app/profile/username.bsky.social/post/postid)")
    },
  • Core helper function that parses the Bluesky URL, resolves handle to DID using agent, and constructs the AT URI.
    export async function convertBskyUrlToAtUri(url: string, agent: AtpAgent): Promise<string | null> {
      try {
        const parsed = parseBskyUrl(url);
        if (!parsed) return null;
        
        // Resolve the handle to a DID
        const resolveResponse = await agent.resolveHandle({ handle: parsed.handle });
        
        if (!resolveResponse.success) {
          return null;
        }
        
        const did = resolveResponse.data.did;
        
        // Construct the AT URI
        return `at://${did}/app.bsky.feed.post/${parsed.rkey}`;
      } catch (error) {
        return null;
      }
    }
  • Supporting helper function to parse Bluesky web URL into handle and rkey components.
    export function parseBskyUrl(url: string): { handle: string, rkey: string } | null {
      try {
        // Remove any @ prefix if provided
        const cleanUrl = url.trim().replace(/^@/, '');
        
        // Match patterns like https://bsky.app/profile/username.bsky.social/post/postid
        const regex = /https?:\/\/bsky\.app\/profile\/([^\/]+)\/post\/([^\/\?#]+)/;
        const match = cleanUrl.match(regex);
        
        if (!match) return null;
        
        return {
          handle: match[1],
          rkey: match[2]
        };
      } catch (error) {
        return null;
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions the output format (AT URI) and its utility for other tools, but lacks details on error handling (e.g., invalid URLs), rate limits, or authentication needs. This is a significant gap for a tool with potential input validation issues.

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

Conciseness5/5

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

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. Every word earns its place, making it easy to parse and understand quickly.

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

Completeness3/5

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

Given the tool's low complexity (one parameter, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and output utility, but lacks behavioral context (e.g., error handling) and doesn't fully compensate for the absence of annotations, leaving gaps for safe agent use.

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?

The input schema has 100% description coverage, clearly documenting the single 'url' parameter with an example. The description adds minimal value beyond the schema by implying the URL must be a Bluesky post URL, but doesn't specify format constraints or edge cases. Baseline 3 is appropriate as the schema does the heavy lifting.

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 action ('Convert') and the resource ('Bluesky web URL to an AT URI format'), making the purpose understandable. It distinguishes from siblings by focusing on URL conversion rather than social interactions like posting or following, though it doesn't explicitly contrast with similar tools (none exist in the sibling list).

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

Usage Guidelines3/5

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

The description implies usage context by stating the converted URI 'can be used with other tools,' suggesting it's a preprocessing step. However, it doesn't provide explicit guidance on when to use this tool versus alternatives (e.g., direct input of URIs) or any prerequisites, leaving some ambiguity.

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

Related 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/brianellin/bsky-mcp-server'

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