foss-mcp-server

sbley/foss-mcp-server

3.1

If you are the rightful owner of foss-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This tool uses Model Context Protocol (MCP) to check files for proper headers according to Open Source policies.

FOSS MCP Server

This tool uses Model Context Protocol (MCP) to check files for proper headers according to Open Source policies. Currently, it checks for SPDX copyright and licensing information headers.

Project Structure

  • mcp_server.py - The main MCP server implementation
  • model_setup.py - Model configuration and initialization
  • license_verifier.py - Functions for verifying license headers
  • run_server.ps1 - PowerShell script to run the server on Windows
  • run_server.sh - Bash script to run the server on Linux/macOS

Setup

  1. Create a virtual environment:

    python -m venv .venv
    
  2. Activate the virtual environment:

    Windows (PowerShell):

    .\.venv\Scripts\Activate.ps1
    

    Linux/macOS/Git Bash:

    source .venv/bin/activate
    
  3. Install requirements:

    pip install -r requirements.txt
    
  4. Configure Azure OpenAI settings:

    The following environment variables are required for the Azure OpenAI client:

    • AZURE_OPENAI_ENDPOINT - Your Azure OpenAI endpoint URL
    • AZURE_OPENAI_API_VERSION - API version to use (e.g., '2024-09-01-preview')
    • AZURE_OPENAI_DEPLOYMENT - The Azure OpenAI deployment name
    • AZURE_OPENAI_API_KEY - Your Azure OpenAI API key

    These can be configured in the environment or provided by the agent/application that calls the MCP server.

Running the server

You need an Azure OpenAI API key to use this tool. There are two ways to provide it:

Option 1: Using the helper script (Recommended)

Windows (PowerShell):

.\run_server.ps1 "your-api-key-here"

Linux/macOS/Git Bash:

bash run_server.sh "your-api-key-here"

Or run without arguments and you'll be prompted to enter the API key:

Windows (PowerShell):

.\run_server.ps1

Linux/macOS/Git Bash:

bash run_server.sh

Option 2: Manual setup

  1. Activate the virtual environment:

    Windows (PowerShell):

    .\.venv\Scripts\Activate.ps1
    

    Linux/macOS/Git Bash:

    source .venv/bin/activate
    
  2. Set the environment variables:

    Windows (PowerShell):

    $env:AZURE_OPENAI_API_KEY = "your-api-key-here"
    $env:AZURE_OPENAI_ENDPOINT = "your-azure-endpoint"
    $env:AZURE_OPENAI_API_VERSION = "your-api-version" 
    $env:AZURE_OPENAI_DEPLOYMENT = "your-deployment-name"
    

    Linux/macOS/Git Bash:

    export AZURE_OPENAI_API_KEY="your-api-key-here"
    export AZURE_OPENAI_ENDPOINT="your-azure-endpoint"
    export AZURE_OPENAI_API_VERSION="your-api-version"
    export AZURE_OPENAI_DEPLOYMENT="your-deployment-name"
    
  3. Run the server:

    python mcp_server.py
    

How it works

The server provides an MCP tool that checks code files for:

  1. SPDX license identifier
  2. Copyright notice
  3. Proper placement of headers at the top of the file

When these elements are missing, the tool suggests appropriate headers to add to your files.