PromptSpeak Governance

io.github.chrbailey由 GitHub 帳號 chrbailey 發布v0.4.1更新於 Oct 24, 2026

Pre-execution governance for AI agents. Validates tool calls before they execute.

已驗證STDIO僅桌面開發者工具安全與監控

概覽

AI 產生的概覽

一個本機治理層,在 AI 代理的工具呼叫執行前進行驗證與攔截,並提供人工核准擱置、漂移偵測和稽核日誌。

可以做什麼
驗證治理框架並批次檢查代理動作,支援在不執行工具的情況下試跑完整流程。管理人工核准擱置:列出待處理操作、帶修改參數核准、拒絕,以及調整擱置觸發條件和統計。控制代理生命週期:讀取代理狀態和系統統計,透過斷路器暫停或恢復代理,重設狀態並檢視漂移歷史。建立、撤銷和列出帶受限權限的父子委派。設定治理規則、信心門檻和功能開關,並匯出或匯入設定。掃描程式碼漏洞並執行攔截、擱置、警告或放行策略,以及讀取稽核記錄。
適用情境
當你執行會呼叫工具的代理,並希望在意圖與執行之間加入確定性檢查時使用,特別適合生產部署或金融交易等高風險操作。也適合需要記錄每次工具呼叫嘗試並人工核准風險操作的受監管情境。
執行需求
透過 stdio 在本機執行,通常用 npx 從 npm 套件啟動,或從原始碼建置。需要 Node.js 20 或更新版本;僅從原始碼建置時需要 TypeScript 5.3+。無需外部服務、帳號或 API 金鑰;治理資料儲存在本機 SQLite 中。
安裝前請注意
它會攔截並可能阻擋、擱置或暫停代理的工具呼叫,設定不當可能中斷正常工作。核准擱置可能執行底層操作,並可附帶修改後的參數。安全掃描以正規表示式為基礎,存在已記錄的誤報率,且不掃描磁碟上既有檔案或深層巢狀參數。模式設定變更僅存於記憶體,重新啟動後重設。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 PromptSpeak Governance,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

promptspeak-mcp-server

[CI] [npm version] [License: MIT] [Tests]

Pre-execution governance for AI agents. Blocks dangerous tool calls before they execute.

AI agents call tools (file writes, API requests, shell commands) with no validation layer between intent and execution. A prompt injection, hallucinated argument, or drifting goal can trigger irreversible actions. PromptSpeak intercepts every MCP tool call, validates it against deterministic rules, and blocks or holds risky operations for human approval — in 0.1ms, before anything executes.

[PromptSpeak Governance Demo]

When to use this

  • You run AI agents that call tools (MCP servers, function calling, tool use) and need a governance layer between the agent and the tools.
  • You need human-in-the-loop approval for high-risk operations (production deployments, financial transactions, legal filings).
  • You want to detect behavioral drift — an agent gradually shifting away from its assigned task.
  • You need an audit trail of every tool call an agent attempted, whether it was allowed or blocked.
  • You operate in a regulated domain (legal, financial, healthcare) where agent actions must be deterministically constrained.

Install

Claude Code

Add to ~/.claude/settings.json (or project-level .claude/settings.json):

json
{  "mcpServers": {    "promptspeak": {      "command": "npx",      "args": ["promptspeak-mcp-server"]    }  }}

Restart Claude Code. All 56 governance tools are immediately available.

Claude Desktop

Add to claude_desktop_config.json:

json
{  "mcpServers": {    "promptspeak": {      "command": "npx",      "args": ["promptspeak-mcp-server"]    }  }}

As a library

bash
npm install promptspeak-mcp-server

From source

bash
git clone https://github.com/chrbailey/promptspeak-mcp-server.gitcd promptspeak-mcp-servernpm install && npm run buildnpm start

Usage examples

1. Validate a governance frame

Validate that a PromptSpeak frame is structurally and semantically correct before using it. Frames encode governance constraints as symbol sequences — mode first, then domain, action, and entity.

