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.1.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.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: policygate-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 e42168598e50d8538c9525c26b3f3f9841d5d80c6091b2f4d6a8b14a4ef83a97
MD5 6725b80e6e8637cdf72ae3b67f9fd7ad
BLAKE2b-256 04f6880edfaf9e49a0591dfcf899b59e3c146a3d2e0f2af0f92d94489ccb41ba

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: policygate-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 02dda5bbf084d58ca5c26101e05a7ad6f9215a7cd61c6bb9e0cda85b034232a9
MD5 ea51193a896634f8e7e3a206756d67f8
BLAKE2b-256 b4dc86df1e09882ef8b1ffe708f586bd48105f3b14d180b30c8414cf1091d00b

See more details on using hashes here.

Provenance

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