A TypeScript package for interacting with the GitHub API through an MCP (Model Context Protocol) server integration.
- Full TypeScript support with type definitions
- 129 MCP tools covering all major GitHub API operations:
- Repository management (create, update, delete, search, settings, administration)
- Issue tracking (create, update, close, comments, search)
- Pull request management (create, merge, review, comments)
- Branch operations (create, delete, list, protect)
- Commit operations (list, get, compare)
- Release management (create, update, delete, assets)
- Content operations (read, write, delete files)
- GitHub Actions (workflows, runs, artifacts)
- Webhooks (create, update, delete, deliveries, redelivery)
- Collaborators and teams (add, remove, permissions)
- Repository statistics and insights
- Security settings (Dependabot, vulnerability alerts)
- Advanced search across repositories, issues, PRs, code, commits, users, topics, and labels
- Built-in logging with
@onamfc/developer-log - Package inspection with
@onamfc/pkg-inspect - Robust error handling
npm install @onamfc/mcp-github-integrationgit clone https://github.com/onamfc/mcp-github-integration.git
cd mcp-github-integration
npm install
npm run buildSet your GitHub personal access token as an environment variable:
export GITHUB_TOKEN=your_github_token_hereimport { MCPServer } from '@onamfc/mcp-github-integration';
const server = new MCPServer(process.env.GITHUB_TOKEN);
// Get authenticated user
const response = await server.handleRequest({
method: 'github_get_authenticated_user',
params: {},
});
if (response.success) {
console.log('User:', response.data);
}
// Search repositories
const searchResponse = await server.handleRequest({
method: 'github_search_repositories',
params: {
q: 'typescript',
per_page: 10,
},
});import { GitHubClient } from '@onamfc/mcp-github-integration';
const client = new GitHubClient({
token: process.env.GITHUB_TOKEN,
});
// Create a new repository
const newRepo = await client.createRepository({
name: 'my-awesome-project',
description: 'My awesome project description',
private: false,
auto_init: true,
});
// Get repository information
const repo = await client.getRepository('owner', 'repo-name');
console.log(repo);
// Create an issue
const issue = await client.createIssue({
owner: 'owner',
repo: 'repo-name',
title: 'Bug Report',
body: 'Description of the bug',
labels: ['bug'],
});
// List pull requests
const prs = await client.listPullRequests({
owner: 'owner',
repo: 'repo-name',
state: 'open',
});github_get_repository- Get repository informationgithub_list_repositories- List user's public repositoriesgithub_create_repository- Create a new repositorygithub_delete_repository- Delete a repositorygithub_update_repository- Update repository settings and configurationgithub_get_repository_topics- Get repository topics/tagsgithub_replace_repository_topics- Set repository topics for discoverabilitygithub_get_repository_languages- Get programming languages usedgithub_get_code_frequency_stats- Get weekly addition/deletion statisticsgithub_get_contributors_stats- Get contributor activity statisticsgithub_get_participation_stats- Get weekly commit count statisticsgithub_transfer_repository- Transfer repository to new ownergithub_list_repository_teams- List teams with access to repositorygithub_check_team_permission- Check team permission for repositorygithub_add_repository_team- Add or update team access to repositorygithub_remove_repository_team- Remove team access from repositorygithub_enable_automated_security_fixes- Enable Dependabot automated security fixesgithub_disable_automated_security_fixes- Disable automated security fixesgithub_enable_vulnerability_alerts- Enable Dependabot vulnerability alertsgithub_disable_vulnerability_alerts- Disable vulnerability alerts
github_list_collaborators- List repository collaboratorsgithub_check_collaborator- Check if user is a collaboratorgithub_add_collaborator- Add collaborator to repositorygithub_remove_collaborator- Remove collaborator from repositorygithub_get_collaborator_permission- Get collaborator permission levelgithub_list_repository_invitations- List pending repository invitationsgithub_delete_repository_invitation- Delete/cancel a repository invitation
github_create_issue- Create a new issuegithub_list_issues- List issues in a repositorygithub_get_issue- Get a specific issuegithub_update_issue- Update an existing issuegithub_close_issue- Close an issuegithub_create_issue_comment- Add a comment to an issuegithub_list_issue_comments- List comments on an issuegithub_update_issue_comment- Update an issue commentgithub_delete_issue_comment- Delete an issue comment
github_create_pull_request- Create a new pull requestgithub_list_pull_requests- List pull requests in a repositorygithub_get_pull_request- Get a specific pull requestgithub_merge_pull_request- Merge a pull request
github_list_branches- List all branches in a repositorygithub_get_branch- Get information about a specific branchgithub_create_branch- Create a new branchgithub_delete_branch- Delete a branchgithub_get_branch_protection- Get branch protection rules
github_list_commits- List commits in a repositorygithub_get_commit- Get a specific commitgithub_compare_commits- Compare two commits or branches
github_list_releases- List all releasesgithub_get_latest_release- Get the latest releasegithub_get_release- Get a specific release by IDgithub_create_release- Create a new releasegithub_update_release- Update a releasegithub_delete_release- Delete a release
github_get_file_content- Get contents of a filegithub_create_file- Create a filegithub_update_file- Update a filegithub_delete_file- Delete a filegithub_get_directory_content- Get contents of a directory
github_list_workflows- List all workflowsgithub_get_workflow- Get a specific workflowgithub_list_workflow_runs- List workflow runsgithub_get_workflow_run- Get a specific workflow rungithub_cancel_workflow_run- Cancel a workflow rungithub_rerun_workflow- Re-run a workflowgithub_delete_workflow_run- Delete a workflow rungithub_list_workflow_run_artifacts- List artifacts for a workflow rungithub_download_artifact- Download a workflow artifact
github_list_webhooks- List all webhooks for a repositorygithub_get_webhook- Get a specific webhook by IDgithub_create_webhook- Create a new webhookgithub_update_webhook- Update an existing webhookgithub_delete_webhook- Delete a webhookgithub_ping_webhook- Trigger a ping event to webhookgithub_test_webhook- Trigger a test push event to webhookgithub_list_webhook_deliveries- List deliveries for a webhookgithub_get_webhook_delivery- Get a specific webhook deliverygithub_redeliver_webhook- Redeliver a webhook delivery
github_search_repositories- Search for repositoriesgithub_search_issues- Search for issues and pull requestsgithub_search_code- Search code across repositoriesgithub_search_commits- Search commitsgithub_search_users- Search for usersgithub_search_topics- Search for topicsgithub_search_labels- Search for labels in a repository
github_get_authenticated_user- Get authenticated user information
Create and configure repositories programmatically:
// Create repository with full configuration
await server.handleRequest({
method: 'github_create_repository',
params: {
name: 'my-project',
description: 'My awesome project',
private: false,
auto_init: true,
gitignore_template: 'Node',
license_template: 'mit',
},
});
// Update repository settings
await server.handleRequest({
method: 'github_update_repository',
params: {
owner: 'myorg',
repo: 'my-project',
has_issues: true,
has_wiki: false,
allow_squash_merge: true,
delete_branch_on_merge: true,
},
});
// Add topics for discoverability
await server.handleRequest({
method: 'github_replace_repository_topics',
params: {
owner: 'myorg',
repo: 'my-project',
topics: ['javascript', 'api', 'automation'],
},
});Manage collaborators and permissions:
// Add collaborator
await server.handleRequest({
method: 'github_add_collaborator',
params: {
owner: 'myorg',
repo: 'my-project',
username: 'developer123',
permission: 'push',
},
});
// Add team access
await server.handleRequest({
method: 'github_add_repository_team',
params: {
owner: 'myorg',
repo: 'my-project',
team_slug: 'backend-team',
permission: 'admin',
},
});Automate workflows and deployments:
// List workflow runs
await server.handleRequest({
method: 'github_list_workflow_runs',
params: {
owner: 'myorg',
repo: 'my-project',
workflow_id: 'deploy.yml',
},
});
// Re-run failed workflow
await server.handleRequest({
method: 'github_rerun_workflow',
params: {
owner: 'myorg',
repo: 'my-project',
run_id: 123456,
},
});
// Download build artifacts
await server.handleRequest({
method: 'github_download_artifact',
params: {
owner: 'myorg',
repo: 'my-project',
artifact_id: 789012,
},
});Set up event-driven integrations:
// Create webhook
await server.handleRequest({
method: 'github_create_webhook',
params: {
owner: 'myorg',
repo: 'my-project',
config: {
url: 'https://myapp.com/webhooks',
content_type: 'json',
secret: 'my-secret-key',
},
events: ['push', 'pull_request', 'issues'],
active: true,
},
});
// List webhook deliveries
await server.handleRequest({
method: 'github_list_webhook_deliveries',
params: {
owner: 'myorg',
repo: 'my-project',
hook_id: 12345,
},
});
// Redeliver failed webhook
await server.handleRequest({
method: 'github_redeliver_webhook',
params: {
owner: 'myorg',
repo: 'my-project',
hook_id: 12345,
delivery_id: 67890,
},
});Automate release workflows:
// Create release
await server.handleRequest({
method: 'github_create_release',
params: {
owner: 'myorg',
repo: 'my-project',
tag_name: 'v1.0.0',
name: 'Version 1.0.0',
body: 'Release notes here',
draft: false,
prerelease: false,
},
});
// Get latest release
await server.handleRequest({
method: 'github_get_latest_release',
params: {
owner: 'myorg',
repo: 'my-project',
},
});A working example demonstrating the client's capabilities is provided in examples/basic-usage.ts:
Demonstrates all core operations:
- Getting repository information
- Listing issues and pull requests
- Listing branches and commits
- Getting authenticated user information
Run the example:
# Using default repository (octocat/Hello-World)
GITHUB_TOKEN=your_token npm run example:basic
# Using your own repository
GITHUB_TOKEN=your_token REPO_OWNER=owner REPO_NAME=repo npm run example:basicNote: The examples/ directory contains additional working examples including setup-new-repo.ts which demonstrates repository setup automation. See examples/README.md for details.
{
method: string, // The tool/method name
params: { // Parameters for the method
[key: string]: any
}
}{
success: boolean, // Whether the request succeeded
data?: any, // Response data (if successful)
error?: { // Error information (if failed)
code: string,
message: string,
details?: any
}
}- A GitHub personal access token is required
- Generate one at: https://github.com/settings/tokens
- Required scopes depend on operations:
repo- Full repository access (for private repos)public_repo- Public repository access onlyread:user- Read user profile datauser:email- Read user email addressesadmin:repo_hook- Full control of repository hooks (webhooks)admin:org- Full control of organization settings (for team operations)workflow- Update GitHub Actions workflows
GitHub API has rate limits:
- Authenticated requests: 5,000 requests per hour
- Unauthenticated requests: 60 requests per hour
- Check rate limit status in response headers
- The client will throw an error if rate limited
All methods throw GitHubAPIError on failure:
try {
const repo = await client.getRepository('owner', 'repo');
} catch (error) {
if (error instanceof GitHubAPIError) {
console.error(`Error ${error.code}: ${error.message}`);
console.error('Status:', error.statusCode);
}
}- Never commit your GitHub token to version control
- Use environment variables for tokens
- Rotate tokens regularly
- Use minimal required scopes for your token
- Consider using GitHub Apps for production applications
- Always use webhook secrets for signature verification
- Enable Dependabot security alerts on repositories
For detailed GitHub API documentation, visit:
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.