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)
  • POLICYGATE__LOG_LEVEL (optional, default INFO)
  • POLICYGATE__LOG_FILE_PATH (optional, default ~/.policygate/policygate.log)

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.3.tar.gz (10.6 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.3-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: policygate-0.1.3.tar.gz
  • Upload date:
  • Size: 10.6 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.3.tar.gz
Algorithm Hash digest
SHA256 0d14d834d960bef609e8d974a1cbc7333f71e5a837dc44bc0799cf7b1d3fe13a
MD5 a13ad1a2fe7395ae2032b0d4ba40f5cd
BLAKE2b-256 a0b8d1a737ac1abd023075446de1d0281567e788cb1c61b98b57dd41bd6d9352

See more details on using hashes here.

Provenance

The following attestation bundles were made for policygate-0.1.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: policygate-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d18a4eb86773749645f92aafe36e9572f862685726394014faeccdac7a46703c
MD5 1f2959aa097d9b946ecf982b1b93a2e8
BLAKE2b-256 6c2d0afae9add626618c1aa7363ee3a8cedeba56ba3a1c364080409ea9b50a5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for policygate-0.1.3-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