agentleFS
YGhorbelYGhorbel/awesome-mastra-skills/skills/mastra-tool-integrations/SKILL.md

mastra-tool-integrations

Skill2 starsChanged 29 days agoApache-2.0View on GitHub

Give Mastra agents ready-made third-party tools: web search and scraping through @mastra/tavily, @mastra/brightdata, @mastra/parallel, @mastra/perplexity, and Firecrawl, plus Mastra platform Connect (@mastra/connect) for platform-managed GitHub, Slack, Linear, Gmail, Notion, Jira, HubSpot, and MCP provider tools, chat channels, and raw credentials. Use this skill whenever the user wants an agent to search the web, read or crawl pages, call a SaaS API without storing OAuth tokens, filter or approve provider tools, choose between connected accounts, or wire Slack, Discord, Telegram, or Teams through Connect. Triggers on createTavilyTools, createTavilySearchTool, createBrightDataTools, createParallelTools, createPerplexitySearchTool, Firecrawl, @mastra/connect, tools() from @mastra/connect, channels(), credential(), mastra connect add, MASTRA_PLATFORM_ACCESS_TOKEN, allowTools, requireApproval, connection_name. Also triggers for any request to add an off-the-shelf integration instead of writing a custom tool.

  • Reads credentials
  • Installs packages

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Add prebuilt third-party tools to agents: web search packages that wrap a vendor SDK, and Mastra Connect for platform-managed SaaS tools, …

    line 14
  2. Very specific:

    Verify the API: If node_modules/@mastra/ exists, read node_modules/@mastra/<package>/dist/docs/ and the installed types (@mastra/connect, …

    line 104
  3. Very specific:

    No tools from a provider: No active connection, wrong project, filtered out, or the installed @mastra/connect lacks that toolset.

    line 144
  4. Distinctive:

    Resend will not connect: Use an API key with Full access, not Sending access.

    line 149
  5. Distinctive:

    Mixing allow and deny domains in one Perplexity call: Not allowed. Use one list type per call.

    line 151

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Mastra Tool Integrations

Add prebuilt third-party tools to agents: web search packages that wrap a vendor SDK, and Mastra Connect for platform-managed SaaS tools, channels, and credentials.


When to use

  • Giving an agent web search, page extraction, crawling, or site mapping
  • Choosing between Tavily, Bright Data, Parallel, Perplexity, and Firecrawl
  • Calling GitHub, Slack, Linear, Gmail, Notion, Jira, HubSpot, and similar APIs without handling OAuth in the app
  • Restricting which provider tools an agent gets, per agent or per request
  • Requiring approval for destructive provider tools
  • Handling several accounts of one provider (two Slack workspaces)
  • Exposing Slack, Discord, Telegram, or Teams channels with platform-managed credentials
  • Fetching a raw provider credential for an SDK the toolsets do not cover

When NOT to use

  • Writing your own tool with createTool (use mastra-tools)
  • Connecting to an arbitrary MCP server yourself (use mastra-mcp)
  • Self-managed channels and channel behavior (use mastra-channels)
  • Handling approval suspend and resume flows (use mastra-agent-approval-hitl)
  • Browser automation (use mastra-browser)
  • Platform projects, deploys, and tokens in general (use mastra-platform)
  • Composio or Arcade catalogs picked in Studio (use mastra-studio-editor)
  • Perplexity as a chat model rather than a search tool (use mastra-models)

Required inputs

  • The capability: search, fetch or extract, crawl, or a specific SaaS action
  • Which provider, and its API key name (see references/providers.md)
  • For Connect: a Mastra platform project, its ID, and a platform access token
  • Which tools the agent may use, and which need human approval
  • Whether access depends on the user (role, tenant)
  • Whether the project has more than one connection per provider

The framework: two integration styles

StylePackagesCredentialsReturns
Vendor tool packages@mastra/tavily, @mastra/brightdata, @mastra/parallel, @mastra/perplexityVendor API key in envTools built with createTool and Zod schemas
Hand-built with an SDKfirecrawl plus createToolVendor API key in envYour own tools
Mastra Connect@mastra/connectStored on the platform, proxied per calltools() resolver, channels() resolver, credential()

Vendor package factories read their key from the environment by default and accept { apiKey } to override:

import { Agent } from '@mastra/core/agent'
import { createTavilySearchTool, createTavilyExtractTool } from '@mastra/tavily'

export const webSearchAgent = new Agent({
  id: 'web-search-agent',
  name: 'Web Search Agent',
  model: 'anthropic/claude-sonnet-5-5',
  instructions:
    'Use the search tool to find relevant pages, then use the extract tool to get full content from the best results.',
  tools: {
    search: createTavilySearchTool(),
    extract: createTavilyExtractTool(),
  },
})

Connect returns a resolver that Mastra calls on every generate() and stream():

import { Agent } from '@mastra/core/agent'
import { tools } from '@mastra/connect'

export const opsAgent = new Agent({
  id: 'ops',
  name: 'ops',
  instructions: 'You help the team track work in Linear and GitHub.',
  model: 'openai/gpt-6-luna',
  tools: tools({
    providers: {
      linear: { allowTools: ['linear_list_issues', 'linear_create_issue'] },
      github: { requireApproval: true },
    },
  }),
})

Workflow

  1. Verify the API. If node_modules/@mastra/ exists, read node_modules/@mastra/<package>/dist/docs/ and the installed types (@mastra/connect, @mastra/tavily, and so on). Otherwise fetch the integration page as Markdown, for example https://mastra.ai/integrations/tools/tavily.md or https://mastra.ai/reference/connect/tools.md. Trust these over memory. Toolsets change with each @mastra/connect release.
  2. Pick the provider with references/providers.md: capability, cost model, and whether the app may hold the key.
  3. Install the package and its peer (npm install @mastra/tavily @tavily/core zod, npm install @mastra/parallel parallel-web zod, npm install @mastra/connect).
  4. Set env vars (TAVILY_API_KEY, BRIGHTDATA_API_TOKEN, PARALLEL_API_KEY, PERPLEXITY_API_KEY, FIRECRAWL_API_KEY, or MASTRA_PLATFORM_ACCESS_TOKEN plus MASTRA_PROJECT_ID). List them in .env.example.
  5. For Connect, connect accounts. mastra auth login, mastra auth tokens create my-app, save it as MASTRA_PLATFORM_ACCESS_TOKEN, then mastra connect add <provider-id> and mastra connect list.
  6. Attach tools. Pass the factory result or tools() to the agent. Merge with your own tools through a tools function when needed.
  7. Narrow the surface. Allowlist tool keys, gate writes with requireApproval, and vary options by role with the callback form.
  8. Write instructions that name each tool and when to call it (search first, then extract).
  9. Handle approval for gated tools (see mastra-agent-approval-hitl).
  10. Test in Studio (npx mastra dev) and confirm tool calls in the trace.

Deep dive: Connect resolution and channels

  • Connection choice per provider: explicit connectionId wins, then the single active connection. With several active connections the toolset gains <provider>__list_connections and every tool requires a connection_name input.
  • Connections in needs_reauth are skipped with a warning. Replace them with the mastra connect CLI.
  • The resolver caches for ttlMs (30000 default) and refreshes in the background. await resolver.refresh() forces a fetch.
  • Callback options are memoized per distinct value, at most 32. Derive them from a closed set such as roles.
import { Mastra } from '@mastra/core'
import { channels } from '@mastra/connect'
import { assistant } from './agents/assistant'

export const mastra = new Mastra({
  agents: { assistant },
  channels: await channels({ providers: ['slack', 'discord'] }),
})

Channels need a public URL for webhooks (MASTRA_SERVER_URL off-platform) and a Studio step to connect the channel to an agent. Set MASTRA_ENCRYPTION_KEY for Telegram and Teams secrets.


Failure patterns

  • Token saved as MASTRA_API_TOKEN. The CLI suggests it but @mastra/connect ignores it. Use MASTRA_PLATFORM_ACCESS_TOKEN.
  • missing_project_id. Set MASTRA_PROJECT_ID or pass projectId.
  • invalid_options at resolution. A tool key or glob in allowTools, disallowTools, or requireApproval matches nothing, or both allow and disallow are set at one level. Check keys in the provider toolsets reference.
  • No tools from a provider. No active connection, wrong project, filtered out, or the installed @mastra/connect lacks that toolset. Run mastra connect list and look for [@mastra/connect] Skipping warnings.
  • proxy_error with status 401 or 403. Expired or revoked credential, or missing scopes. Reauthorize. Filtering tools does not change credential permissions.
  • Passing autoApproveTools. Removed. It throws invalid_options. Use requireApproval.
  • Per-request options from user IDs. Each distinct value creates a cache entry (max 32). Use roles.
  • Logging credential() output. It bypasses the proxy, host limits, and audit records. Never log or return it.
  • Resend will not connect. Use an API key with Full access, not Sending access.
  • Missing search API key. Parallel fails only when the tool runs. Check env vars at startup.
  • Mixing allow and deny domains in one Perplexity call. Not allowed. Use one list type per call.
  • Too many provider tools on one agent. Tool choice degrades. Allowlist or split into subagents (see mastra-multi-agent).

Output format

A finished integration delivery contains:

  • Installed packages and their peers in package.json
  • The tool factory or tools() call wired into the agent, with allowlists and approval rules
  • Agent instructions naming each tool and when to call it
  • Required env vars in .env.example (never commit keys or platform tokens)
  • For Connect: the mastra connect add commands run and the connection names chosen
  • Evidence: a Studio run or trace showing the tool call and result

Reference files

  • references/api.md - Factory signatures, tool IDs, inputs and outputs for each web package, and tools(), channels(), credential() options and errors.
  • references/providers.md - Comparison of web tool packages and the Connect provider directory with IDs.
  • references/examples.md - Research agent, Firecrawl tools, role-based Connect tools, combined tools, multi-account Slack, raw credential.
  • references/checklist.md - Integration security and readiness checklist.

Live docs

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.