← Learn / Notebooks

AI securityTechnicalStudy guide

MCP Servers: Architecture, Hardening and Threat Modeling

Study six trust boundaries, compare legacy and 2026 MCP protocol behavior, and build a defensive threat register using matched in-memory Python and TypeScript policy examples.

Before you start: You should understand HTTP, JSON objects, basic authorization concepts, and functions in Python or TypeScript.

AI-assisted study notebook · Published 2026-11-19. Separate automated source and visual reviews passed; these checks are not independent expert fact verification. Source audit · Review record.

1. Architecture, protocol versions and trust boundaries

This expanded adaptation retains the original seven modules: architecture, implementations, threats, threat modeling, decision exercises, tests, and checklist/self-checks. The learning objective is to identify where an MCP integration turns untrusted information into an authorized operation, then specify evidence that the boundary holds.

An MCP host coordinates model interaction and manages clients. Servers expose capabilities through the protocol. Host consent and server authorization are different responsibilities: a host decision to offer a tool does not itself establish that a particular caller may access a particular object. The current architecture uses self-contained requests. Architecture specification.

Scope and limits. This is a defensive design lesson, not a deployable server or vulnerability reproduction. All identities, records, approvals and risk scores in the exercises are synthetic. The published review record identifies the exact standalone Python fixture check. The framework and TypeScript examples are illustrative. It makes no network, filesystem, subprocess or model calls. It does not implement token verification, operating-system containment, a Unicode detector, or an MCP transport.

Versioned lifecycle comparison

Read lifecycle behavior against an explicit protocol revision
RevisionOpening and operationTermination and compatibility
Client sends initialize; server returns version and capabilities; client sends notifications/initialized. Normal operation follows the agreed capabilities.The lifecycle defines transport termination rather than a shutdown RPC.
The initialization handshake remains. Operation must respect the negotiated version and capabilities.Still a handshake-based revision. Do not apply its connection assumptions indiscriminately to modern requests.
No initialization handshake: requests carry version and capability metadata. server/discover supports discovery; unsupported versions receive an error identifying supported versions.Modern Streamable HTTP removes protocol sessions and the GET stream. Change subscriptions use subscriptions/listen. Dual-era implementations can also serve legacy clients.

The original three-phase stepper remains useful for the older revisions, but it is not the universal lifecycle. Compare 2024 lifecycle, 2025 lifecycle and 2026 versioning. Capability compatibility also does not grant business permission; the policy below is a separate application decision.

Transport choices and their distinct boundaries
ConcernstdioModern Streamable HTTP
DeliveryClient-launched subprocess; newline-delimited JSON-RPC on standard streams.Requests use POST; responses are JSON or request-scoped SSE.
LoggingKeep diagnostic output on stderr; stdout carries protocol messages.Use the application's logging path, with sensitive data excluded.
ExposureReview executable provenance, launch configuration and process privileges.Apply authentication and endpoint controls. Validate Origin; local deployments should bind loopback. SDK HTTP adapters also require appropriate Host validation.
End of workClosing stdin signals graceful process shutdown.In revision 2026-07-28, closing a request's SSE response stream signals cancellation of that request.

JSON-RPC responses correlate with request IDs; notifications are a distinct message category. Transport framing is not interchangeable with arbitrary logging. Also distinguish the older HTTP+SSE transport from SSE used inside Streamable HTTP responses. stdio binding; HTTP binding.

Six numbered trust boundaries

Six directed crossings: external content to host, host proposals to client policy, client requests to server, server operations to local system, server calls to remote API, and server catalogue definitions to client policy.
Application threat-model view. Arrows identify the crossing being reviewed, not a complete wire trace. The catalogue is a logical view of server-provided metadata. Editable draw.io source.
  1. TB-1 — host to client policy: a model proposes an action. Check its relationship to the user's task and any required approval before dispatch.
  2. TB-2 — client to server: a request crosses the transport boundary. Establish caller identity and authorize the operation at the server; receiving well-formed JSON is insufficient.
  3. TB-3 — server to local system: a handler would access a file or invoke a library/process. Bound the object and operation independently of model wording.
  4. TB-4 — server to remote API: a handler would send data or use downstream credentials. Identify the intended destination and minimum downstream authority.
  5. TB-5 — external content to host context: retrieved material becomes model input. Preserve provenance and prevent that material from supplying trusted authorization facts.
  6. TB-6 — catalogue to client policy: tool names, descriptions and schemas enter discovery and approval state. Associate decisions with server identity and reviewed definitions, not only a display name.

