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
| Name | Required | Description | Default |
|---|---|---|---|
| uri | Yes | The URI of the post to like |
Implementation Reference
- src/index.ts:648-677 (handler)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)}`); } }
- src/index.ts:646-647 (schema)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)}`); } } );