GitHub PR Analyzer with Notion Integration

GitHub PR Analyzer with Notion Integration

Fetches GitHub pull request information including file changes, diffs, and metadata, then creates analysis summaries in Notion pages.

Category
Visit Server

README

GitHub PR Analyzer with Notion Integration

A Model Context Protocol (MCP) server that fetches GitHub pull request changes and creates analysis summaries in Notion.

Tutorial: Follow this step-by-step guide at DataCamp's MCP Tutorial

Features

  • šŸ” Fetch detailed GitHub pull request information including:
    • File changes (additions, deletions, modifications)
    • PR metadata (title, description, author, timestamps)
    • Diff patches for each changed file
  • šŸ“ Create Notion pages with PR analysis
  • šŸ”Œ MCP server integration for seamless tool usage

Prerequisites

  • Python 3.8 or higher
  • GitHub Personal Access Token
  • Notion API Key and Page ID

Installation

  1. Clone the repository:
git clone <repository-url>
cd mcp-starter
  1. Create and activate a Python virtual environment:
# Create virtual environment
python -m venv venv

# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate

# On Windows:
# venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file in the project root with your credentials:
GITHUB_TOKEN=your_github_token_here
NOTION_API_KEY=your_notion_api_key_here
NOTION_PAGE_ID=your_notion_page_id_here

Getting Your Credentials

GitHub Token:

  1. Go to GitHub Settings → Developer settings → Personal access tokens
  2. Generate a new token with repo scope
  3. Copy the token to your .env file

Notion API Key:

  1. Go to https://www.notion.so/my-integrations
  2. Create a new integration and copy the Internal Integration Token
  3. Share your Notion page with the integration

Notion Page ID:

  1. Open your Notion page in a browser
  2. Copy the page ID from the URL (the part after the last / and before the ?)

Usage

Running the MCP Server

First, ensure your virtual environment is activated:

# On macOS/Linux:
source venv/bin/activate

# On Windows:
# venv\Scripts\activate

Then run the server:

python pr_analyzer.py

The server exposes two MCP tools:

1. fetch_pr

Fetches pull request information from GitHub.

Parameters:

  • repo_owner (str): Repository owner username
  • repo_name (str): Repository name
  • pr_number (int): Pull request number

Returns:

  • PR metadata and detailed file changes

2. create_notion_page

Creates a Notion page with analysis content.

Parameters:

  • title (str): Page title
  • content (str): Page content

Returns:

  • Success or error message

Direct Usage (Development/Testing)

You can also use the github_integration.py module directly:

from github_integration import fetch_pr_changes

# Fetch PR changes
pr_data = fetch_pr_changes('owner', 'repo', 123)
print(pr_data)

Project Structure

mcp-starter/
ā”œā”€ā”€ github_integration.py  # GitHub API integration
ā”œā”€ā”€ pr_analyzer.py         # MCP server implementation
ā”œā”€ā”€ requirements.txt       # Project dependencies
ā”œā”€ā”€ .env                   # Environment variables (not in git)
└── README.md             # This file

Dependencies

Key dependencies include:

  • mcp - Model Context Protocol server
  • requests - GitHub API calls
  • notion-client - Notion API integration
  • python-dotenv - Environment variable management
  • pydantic - Data validation
  • httpx - Async HTTP client

See requirements.txt for the complete list.

Error Handling

The application includes comprehensive error handling:

  • API request failures are caught and logged
  • Missing credentials trigger appropriate error messages
  • Stack traces are printed to stderr for debugging

Development

To contribute or modify:

  1. Ensure your .env file is properly configured
  2. Test changes with the direct usage method before running the MCP server
  3. Check stderr output for debugging information

Security Notes

āš ļø Important: Never commit your .env file to version control. It contains sensitive credentials.

Add to your .gitignore:

.env
__pycache__/
*.pyc

License

MIT License

Copyright (c) 2024

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

-+--+-+-+-+-+

This project is released into the public domain under the Unlicense.

You are free to use, modify, distribute, and utilize this software for any purpose, commercial or non-commercial, without any restrictions or attribution requirements.

For more details, see the Unlicense.

Author

Kiet Tran (Leo Loves Coding)

Support

For issues or questions, please open an issue in the repository.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured