Skip to main content

MCP server gateway for task-specific AI rules and scripts stored in GitHub

Project description

policygate banner

Publish workflow PyPI version Python versions MIT license

policygate

Policygate is an MCP server gateway for task-specific AI rules and scripts stored in a GitHub repository.

Features

  • Syncs repository content into a local cache at ~/.policygate/repo_data
  • Parses and validates router.yaml
  • Exposes MCP tools:
    • sync_repository
    • outline_router
    • read_rules
    • copy_scripts

Detailed usage reference: docs/REFERENCE.md

Required repository structure

rules/
scripts/
router.yaml

router.yaml structure:

tasks:
    task1:
        description: "Short description of task 1"
        rules:
            - rule1
        scripts:
            - script1

rules:
    rule1:
        path: rules/rule1.md
        description: "Short description of rule 1"

scripts:
    script1:
        path: scripts/script1.py
        description: "Short description of script 1"

Configuration

Set environment variables:

  • POLICYGATE__GITHUB_REPOSITORY_URL
  • POLICYGATE__GITHUB_ACCESS_TOKEN
  • POLICYGATE__LOCAL_REPO_DATA_DIR (optional, default ~/.policygate/repo_data)
  • POLICYGATE__REPOSITORY_REFRESH_INTERVAL_SECONDS (optional, default 1800)

Run MCP server

Run with:

uv run policygate-mcp

VS Code workspace MCP config example (.vscode/mcp.json):

{
    "inputs": [
        {
            "id": "POLICYGATE__GITHUB_REPOSITORY_URL",
            "type": "promptString",
            "description": "GitHub repository URL",
            "password": false
        },
        {
            "id": "POLICYGATE__GITHUB_ACCESS_TOKEN",
            "type": "promptString",
            "description": "GitHub access token",
            "password": true
        }
    ],
    "servers": {
        "policygate": {
            "type": "stdio",
            "command": "uvx",
            "args": ["--from", "policygate@latest", "policygate-mcp"],
            "env": {
                "POLICYGATE__GITHUB_REPOSITORY_URL": "${input:POLICYGATE__GITHUB_REPOSITORY_URL}",
                "POLICYGATE__GITHUB_ACCESS_TOKEN": "${input:POLICYGATE__GITHUB_ACCESS_TOKEN}"
            },
        }
    }
}

For local testing from the current workspace (after uv sync --all-groups):

{
    "inputs": [
        {
            "id": "POLICYGATE__GITHUB_REPOSITORY_URL",
            "type": "promptString",
            "description": "GitHub repository URL",
            "password": false
        },
        {
            "id": "POLICYGATE__GITHUB_ACCESS_TOKEN",
            "type": "promptString",
            "description": "GitHub access token",
            "password": true
        }
    ],
    "servers": {
        "policygate-local": {
            "type": "stdio",
            "command": "uv",
            "args": ["run", "policygate-mcp"],
            "env": {
                "POLICYGATE__GITHUB_REPOSITORY_URL": "${input:POLICYGATE__GITHUB_REPOSITORY_URL}",
                "POLICYGATE__GITHUB_ACCESS_TOKEN": "${input:POLICYGATE__GITHUB_ACCESS_TOKEN}"
            },
            "cwd": "${workspaceFolder}"
        }
    }
}

Testing

Run feature-organized end-to-end suites:

uv run pytest --maxfail=1 --tb=short

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

policygate-0.1.2.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

policygate-0.1.2-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file policygate-0.1.2.tar.gz.

File metadata

  • Download URL: policygate-0.1.2.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for policygate-0.1.2.tar.gz
Algorithm Hash digest
SHA256 43357be545cb354013dd58541cdd9cd7798b980b122903a3fbdeaa5839817a15
MD5 5321e76b1442e4d4c5d6217d9a7a89ef
BLAKE2b-256 3b7d09c0656d76abbeaae3e5342cdf831b7c87b252ae73cd2a2a4efd331dabfa

See more details on using hashes here.

Provenance

The following attestation bundles were made for policygate-0.1.2.tar.gz:

Publisher: publish-to-pypi.yml on l0kifs/policygate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file policygate-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: policygate-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for policygate-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 812fc0ec3da5bb312767b79d4aeaedf88c635786cbdb5624afe06b69d7ed5911
MD5 5573f4bde118f25bc09066e219e7b400
BLAKE2b-256 1fb5169d5b326cbaf5f0de851fe240f7a347968092892f84887aa8a21019bcd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for policygate-0.1.2-py3-none-any.whl:

Publisher: publish-to-pypi.yml on l0kifs/policygate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page