jsonc
// Tool call: ps_validate{  "name": "ps_validate",  "arguments": {    "frame": "⊕◊▶α",    "validationLevel": "full"  }}
jsonc
// Response{  "valid": true,  "frame": "⊕◊▶α",  "parsedFrame": {    "mode": { "symbol": "⊕", "meaning": "strict" },    "domain": { "symbol": "◊", "meaning": "financial" },    "action": { "symbol": "▶", "meaning": "execute" },    "entity": { "symbol": "α", "meaning": "primary" }  },  "parseConfidence": 1.0,  "report": {    "valid": true,    "errors": [],    "warnings": [      { "code": "ACTION_MISSING_DOMAIN", "message": "Consider adding domain context", "severity": "warning" }    ]  },  "summary": { "errors": 0, "warnings": 1, "passed": 16 }}

Invalid frames return actionable suggestions:

jsonc
// Tool call: validate a frame with conflicting modes{  "name": "ps_validate",  "arguments": { "frame": "⊕⊖▶", "validationLevel": "semantic" }}
// Response: blocked — strict + flexible modes conflict{  "valid": false,  "summary": { "errors": 1, "warnings": 0, "passed": 10 },  "suggestions": ["Remove either ⊕ (strict) or ⊖ (flexible) - cannot have both"]}

2. Hold queue workflow — human-in-the-loop approval

When an agent attempts a risky operation (high drift score, low confidence, security finding), the action is held for human review instead of executing. This is the full hold lifecycle: list, inspect, approve or reject.

Step 1: List pending holds

jsonc
// Tool call: ps_hold_list{  "name": "ps_hold_list",  "arguments": {}}
jsonc
// Response: one hold awaiting human review{  "holds": [    {      "holdId": "hold_7k2m9x",      "agentId": "devops-agent",      "frame": "⊕◈▶α",      "tool": "deploy_to_production",      "severity": "high",      "reason": "drift_prediction",      "state": "pending",      "evidence": { "driftScore": 0.72, "predictedDrift": 0.85 }    }  ],  "count": 1,  "expiredCount": 0}

Step 2: Approve with modifications (or reject)

jsonc
// Tool call: ps_hold_approve — approve but downgrade to staging{  "name": "ps_hold_approve",  "arguments": {    "holdId": "hold_7k2m9x",    "reason": "Reviewed — safe for staging, not production",    "modifiedArgs": { "environment": "staging" }  }}
jsonc
// Response{  "success": true,  "decision": {    "holdId": "hold_7k2m9x",    "state": "approved",    "decidedBy": "human",    "reason": "Reviewed — safe for staging, not production"  },  "executionResult": { "success": true }}

To reject instead:

jsonc
{  "name": "ps_hold_reject",  "arguments": {    "holdId": "hold_7k2m9x",    "reason": "Drift too high — recalibrate agent first",    "haltAgent": true  }}// Agent is halted (circuit breaker tripped) and the operation is denied.

3. Security scanning — catch vulnerabilities before execution

Scan code content for security issues before an agent writes it to disk. Critical findings block execution; high-severity findings are held for human review.

jsonc
// Tool call: ps_security_scan{  "name": "ps_security_scan",  "arguments": {    "content": "const query = `SELECT * FROM users WHERE id = ${userId}`;\nconst API_KEY = 'sk-1234567890abcdef1234567890abcdef';"  }}
jsonc
// Response: two findings — one critical (blocked), one critical (blocked){  "findings": [    {      "patternId": "sql-injection",      "severity": "critical",      "match": "SELECT * FROM users WHERE id = ${userId}",      "line": 1,      "context": "const query = `SELECT * FROM users WHERE id = ${userId}`;",      "suggestion": "Use parameterized queries or prepared statements instead of template literals"    },    {      "patternId": "hardcoded-secret",      "severity": "critical",      "match": "API_KEY = 'sk-1234567890abcdef1234567890abcdef'",      "line": 2,      "context": "const API_KEY = 'sk-1234567890abcdef1234567890abcdef';",      "suggestion": "Move secrets to environment variables or a secrets manager"    }  ],  "scannedAt": "2026-03-19T12:00:00.000Z",  "contentLength": 98,  "patternsChecked": 10,  "enforcement": {    "blocked": [      { "patternId": "sql-injection", "severity": "critical" },      { "patternId": "hardcoded-secret", "severity": "critical" }    ],    "held": [],    "warned": [],    "logged": []  }}

