Skip to content

About

Development Experiment 014 — askance: offline, LLM-free elicitation-safety & conformance auditor for MCP (elicitation/create)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Development Experiment 014 — askance

Offline, LLM-free elicitation-safety & conformance auditor for the Model Context Protocol.

askance audits MCP elicitation/create exchanges — the flow where a server asks a human, through the client, for structured input. It reads a captured JSON trace and grades each request against a 32-rule catalog derived directly from the MCP 2025-06-18 elicitation specification: is the requested schema legal, is the server trying to phish a secret, is the prompt smuggling invisible text, and does the client's response actually conform to the schema it was handed? It emits a scored report and a CI exit-code gate. Pure Python standard library. Deterministic. No model calls, no network.


Thesis

Elicitation is the one MCP feature that puts a server-authored prompt in front of a human and asks them to type something back — which makes it the protocol's most direct social-engineering surface. The spec anticipates this with hard rules: the requestedSchema is restricted to a flat, primitive-only object, and "servers MUST NOT use elicitation to request sensitive information." Yet the existing MCP security tooling scans tool descriptions and server source for poisoning — nobody is checking the elicitation channel itself. Every one of the spec's elicitation rules is statically decidable from the request JSON, and every response can be checked against the schema that produced it. askance is the smallest thing that proves an elicitation audit can be fully deterministic, offline, and CI-gateable: a rule catalog, a scorer, a conformant reference capture that scores 100/A, and a deliberately buggy capture with 24 ground-truth defects it must catch exactly.

What it checks (5 rule families, 32 rules)

Family Prefix Focus Example
Schema legality A The flat/primitive requestedSchema subset nested object, array, $ref, bad string format, inconsistent enum/enumNames, required naming an undefined property
Sensitive data B The MUST-NOT: no credential/PII requests property named password/api_key/ssn/cvv; a message that says "enter your password"
Perception & injection C Hazards in user-visible text zero-width / bidi Unicode, prompt-injection markers, homoglyph (mixed-script) field names, oversized messages
Usability D Can the client render a clear form? missing message, property with no title/description, enum without enumNames, boolean without default
Response conformance E "Both parties SHOULD validate content against schema" invalid action, accept-without-content, missing required field, type mismatch, enum/bounds violations

Run askance --list-rules for the full catalog with severities.

How to run

Requires Python 3.11+. Runtime dependencies: none (standard library only).

# audit a capture (text report)
python main.py fixtures/buggy_capture.json      # exits 1 (gate failed)
python main.py fixtures/clean_capture.json      # exits 0 (clean)

# equivalent module invocation
python -m askance fixtures/buggy_capture.json

# machine-readable output for CI dashboards
python -m askance fixtures/buggy_capture.json --json

# tune the gate (info|low|medium|high|critical|never)
python -m askance capture.json --fail-on critical   # only CRITICAL fails CI
python -m askance capture.json --fail-on never       # report only, never fail

# hide low-noise findings in the report (scoring is unaffected)
python -m askance capture.json --min-severity medium

# list the rule catalog
python -m askance --list-rules

Via make:

make test        # run the 82-test suite (needs pytest)
make run         # audit the buggy fixture
make run-clean   # audit the clean fixture
make list        # print the catalog

Exit codes (CI contract)

Code Meaning
0 audit ran, gate passed
1 audit ran, gate failed (a finding at/above --fail-on)
2 usage / I/O / capture-parse error (nothing was audited)

Accepted capture formats

askance reads three JSON shapes so it drops into real workflows:

  1. Canonical — {"elicitations": [{"request": {...}, "response": {...}}]}. request may be a full JSON-RPC message, its params, or a bare {"message", "requestedSchema"}; response may be the message or its result, and is optional.
  2. JSON-RPC trace — a top-level list of JSON-RPC messages (e.g. a proxy tee log). elicitation/create requests are matched to results by id.
  3. Single message — one elicitation/create request object.

Architecture

capture.json ──> loader ──> [Exchange] ──> engine (32 checks) ──> [Finding]
                  │                              │                    │
      3 shapes normalized to           each check is a pure     scorer + grader
      one Exchange model               fn(Exchange)->Issues     + gate verdict
                                                                      │
                                                          report (text | json) + exit code
  • loader.py — normalizes the three input shapes into Exchange objects. Deliberately forgiving: a malformed request still yields an Exchange (with requested_schema=None) so the rules report the defect instead of the loader crashing the whole audit.
  • model.py — Severity (ordered enum + scoring weights), Exchange, Finding, Report. All frozen/plain dataclasses, no hidden state.
  • rules/ — five modules (A–E). Each rule is a small pure function fn(Exchange) -> Iterator[Issue] bundled with metadata into a Check. Every rule is importable and unit-testable in isolation.
  • catalog.py — gathers all CHECKS, guards against duplicate ids, sorts deterministically.
  • scoring.py — runs every check against every exchange, deducts points by severity (CRITICAL 40 / HIGH 20 / MEDIUM 8 / LOW 3 / INFO 0, floored at 0), grades A–F (any CRITICAL caps the grade at F), and computes the gate verdict.
  • report.py / cli.py — stable text/JSON rendering and the exit-code contract.

