Skip to main content
Glama
brianellin

Bluesky MCP Server

by brianellin

like-post

Like a specific post on Bluesky using its URI. Part of the Bluesky MCP Server, enabling AI assistants to interact with social features on the ATProtocol platform.

Instructions

Like a post on Bluesky

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uriYesThe URI of the post to like

Implementation Reference

  • Handler function that fetches the post thread to get the CID and then calls agent.like() to like the post.
    async ({ uri }) => {
      if (!agent) {
        return mcpErrorResponse("Not logged in. Please check your environment variables.");
      }
    
      try {
        // First, we need to get the CID of the post
        const parts = uri.split('/');
        const repo = parts[2]; // The DID
        const collection = parts[4]; // Usually app.bsky.feed.post
        const rkey = parts[5]; // The record key
        
        const response = await agent.app.bsky.feed.getPostThread({ uri });
        
        if (!response.success || response.data.thread.$type !== 'app.bsky.feed.defs#threadViewPost') {
          return mcpErrorResponse("Failed to get post information.");
        }
        
        // Type assertion to tell TypeScript this is a post
        const threadPost = response.data.thread as any;
        const post = threadPost.post;
        const cid = post.cid;
        
        await agent.like(uri, cid);
        
        return mcpSuccessResponse("Post liked successfully!");
      } catch (error) {
        return mcpErrorResponse(`Error liking post: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema defining the 'uri' parameter as a string with description.
      uri: z.string().describe("The URI of the post to like"),
    },
  • src/index.ts:642-678 (registration)
    Registration of the 'like-post' tool using server.tool(), including name, description, schema, and handler.
    server.tool(
      "like-post",
      "Like a post on Bluesky",
      {
        uri: z.string().describe("The URI of the post to like"),
      },
      async ({ uri }) => {
        if (!agent) {
          return mcpErrorResponse("Not logged in. Please check your environment variables.");
        }
    
        try {
          // First, we need to get the CID of the post
          const parts = uri.split('/');
          const repo = parts[2]; // The DID
          const collection = parts[4]; // Usually app.bsky.feed.post
          const rkey = parts[5]; // The record key
          
          const response = await agent.app.bsky.feed.getPostThread({ uri });
          
          if (!response.success || response.data.thread.$type !== 'app.bsky.feed.defs#threadViewPost') {
            return mcpErrorResponse("Failed to get post information.");
          }
          
          // Type assertion to tell TypeScript this is a post
          const threadPost = response.data.thread as any;
          const post = threadPost.post;
          const cid = post.cid;
          
          await agent.like(uri, cid);
          
          return mcpSuccessResponse("Post liked successfully!");
        } catch (error) {
          return mcpErrorResponse(`Error liking post: ${error instanceof Error ? error.message : String(error)}`);
        }
      }
    );

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