These six labels are the notebook's decomposition, not six official MCP security layers. TB-1 and TB-5 may exist inside one process; TB-2 and TB-6 may share one transport. A trust boundary describes a change in authority or trust, not necessarily a network hop. The list is also the figure's text alternative.

Host, clients and servers

One host can create several clients. Each client communicates with exactly one server. For example, the host can connect a records client to a records server and a catalog client to a catalog server. Tools expose operations, resources provide context identified by a URI, and prompts offer reusable message templates. A client can discover a capability without gaining permission to use it. MCP architecture.

JSON-RPC request, reply and notification

A request carries jsonrpc, a method and an ID. The matching reply repeats the ID and contains either result or error. A notification omits the ID and receives no JSON-RPC reply. The following standalone examples illustrate the envelope, using a fictional method and omitting MCP-specific metadata. JSON-RPC 2.0 specification.

  1. Request: {"jsonrpc":"2.0","id":1,"method":"recordCount"}
  2. Success: {"jsonrpc":"2.0","id":1,"result":3}
  3. Alternative error: {"jsonrpc":"2.0","id":1,"error":{"code":-32601,"message":"Method not found"}}
  4. Notification: {"jsonrpc":"2.0","method":"catalogChanged"}

2. Matched Python and TypeScript policy examples

Consider a synthetic document service. One reviewed tool, records/document at revision r1, may read doc-17. It may propose a note only after a separate approval. Another service audience, another server, a changed definition, an unknown object or an unsupported action is denied. The policy returns a reason; it never performs the action.

The trusted adapter supplies audience, server, revision, metadata_reviewed and approved. The model may propose action and object_id, but must not supply the trusted fields. Here these facts are ordinary values solely to make tests transparent. In a real design, bind approval to the caller, exact action, object, definition and expiry; a reusable boolean is not an authorization credential. The fixed doc-17 allowlist represents one caller's entitlement, not global access.

Python: lab.py

Illustrative synthetic policy, Python 3.11+ syntax. Download the complete lab.

Python
# Synthetic Python policy. See the review record for the standalone fixture check.
TEXT = ("audience", "server", "tool", "revision", "object_id", "action")
FLAGS = ("metadata_reviewed", "approved")


def decide(value: object) -> str:
    if type(value) is not dict or set(value) != set(TEXT + FLAGS):
        return "deny:schema"
    if any(type(value[k]) is not str or not 1 <= len(value[k]) <= 64
           for k in TEXT):
        return "deny:schema"
    if any(type(value[k]) is not bool for k in FLAGS):
        return "deny:schema"
    if value["audience"] != "service-A":
        return "deny:audience"
    if (value["server"], value["tool"]) != ("records", "document"):
        return "deny:identity"
    if value["revision"] != "r1":
        return "deny:revision"
    if not value["metadata_reviewed"]:
        return "deny:metadata"
    if value["object_id"] != "doc-17":
        return "deny:object"
    if value["action"] not in ("read", "note"):
        return "deny:action"
    if value["action"] == "note" and not value["approved"]:
        return "deny:approval"
    return "allow"


def baseline() -> dict:
    return dict(audience="service-A", server="records", tool="document",
                revision="r1", object_id="doc-17", action="read",
                metadata_reviewed=True, approved=False)


CASES = (
    ("read", {}, "allow"),
    ("approved note", {"action": "note", "approved": True}, "allow"),
    ("metadata", {"metadata_reviewed": False}, "deny:metadata"),
    ("approval", {"action": "note"}, "deny:approval"),
    ("audience", {"audience": "service-B"}, "deny:audience"),
    ("object", {"object_id": "doc-99"}, "deny:object"),
    ("action", {"action": "other"}, "deny:action"),
    ("identity", {"server": "other"}, "deny:identity"),
    ("revision", {"revision": "r2"}, "deny:revision"),
    ("extra key", {"extra": "unused"}, "deny:schema"),
    ("wrong type", {"approved": "yes"}, "deny:schema"),
)


def run_lab() -> list:
    return [(name, decide(baseline() | change), expected)
            for name, change, expected in CASES]

TypeScript: the same decision order

Illustrative synthetic policy. Type annotations do not validate an incoming JSON value, so the function accepts unknown and checks its runtime shape. The examples use short ASCII identifiers; Python and JavaScript string-length conventions should not be assumed identical for arbitrary Unicode inputs.