Use ps_security_gate instead of ps_security_scan to enforce the policy — it blocks on critical, holds high-severity for human review, and warns on medium:

jsonc
// Tool call: ps_security_gate — scan AND enforce{  "name": "ps_security_gate",  "arguments": {    "content": "app.use(cors());\napp.listen(0.0.0.0, 3000);",    "action": "write_file"  }}
// Response: held for review (insecure defaults = high severity){  "decision": "held",  "reason": "Security: 1 high-severity finding(s) held for review — insecure-defaults",  "scan": { "findings": [{ "patternId": "insecure-defaults", "severity": "high", "line": 1 }] }}

How it works: 9-stage validation pipeline

Every tool call passes through this pipeline. If any stage fails, execution is blocked.

Agent calls tool  │  ├─ 1. Circuit Breaker ──── Halted agents blocked instantly (no further checks)  ├─ 2. Frame Validation ─── Structural, semantic, and chain rule checks  ├─ 3. Drift Prediction ─── Pre-flight behavioral anomaly detection  ├─ 4. Hold Check ────────── Risky operations held for human approval  ├─ 5. Interceptor ───────── Final permission gate (confidence thresholds)  ├─ 6. Security Scan ─────── Scans write actions for vulnerabilities (see below)  ├─ 7. Tool Execution ────── Only reached if all 6 pre-checks pass  ├─ 8. Post-Audit ────────── Confirms behavior matched prediction  └─ 9. Immediate Action ──── Halts agent if critical drift detected post-execution

Stages 1-6 are pre-execution — the tool never runs if any check fails. Stages 8-9 are post-execution — they detect drift and can halt the agent for future calls.

Security scanning

When an agent writes code (write_file, edit_file, create_file, patch_file), the content is scanned against 10 detection patterns before execution. Severity determines enforcement:

SeverityEnforcementWhat it catches
CRITICALBlocked — execution deniedSQL injection via template literals, hardcoded API keys/passwords/tokens
HIGHHeld — queued for human reviewSecurity-related TODOs, logging sensitive data, insecure defaults (cors(), 0.0.0.0, debug: true)
MEDIUMWarned — logged, execution continuesEmpty catch blocks, hedging comments ("probably works"), disabled tests
LOWLogged — no enforcementDROP TABLE, rm -rf (flagged for awareness)

What works (tested)

All claims below are backed by passing tests (104 tests across 5 test files):

  • Pattern detection works. Each of the 10 patterns is tested for true positives AND false positives. Example: api_key = "sk-1234567890abcdef" is caught; API_KEY = process.env.API_KEY is not. SQL injection catches \SELECT * FROM users WHERE id = ${id}` but not parameterized queries (db.query("SELECT * FROM users WHERE id = ?", [id])`).
  • Severity enforcement works. Critical findings block execution. High findings hold for review. Medium findings warn but allow. Tested end-to-end through the interceptor pipeline.
  • Only write actions are scanned. read_file and other non-write actions pass through without scanning, even if their arguments contain vulnerable code. Tested.
  • Runtime configuration works. Patterns can be enabled/disabled and severity can be changed at runtime via ps_security_config. A disabled pattern stops firing immediately. Changing a pattern from medium to critical makes it block instead of warn. Tested end-to-end.
  • Performance is fine. 100-line file scans complete in under 10ms. Tested.
  • Multiple findings in one file work. A file with 6 different vulnerability types correctly classifies each into the right severity bucket. Tested.

