About Mcp2grule
Mcp2grule is an MCP server published by hungpdn in the Developer Tools category: mCP Server for Grule. It has been installed 0 times through Conduid.
Six months or more without a commit doesn't mean the server is broken, but check the open issues (0) before depending on it in production.
Install
npx mcp2gruleThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Mcp2grule
Powered by Claude · Grounded in docs
Security checks
- ·README presentNot checked yet.
- ·License declaredNot checked yet.
- ·Tests presentNot checked yet.
- ·Dependencies pinnedNot checked yet.
- ·No dynamic code executionNot checked yet.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
README
mcp2grule
mcp2grule 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).
Quick start
-
Clone and build:
git clone https://github.com/hungpdn/mcp2grule.git cd mcp2grule go mod tidy go build -o mcp2grule -
Run the server (defaults to stdio transport):
./mcp2grule server -
Or run with HTTP transport for easy testing (streamable-HTTP):
MCP_TRANSPORT=streamable-http DATABASE_TYPE=memory ./mcp2grule server
Configuration
All configuration is provided via environment variables (see internal/config/config.go). The minimal values you may set locally are in .env.example:
MCP_TRANSPORT=streamable-http
DATABASE_TYPE=memory
Key env vars
MCP_TRANSPORT:stdio,sse, orstreamable-http(default:stdio)DATABASE_TYPE:memory,sqlite, orpostgresql(default:memory)HTTP_HOST/HTTP_PORT: used for SSE / streamable-http transports
Project Structure
mcp2grule/
├─ cmd/ # CLI entrypoint (wires services and starts server)
├─ internal/
│ ├─ api/
│ │ ├─ server.go # MCP transport selection (stdio / sse / streamable-http), tool registration, graceful shutdown
│ │ └─ tool.go # MCP tool registration (grule.evaluate, grule.create, ...)
│ │ └─ handler/ # MCP handlers that map requests to domain DTOs
│ ├─ grule/
│ │ └─ grule.go # Domain service: constructs grule engine, Evaluate/Create/Update/Delete logic
│ ├─ storage/
│ │ ├─ storage.go # IRulesetStorage interface and common errors
│ │ ├─ memory.go # In-memory ruleset storage (default for local dev)
│ │ └─ postgres.go # Postgres driver (optional; implements IRulesetStorage)
│ ├─ config/
│ │ └─ config.go # Environment variable parsing and typed config
│ └─ pkg/
│ ├─ exitcode/ # Canonical exit codes for CLI/startup failures
│ └─ logger/ # Logging helpers and context wiring
├─ ...
└─ README.md
MCP tools provided
The server registers these MCP tools (exact names used by clients):
grule.evaluate- Evaluate facts against a named rulesetgrule.create- Create a new rulesetgrule.update- Update an existing rulesetgrule.delete- Delete ruleset by namegrule.list- List all rulesetsgrule.detail- Get ruleset details by name
See internal/api/tool.go for the registration and internal/api/handler/mcp.go for request/response handling examples.
Linters & formatting
This repo uses golangci-lint. A starter config is present at .golangci.yml. Run:
golangci-lint run
Docker
A multi-stage Dockerfile is included. It builds a static binary and copies it into a minimal distroless runtime image. Example build:
docker build -t mcp2grule:latest .
docker run -e MCP_TRANSPORT=streamable-http -e DATABASE_TYPE=memory -p 9000:9000 mcp2grule:latest
Security note: builder images can contain OS-level CVEs. Consider scanning images in CI and using patched base images.
Testing
There are currently no unit tests in the repo. Recommended next steps:
- Add unit tests for
internal/storageandinternal/grule(happy path + error conditions). - Add a CI workflow to run
go test ./...andgolangci-lint runon PRs.
TODO
- Add tests.
- Add CI.
- Add pprofing.
- Add middleware for auth, metrics and logging.
- Add postgres storage.
- Add migration.
README mirrored from the source repository 4 months ago. The original is authoritative.