TypeScript
// Illustrative synthetic policy; no execution report is supplied.
const TEXT = ["audience", "server", "tool", "revision", "object_id", "action"];
const FLAGS = ["metadata_reviewed", "approved"];

export function decide(value: unknown): string {
  if (typeof value !== "object" || value === null || Array.isArray(value))
    return "deny:schema";
  const v = value as Record<string, unknown>;
  const keys = Object.keys(v);
  const expected = [...TEXT, ...FLAGS];
  if (keys.length !== expected.length || !expected.every(k => keys.includes(k)))
    return "deny:schema";
  if (!TEXT.every(k => typeof v[k] === "string" &&
      (v[k] as string).length >= 1 && (v[k] as string).length <= 64))
    return "deny:schema";
  if (!FLAGS.every(k => typeof v[k] === "boolean")) return "deny:schema";
  if (v.audience !== "service-A") return "deny:audience";
  if (v.server !== "records" || v.tool !== "document") return "deny:identity";
  if (v.revision !== "r1") return "deny:revision";
  if (!v.metadata_reviewed) return "deny:metadata";
  if (v.object_id !== "doc-17") return "deny:object";
  if (v.action !== "read" && v.action !== "note") return "deny:action";
  if (v.action === "note" && !v.approved) return "deny:approval";
  return "allow";
}

export function baseline(): Record<string, unknown> {
  return { audience: "service-A", server: "records", tool: "document",
    revision: "r1", object_id: "doc-17", action: "read",
    metadata_reviewed: true, approved: false };
}

Transport integration and SDK version boundaries

Current Python SDK documentation uses MCPServer from mcp.server and the tool decorator. Its run method selects stdio by default or Streamable HTTP explicitly. Transport options belong to run, not the server constructor. The original FastMCP example must therefore be read with its own SDK version, not silently treated as current v2 wiring. Python serving documentation.

Current TypeScript v2 documentation uses McpServer and registerTool. serveStdio accepts a server factory. For HTTP, createMcpHandler builds a handler from a factory; handler.fetch does not itself start a listener. The documented HTTP factory receives request context including authInfo. Host, Origin and token validation must be composed in front of the handler. These are different entry points from the original v1 transport/connect pattern. stdio, HTTP, tools.

Integration design: validate tool arguments in the SDK, derive trusted policy facts from verified request context and server-owned state, call decide, and only then invoke a separately constrained adapter. Never register decide itself as a tool accepting all eight fields. A policy resource may expose a static environment description selected from an explicit environment allowlist, but its text must not be mistaken for enforcement. No SDK-dependent server is included here; package patch versions and transport behavior require their own integration test.

Resource subscription lifecycle

Use a synthetic document URI and two authorized test clients. In the 2025-11-25 protocol, register the first client with resources/subscribe. After a change, verify that only the subscribed client receives notifications/resources/updated. Unsubscribe and repeat the change. For 2026-07-28, use subscriptions/listen with the resourceSubscriptions filter and check delivery while the subscription stream is open. Close that stream and verify no further update is delivered there. A successful acknowledgement alone leaves delivery, isolation and cleanup untested. Resource notification rules and SDK migration notes.

3. Six defensive threat comparisons and vendor risk

The original threat categories are retained below. Its CVE badges are not carried forward as verified incident mappings. The lesson relies on the cited generic mechanisms and protocol requirements, not on claims that the original simulator reproduced those vulnerabilities.

Threat, defensive decision and residual limitation
ThreatDefensive comparisonWhat remains unproved
1. Tool poisoning and concealed textInspect metadata and provenance before exposing it to a model. Route unexpected invisible characters to review under a text-support policy.Removing one character range does not establish injection resistance; indiscriminate removal can damage legitimate text. OWASP.
2. Post-approval definition changesRefresh changed tool lists and compare security-relevant definitions with reviewed state. Require renewed approval where meaning or authority changed.A list-change event is not itself proof of compromise. A definition fingerprint cannot prove unchanged implementation behavior. Tools specification.
3. Tool shadowingUse server identity plus tool identity as the lookup key; show provenance to the user.A namespace prefix helps distinguish names but does not authenticate a server. In the lab, another server is denied even with the same tool name.
4. Audience confusion and confused deputyValidate token recipient and use separately issued downstream tokens. At an OAuth proxy, preserve per-client consent.Audience validation and consent are separate controls. RFC 8707's request parameter is resource; aud can express a token's audience. RFC 8707; MCP authorization; proxy guidance.
5. Command and argument injectionPrefer library operations. Where commands are necessary, use structured arguments and command-specific validation.Removing a shell does not remove the called program's argument parser. The meaning of -- depends on that program. OWASP; Git manual.
6. Path containment failurePrefer object identifiers mapped by the server. If paths are unavoidable, validate resolved containment and enforce it during access.A raw prefix is not a directory boundary; resolving a path before opening it can still leave a symlink race. Path guidance.

A substantive correction concerns the original Git example: git log places path operands after --. Appending a branch variable there does not implement the advertised branch-selection behavior. The supplied console string also does not prove process execution. This revision preserves the argument-validation objective using an action selector and omits the unsupported reproduction claim.

Trusted vendors and untrusted inputs

Design review prompts for any vendor integration; no vendor-specific incident claims
Original concernReview taskEvidence to request
External issues, messages and webhooksKeep retrieved text out of the trusted approval channel.A denied action proposed after reading untrusted content, plus an allowed legitimate task.
Ambient authorityReduce account and tool permissions to the intended task.Actual grants and an object-level denial, not a read-only description.
Implementation flawsReview adapter behavior and restrict runtime privileges.Dependency/advisory review and containment tests for the chosen deployment.
Dependency changesRecord reviewed versions and hashes; reassess changed components and egress needs.A dependency inventory, change review and rollback plan.

Outbound access needs its own policy. A preliminary DNS lookup followed by a client request that resolves again does not bind the actual connection to the checked address. Destination allowlists, address checks at the connection boundary, network restrictions and redirect policy belong together. Disabling automatic redirects removes one bypass route; it is not a complete SSRF defense. OWASP SSRF guidance.

4. MAESTRO, STRIDE and a worked threat register

Ken Huang's MAESTRO framework, published by the Cloud Security Alliance, decomposes agent systems into seven layers and considers cross-layer threats. Use its actual layer names; the original workbench substituted several names and positions. MAESTRO framework.

MAESTRO layers with original review prompts for the synthetic service
LayerQuestion to investigate
L1 Foundation ModelsCan a model proposal bypass the deterministic policy?
L2 Data OperationsWhich caller may read doc-17, and how is that entitlement established?
L3 Agent FrameworksCan every dispatch route reach the same policy check?
L4 Deployment and InfrastructureWhat can the adapter access if application checks fail?
L5 Evaluation and ObservabilityDo records show actual denials without storing secrets?
L6 Security and ComplianceWho owns approval, revocation and exceptions across layers?
L7 Agent EcosystemCan another server's tool be confused with the reviewed tool?

L6 is a cross-cutting security layer, not simply a UI tier. The prompts are this notebook's application of the framework. No one-to-one OWASP MCP/agentic category mapping is asserted.

Microsoft STRIDE categories and notebook-specific MCP interpretations
CategoryClassic concernMCP review example
SpoofingFalse identityAnother server presented as records
TamperingUnauthorized modificationA changed tool definition reused under old approval
RepudiationUntraceable disputed actionNo record linking caller, policy decision and operation
Information disclosureUnauthorized access to informationA document released to the wrong caller
Denial of serviceLoss of availabilityUnbounded repeated tool work
Elevation of privilegeAccess beyond granted authorityA read entitlement used to authorize a write

STRIDE names the type of failure; MAESTRO helps locate components and interactions. The right-hand column is an adaptation, not an independently standardized framework named STRIDE-AI. Microsoft's STRIDE definitions.

Capability combinations and blast radius

Simon Willison's lethal trifecta describes the combination of private-data access, untrusted-content exposure and external communication. Credit belongs to that formulation, rather than treating it as a CSA numerical scoring system. Original explanation.

For the document service, write down each capability as present, absent or unknown. If all three are present, identify a concrete path from retrieved content to private data to an external destination. Remove an unnecessary capability or enforce an independently authorized release boundary. Counting two capabilities does not prove “high risk,” and counting one does not prove safety. Local state mutation is an additional integrity concern; it is not synonymous with external communication.

Register fields, assumptions and update

Use ID, threat, affected boundary, MAESTRO layer, STRIDE category, likelihood, impact, score, control, status, owner and evidence. Here likelihood and impact are ordinal planning scores from 1 to 5, not probabilities. Define 1 as difficult/limited, 3 as plausible/material and 5 as readily reachable/severe for this exercise; 2 and 4 are intermediate judgments. Score = likelihood × impact. Multiplication provides a prioritization convention, not measured expected loss.