What does NOT work yet

  • No hold queue integration for HIGH findings. FIXED. HIGH-severity security findings now create real holds in HoldManager via security_finding HoldReason. They appear in ps_hold_list and can be approved/rejected through the normal hold flow.
  • No auto-scan on ps_execute. The security scan only triggers in the interceptor's intercept() method for direct tool calls. If an agent uses ps_execute (the governed execution path), the scan runs only if the inner tool is a write action AND the content is passed as a top-level arg. Nested argument structures may bypass scanning. Why: ps_execute wraps tool calls in its own argument schema; the scanner checks proposedArgs.content, not deeply nested fields.
  • No file-path-based scanning. The scanner only examines content passed as arguments. It cannot scan files already on disk — it doesn't read from the filesystem. Why: The scanner is a pure function that takes a string. Adding filesystem access would change the security model.
  • Patterns are regex-based, not AST-aware. The patterns use regular expressions, which means they can't understand code structure. A hardcoded secret inside a test fixture or a SQL injection in a comment will still trigger. False positive rates range from 25-70% depending on the pattern (documented per-pattern). Why: AST parsing would add dependencies and complexity. Regex is fast and good enough for a governance layer that holds for human review rather than silently blocking.
  • Partial persistence. Holds and circuit breaker state now persist to SQLite (data/governance.db) and survive server restarts. However, pattern configuration changes (enable/disable, severity changes via ps_security_config) are still in-memory only and reset on restart. Why: Pattern config is lightweight and rarely changed; full config persistence would need a separate config store.

MCP tools (56)

Core governance

ToolWhen to call itWhat it does
ps_validateBefore executing any agent actionValidate a frame against all rules without executing
ps_validate_batchWhen checking multiple actions at onceBatch validation for efficiency
ps_executeWhen an agent wants to perform a tool callFull pipeline: validate → hold check → execute → audit
ps_execute_dry_runWhen previewing what would happenRun full pipeline without executing the tool

Human-in-the-loop holds

ToolWhen to call itWhat it does
ps_hold_listWhen reviewing pending agent actionsList all operations awaiting human approval
ps_hold_approveWhen a held operation should proceedApprove with optional modified arguments
ps_hold_rejectWhen a held operation should be deniedReject with reason
ps_hold_configWhen tuning which operations require approvalConfigure hold triggers and thresholds
ps_hold_statsWhen monitoring hold queue healthHold queue statistics

Agent lifecycle

ToolWhen to call itWhat it does
ps_state_getWhen checking what an agent is doingGet agent's active frame and last action
ps_state_systemWhen monitoring overall system healthSystem-wide statistics
ps_state_haltWhen an agent must be stopped immediatelyTrip circuit breaker — blocks all future calls
ps_state_resumeWhen a halted agent should be allowed to continueReset circuit breaker
ps_state_resetWhen clearing agent stateFull state reset
ps_state_drift_historyWhen investigating behavioral changesDrift detection alert history

Delegation

ToolWhen to call itWhat it does
ps_delegateWhen an agent spawns a sub-agentCreate parent→child delegation with constrained permissions
ps_delegate_revokeWhen revoking a sub-agent's authorityRemove delegation
ps_delegate_listWhen auditing delegation chainsList active delegations

Configuration

ToolWhen to call itWhat it does
ps_config_setWhen changing governance rules at runtimeSet configuration key-value pairs
ps_config_getWhen reading current configurationGet current config
ps_config_activateWhen switching policy profilesActivate a named configuration
ps_config_exportWhen backing up configurationExport full config as JSON
ps_config_importWhen restoring configurationImport config from JSON
ps_confidence_setWhen tuning validation strictnessSet confidence thresholds
ps_confidence_getWhen checking current thresholdsGet current thresholds
ps_confidence_bulk_setWhen reconfiguring multiple thresholdsBatch threshold update
ps_feature_setWhen toggling pipeline stagesEnable/disable specific checks
ps_feature_getWhen checking which stages are activeGet feature flags

Symbol registry (entity tracking)

ToolWhen to call itWhat it does
ps_symbol_createWhen registering a new entity (company, person, system)Create symbol with type, metadata, and tags
ps_symbol_getWhen looking up an entityRetrieve by ID
ps_symbol_updateWhen entity data changesUpdate metadata or tags
ps_symbol_listWhen browsing entities by typeList with optional type filter
ps_symbol_deleteWhen removing an entityDelete by ID
ps_symbol_importWhen bulk-loading entitiesBatch import
ps_symbol_statsWhen monitoring registry healthRegistry statistics
ps_symbol_formatWhen displaying an entityFormat symbol for display
ps_symbol_verifyWhen confirming entity data is currentMark symbol as verified
ps_symbol_list_unverifiedWhen auditing stale dataList symbols needing verification
ps_symbol_add_alternativeWhen an entity has aliasesAdd alternative identifier

