AI Agents and MCP

Knowledge exposes tools through the Model Context Protocol (MCP). Any MCP-compatible agent can query the registry, check compliance, record decisions, and request approvals.


Setup

1. Configure MCP

Add to your .mcp.json:

{
  "mcpServers": {
    "knowledge": {
      "url": "https://mcp.asplenz.com/knowledge",
      "headers": {
        "Authorization": "Bearer kn_..."
      }
    }
  }
}

2. Launch your agent

The MCP tools are automatically available. Asplenz provides system prompt templates so agents use them correctly out of the box.

3. Monitor in the dashboard

Every query, check, approval, and reference appears in the event timeline. Review agent behavior in real time or audit historically.


Available MCP Tools

Before acting

knowledge_list_invariantsGet all blocking constraints for a scope
knowledge_list_rulesGet all active directives (mandatory + advisory)
knowledge_checkTest an intended action against the normative state
knowledge_resolveGet the full normative state for a scope/namespace
knowledge_request_approvalRequest human approval for gated actions
knowledge_get_approval_statusCheck if approval was granted

After acting

knowledge_record_referenceRecord that a constraint was followed or diverged from
knowledge_create_decisionCapture a new decision with context and reasoning

Anytime

knowledge_querySearch the registry by keywords, type, scope

How Constraints Apply

Invariants: Hard Stops

Absolute constraints that block violating actions. If an agent's intended action conflicts with an invariant, knowledge_check returns a conflict and the agent must stop.

Rules: Active Guidance

Directives that shape behavior. Mandatory rules must be followed; advisory rules should be considered. Agents receive both and can explain which rules influenced their decisions.

Approval Gates

Some invariants require human approval before proceeding. The agent calls knowledge_request_approval, Knowledge notifies the right people via webhook (Slack, Teams, or any external system) with an ECDSA signature. The agent can provide a callback_url to be notified automatically when the decision is made - no polling needed.


Example: Full Workflow

Agent: I need to add a new API endpoint for payment processing.

1. knowledge_resolve(scope="Engineering", namespace="payments")
   --> 14 applicable entries: 2 invariants, 5 decisions, 6 rules, 1 override

2. knowledge_check(scope="Engineering", action="Add REST endpoint for payment processing")
   --> No conflicts. Proceed.

3. Agent writes the endpoint with authentication middleware and PostgreSQL.

4. knowledge_record_reference(
     entry_id="inv-a1b2c3",
     context_type="pull_request",
     context_ref="PR #142",
     compliance="followed"
   )

5. knowledge_create_decision(
     scope="Engineering",
     decision="Added /api/payments endpoint using REST with bearer auth",
     context="Payment team requested payment initiation API",
     reasoning="Followed existing REST convention per Engineering rules"
   )

The agent acted with full context. The compliance trail is automatic.


Audit Trail

Every agent interaction with Knowledge generates structured data:

EventWhat's Recorded
Constraint queryScope, timestamp, entries returned
Compliance checkAction, conflicts, result
Approval requestEntry, justification, status
ReferenceEntry cited, context (PR, commit, deploy), compliance status
Decision recordedFull decision with context and reasoning

When an auditor asks "what constraints governed this AI-generated code?", the answer is a database query.


Compatible Agents

Knowledge works with any MCP-compatible agent: coding agents, finance agents, compliance agents, operations agents. The same API is available via REST for custom integrations, CI pipelines, and scripts.


Learn More