proactive-agent-mcp
You can run proactive triage, document compliance, grounded retrieval, human approval, and cost enforcement for autonomous agents via MCP tools.
Claim unprocessed events under time-boxed leases; complete, release, or push events.
Evaluate document compliance with missing-field, regex, confidence, and risk reporting.
Query an in-repository TF-IDF corpus for ranked knowledge with grounding verdict.
Request human approval tickets and verify single-use HMAC-SHA256 confirmation codes.
Track token spend and enforce per-session USD budgets server-side.
Select the active session charged by the budget guard.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@proactive-agent-mcp Poll the event queue for unhandled high-severity alerts and summarize them."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
proactive-agent-mcp
A Model Context Protocol server in Python that exposes a proactive triage queue, document compliance validation, grounded knowledge retrieval, and server-enforced guardrails for autonomous agents. Speaks JSON-RPC 2.0 over stdio.
What it does
Proactive triage with leases.
poll_event_queueclaims unprocessed events and takes a time-boxed lease on each. If the agent dies mid-triage the lease lapses and the event returns to the queue.complete_eventandrelease_eventsettle or hand back work explicitly.Document compliance evaluation.
evaluate_document_compliancechecks extracted document fields against a declared schema, reporting missing fields, regex violations, a confidence score, and a risk level.Grounded retrieval.
query_rag_knowledgeranks an in-repository corpus with sparse TF-IDF vectors and cosine similarity, returning measured latency and an explicit grounding verdict.Human-in-the-loop gates.
request_human_approvalparks a sensitive action behind an HMAC-SHA256 signed ticket.verify_approval_tokenchecks a supervisor's confirmation code.Cost enforcement.
track_cost_budgetbooks token spend, and the server refuses further tool calls for any session that has exhausted its budget.
Related MCP server: agent-work-mcp
Architecture
+--------------------------------------------------+
| Client (Claude Desktop / Cursor / IDE) |
+----------------------+---------------------------+
|
| JSON-RPC 2.0 over stdio
v
+--------------------------------------------------+
| proactive-agent-mcp |
| |
| server.py dispatch, negotiation, budgets |
| protocol.py JSON-RPC + MCP primitives |
| validation.py pydantic argument enforcement |
| |
| tools/ triage, compliance, knowledge, |
| guardrails (HITL + cost) |
| resources/ system://health, compliance://standards
| prompts/ autonomous_triage_loop, |
| compliance_audit_brief |
+--------------------------------------------------+The event queue and knowledge corpus are in-memory reference implementations. They reset on restart and are not shared between replicas.
Quick start
git clone https://github.com/MishaelOliva/proactive-agent-mcp.git
cd proactive-agent-mcp
pip install -e ".[dev]"
python -m proactive_agent_mcp.serverTo watch a full triage session, including the human-approval round trip and budget enforcement:
python examples/run_client_demo.pyConfiguration
Claude Desktop
{
"mcpServers": {
"proactive-agent": {
"command": "python",
"args": ["-m", "proactive_agent_mcp.server"],
"env": {
"PYTHONUNBUFFERED": "1",
"MCP_SIGNING_SECRET": "generate-with-openssl-rand-hex-32"
}
}
}
}Cursor (.cursor/mcp.json)
{
"mcpServers": {
"proactive-agent": {
"command": "python",
"args": ["-m", "proactive_agent_mcp.server"],
"env": {
"MCP_SIGNING_SECRET": "generate-with-openssl-rand-hex-32"
}
}
}
}Environment variables
Variable | Purpose | Default |
| Key for HMAC-SHA256 approval codes. Set this. An unset value produces a random per-process secret and logs a warning, so tokens do not survive a restart. | random, per process |
| Default per-session spend ceiling. |
|
| Log level for the stderr stream. |
|
| Flush stdout so responses are not buffered. |
|
Tools
Tool | Purpose |
| Claim events under a lease. |
| Settle a claimed event. |
| Return a claimed event to the queue. |
| Record an observation onto the queue. |
| Validate extracted document fields. |
| Rank the corpus by TF-IDF cosine similarity. |
| Park a sensitive action for human authorization. |
| Verify a supervisor's confirmation code. |
| Book token spend against a session. |
| Choose which session the budget guard charges. |
Security model
The human-in-the-loop gate is a worked pattern, not a production authorization system. What it does guarantee:
Approval codes are full 256-bit HMAC-SHA256 values, base32-encoded for legibility. They are not truncated.
The signed payload binds the ticket id, action name, a SHA-256 digest of the action parameters, and the absolute expiry. A code cannot be re-pointed at a different action, swapped for different parameters, or replayed after expiry.
The code is recomputed at verification time rather than read from a stored expected value, so a tampered ticket record invalidates its own code.
Tickets are single-use, compared in constant time, and garbage-collected once settled.
The confirmation code is never returned by
request_human_approval. It must arrive through a channel the agent cannot reach.The signing secret has no hardcoded default. With
MCP_SIGNING_SECRETunset, a random secret is generated at start-up, so a code cannot be derived from knowledge of this repository.
What it does not guarantee, and what a real deployment must add:
Binding approvals to an authenticated human principal. The gate proves a holder of the secret approved, not who.
Surviving a restart or spanning replicas. Tickets live in process memory.
An authenticated delivery channel for the confirmation code.
Protection against a sufficiently privileged caller with in-process access.
The budget guard enforces rather than advises: once a session exceeds its ceiling, the server refuses non-guardrail tool calls. Accounting tools stay reachable so the agent can report honestly rather than dead-ending.
Testing
python -m unittest discover -s tests -t .116 tests covering protocol conformance (initialization gating, notification suppression, version negotiation, batching, pagination, error codes), tool behaviour, the HITL security properties, budget enforcement, and an end-to-end stdio session against a real subprocess.
Several tests are explicit regression guards for defects fixed in v1.1.0: a confidence score that capped a perfect document at 0.571, a hardcoded retrieval latency, a forgeable approval secret, a mid-session budget change that was silently ignored, and an event queue that stranded work when an agent crashed.
CI runs the suite on Python 3.10-3.12 with and without MCP_SIGNING_SECRET set, lints with ruff,
verifies the wheel installs in a clean environment, and smoke tests the container entrypoint.
Limitations
Single process. State is in memory, so the event queue, tickets, and budget ledger reset on restart and are not shared across replicas.
stdio only. Streamable HTTP transport is not implemented.
Lexical retrieval. TF-IDF cosine matches vocabulary, not meaning. Paraphrased queries retrieve poorly. Dense embeddings would be the natural upgrade; the interface would not change.
Deterministic compliance. Field and regex validation only. It says nothing about whether extracted values are truthful.
Illustrative pricing.
MODEL_PRICINGintools/guardrails.pyis a static table that needs periodic refreshing. Treat it as configuration.
License
MIT.
Built by Mishael Oliva • LinkedIn
Available Tools
10 toolscomplete_eventAIdempotent
Settle a claimed event with an outcome and an optional note. Use this once triage of an event has finished.
Inputs: event_id (required), note, outcome. Returns: object
evaluate_document_complianceARead-onlyIdempotent
Check an extracted document against a declared schema. Reports missing required fields, pattern violations, a confidence score, and a triage verdict. This is deterministic field validation over regex rules, not document understanding.
Inputs: document_payload (required), schema_type, strict_mode. Returns: object
poll_event_queueARead-only
Claim unprocessed events from the proactive triage queue and take a time-boxed lease on each. Events whose lease lapses return to the queue automatically, so a crashed agent does not strand work.
Inputs: max_items, queue_name, lease_seconds, filter_severity. Returns: object
push_eventA
Record an observation the agent made onto the triage queue so it becomes visible to other workers. Rejected when the queue is full.
Inputs: payload (required), severity (required), event_type (required), source. Returns: object
query_rag_knowledgeARead-onlyIdempotent
Rank the built-in knowledge corpus against a query using sparse TF-IDF vectors and cosine similarity. Lexical rather than semantic: it matches vocabulary, so paraphrased queries retrieve poorly. Returns measured retrieval latency and an explicit grounding verdict.
Inputs: query (required), top_k, min_score_threshold. Returns: object
release_eventAIdempotent
Return a claimed event to the unprocessed pool without settling it, so another worker can pick it up immediately instead of waiting for the lease to lapse.
Inputs: event_id (required). Returns: object
request_human_approvalBRead-only
Park a sensitive action behind a human decision and return an authorization ticket. The confirmation code is never returned here: it must be supplied by an authorized human over an authenticated out-of-band channel, otherwise the gate proves nothing.
Inputs: rationale (required), action_name (required), action_parameters (required), urgency, +1 more. Returns: object
set_active_sessionAIdempotent
Select which session the server's budget guard charges. The server refuses non-guardrail tool calls for any session that has exhausted its budget.
Inputs: session_id (required). Returns: object
track_cost_budgetA
Book token spend against a session budget. Once a session exceeds its budget the server refuses further tool calls for it until the budget is raised; enforcement is server-side, not advisory.
Inputs: session_id (required), prompt_tokens (required), completion_tokens (required), model_name, +1 more. Returns: object
verify_approval_tokenA
Verify a supervisor's confirmation code against a ticket and consume the ticket on success. The code is bound to the action name, a digest of the action parameters, and the expiry, and each ticket is single-use.
Inputs: ticket_id (required), confirmation_code (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
The tools cluster into four clear domains: event-queue lifecycle (poll/complete/release/push), approval (request/verify), budget (track/set_active_session), and two standalone capabilities (compliance, RAG). complete_event vs release_event could be momentarily confused, but the descriptions clearly distinguish settling from returning to the pool. set_active_session and track_cost_budget are related but have distinct roles.
Every tool follows a consistent verb_noun snake_case pattern (poll_event_queue, complete_event, verify_approval_token, track_cost_budget, etc.). No mixed conventions or vague verbs anywhere in the set.
Ten tools is well within the sweet spot for a triage/guardrail agent, and each tool earns its place by covering a distinct operation rather than duplicating another. No bloat or thin coverage.
The event queue has full lifecycle coverage (push/poll/complete/release), approval has request+verify, and budget has tracking plus session selection. Minor gaps like inspecting queue depth or listing pending events exist, but agents can work around them via polling.
Maintenance
Related MCP Connectors
Connect, monitor, and control AI agents — tasks, approvals, schedules, and governance.
Governed autonomous-agent platform: HITL approvals, budget gates, audit chain, effect ledger.
Autonomous and governed SRE & MLOps control plane for AI agent platforms.
Deterministic compliance and vertical knowledge bases for autonomous agents. Free 24hr trial.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides durable queues, human-in-the-loop approval gates, and an audit trail for AI agent fleets, enabling blocking approval requests and reliable work handoffs.MIT
- AlicenseAqualityCmaintenanceEnables coding agents to run persistent, budgeted work sessions with dependency graphs, human decision queues, required validation, and clean handoffs for autonomous or human-in-the-loop execution.16MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables agents to track real-time token spend and cost velocity, automatically throttle or freeze execution when budgets are exceeded, and enforce sandbox and safety guardrails.MIT
- AlicenseNot gradedqualityBmaintenanceEnables agents to route every action through a pre-execution gate that returns allow, escalate-to-human, or deny verdicts, backed by deterministic hard-rule blocks plus probabilistic gray-zone scoring, and to run a resumable orchestration loop covering routing, quality gates, stop-loss, acceptance, and escalation. Every decision, arbitration between conflicting agents, and human approval is written to an append-only hash-chained, Ed25519-signed ledger that can be postmortemed, calibrated, alert-scanned, and exported as offline verification bundles or OTel spans.1MIT