Skip to main content

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

Metadata

Release files for policygate 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for policygate 0.1.3
File Size Uploaded
policygate-0.1.3.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for policygate 0.1.3
File Interpreter ABI Platform
policygate-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 26.3 kB

Release files / policygate-0.1.3.tar.gz

Download URL policygate-0.1.3.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0d14d834d960bef609e8d974a1cbc7333f71e5a837dc44bc0799cf7b1d3fe13a
BLAKE2b-256 checksum
How to use checksums
a0b8d1a737ac1abd023075446de1d0281567e788cb1c61b98b57dd41bd6d9352
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

Release files / policygate-0.1.3-py3-none-any.whl

Download URL policygate-0.1.3-py3-none-any.whl
Size 15.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d18a4eb86773749645f92aafe36e9572f862685726394014faeccdac7a46703c
BLAKE2b-256 checksum
How to use checksums
6c2d0afae9add626618c1aa7363ee3a8cedeba56ba3a1c364080409ea9b50a5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page