Skip to main content

GitHub

The @mastra/github-signals provider lets an agent follow pull requests (PRs). It polls subscribed PRs and sends notification signals to the agent thread when relevant activity occurs.

Installation
Direct link to Installation

Install GitHub Signals and the memory packages used in this example:

npm install @mastra/github-signals @mastra/libsql @mastra/memory

Prerequisites
Direct link to Prerequisites

GitHub Signals requires:

  • A Mastra storage adapter with memory and notification support. The provider stores each subscription in the thread's metadata, so the thread must already exist.
  • The gitcrawl command on PATH, configured to access the repositories you want to monitor. The provider runs gitcrawl sync and reads its SQLite database.
  • The sqlite3 command on PATH.
  • The GitHub CLI installed and authenticated. The provider uses gh api to check whether comment authors have access to the repository before notifying the agent.

By default, comments from users with admin, maintain, or write access can trigger notifications. CodeRabbit and Devin bot comments are also allowed. Configure authorizedPermissions, authorizedBots, or ignoredBots when you need different rules.

Agent and subscription
Direct link to Agent and subscription

Create one GithubSignals instance and register it on the agent. Register the agent and a storage adapter on the Mastra instance:

src/mastra/index.ts
import { Agent } from '@mastra/core/agent'
import { Mastra } from '@mastra/core/mastra'
import { Memory } from '@mastra/memory'
import { GithubSignals } from '@mastra/github-signals'
import { LibSQLStore } from '@mastra/libsql'

export const githubSignals = new GithubSignals()

export const devAgent = new Agent({
id: 'dev-agent',
name: 'Development Agent',
instructions: 'Triage pull request activity and help resolve issues.',
model: 'openai/gpt-5.6-sol',
memory: new Memory(),
signals: [githubSignals],
})

export const mastra = new Mastra({
agents: { devAgent },
storage: new LibSQLStore({
id: 'mastra-storage',
url: 'file:./mastra.db',
}),
})

After the agent has created a memory thread, subscribe that thread to a PR. Passing owner and repo works from any directory:

await githubSignals.subscribeThreadToPR({
threadId: 'thread-123',
resourceId: 'user-123',
pr: {
owner: 'acme',
repo: 'web-app',
number: 42,
},
})

The provider syncs the PR immediately, stores the subscription, and starts polling every five minutes. Set pollIntervalMs in the GithubSignals constructor to change the interval. If the process restarts, call startPollingForThread() for each persisted thread subscription to resume polling.

Pull request notifications
Direct link to Pull request notifications

GitHub Signals notifies the agent when a subscribed PR has:

  • A new authorized comment, commit, or other pull request activity.
  • A change in unresolved review threads.
  • Continuous integration (CI) checks that start, fail, or recover.
  • Merge conflicts that appear or are resolved.
  • A state change to closed, reopened, or merged.

The initial sync sends a baseline notification with the current PR state. A merge automatically removes the thread's subscription to that PR.

On this page