Content
# @nntechai/opus-advisor-mcp
> The first governance-ready AI consultation server.
> Every AI interaction audited. Every document traced. Every output verifiable.
[](https://www.npmjs.com/package/@nntechai/opus-advisor-mcp)
[](https://opensource.org/licenses/MIT)
A Model Context Protocol (MCP) server that turns any OpenAI-compatible LLM into a senior architect advisor — with optional **ISO-auditable governance features** that no other MCP tool provides.
## Why Opus Advisor?
Other MCP tools just call an LLM. Opus Advisor gives you:
| Feature | Other MCPs | Opus Advisor |
|---|---|---|
| Call an LLM | Yes | Yes |
| File injection (no copy-paste) | No | `document_paths` |
| Folder scanning | No | `context_folder` |
| Auto-deduplication | No | Yes |
| **Governance: Output control headers** | No | **YAML frontmatter** |
| **Governance: Context attestation** | No | **Per-file SHA-256** |
| **Governance: Audit trail** | No | **JSONL log** |
| Auto-continuation | No | Multi-round |
### The Context Problem (Solved)
```
Traditional: Agent reads files → Agent summarizes → Advisor gets summary (LOSSY)
Opus Advisor: Agent sends paths → MCP reads files → Advisor gets raw content (LOSSLESS)
```
### The Governance Problem (Solved)
```
Traditional: AI generates output → no record of what it received → unauditable
Opus Advisor: AI generates output → document control header + attestation table + audit log → ISO-ready
```
## Quick Start
### 1. Install
```bash
npm install @nntechai/opus-advisor-mcp
```
Or run directly with npx:
```bash
npx @nntechai/opus-advisor-mcp
```
### 2. Configure
```env
# Required
LLM_API_KEY=sk-your-api-key
# Optional (with defaults)
LLM_BASE_URL=https://api.openai.com/v1
LLM_MODEL=gpt-4o
LLM_MAX_TOKENS=128000
LLM_TIMEOUT_MS=600000
# Governance (off by default)
GOVERNANCE_MODE=false
```
> **Legacy support:** `OPUS_API_KEY`, `OPUS_BASE_URL`, `OPUS_MODEL` env vars still work.
### 3. Add to your MCP client
```json
{
"mcpServers": {
"opus-advisor": {
"command": "node",
"args": ["path/to/server.js"],
"env": {
"LLM_API_KEY": "sk-your-key",
"LLM_MODEL": "claude-sonnet-4-20250514",
"GOVERNANCE_MODE": "true"
}
}
}
}
```
## Tools
### `advisor_consult` — Architecture Planning
```javascript
advisor_consult({
task: "Design a real-time notification system",
document_paths: [
"E:/project/docs/srs.md",
"E:/project/docs/architecture.md"
],
context_folder: "E:/project/specs/",
constraints: "Must use WebSockets, deploy on AWS",
governance: true // Enable for this call
})
```
### `advisor_ask` — Freeform Questions
```javascript
advisor_ask({
question: "Should we use GraphQL or REST for this API?",
document_paths: ["E:/project/src/api/routes.ts"],
governance: true
})
```
### `advisor_review` — Code Review
```javascript
advisor_review({
context: "Authentication module refactor",
document_paths: [
"E:/project/src/auth/login.ts",
"E:/project/src/auth/middleware.ts"
],
focus_areas: "security, error handling"
})
```
### `advisor_debug` — Debugging Escalation
```javascript
advisor_debug({
problem: "WebSocket connections drop after 30 seconds",
error_message: "ECONNRESET",
document_paths: ["E:/project/src/ws/server.ts"]
})
```
---
## Governance Mode
Governance is **off by default**. Enable it when you need auditable AI outputs.
### How to Enable
**Option A: Global (all calls)**
```env
GOVERNANCE_MODE=true
```
**Option B: Per-call (selective)**
```javascript
advisor_consult({
task: "...",
governance: true // Just this call
})
```
### What You Get
When governance is active, every output file includes three artifacts:
#### 1. Document Control Header (YAML Frontmatter)
Prepended to the top of every output file:
```yaml
---
document_control:
tool: opus-advisor/advisor_consult
model: claude-sonnet-4-20250514
generated_at: "2026-04-13T04:15:00.000Z"
governance_version: "1.0"
input_context_hash: "sha256:a1b2c3d4e5f67890"
input_chars: 180443
documents_count: 6
documents_referenced:
- "srs.md (45,000 chars)"
- "CONTEXT.yaml (6,473 chars)"
document_hashes:
- file: "srs.md"
sha256: "sha256:abc123def456"
chars: 45000
- file: "CONTEXT.yaml"
sha256: "sha256:789ghi012jkl"
chars: 6473
---
```
#### 2. Context Attestation Table
Appended to the bottom of every output file:
```markdown
## Context Attestation
| # | File | Chars | SHA-256 | Source |
|---|------|-------|---------|--------|
| 1 | srs.md | 45,000 | `sha256:abc123def456` | document_paths |
| 2 | CONTEXT.yaml | 6,473 | `sha256:789ghi012jkl` | document_paths |
| 3 | project-spec.md | 25,121 | `sha256:mno345pqr678` | context_folder |
**Combined Context Hash:** `sha256:a1b2c3d4e5f67890`
```
#### 3. Audit Trail (JSONL)
Append-only log at `audit/audit.jsonl`:
```json
{
"timestamp": "2026-04-13T04:15:42.000Z",
"tool": "advisor_consult",
"model": "claude-sonnet-4-20250514",
"input_hash": "sha256:a1b2c3d4e5f67890",
"output_hash": "sha256:f9e8d7c6b5a43210",
"output_file": "outputs/advisor-consultation-2026-04-13.md",
"documents_loaded": 6,
"total_input_chars": 180443,
"total_output_chars": 45000,
"duration_seconds": 42.3,
"rounds": 1,
"governance_version": "1.0"
}
```
### Why This Matters for Compliance
| Requirement | How Opus Advisor Satisfies It |
|---|---|
| **ISO 42001: AI Traceability** | Every output has traceable document control headers |
| **ISO 42001: Risk Management** | Context hash proves exactly what the AI received |
| **ISO 27001: Audit Trail** | Append-only JSONL log of every AI interaction |
| **SOC 2: Evidence Collection** | Per-file SHA-256 hashes verify document integrity |
| **NIST AI RMF: Transparency** | Context attestation table in every output |
---
## Provider Examples
| Provider | `LLM_BASE_URL` | `LLM_MODEL` |
|----------|----------------|-------------|
| OpenAI | `https://api.openai.com/v1` | `gpt-4o` |
| Anthropic | `https://api.anthropic.com/v1` | `claude-sonnet-4-20250514` |
| Google Gemini | `https://generativelanguage.googleapis.com/v1beta/openai` | `gemini-3.1-pro` |
| Groq | `https://api.groq.com/openai/v1` | `llama-3.3-70b` |
| Together AI | `https://api.together.xyz/v1` | `meta-llama/Llama-3-70b-chat-hf` |
| Local (Ollama) | `http://localhost:11434/v1` | `llama3` |
> **Note:** All providers work through their native OpenAI-compatible endpoints — no proxies or middleware required. Opus Advisor uses the [OpenAI Node.js SDK](https://github.com/openai/openai-node) under the hood, which most major providers now support natively.
## Architecture
```
Agent (Claude/Gemini/GPT)
│
├─ advisor_consult({ task, document_paths, governance: true })
│
▼
Opus Advisor MCP Server
│
├─ resolveDocuments() ← Read files, deduplicate, compute per-file hashes
├─ buildGovernanceHeader() ← YAML frontmatter with document control metadata
├─ streamCompletions() ← Stream to LLM API with auto-continuation
├─ buildContextAttestation() ← Verifiable document inventory table
└─ writeAuditEntry() ← Append-only JSONL audit log
│
▼
Returns: { file_path, output_hash, governance_active, context_metadata }
```
## File Structure
```
opus-advisor-mcp/
├── server.js # MCP server (single file, zero framework deps)
├── package.json # npm metadata
├── .env # Local configuration
├── outputs/ # Generated responses (markdown files)
└── audit/ # Governance audit trail (auto-created)
└── audit.jsonl # Append-only audit log
```
## License
MIT — Built by [New Normal AI Lab](https://nntechai.com)