Last active
October 16, 2025 15:49
-
-
Save bookercodes/6081b8c2605a26ca1a97def2a21abba1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // add ...tools to agent.tools[] | |
| const mcp = new MCPClient({ | |
| servers: { | |
| hackernews: { | |
| command: "npx", | |
| args: ["-y", "@devabdultech/hn-mcp-server"], | |
| } | |
| }, | |
| }); | |
| const tools = await mcp.getTools() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }; | |
| }, | |
| }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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