Skip to main content

Creating a Bluesky Bot with Tasks

This tutorial guides you through creating a Bluesky bot that can interact using mcp.run's Tasks. You'll learn how to set up a bot that can process messages and use various mcp.run servlets to enhance its capabilities.

Prerequisites

Before starting, ensure you have:

Required Tools

This tutorial requires the following mcp.run servlets:

  • Bluesky - For Bluesky bot interactions
  • fetch - To read the contents of a website
  • brave-search - For search capabilities (optional)

Install each servlet by:

  1. Visiting the respective URL
  2. Clicking the 'Install' button
  3. Verifying they appear in your install profile

Getting A Bluesky App Password

  1. Open Bluesky and navigate to Settings > Privacy and Security > App Passwords
  2. Click the Add App Password button
  3. Enter a unique name to identify your app
  4. Copy the app password from the next dialog.

Configuring the Bluesky Servlet

  1. Install the Bluesky servlet on mcp.run
  2. Configure the base URL, usually https://bsky.social
  3. Type the handle of your account (for instance mybot.bsky.social)
  4. Paste the app password you generated earlier

Make sure you allow the bsky.social domain (it must correspond to the base URL).


A News Updater Task

Let's now create a simple news bot. It will read the contents of the Hacker News home page, and post the first item on the list.

  1. Create a new task in mcp.run named bluesky-news-updater
  2. Configure the basic prompt:
Fetch the Hacker News homepage https://news.ycombinator.com/ and post the first news item.
  1. Under Settings configure the language model.
  2. Navigate to settings in mcp.run
  3. Choose your preferred service (OpenAI, Anthropic, etc.)

Testing the integration

You can now trigger the task manually, by clicking the Run Task button, or you can also schedule it to run periodically, for instance every hour

Your bot will publish a link to the first item on the Hacker News homepage.


A GitHub Action task

You can also trigger the task with a wehook. In this example we will connect the bot to a GitHub repository. Every time a change affects the repo, the task will be triggered.

Signed URL Security

Once you have generated a Signed URL, do not share it with any untrusted party. Treat it like a secret. This URL enables anyone to trigger your Task, so please be cautious where you use it.

  1. Create a new task in mcp.run named bluesky-github-actions
  2. Configure the basic prompt:
Every time you receive a message, post the details to bluesky. 
The message is enclosed in `<message></message>` tags.

<message>
{{ @payload }}
</message>
  1. Under Settings configure the language model.
  2. Navigate to the Triggers section
  3. Click "Generate URL" to get your Webhook URL

Now navigate to the GitHub repository you want to monitor:

  1. Click Settings > Webhooks > Add webhook (you might need to authenticate)
  2. Paste the webhook into the "Payload URL" field, and make sure that "Content type" is "application/json".
  3. Optionally, you can select the type of events you want to monitor; you might listen to push, to everything, or select individual events. For this example, you can select "Send me everything".
  4. Finally, click "Add webhook".

Testing the Integration

Navigate again to your repo, and make a change. For instance, you can create a new file.

Your bot will publish a summary of the event.


A Conversational Bot (Scheduled Task)

In this example the bot will reply to any message that mentions it. In order to read the mentions, we need to either poll the Bluesky message feed for mentions, or to receive a push notification. At the moment Bluesky does not provide a way to be notified via webhooks, instead we can schedule a task to check for new notifications.

  1. Create a new task in mcp.run named bluesky-bot-polling
  2. Configure the basic prompt:
You are a helpful bot called mcprunbot.bsky.social
Check your new mentions in the last 10 minutes, and reply to them.
  1. Under Settings configure the language model.
  2. Navigate to the Triggers section.
  3. Activate the toggle in the Schedule section.
  4. Set the frequency to 10 minutes

Testing the integration

You can now mention your bot by name. For instance, if your bot is called mybot.bsky.social You can write the message

Hey @mybot.bsky.social tell us a little about mcp.run!

If you installed the fetch servlet, the bot will reply with a short description of mcp.run.


A Conversational Bot (Webhooks)

Polling repeatedly an endpoint can rapidly become expensive. Even though Bluesky does not provide native support for webhooks we can rely on a third-party service to do the heavy lifting. In this example we will use mention.blue.

  1. Create a new task in mcp.run named bluesky-bot-webhook
  2. Configure the prompt:
You are a helpful bot called mcprunbot.bsky.social You are receiving an input enclosed in <mentions>(message here)</mentions>. The input contains several messages. Each message includes a URL pointing to `https://bsky.app/profile/`. 

<message>
{{ @payload }}
</message>

Reply to each message using the Bluesky tool.
  1. Create an account on mention.blue.
  2. Register your Bluesky bot account using an app password as explained in the section above.
  3. Fill the following details in the dashboard:
  • Keyword: yourbot.bsky.social
  • Where to look for matches: tick both "Post content" and "Replies & Comments"
  • Notification Type: pick "Discord Webhook"

The service is designed to invoke a Discord webhook, but the LLM will be able to interpret the payload correctly and the bluesky servlet is designed to be lenient with the reply parameters.

Testing the Integration

Similarly to the poll example, you can now mention your bot by name. For instance, if your bot is called mybot.bsky.social You can write the message:

Hey @mybot.bsky.social can you search the web for interesting movies to watch tonight?

If you have configured the brave-search servlet, the bot will use it to look for movies. The task will trigger as soon as a the webhook is hit (usually, about every 10 minutes).


Extending The Bot Further

  • Add more servlets to enhance the capabilities of your bot: for instance
    • the GitHub servlet allows you to post issues and create PRs.
    • the Notion servlet allows your bot to read and create Notion pages
    • the Python allows your bot to evaluate Python programs
    • the WordPress servlet turns your bot into a blogger!
  • Each task can be linked to different mcp.run profiles, allowing you to create multiple bots with distinct capabilities by using different combinations of servlets.
  • The Bluesky servlet is open source and available in the mcp.run-servlets repo: fork it and customize it to your liking!

We look forward to see what you will build!


Support

If you encounter issues or need help:

  1. Check the webhook info using the getWebhookInfo URL
  2. Verify your servlets are properly installed
  3. Review the mcp.run task logs
  4. Visit our support page for additional assistance