Security enforcement

ToolWhen to call itWhat it does
ps_security_scanWhen checking code for vulnerabilitiesScan content, return findings by severity
ps_security_gateWhen enforcing security policy on writesScan + enforce: block/hold/warn/allow
ps_security_configWhen tuning detection patternsList, enable, disable, change severity of patterns

Audit

ToolWhen to call itWhat it does
ps_audit_getWhen reviewing what happenedFull audit trail with filters

Architecture

src/├── gatekeeper/       # 8-stage validation pipeline (core enforcement)│   ├── index.ts      #   Pipeline orchestrator + agent eviction policy│   ├── validator.ts  #   Frame structural/semantic/chain validation│   ├── interceptor.ts#   Permission gate with confidence thresholds│   ├── hold-manager.ts#  Human-in-the-loop hold queue│   ├── resolver.ts   #   Frame resolution with operator overrides│   └── coverage.ts   #   Coverage confidence calculator├── drift/            # Behavioral drift detection│   ├── circuit-breaker.ts  # Per-agent halt/resume│   ├── baseline.ts         # Behavioral baseline comparison│   ├── tripwire.ts         # Anomaly tripwires│   └── monitor.ts          # Continuous monitoring├── security/         # Security vulnerability scanning│   ├── patterns.ts   #   10 detection patterns (regex-based)│   └── scanner.ts    #   Scanner engine + severity classification├── persistence/      # SQLite governance persistence│   └── database.ts   #   Holds, decisions, circuit breakers (WAL mode)├── symbols/          # SQLite-backed entity registry (11 CRUD tools)├── policies/         # Policy file loader + overlay system├── operator/         # Operator configuration├── tools/            # MCP tool implementations│   ├── registry.ts   #   29 core tools│   ├── ps_hold.ts    #   5 hold tools│   └── ps_security.ts#   3 security tools├── handlers/         # Tool dispatch + metadata registry├── core/             # Logging, errors, result patterns└── server.ts         # MCP server entry point (stdio transport)

Performance

PromptSpeak adds governance to every tool call with sub-millisecond overhead. Benchmarked on Apple M2 Pro, Node.js 22, Vitest 4.0:

Latency (pre-execution check, 1000 iterations)

PercentileLatency
Average0.164ms
P950.368ms
P991.183ms
Full execution path P950.074ms

Throughput (concurrent operations)

OperationRate
Circuit breaker checks (1000 concurrent)6,173 ops/sec
Hold creation55,556 holds/sec
Hold approval/rejection200,000+/sec
Mixed operations (halt + hold + allow)6,818 ops/sec

Stress Tests

TestResult
1000 concurrent blocked executions162ms total, all blocked correctly
100 rapid halt/resume cycles100% correct state transitions
500 agents with mixed states250 blocked, 250 allowed — zero misclassification
Memory under sustained load (1000 ops)Negative delta (-11.76 MB, GC reclaimed)

Suite

MetricValue
Test count829 tests across 33 files
Test duration1.11s total
CategoriesUnit, integration, stress, security, grammar

Requirements

  • Node.js >= 20.0.0
  • TypeScript 5.3+ (build from source)
  • No external services required — SQLite for symbols and governance persistence

Related Projects

  • deeptrend — Structured AI trend feed for autonomous agents. Curated from 14+ sources, synthesized via LLM Counsel, published every 6h as JSON Feed, RSS, and llms.txt. Designed as a data source for agent monitoring pipelines.

Privacy Policy

https://promptspeak.admin-as-a-service.com/privacy

PromptSpeak does not collect personal data, has no telemetry, and stores all governance data locally in SQLite. See the full policy at the link above.

Data Processing Terms

https://promptspeak.admin-as-a-service.com/dpa

Standard data processing terms for platform integrations (e.g., Anthropic Connectors). PromptSpeak acts as a data processor; no sub-processors, no external data transmission.

License

MIT

來源:README.md,提交 b9c3698

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.4.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分