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
Clone the repository:
Create and activate a Python virtual environment:
Install dependencies:
Create a
.envfile in the project root with your credentials:
Getting Your Credentials
GitHub Token:
Go to GitHub Settings ā Developer settings ā Personal access tokens
Generate a new token with
reposcopeCopy the token to your
.envfile
Notion API Key:
Create a new integration and copy the Internal Integration Token
Share your Notion page with the integration
Notion Page ID:
Open your Notion page in a browser
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:
Then run the server:
The server exposes two MCP tools:
1. fetch_pr
Fetches pull request information from GitHub.
Parameters:
repo_owner(str): Repository owner usernamerepo_name(str): Repository namepr_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 titlecontent(str): Page content
Returns:
Success or error message
Direct Usage (Development/Testing)
You can also use the github_integration.py module directly:
Project Structure
Dependencies
Key dependencies include:
mcp- Model Context Protocol serverrequests- GitHub API callsnotion-client- Notion API integrationpython-dotenv- Environment variable managementpydantic- Data validationhttpx- 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:
Ensure your
.envfile is properly configuredTest changes with the direct usage method before running the MCP server
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:
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.
This server cannot be installed