Synthetic threat register before verification
ID / threatBoundary / layer / STRIDEL × IControl and statusOwner / evidence
T1: Unreviewed metadataTB-6 / L7 / Tampering4 × 4 = 16Review gate; proposedHost owner / metadata case
T2: Unsupported operationTB-3 / L3 / Elevation3 × 5 = 15Action allowlist; proposedAdapter owner / action case
T3: Wrong audienceTB-2 / L6 / Spoofing4 × 5 = 20Verified recipient binding; proposedIdentity owner / audience case and separate token tests
T4: Wrong objectTB-3 / L2 / Disclosure3 × 4 = 12Object entitlement; proposedData owner / object case

Example update: after obtaining real evidence that the wrong-audience case is rejected on every entry route, an owner might revise T3 likelihood from 4 to 2 while retaining impact 5, giving 10. Record the evidence identifier, date and rationale. This is a hypothetical update, not a measured result or a claim that the control is implemented. Keep mitigation text separate from status; a proposed control must not appear as “mitigated.”

Exercise: copy the blank register template, add a cross-layer threat, assign an owner, and state one observation that would make you increase its likelihood. Filter by owner or boundary when reviewing; retain stable IDs when retiring entries. The template replaces the original add/delete/export interface without silently discarding its fields.

Keep query structure separate from data

For a synthetic Data Operations design, give the document tool a fixed query and bind the requested document ID as a database parameter. In a design review, trace where the tool checks caller access to that document and what rows the database role can read. Parameter binding keeps values out of the query structure. Per-document authorization and database privileges control access to rows. This example uses no database connection. OWASP query parameterization guidance.

5. Five synthetic decision exercises

The original scenarios are unicode, github, oauth, traversal and flag. Their JavaScript assigns stored strings to console panels. These are narrated outcomes, not executions. Each exercise below changes one baseline fact and compares a specified check with a hypothetical policy lacking only that check. “Allow” means a decision would pass that simplified policy; it does not mean an attack succeeded.

Original learning goals retained without payloads or live targets
ScenarioSynthetic input changeControl present: expected decisionControl absent: counterfactual
Unicode concealmentmetadata_reviewed = falsedeny:metadata; keep unreviewed metadata out of the approved catalogueAllow if the review check alone is omitted
Indirect content-driven actionaction = note; approved remains falsedeny:approval; content cannot manufacture approvalAllow if the approval check alone is omitted
OAuth recipient mismatchaudience = service-Bdeny:audienceAllow if recipient checking alone is omitted
Path/symlink containment objectiveobject_id = doc-99deny:object; object selection remains server-controlledAllow if the object allowlist alone is omitted
CLI argument objectiveaction = otherdeny:action; unsupported operation rejected before adapter dispatchAllow if the action check alone is omitted

Predict each result before expanding the self-checks. Then propose a legitimate positive case that the control must preserve. The metadata flag is not a Unicode scanner, the audience string is not a verified token, the object check is not a symlink test, and the action selector does not validate a real command line. Those distinctions preserve the learning goals without making simulated decisions stand in for operational security evidence.

6. Paired in-memory policy tests

Both suites exercise the same contract: two allowed cases and nine denied cases, plus malformed-object and repeatability checks. They assert the exact reason and check that decisions do not mutate the request. The framework examples are illustrative. A separate standalone check covers the eleven Python fixture decisions and is recorded in the published review record. These are policy unit tests, not MCP memory-transport tests or end-to-end authorization tests.

Positive and negative case coverage
Case groupExpected resultWhy it matters
Baseline read; approved noteallowA policy that denies everything is not useful.
Unreviewed metadata; unapproved notemetadata / approval denialContent and consent remain distinct.
Wrong audience; server; revisionaudience / identity / revision denialReviewed identity and definition matter.
Unknown object; unsupported actionobject / action denialScope is checked before any adapter operation.
Extra key; string-valued approvalschema denialUnknown fields and coercion do not create authority.

Pytest example

Pytest parametrization runs a test against multiple argument sets. The cases here are original; no source-supplied test is executed or copied. Pytest documentation.

Python
# Illustrative tests for lab.py; execution status: unexecuted.
import pytest
from lab import CASES, baseline, decide


@pytest.mark.parametrize("name,change,expected", CASES)
def test_decision(name, change, expected):
    request = baseline() | change
    before = request.copy()
    assert decide(request) == expected
    assert request == before


