Enhance GitHub MCP Server With License Verification
Hey folks! 👋 This is a super cool guide on how to integrate license verification into your GitHub MCP Server. This is all about making sure you're using the server legally and getting the most out of it. We're talking about a seamless way to verify your license, making sure everything is above board, and unlocking all the features you're entitled to. The best part? This guide comes directly from the GitHub MCP tools themselves – talk about dogfooding! 🐕 Let's dive in and see how we can make your server even better. You will find all the steps to include license checks, status displays, and a whole lot more. Are you ready to level up your server management game? Let's get started!
🛠️ Implementation Steps: Adding License Verification
Alright, let's get down to business and integrate that license verification. We'll start by importing the necessary components, then add a startup check to ensure your license is valid right from the get-go. Finally, we'll create a handy tool to display your current license information. This is all about making the process straightforward and easy to understand. Ready? Let's get started. Make sure you follow these steps carefully, and you'll have license verification up and running in no time.
1. Import Statements: Setting Up the Foundation
First things first, we need to import some modules. This is the foundation for all the cool stuff we’re about to do. We're going to add an import statement to bring in the license_manager functionalities, the brains behind the license checks. This line of code will give our script access to all the tools we need to verify your license and ensure everything is running smoothly. Don't worry, it's a simple addition, but it's crucial! By doing this, we're essentially preparing the environment for license verification, making sure everything is in place for the checks to work correctly. This step is like making sure you have all the necessary ingredients before you start cooking.
-
Location: After the line
from mcp.server.fastmcp import FastMCP(around line 64). -
Add: The code for the import should look like this:
from license_manager import check_license_on_startup, get_license_manager
2. Startup License Check: Ensuring Legal Compliance
Next, we need to add a startup license check. This ensures that the license is checked every time the server starts. This is a very important step to make sure you are in compliance and make sure everything is legal. We will add a function that is executed at the very start of the server's lifecycle. This is so important because it provides a safety net, automatically verifying your license every time the server boots up. This proactive approach helps to catch any issues early on, ensuring uninterrupted access to your GitHub MCP server and its features. The startup check is like the security guard at the front door, making sure everything is okay before you can enter.
-
Location: At the very end of
github_mcp.py -
Add: Paste the following code block to the end of your file:
if __name__ == "__main__": import asyncio async def startup(): """Run startup checks before starting the MCP server.""" # Check license on startup await check_license_on_startup() # Start the MCP server await mcp.run() # Run the server with license check asyncio.run(startup())
3. License Info Tool: Keeping You Informed
Now, let's add a tool that provides information about your license. This feature will let you easily see your current license details, status, and other important info. It helps you stay informed about your license's validity and any potential issues. This tool will display whether your license is valid, the type of tier you have, expiration dates, and any developer limits. It is designed to be easily accessible, giving you all the necessary information at your fingertips. By providing clear and concise information, this tool ensures you’re always aware of your license status, helping you avoid any interruptions.
-
Location: Add it with other
@mcp.tool()functions. -
Add: Use this code block to add the license info tool.
@mcp.tool() async def github_license_info() -> str: """ Display current license information and status for the GitHub MCP Server. Shows: - License tier (Free/Startup/Business/Enterprise) - Expiration date (for commercial licenses) - Max developers allowed - Current status Returns: Formatted license information """ license_manager = get_license_manager() license_info = await license_manager.verify_license() if license_info.get('valid'): tier = license_info.get('tier', 'free') tier_info = license_manager.get_tier_info(tier) response = f"""# GitHub MCP Server License **Status:** ✅ Valid **Tier:** {tier_info['name']} **License Type:** {tier.upper()} """ if tier != 'free': response += f""" **Expires:** {license_info.get('expires_at', 'N/A').split('T')[0]} **Max Developers:** {license_info.get('max_developers') or 'Unlimited'} **Status:** {license_info.get('status', 'unknown').upper()} """ else: response += """ **License:** AGPL v3 (Open Source) **Commercial Use:** Requires commercial license **Purchase:** https://mcplabs.co.uk/pricing **Contact:** licensing@mcplabs.co.uk """ return response else: return f"""# License Verification Failed **Error:** {license_info.get('error', 'Unknown')} **Message:** {license_info.get('message', '')} **Options:** 1. Get free AGPL license: https://github.com/crypto-ninja/github-mcp-server 2. Purchase commercial license: https://mcplabs.co.uk/pricing 3. Contact support: licensing@mcplabs.co.uk """
🧪 Testing: Ensuring It Works
Time to put this to the test, guys! We'll cover testing both without and with a license key, plus how to call the tool we just created. This ensures everything is running smoothly and that you know what to expect. This phase is important to verify everything is working as it should and that you're getting the correct output in different scenarios. Think of it as the quality control phase – we want to make sure everything functions flawlessly. If we find anything wrong, this is where we fix it before we go live. Ready to see if it all comes together?
Without License Key: Checking the Defaults
Let’s start by testing without a license key. In this scenario, we want to ensure that the system defaults to the correct behavior, likely displaying an open-source message or a reminder about licensing. This part is super important because it confirms that the system handles situations where a license key isn't provided. This test shows us what users will see if they're using the free version, or if they haven't yet entered their license. It’s all about making sure the system provides appropriate information and guidance to the user, even before they enter their key.
-
Command: Run the following command in your terminal.
python github_mcp.py -
Expected Output: The system should display the AGPL v3 message. This confirms that the default open-source license information is correctly displayed when no license key is present. This is a crucial test to ensure the fallback mechanism functions as intended, providing users with the necessary information about the licensing terms.
With License Key: Validating Commercial Use
Now, let's test with a license key. This is the moment of truth! We're checking to see if the system correctly validates the license key and displays the status. This test validates that the system recognizes the provided key, verifies its validity, and provides the appropriate status information. This part is a core function of the integration, ensuring that users with valid licenses have seamless access to the server’s features. It's like unlocking the door with the right key. This test is critical to prove commercial use and make sure everything is working as expected.
-
Command: Set the license key as an environment variable and then run the script.
export GITHUB_MCP_LICENSE_KEY="your-key" python github_mcp.py -
Expected Output: The server should verify the key and display the correct license status. This could include the license tier, expiration date, and any other relevant details. Seeing this confirms that the license verification is fully functional. It is all about validating that the license key is correctly recognized and that the associated information is accurately displayed.
Test License Tool: Using the New Feature
Finally, let's test the license info tool we added. This test lets us verify if the tool displays the license details as expected. This will confirm that the tool correctly retrieves and displays the license information, giving you a quick and easy way to check your license status. Testing this tool ensures that you have a functional way to access vital license data. It's like checking the fuel gauge on your car – you need it to know where you stand. This step gives you confidence in the tool's functionality, and it ensures it provides the right information.
-
Action: Use Claude or any tool that can call
github_license_infoto trigger the tool. -
Expected Output: The tool should display the current license information. It should display a summary of your license, including tier, expiration dates (if applicable), and any other relevant details. It’s like a report card for your license, and it should accurately reflect your current standing.
📦 Files at Your Disposal
You're not starting from scratch! There are pre-built files that will help. These files have been carefully put together to help you seamlessly integrate license verification. They will save you time and effort and make the process smoother, from start to finish. It's all about making your work more efficient and making sure you have all the tools you need to succeed. With these files, you can concentrate on your main task.
- ✅
license_manager.py- Complete license verification system. - ✅
integrate_license.py- Integration helper script. - ✅
LICENSE_INTEGRATION.md- Full documentation.
🚀 Expected Output: What to Look For
After you have done the integration, you will see a specific message during startup. This is your cue to confirm that everything is working as planned. The startup process is the best moment to see if license verification is correctly implemented. This confirms the verification is active and the system is recognizing the license correctly. Seeing this message confirms that the integration was successful, and your license is being managed correctly.
============================================================
✅ GitHub MCP Server - License Valid
============================================================
License: Open Source (AGPL v3)
Tier: FREE
License: AGPL v3 (Open Source)
⚠️ For commercial use, purchase a license at https://mcplabs.co.uk
============================================================
🐕 Meta Continues... The Next Steps
This is where it gets interesting! We're not stopping here, guys. This is a chance to use the GitHub MCP tools to manage their own development process. We're talking about automating everything from branch creation to merging pull requests and creating releases. It’s like a self-fulfilling prophecy – the tools are building themselves. The goal here is to use the tools to manage their own development. The aim is to make the whole process super-efficient and automated. The aim is to create an end-to-end development workflow managed by the very tools we're talking about. This is the future, guys!
Here's the plan:
- ✅ Create this issue (DONE! 😎)
- ⏳ Create a branch
- ⏳ Make the changes
- ⏳ Create a PR
- ⏳ Merge the PR
- ⏳ Create a release
All using the tools to manage their own development! 🤯🎉