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;
      }
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A3.6/5.0
Behavior2/5

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

No annotations are provided, so the description bears full responsibility for behavioral disclosure. It does not mention edge cases (e.g., invalid URLs), whether only post URLs are supported (schema says 'post URL' but description says 'web URL'), or the exact shape of the returned value (plain string vs. object). This leaves significant unknowns for an agent.

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, front-loaded sentence that immediately conveys the action and output. Every word serves a purpose, and it avoids extraneous detail.

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 no output schema, the description should clarify the return value format (e.g., 'returns a string') and any input constraints (e.g., only post URLs). It does not, nor does it mention error handling or supported URL types, leaving the agent to guess about behavior that is not inferable from structured data.

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 schema covers the only parameter with a description and example, so schema_description_coverage is 100%. The tool description adds no additional parameter details beyond what the schema provides, which meets the baseline but does not elevate it.

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

Purpose5/5

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

The description clearly states a specific verb ('Convert') and resource ('Bluesky web URL') with a distinct output ('AT URI format'). This distinguishes it from sibling tools, which are all CRUD/search operations, making the tool's purpose unambiguous.

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

Usage Guidelines4/5

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

The description implies usage context: when you have a Bluesky web URL and need an AT URI for other tools. It does not explicitly state when not to use it or name alternative tools, but the conversion-focused purpose naturally separates it from siblings in the list.

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

Deploy Server

Other Tools

Related Tools