{"id":34937281,"url":"https://github.com/hungpdn/mcp2grule","last_synced_at":"2026-04-25T13:33:29.387Z","repository":{"id":315154989,"uuid":"1043828539","full_name":"hungpdn/mcp2grule","owner":"hungpdn","description":"MCP Server for Grule.","archived":false,"fork":false,"pushed_at":"2025-09-17T00:40:40.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-17T02:35:29.196Z","etag":null,"topics":["golang","grule","mcp","mcp-server","mcp-servers","rule","rules-engine"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hungpdn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-24T17:48:44.000Z","updated_at":"2025-09-17T00:40:44.000Z","dependencies_parsed_at":"2025-09-17T02:35:39.260Z","dependency_job_id":null,"html_url":"https://github.com/hungpdn/mcp2grule","commit_stats":null,"previous_names":["hungpdn/mcp2grule"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/hungpdn/mcp2grule","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fmcp2grule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fmcp2grule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fmcp2grule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fmcp2grule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hungpdn","download_url":"https://codeload.github.com/hungpdn/mcp2grule/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hungpdn%2Fmcp2grule/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32264426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","grule","mcp","mcp-server","mcp-servers","rule","rules-engine"],"created_at":"2025-12-26T18:33:32.403Z","updated_at":"2026-04-25T13:33:29.377Z","avatar_url":"https://github.com/hungpdn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mcp2grule\n\nmcp2grule is a production-ready, high-performance Go server that exposes the Grule rule engine to Large Language Models (LLMs) and other AI applications via the Model Context Protocol (MCP).\n\n## Quick start\n\n1. Clone and build:\n\n    ```bash\n    git clone https://github.com/hungpdn/mcp2grule.git\n    cd mcp2grule\n    go mod tidy\n    go build -o mcp2grule\n    ```\n\n2. Run the server (defaults to stdio transport):\n\n    ```bash\n    ./mcp2grule server\n    ```\n\n3. Or run with HTTP transport for easy testing (streamable-HTTP):\n\n    ```bash\n    MCP_TRANSPORT=streamable-http DATABASE_TYPE=memory ./mcp2grule server\n    ```\n\n## Configuration\n\nAll configuration is provided via environment variables (see `internal/config/config.go`). The minimal values you may set locally are in `.env.example`:\n\n```bash\nMCP_TRANSPORT=streamable-http\nDATABASE_TYPE=memory\n```\n\nKey env vars\n\n- `MCP_TRANSPORT`: `stdio`, `sse`, or `streamable-http` (default: `stdio`)\n- `DATABASE_TYPE`: `memory`, `sqlite`, or `postgresql` (default: `memory`)\n- `HTTP_HOST` / `HTTP_PORT`: used for SSE / streamable-http transports\n\n## Project Structure\n\n```text\nmcp2grule/\n├─ cmd/                # CLI entrypoint (wires services and starts server)\n├─ internal/\n│  ├─ api/\n│  │  ├─ server.go     # MCP transport selection (stdio / sse / streamable-http), tool registration, graceful shutdown\n│  │  └─ tool.go       # MCP tool registration (grule.evaluate, grule.create, ...)\n│  │  └─ handler/      # MCP handlers that map requests to domain DTOs\n│  ├─ grule/\n│  │  └─ grule.go      # Domain service: constructs grule engine, Evaluate/Create/Update/Delete logic\n│  ├─ storage/\n│  │  ├─ storage.go    # IRulesetStorage interface and common errors\n│  │  ├─ memory.go     # In-memory ruleset storage (default for local dev)\n│  │  └─ postgres.go   # Postgres driver (optional; implements IRulesetStorage)\n│  ├─ config/\n│  │  └─ config.go     # Environment variable parsing and typed config\n│  └─ pkg/\n│     ├─ exitcode/     # Canonical exit codes for CLI/startup failures\n│     └─ logger/       # Logging helpers and context wiring\n├─ ...\n└─ README.md           \n```\n\n## MCP tools provided\n\nThe server registers these MCP tools (exact names used by clients):\n\n- `grule.evaluate` - Evaluate facts against a named ruleset\n- `grule.create` - Create a new ruleset\n- `grule.update` - Update an existing ruleset\n- `grule.delete` - Delete ruleset by name\n- `grule.list` - List all rulesets\n- `grule.detail` - Get ruleset details by name\n\nSee `internal/api/tool.go` for the registration and `internal/api/handler/mcp.go` for request/response handling examples.\n\n## Linters \u0026 formatting\n\nThis repo uses `golangci-lint`. A starter config is present at `.golangci.yml`. Run:\n\n```bash\ngolangci-lint run\n```\n\n## Docker\n\nA multi-stage `Dockerfile` is included. It builds a static binary and copies it into a minimal distroless runtime image. Example build:\n\n```bash\ndocker build -t mcp2grule:latest .\ndocker run -e MCP_TRANSPORT=streamable-http -e DATABASE_TYPE=memory -p 9000:9000 mcp2grule:latest\n```\n\nSecurity note: builder images can contain OS-level CVEs. Consider scanning images in CI and using patched base images.\n\n## Testing\n\nThere are currently no unit tests in the repo. Recommended next steps:\n\n- Add unit tests for `internal/storage` and `internal/grule` (happy path + error conditions).\n- Add a CI workflow to run `go test ./...` and `golangci-lint run` on PRs.\n\n## TODO\n\n- [ ] Add tests.\n- [ ] Add CI.\n- [ ] Add pprofing.\n- [ ] Add middleware for auth, metrics and logging.\n- [ ] Add postgres storage.\n- [ ] Add migration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungpdn%2Fmcp2grule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhungpdn%2Fmcp2grule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhungpdn%2Fmcp2grule/lists"}