@pytest.mark.parametrize("value", [None, [], {}, "request"])
def test_malformed(value):
    assert decide(value) == "deny:schema"


def test_repeatability_and_definition_change():
    request = baseline()
    assert decide(request) == decide(request) == "allow"
    request["revision"] = "r2"
    assert decide(request) == "deny:revision"

Vitest example

Vitest's test.each supports the corresponding table-driven test. Save the TypeScript policy above as policy.ts and the following as security.test.ts in an existing configured test project. No dependency installation or runtime version is implied. Vitest documentation.

TypeScript
// Illustrative tests; execution status: unexecuted.
import { expect, test } from "vitest";
import { baseline, decide } from "./policy";

const cases: [string, Record<string, unknown>, string][] = [
  ["read", {}, "allow"],
  ["approved note", { action: "note", approved: true }, "allow"],
  ["metadata", { metadata_reviewed: false }, "deny:metadata"],
  ["approval", { action: "note" }, "deny:approval"],
  ["audience", { audience: "service-B" }, "deny:audience"],
  ["object", { object_id: "doc-99" }, "deny:object"],
  ["action", { action: "other" }, "deny:action"],
  ["identity", { server: "other" }, "deny:identity"],
  ["revision", { revision: "r2" }, "deny:revision"],
  ["extra key", { extra: "unused" }, "deny:schema"],
  ["wrong type", { approved: "yes" }, "deny:schema"],
];

test.each(cases)("%s", (_name, change, expected) => {
  const request = { ...baseline(), ...change };
  const before = { ...request };
  expect(decide(request)).toBe(expected);
  expect(request).toEqual(before);
});

test.each([null, [], {}, "request"])("malformed %#", value => {
  expect(decide(value)).toBe("deny:schema");
});

test("repeatability and definition change", () => {
  const request = baseline();
  expect(decide(request)).toBe("allow");
  expect(decide(request)).toBe("allow");
  request.revision = "r2";
  expect(decide(request)).toBe("deny:revision");
});

Further integration evidence must establish where trusted facts originate, how denial is encoded, whether every dispatch route checks permission, and whether cancellation, retries and concurrent requests preserve the intended policy. A unit result cannot establish network isolation, token authenticity, filesystem containment or model robustness.

In-memory protocol integration exercise

Plan a second test layer with a paired in-memory client and server on one pinned supported revision. Register one synthetic tool named count_documents. Inject a fake document counter and capture the arguments passed to it. This exercise is a test plan for readers.

  1. Discover tools. Check that tools/list returns the expected name and input schema, and that discovery leaves the counter untouched.
  2. Make an authorized tools/call with a known collection ID. Assert that exactly one handler ran and that the reply contains the expected fixture count.
  3. Make a call to an unknown tool. Assert the version-specific protocol error and verify that the fake counter was not invoked.
  4. Send valid arguments for a collection outside the caller's grants. For the sample adapter, specify a tool failure result, assert its error indicator, and verify the backing operation was never called.

Correlate replies with their request IDs, and keep fixtures for both the protocol-level error and the tool-level failure. Pin the SDK revision in a real test harness and use its documented in-memory transport. MCP Tools error handling.

7. Hardening checklist, study notes and self-checks

The supplied checklist has 15 items across six named domains. Preserve evidence alongside each item; completion means a documented control with an appropriate test, not merely agreement with a sentence. The following corrections retain the original objectives while removing blanket security guarantees.

Transport Hygiene

  1. Keep stdio diagnostic logging on stderr and test startup as well as steady-state output.
  2. Validate HTTP Origin and configured Host expectations; verify the reverse-proxy and local-bind configuration.
  3. For protected HTTP access, validate token authenticity and intended recipient. Distinguish the resource request parameter from audience information.

Input Validation

  1. Validate runtime schemas, bounds and semantic authorization for every tool input.
  2. Prefer libraries over subprocesses; where unavoidable, separate arguments from shell interpretation.
  3. Use command-specific operand rules. Apply -- only where its documented meaning fits; it is not a universal branch-selection fix.

Path Sandbox

  1. Prefer opaque object IDs. For required paths, assess canonical resolution and access-time containment.
  2. Check directory components rather than a raw prefix; address symlinks and races separately.
  3. Reject null bytes and other unsupported path representations at the input boundary; this is one check, not a sandbox.

Network & SSRF

  1. Allow only required destinations and validate the addresses actually used for connections.
  2. Disable automatic redirects unless each redirected destination receives equivalent validation.
  3. Prevent access to metadata and other forbidden internal endpoints through enforceable egress policy, not one hard-coded address alone.

Output Hygiene

  1. Label and separate untrusted content, while enforcing action permissions outside the model.
  2. Review unexpected invisible text under a policy that preserves supported languages and symbols; stripping characters is not proof of safety.

Lifecycle & State

  1. Refresh changed tool definitions and reassess affected approvals. Bind approved use to reviewed identity and meaning; do not equate every list notification with an attack.

Use the reusable notes template to record a boundary, assumption, source, control, expected decision, actual observation and unresolved limitation. Keep credentials and private incident details out of shared notes. The template is a copyable document, not a claim that this page stores browser state.

Q1 · TransportWhy must diagnostics stay off a stdio server's protocol output?

The client parses stdout as newline-delimited MCP messages. Ordinary diagnostic lines can violate that framing. stderr is the diagnostic channel; test import-time and shutdown behavior as well as the main handler. An SDK's output redirection is not a reason to intentionally mix the channels. stdio specification.

Q2 · ContainmentWhy is a matching text prefix insufficient to prove directory containment?

Two sibling names can share a prefix without one being a child of the other. Component-aware checks address that ambiguity, but resolving a name and opening it later can still race with changes to symbolic links. Prefer server-owned object mappings and access-time enforcement. Path guidance.

Q3 · Hidden textWhat does the concealed-metadata exercise prove about Unicode filtering?

Nothing about a real filter or model: it demonstrates the declared behavior of a metadata-review gate. Invisible characters can conceal instructions, but removing a range does not establish safety and may damage legitimate content. The original fixed console strings are not a detection measurement. OWASP guidance.

Q4 · ArgumentsDoes avoiding a shell make every command argument safe?

No. The invoked program still interprets its arguments. Validate the permitted operation and operand according to that program's grammar. For git log, values after -- are paths, so the original placement changes the meaning of the advertised branch operation. This does not establish the original simulated exploit claim. Argument defenses; Git syntax.

Q5 · Capability compositionWhich three capabilities form the lethal trifecta, and is their count a risk score?

Private-data access, exposure to untrusted content and external communication form Willison's combination. Their presence prompts analysis of a concrete disclosure route. A count is not a calibrated likelihood, impact or guarantee of compromise; local mutation also needs a separate integrity assessment. Original formulation.

Q6 · AuthorizationHow do resource indicators, audience validation and proxy consent differ?

The resource parameter tells the authorization server where access is requested. Audience information restricts the token's intended recipient, which the resource server must validate. A proxy must additionally preserve the user's consent for the requesting client. The lab's service-A comparison models only a decision premise, not signature, issuer, expiry or consent verification. RFC 8707; authorization; proxy consent.

Source-check scope and adaptation notes

The evidence method separates versioned protocol requirements, maintainer SDK documentation, security guidance and original teaching assumptions. Claims are linked to short passages and section locations in the accompanying claim ledger. Source-backed guidance does not certify this synthetic implementation, and a policy test does not independently verify an operational security claim.

What was inspected and changed

The supplied original HTML and script data were inspected as text without executing them. The five scenario outcomes are stored strings. The checklist's domain labels total six. This adaptation replaces the console simulation with decision tables; language tabs with visible code; the editable register with a worked register and blank template; and the notes pad with a reusable text template. Native question disclosures retain the six quiz objectives without a fabricated score.

Substantive corrections include version-specific lifecycle behavior, current SDK integration descriptions, MAESTRO names, STRIDE attribution, the resource/aud distinction, the Git operand issue, and limits of delimiters, character removal, DNS prechecks and path canonicalization. CVE mappings and automatic mitigation success labels are omitted rather than presented as verified. The import coverage asset records the seven-module mapping.

Evidence provenance and limitations

Public primary pages were accessed on 19 November 2026. ResearchNode searches used MCP, MAESTRO and MCP authorization. The saved public MCP client-registration original was read, with document ID 23e40b4b0af0a8cde3a571155ae5a57b and revision edc04c0faa71610c0079a6303359573a, and its public page was opened. Its discussion of client impersonation supplies background rather than a current implementation mandate. Other cited sources use public web originals and have no saved-document identifiers in this package.

SDK and security-guidance pages are mutable snapshots; exact installed patch versions are not established. Protocol comparisons explicitly identify their revisions. Source passages were inspected for the claims made here; the review record covers only the isolated standalone Python lab. Pytest, Vitest, TypeScript, SDK transport and the supplied original scripts were not executed. Source review does not establish independent expert verification or a measured protection rate.

References and source links

Public originals

  1. Model Context Protocol · revision 2026-07-28. Architecture.
    https://modelcontextprotocol.io/specification/2026-07-28/architecture
  2. Model Context Protocol · revision 2024-11-05. Lifecycle.
    https://modelcontextprotocol.io/specification/2024-11-05/basic/lifecycle
  3. Model Context Protocol · revision 2025-11-25. Lifecycle.
    https://modelcontextprotocol.io/specification/2025-11-25/basic/lifecycle
  4. Model Context Protocol · revision 2026-07-28. Versioning and Compatibility.
    https://modelcontextprotocol.io/specification/2026-07-28/basic/versioning
  5. Model Context Protocol · revision 2026-07-28. stdio.
    https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/stdio
  6. Model Context Protocol · revision 2026-07-28. Streamable HTTP.
    https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http
  7. MCP Python SDK maintainers · v2 documentation, undated. Running your server.
    https://py.sdk.modelcontextprotocol.io/run/
  8. MCP TypeScript SDK maintainers · v2 documentation, undated. Serve over stdio.
    https://ts.sdk.modelcontextprotocol.io/v2/serving/stdio.html
  9. MCP TypeScript SDK maintainers · v2 documentation, undated. Serve over HTTP.
    https://ts.sdk.modelcontextprotocol.io/v2/serving/http.html
  10. MCP TypeScript SDK maintainers · v2 documentation, undated. Tools.
    https://ts.sdk.modelcontextprotocol.io/v2/servers/tools.html
  11. OWASP · undated. LLM Prompt Injection Prevention Cheat Sheet.
    https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html
  12. Model Context Protocol · revision 2026-07-28. Tools.
    https://modelcontextprotocol.io/specification/2026-07-28/server/tools
  13. Campbell, Bradley and Tschofenig · 2020. RFC 8707: Resource Indicators for OAuth 2.0. IETF.
    https://www.rfc-editor.org/rfc/rfc8707.html
  14. Model Context Protocol · revision 2025-11-25. Authorization.
    https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization
  15. Model Context Protocol · versioned 2025-11-25 guidance. Security Best Practices.
    https://modelcontextprotocol.io/docs/2025-11-25/tutorials/security/security_best_practices
  16. OWASP · undated. OS Command Injection Defense Cheat Sheet.
    https://cheatsheetseries.owasp.org/cheatsheets/OS_Command_Injection_Defense_Cheat_Sheet.html
  17. Git project · manual 2.56.0. git-log.
    https://git-scm.com/docs/git-log
  18. OWASP · undated. Path Traversal Prevention Cheat Sheet.
    https://cheatsheetseries.owasp.org/cheatsheets/Path_Traversal_Prevention_Cheat_Sheet.html
  19. OWASP · undated. Server Side Request Forgery Prevention Cheat Sheet.
    https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html
  20. Ken Huang / Cloud Security Alliance · 2025. Agentic AI Threat Modeling Framework: MAESTRO.
    https://cloudsecurityalliance.org/blog/2025/02/06/agentic-ai-threat-modeling-framework-maestro
  21. Microsoft · undated snapshot. Microsoft Threat Modeling Tool threats.
    https://learn.microsoft.com/en-us/azure/security/develop/threat-modeling-tool-threats
  22. Simon Willison · 2025. The lethal trifecta for AI agents: private data, untrusted content, and external communication.
    https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/
  23. pytest maintainers · stable documentation, undated. How to parametrize fixtures and test functions.
    https://docs.pytest.org/en/stable/how-to/parametrize.html
  24. Vitest maintainers · undated. Test API reference.
    https://vitest.dev/api/test
  25. Paul Carleton / Model Context Protocol · 2025. Evolving OAuth Client Registration in the Model Context Protocol.
    https://blog.modelcontextprotocol.io/posts/client_registration/
  26. JSON-RPC Working Group · 2.0. JSON-RPC 2.0 Specificationhttps://www.jsonrpc.org/specification
  27. Model Context Protocol · 2026-07-28. Resourceshttps://modelcontextprotocol.io/specification/2026-07-28/server/resources
  28. MCP Python SDK · v2. Migration Guide: v1 to v2https://py.sdk.modelcontextprotocol.io/migration/
  29. OWASP Cheat Sheet Series · Living documentation. SQL Injection Prevention Cheat Sheethttps://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html