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 60)

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.0.tar.gz (9.4 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.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: policygate-0.1.0.tar.gz
  • Upload date:
  • Size: 9.4 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.0.tar.gz
Algorithm Hash digest
SHA256 04f6a6e3b9ae6b6264bd970203cfec8e3c107ee2408df991f5d2e0edbe980504
MD5 922e5838e3c2bfeb918baace31f3484a
BLAKE2b-256 e733c98b857a96dbe79e996ce327bd895750211fd0c617fdd5feabe4d498d1b5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: policygate-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ba223a78397fc5652b28ab496c361ce6b428a170561b0db6c784b04f32289b7
MD5 e5606024c6d46e1b480d8eeae105ddf3
BLAKE2b-256 2393b85b3672127a67a1ea36553130c94ce9630dd8503e3698351a6e67d874ce

See more details on using hashes here.

Provenance

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