Two approaches considered

  1. Dynamic driver (like a live MCP client that provokes elicitations and inspects them) vs. 2. passive capture auditor (grade a recorded trace). The passive approach won: elicitation is inherently interactive and requires a human in the loop, so driving it in CI is awkward and non-deterministic, whereas every elicitation rule is decidable from the request JSON alone. A passive auditor is trivially reproducible, needs no server to be running, and slots into CI as a log-analysis step. The cost is that it only sees what the capture recorded — it cannot observe elicitations a server would send under untaken code paths. Given the goal (a deterministic CI gate), that trade is clearly worth it. This mirrors how a linter beats a fuzzer when the property you care about is statically decidable.

Trade-offs

  • Deterministic > clever. Every rule is a lexical/structural check with a spec citation. No LLM means no nondeterminism, no cost, no false-confidence — but also no semantic judgement (see limitations).
  • Forgiving loader > strict loader. Broken input becomes findings, not stack traces, so one malformed exchange never blinds the audit to the rest.
  • Memory/CPU: O(total properties + response keys); the whole capture is held in memory as parsed JSON. Fine for traces up to millions of exchanges; a streaming loader would be the next step for larger logs.
  • Curated lexicon > ML classifier for sensitive-data detection: transparent and auditable, at the price of missing creatively-worded requests.

Assumptions & limitations

  • Spec version: rules target MCP 2025-06-18 elicitation. The restricted schema subset and the sensitive-data MUST-NOT are stable, but a future spec could change formats or keywords; the catalog is the single place to update.
  • Sensitive-data detection is lexical. askance flags fields whose name/title/description/format matches a curated credential/PII lexicon (SENSITIVE_TERMS). It will miss a password field euphemistically named your_special_phrase, and could in principle over-flag an innocent field that merely contains a trigger word. It is a high-signal linter, not a semantic classifier.
  • Perception heuristics (injection markers, homoglyphs) are signatures, not proofs of intent — they surface candidates for human review.
  • It audits captures, not servers. It sees the elicitations that were recorded, not every one a server could emit. Pair it with good capture coverage.
  • Overlap with prior experiments is intentional but bounded. Unicode smuggling was studied for tool manifests & skills in an earlier experiment (context-xray); here it is one minor rule (C001) inside a catalog whose spine — elicitation schema legality (A), the sensitive-data MUST-NOT (B), and response-vs-schema conformance (E) — is a surface no prior entry touched.

Sample run

Auditing the shipped buggy capture (abridged; exit code 1):

askance report for fixtures/buggy_capture.json
============================================================
exchanges audited : 9
score             : 0/100   grade F
gate (>= HIGH    ): FAIL
findings          : 24   [CRITICAL=2  HIGH=10  MEDIUM=7  LOW=4  INFO=1]

-- exchange #0 ----------------------------------------
  [CRITICAL] B001 Sensitive property requested
      property 'password' requests sensitive data (password); servers MUST NOT
      request sensitive information via elicitation
      at: requestedSchema/properties/password
      ref: MCP 2025-06-18 elicitation §Security Considerations #1
  [HIGH    ] B003 Sensitive data solicited in message
      elicitation message solicits sensitive data (password); this reads as a
      credential-phishing prompt
      at: message
...
-- exchange #3 ----------------------------------------
  [HIGH    ] C001 Invisible/bidi Unicode in text
      user-visible text contains invisible/bidi codepoints [U+200B ZERO WIDTH
      SPACE]; content may be smuggled past the user
      at: message
...
-- exchange #4 ----------------------------------------
  [HIGH    ] E006 Content type mismatch
      accepted value for 'age' is str, but the schema declares type 'integer'
      at: response/content/age

The clean capture (fixtures/clean_capture.json) scores 100/100, grade A, zero findings, exit code 0. The exact ground-truth defect list for the buggy capture is in fixtures/EXPECTED.md, and tests/test_fixtures.py asserts the auditor reproduces it exactly.

Tests

python -m pytest        # 82 tests: per-rule units + loader + scoring + CLI + fixtures

Every rule has a fires-on-bad / silent-on-clean unit test; the fixtures are verified against the documented ground truth; the CLI's exit-code contract and --fail-on/--min-severity/--json behaviours are covered.

License

MIT — see LICENSE.

About

Development Experiment 014 — askance: offline, LLM-free elicitation-safety & conformance auditor for MCP (elicitation/create)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages