Skip to content

Instantly share code, notes, and snippets.

@bookercodes
Last active October 16, 2025 15:49
Show Gist options
  • Select an option

  • Save bookercodes/6081b8c2605a26ca1a97def2a21abba1 to your computer and use it in GitHub Desktop.

Select an option

Save bookercodes/6081b8c2605a26ca1a97def2a21abba1 to your computer and use it in GitHub Desktop.
// add ...tools to agent.tools[]
const mcp = new MCPClient({
servers: {
hackernews: {
command: "npx",
args: ["-y", "@devabdultech/hn-mcp-server"],
}
},
});
const tools = await mcp.getTools()
import { createTool } from '@mastra/core/tools';
import { z } from 'zod';
import { AtpAgent } from '@atproto/api';
export const blueskyPostTool = createTool({
id: 'bluesky-post',
description: 'Post a text update to Bluesky using username/password credentials',
inputSchema: z.object({
text: z.string().min(1).max(300).describe('Post text'),
}),
outputSchema: z.object({
uri: z.string(),
cid: z.string(),
url: z.string()
}),
execute: async ({ context }) => {
const agent = new AtpAgent({ service: 'https://bsky.social' });
await agent.login({
identifier: process.env.BLUESKY_USERNAME!,
password: process.env.BLUESKY_PASSWORD!,
});
const res = await agent.post({
$type: 'app.bsky.feed.post',
text: context.text,
createdAt: new Date().toISOString(),
});
const rkey = res.uri.split('/').pop();
const profile = agent.session?.handle ?? agent.session?.did;
const url = profile && rkey ? `https://bsky.app/profile/${profile}/post/${rkey}` : `https://bsky.app`;
return { uri: res.uri, cid: res.cid, url };
},
});
import { createTool } from "@mastra/core";
import Exa from "exa-js";
import z from "zod";
export const crawlTool = createTool({
id: 'crawlTool',
description: '',
inputSchema: z.object({
url: z.string()
}),
outputSchema: z.object({
title: z.string(),
summary: z.string(),
content: z.string()
}),
execute: async ({ context }) => {
const exa = new Exa(process.env.EXA_API_KEY!)
const {results} = await exa.getContents(
[context.url],
{
text: true,
context: true,
summary: true
}
)
const page = results[0]
return {
title: page.title!,
summary: page.summary,
content: page.text,
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment