npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@osiris-ai/github-sdk

v0.1.1

Published

Osiris GitHub SDK

Readme

@osiris-ai/github-sdk

OAuth 2.0 GitHub authenticator for building authenticated MCPs with GitHub integration.

npm version License: MIT

Overview

The GitHub SDK provides seamless OAuth 2.0 authentication for GitHub in the Osiris ecosystem. Build powerful MCPs (Model Context Protocol) that can interact with GitHub repositories, issues, pull requests, and more with enterprise-grade security and zero-configuration authentication.

Key Features:

  • 🔐 Zero-config OAuth - No client credentials or setup required
  • 📚 Full GitHub API - Complete access to repositories, issues, PRs, and more
  • 🔄 Auto Token Refresh - Automatic token lifecycle management
  • 🛡️ Enterprise Security - Built on Osiris Hub authentication
  • 📝 Full TypeScript - Complete type safety with Octokit integration
  • Octokit Integration - Familiar GitHub API interface

Installation

npm install @osiris-ai/github-sdk @osiris-ai/sdk

Quick Start

Hub Authentication (Recommended)

The GitHub authenticator works automatically through the Osiris Hub - no GitHub OAuth app setup required.

import { createMcpServer, getAuthContext } from '@osiris-ai/sdk';
import { createHubGitHubClient } from '@osiris-ai/github-sdk';
import { createSuccessResponse, createErrorResponse } from '../utils/types.js';
import { z } from 'zod';

await createMcpServer({
  name: 'github-mcp',
  version: '1.0.0',
  auth: {
    useHub: true,
    hubConfig: {
      baseUrl: process.env.HUB_BASE_URL!,
      clientId: process.env.OAUTH_CLIENT_ID!,
      clientSecret: process.env.OAUTH_CLIENT_SECRET!,
    }
  },
  configure: (server) => {
    // Create GitHub issue
    server.tool(
      'create_github_issue',
      'Create a new GitHub issue',
      {
        owner: z.string(),
        repo: z.string(),
        title: z.string(),
        body: z.string(),
        labels: z.array(z.string()).optional()
      },
      async ({ owner, repo, title, body, labels }) => {
        try {
          const { token, context } = getAuthContext("osiris");
          if (!token || !context) {
            return createErrorResponse("User not authenticated");
          }

          // Create authenticated GitHub client
          const github = createHubGitHubClient({
            hubBaseUrl: process.env.HUB_BASE_URL!,
            token: token,
            context: context
          });

          // Create issue using Octokit interface
          const issue = await github.rest.issues.create({
            owner,
            repo,
            title,
            body,
            labels
          });

          return createSuccessResponse('Issue created successfully', {
            issueNumber: issue.data.number,
            issueUrl: issue.data.html_url,
            issueId: issue.data.id
          });
        } catch (error) {
          return createErrorResponse(error);
        }
      }
    );
  }
});

Available GitHub Scopes

Configure your MCP to request specific GitHub permissions:

All slack scopes are supported and they all need to prefixed with github:

Local Authentication (Advanced)

For custom authentication flows or enterprise requirements:

import { GitHubAuthenticator } from '@osiris-ai/github-sdk';
import { createMcpServer } from '@osiris-ai/sdk';

const githubAuth = new GitHubAuthenticator(
  ['repo', 'user:email', 'issues:write'],
  {
    clientId: process.env.GITHUB_CLIENT_ID!,
    clientSecret: process.env.GITHUB_CLIENT_SECRET!,
    redirectUri: 'http://localhost:3000/github/callback'
  }
);

await createMcpServer({
  name: 'github-mcp',
  version: '1.0.0',
  auth: {
    useHub: false,
    directAuth: {
      github: githubAuth
    }
  },
  configure: (server) => {
    // Your GitHub tools here
  }
});

API Reference

GitHubAuthenticator

The main authenticator class for GitHub OAuth integration.

class GitHubAuthenticator extends OAuthAuthenticator<GitHubCallbackParams, GitHubTokenResponse>

Constructor

new GitHubAuthenticator(allowedScopes: string[], config: GitHubAuthenticatorConfig)

Parameters:

  • allowedScopes: Array of GitHub OAuth scopes your MCP requires
  • config: GitHub OAuth application configuration

Methods

getAuthenticationURL(scopes: string[], options: AuthenticationURLOptions): string

Generate GitHub OAuth authorization URL.

callback(params: GitHubCallbackParams): Promise<GitHubTokenResponse>

Handle OAuth callback and exchange code for tokens.

refreshToken(refreshToken: string): Promise<GitHubTokenResponse>

Refresh an expired access token.

getUserInfo(accessToken: string): Promise<GitHubUserInfo>

Get authenticated user information.

action(params: ActionParams, accessToken: string, refreshToken?: string): Promise<ActionResponse>

Execute GitHub API actions with automatic token refresh.

HubGitHubClient

GitHub client that routes requests through the Osiris Hub with full Octokit compatibility.

class HubGitHubClient

Methods

rest: RestEndpointMethods

Access to the full GitHub REST API through Octokit interface.

request(endpoint: string, options?: any): Promise<OctokitResponse<any, any>>

Make direct GitHub API requests.

getAuthStatus(): AuthStatus

Get current authentication status and debugging information.

createHubGitHubClient

Factory function to create Hub-authenticated GitHub client.

function createHubGitHubClient(config: GitHubClientConfig): HubGitHubClient

Usage Examples

Repository Management

server.tool(
  'list_repos',
  'List user repositories',
  { type: z.enum(['all', 'public', 'private']).default('all') },
  async ({ type }) => {
    const { token, context } = getAuthContext("osiris");
    if (!token || !context) {
      return createErrorResponse("User not authenticated");
    }

    const github = createHubGitHubClient({
      hubBaseUrl: process.env.HUB_BASE_URL!,
      token: token,
      context: context
    });

    const repos = await github.rest.repos.listForAuthenticatedUser({
      type,
      sort: 'updated',
      per_page: 30
    });

    return createSuccessResponse('Repositories retrieved', {
      repositories: repos.data.map(repo => ({
        name: repo.name,
        fullName: repo.full_name,
        url: repo.html_url,
        private: repo.private,
        language: repo.language
      }))
    });
  }
);

Error Handling

The GitHub authenticator provides robust error handling with automatic retries and detailed error messages:

server.tool('resilient_github_tool', 'GitHub tool with error handling', schema, async (params) => {
  try {
    const { token, context } = getAuthContext("osiris");
    if (!token || !context) {
      return createErrorResponse("🔐 Please connect your GitHub account first");
    }

    const github = createHubGitHubClient({
      hubBaseUrl: process.env.HUB_BASE_URL!,
      token: token,
      context: context
    });

    // GitHub API call with automatic error handling
    const result = await github.rest.repos.listForAuthenticatedUser();
    return createSuccessResponse('GitHub repositories retrieved', result.data);
  } catch (error: any) {
    if (error.status === 401) {
      return createErrorResponse("❌ GitHub authentication expired. Please reconnect your account.");
    }
    if (error.status === 403) {
      return createErrorResponse("❌ Insufficient GitHub permissions. Please grant additional scopes.");
    }
    if (error.status === 404) {
      return createErrorResponse("❌ GitHub resource not found. Check repository name and permissions.");
    }
    return createErrorResponse(`GitHub error: ${error.message}`);
  }
});

Getting Started

  1. Install the Osiris CLI:

    npm install -g @osiris-ai/cli
  2. Set up authentication:

    npx @osiris-ai/cli register
    npx @osiris-ai/cli create-client
    npx @osiris-ai/cli connect-auth
  3. Create your GitHub MCP:

    npx @osiris-ai/cli create-mcp my-github-mcp
  4. Add GitHub integration:

    npm install @osiris-ai/github-sdk

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Support

License

MIT License - see LICENSE file for details.


Built with ❤️ by the Osiris Labs team.