Shared utilities for token-efficient MCP servers — RBAC, audit logging, lean response shaping, TLS config
Project description
node804-mcp-toolkit
Shared utilities for building token-efficient, security-conscious MCP servers for IT operations. Provides the cross-cutting concerns every ops MCP needs — permission gating, audit logging, response shaping, TLS config — so each server in a suite implements them the same way.
Installation
pip install node804-mcp-toolkit
What's in here
| Module | Purpose |
|---|---|
rbac |
Hierarchical permission modes (read / standard / full / admin); a gate decorator that only registers tools with the MCP server when the active mode qualifies — ungated tools are invisible to the AI client, not just blocked |
audit |
JSON-lines audit logging of every tool call with timing, success/error state, sensitive-key redaction, and long-value truncation |
lean |
Pure response-shaping helpers: field whitelisting, internal-key stripping, pagination, server-side pattern filtering |
tls |
Verify-by-default TLS config from env vars, with custom CA bundle support for internal PKI |
params |
Shared Pydantic parameter types (VerboseFlag, FieldsList, Pagination, Pattern) so every tool uses the same names, defaults, and descriptions |
Quick start
Gate tools by permission mode, with audit logging composed in:
from mcp.server.fastmcp import FastMCP
from node804_mcp_toolkit import Mode, ModeGate, open_sink
mcp = FastMCP("panos-mcp")
# Audit sink: writes JSONL when PANOS_AUDIT_LOG is set, no-op otherwise.
sink = open_sink(env_var="PANOS_AUDIT_LOG")
# Mode comes from env. Missing or invalid values fail safe to read-only.
gate = ModeGate.from_env(env_var="PANOS_MODE", audit_sink=sink)
@gate.tool(mcp, required=Mode.READ)
async def get_security_rules(...): ...
@gate.tool(mcp, required=Mode.ADMIN)
async def commit(...): ... # not registered at all unless PANOS_MODE=admin
Shape responses for token efficiency:
from node804_mcp_toolkit import filter_by_pattern, paginate, strip_keys, whitelist
rules = strip_keys(raw_rules, ["@uuid", "@loc"]) # drop SDK internals
rules = filter_by_pattern(rules, pattern, name_field="name")
rules = paginate(rules, limit=100, offset=0)
rules = whitelist(rules, ["name", "action", "source", "destination"])
Resolve TLS settings from environment (verify-by-default):
from node804_mcp_toolkit import resolve_tls_config
import httpx, os
tls = resolve_tls_config(dict(os.environ), prefix="PRTG")
# PRTG_TLS_VERIFY=false → verify off, with a loud stderr warning
# PRTG_TLS_CA=/path.pem → custom CA bundle for internal PKI
client = httpx.Client(verify=str(tls.ca_path) if tls.ca_bundle else tls.verify)
Design philosophy
- One toolkit, one set of patterns. A user who learns the parameter conventions in any one MCP —
verbose,fields,limit,offset,pattern— gets the same conventions in all of them. - Default deny. Unset or misconfigured mode env vars fall back to read-only. Tools above the active mode are never registered, so the AI client can't even see them.
- Token-lean by default. Responses expose the fields the AI actually reasons over;
verbose=trueopts into the full payload. - Best-effort observability. Audit logging never breaks a tool call — sink failures warn once to stderr and move on.
Used by
node804-panos-mcp— Palo Alto firewall managementnode804-freshservice-mcp— Freshservice ticketing- Planned: PRTG and Veeam MCPs
Development
pip install -e ".[dev]"
pytest
ruff check .
mypy src
Requires Python 3.11+. Fully typed (py.typed included), mypy --strict clean.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file node804_mcp_toolkit-0.1.0.tar.gz.
File metadata
- Download URL: node804_mcp_toolkit-0.1.0.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
250b26bb6a434ea906641c9a17cecc84c804a6237fd151c2f3effecfab7a7e44
|
|
| MD5 |
78155dc042589c0eea27f0789fd0fc1a
|
|
| BLAKE2b-256 |
bcb45def9338b8978a403ed68decce10ad0387905287f969238b438adf20b92c
|
Provenance
The following attestation bundles were made for node804_mcp_toolkit-0.1.0.tar.gz:
Publisher:
publish.yml on Node804/node804-mcp-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
node804_mcp_toolkit-0.1.0.tar.gz -
Subject digest:
250b26bb6a434ea906641c9a17cecc84c804a6237fd151c2f3effecfab7a7e44 - Sigstore transparency entry: 1782473988
- Sigstore integration time:
-
Permalink:
Node804/node804-mcp-toolkit@8716280d5e3853bbd4d2fa14812f8aa28ec17a3b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Node804
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8716280d5e3853bbd4d2fa14812f8aa28ec17a3b -
Trigger Event:
push
-
Statement type:
File details
Details for the file node804_mcp_toolkit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: node804_mcp_toolkit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ac47ea1e4a3b43b130dec6834bb7dc6d79563500a7ae2c2448d01b5ec73b4de
|
|
| MD5 |
d4382fe38f3f8050902b9f6301907f23
|
|
| BLAKE2b-256 |
8307ceb3648b9798bff9ddcac50a7b6f1a8600de56273a802f4aa8286beae6fd
|
Provenance
The following attestation bundles were made for node804_mcp_toolkit-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Node804/node804-mcp-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
node804_mcp_toolkit-0.1.0-py3-none-any.whl -
Subject digest:
2ac47ea1e4a3b43b130dec6834bb7dc6d79563500a7ae2c2448d01b5ec73b4de - Sigstore transparency entry: 1782474101
- Sigstore integration time:
-
Permalink:
Node804/node804-mcp-toolkit@8716280d5e3853bbd4d2fa14812f8aa28ec17a3b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Node804
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8716280d5e3853bbd4d2fa14812f8aa28ec17a3b -
Trigger Event:
push
-
Statement type: