Finding the Right MCP Tool: Decision Trees and Routing Protocols for Autonomous Agents

Autonomous coding agents interacting with modern knowledge bases require rigorous tool selection protocols. When an agent chooses an improperly scoped tool, it incurs severe context pollution, latency spikes, or catastrophic authorization rejections. Wikantik exposes exactly 51 distinct Model Context Protocol (MCP) tools distributed across two cryptographically partitioned server interfaces: 22 read-only tools on /knowledge-mcp and 29 privileged write, curation, and analytical tools on /wikantik-admin-mcp.

While simple agent implementations treat an MCP server as an undifferentiated bag of functions, production agentic architectures—such as those operating across the Simple Agility ecosystem—leverage strict functional decision trees. This runbook provides the definitive operational decision procedure, routing taxonomy, token economic equations, and error recovery workflows necessary to navigate Wikantik's dual-MCP surface with maximal precision and minimal token expenditure.

graph TD
    A["Agent Intent Received"] --> B{"Requires Mutation or Admin Analytics?"}
    
    %% Write Branch
    B -- "Yes (Write / Mutate / Curate)" --> C["Authenticate on /wikantik-admin-mcp (mcp_admin Key)"]
    C --> D{"Mutation Category"}
    D -- "Create New Pages" --> D1["write_pages (Batch Creation)"]
    D -- "Edit Existing Content" --> D2["update_page (Optimistic Locking + removeKeys)"]
    D -- "Taxonomy / Cluster Refactor" --> D3["rename_cluster or rename_page"]
    D -- "Verification Gate" --> D4["verify_pages → mark_page_verified"]
    D -- "Knowledge Graph Curation" --> D5["curate_nodes / curate_edges"]
    D -- "Traffic & Query Signals" --> D6["list_content_opportunities / list_retrieval_queries"]

    %% Read Branch
    B -- "No (Read-Only Grounding)" --> E["Authenticate on /knowledge-mcp (mcp_read Key)"]
    E --> F{"Information Goal"}
    F -- "Answer Specific Question" --> F1["assemble_bundle (Check coverage.confidence)"]
    F -- "Discover Relevant Pages" --> F2["retrieve_context (Query-driven Chunks)"]
    F -- "Metadata & Structural Faceting" --> F3["list_pages_by_filter (Cluster / Tag / Freshness)"]
    F -- "Page Orientation & Verification" --> F4["get_page_for_agent (Token-Budgeted Projection)"]
    F -- "Deep Code / Content Extraction" --> F5["read_pages (Batched Raw Markdown, ≤20 pages)"]
    F -- "Entity Triples & Ontological Graph" --> F6["traverse / query_nodes / sparql_query"]

1. Architectural Bifurcation: Dual-MCP Topology and Trust Boundaries

Wikantik partitions its MCP tools into two distinct server endpoints. This bifurcation enforces the principle of least privilege, protects sensitive corpus telemetry, and optimizes transport serialization over HTTP Server-Sent Events (SSE).

Security Boundaries and Authentication Contracts

Every interaction begins with an HTTP POST JSON-RPC handshake against the appropriate endpoint:

  1. The Knowledge MCP Endpoint (/knowledge-mcp):
    • Scope: Strictly read-only operations. Hosts 22 tools covering semantic search, chunk retrieval, metadata listing, structural Page Graph navigation, RDF triple queries, and ontology inspection.
    • Authentication: Requires a bearer token with mcp_read authorization. If an agent presents an invalid or administrative token, it is accepted under read constraints; however, attempting any mutating operation returns JSON-RPC Method Not Found (-32601).
    • Security Guarantees: Guarantees read parity with anonymous site visitors. Guest access control lists (ACLs) are strictly enforced at the database layer. An agent cannot leak private drafts or unverified administrative telemetry through /knowledge-mcp.
  2. The Admin MCP Endpoint (/wikantik-admin-mcp):
    • Scope: Authoritative mutations, verification gates, link-graph repair, sitemap pings, Knowledge Graph curation, and search query analytics. Hosts 29 tools.
    • Authentication: Requires a high-privilege bearer token with mcp_admin authorization. Presenting an mcp_read token immediately results in an HTTP 403 Forbidden status code.
    • Safety Guarantees: Enforces optimistic concurrency control on every document update via cryptographic content hashes (expectedContentHash), preventing concurrent agent overwrites.

Transport Lifecycle and SSE Connection State

Both endpoints follow the standard Model Context Protocol transport specification over HTTP:


2. Decision Tree for MCP Tool Selection

When an agent needs to retrieve data or mutate state, it must evaluate three sequential branching criteria:

Branching Criterion 1: Access Level (Privilege)

Branching Criterion 2: Retrieval Granularity (Read Path)

Branching Criterion 3: Mutation Class (Write Path)


3. High-Efficiency Read Routing on /knowledge-mcp

The read server exposes 22 specialized tools designed to satisfy the spectrum between high-level orientation and deep graph queries.

Tool NamePrimary Functional IntentKey Input ArgumentsResponse ShapeAverage Token FootprintEscalation / Fallback Path
assemble_bundleGrounded question answeringquery, max_tokens (opt)Ranked, deduplicated sections + confidence1,200 – 3,500 tokensIf confidence is sparse, escalate to retrieve_context
retrieve_contextDiscovering relevant pages/chunksquery, limit (default 5)Scored list of page slugs and text snippets400 – 800 tokensRead surfaced slugs via read_pages
get_page_for_agentToken-budgeted orientationcanonical_id or slugStructured JSON: facts, outline, hints350 – 500 tokensIf full prose needed, escalate to read_pages
read_pagesBatched raw markdown ingestionpages (array of slugs, ≤20)Map of {slug: {content, version, hash}}1,500 – 15,000+ tokensHandle per-page not_found errors
list_pages_by_filterStructural taxonomy filteringcluster, type, tagsArray of page descriptors with canonical IDs200 – 600 tokensPass canonical_id into get_page_for_agent
get_page_neighborsGraph link neighborhood explorationpageName, directionInbound wikilinks, outbound wikilinks150 – 400 tokensTraverses Page Graph without reading bodies
traverseCo-mention Knowledge Graph walkseedNode, maxDepthEntity sub-graph, node attributes, edge types500 – 1,200 tokensUse query_nodes if seed node is unknown
sparql_queryFormal RDF/OWL ontology reasoningquery (valid SPARQL)SPARQL JSON result set (bindings)250 – 900 tokensInspect schema with get_ontology first

Deep-Dive: The assemble_bundle Confidence Protocol

When executing assemble_bundle, autonomous agents must not treat the output as raw, unquestioned truth. The tool returns a vital metadata block: coverage.confidence.

{
  "coverage": {
    "confidence": "strong",
    "directMatches": 4,
    "semanticClusters": ["agentic-coding", "context-engineering"],
    "scoreThreshold": 0.742
  },
  "bundle": "### AgenticCodingHub > Structural Spine\n..."
}

4. Authoritative Write Routing on /wikantik-admin-mcp

The admin server exposes 29 privileged tools governing document creation, mutation, schema migration, and graph curation.

Tool NameOperation ClassConcurrency ControlValidation GatesPrimary Failure Modes
write_pagesBatch document creationFails if slug already existsFrontmatter schema validation409 Conflict if page exists; use update_page
update_pageOptimistic document mutationCompares expectedContentHashServer frontmatter schema, KaTeX checks412 Precondition Failed on hash mismatch
rename_pagePage slug migrationAcquires page lockAutomated backlink rewritesBroken links if referencing pages are locked
rename_clusterBulk taxonomy migrationMutates all cluster membersValidates cluster slug formatLong execution time across large clusters
verify_pagesBatch health auditingRead-only admin auditExistence, SEO metadata, KaTeX rulesReturns warning arrays; does not fail HTTP
mark_page_verifiedAuthoritative verificationWrites audit timestampsRequires human/agent verification IDRejection if required checklist criteria fail
curate_nodesKnowledge Graph entity updateTransactional batchNode type constraints, URI formatsSchema validation rejection on invalid types
curate_edgesKnowledge Graph edge updateTransactional batchSubject/object entity existenceDangling edge rejection

Safe Document Updates via Optimistic Locking

The most critical write operation is update_page. To prevent race conditions between concurrent agents or human editors, update_page implements strict optimistic concurrency control:

{
  "pageName": "SkillsVsMcp",
  "expectedContentHash": "93c27087ed727cdfa4d8b95055f30cfdf1a4ba71b8bbb4c6be1532c7ea57cec4",
  "content": "---\nstatus: active\n...",
  "frontmatter": {
    "status": "active",
    "cluster": "agentic-coding"
  },
  "removeKeys": ["hubs", "legacy_category"]
}
  1. expectedContentHash: The SHA-256 hash of the page content as received during the read phase. If another agent or user has modified the page in the interim, the server rejects the update with 412 Precondition Failed.
  2. removeKeys: Explicitly unsets deprecated frontmatter fields. This provides safe, server-authoritative schema pruning (e.g., eliminating retired hubs: fields under the Wikantik v2.4+ Cluster Declaration Architecture).

5. Token Economics and Projection Mathematical Modeling

A central design failure in autonomous agent workflows is the unbudgeted consumption of raw markdown. When an agent reads full articles simply to discover metadata, verify citations, or extract section headers, it rapidly exhausts the active context window.

Token Consumption Model

The total token cost of a multi-turn agent interaction across N wiki interactions is defined as:

T_{\text{consumed}} = \sum_{i=1}^{N} \left( T_{\text{transport}}^{(i)} + T_{\text{payload}}^{(i)} + T_{\text{overhead}}^{(i)} \right)

Where:

When an agent invokes read_pages for an average deep-dive article (approximately 2,200 words or 2,900 tokens), the payload consumes substantial budget. Conversely, the agent projection emitted by get_page_for_agent emits only the compressed structural spine (approximately 350 words or 460 tokens).

Projection Efficiency Ratio

We define the Projection Token Efficiency Ratio as:

\Omega_{\text{projection}} = \frac{T_{\text{get\_page\_for\_agent}}}{T_{\text{read\_pages}}} = \frac{C_{\text{facts}} + C_{\text{outline}} + C_{\text{hints}}}{C_{\text{prose}} + C_{\text{code}} + C_{\text{markup}}} \approx \frac{460}{2900} \approx 0.1586

By routing orientation steps to get_page_for_agent, the agent achieves an 84.1% reduction in context consumption per orientation step. Over a 20-step autonomous research and curation trajectory, this preserves over 48,000 tokens, directly reducing inference costs from approximately $0.15 per session to less than $0.024 per session while eliminating prompt truncation and attention degradation.


6. Real-World Execution Patterns and JSON-RPC Schemas

The following concrete JSON-RPC payloads demonstrate compliant invocations across both endpoints.

Pattern 1: Targeted Question Answering via assemble_bundle

# POST /knowledge-mcp
{
  "jsonrpc": "2.0",
  "id": 101,
  "method": "tools/call",
  "params": {
    "name": "assemble_bundle",
    "arguments": {
      "query": "How do Simple Agility coding agents verify PRs before merging?",
      "max_tokens": 2500
    }
  }
}

Pattern 2: Token-Budgeted Orientation via get_page_for_agent

# POST /knowledge-mcp
{
  "jsonrpc": "2.0",
  "id": 102,
  "method": "tools/call",
  "params": {
    "name": "get_page_for_agent",
    "arguments": {
      "pageName": "SpecDrivenDevelopment"
    }
  }
}

Pattern 3: Optimistic Document Update via update_page

# POST /wikantik-admin-mcp
{
  "jsonrpc": "2.0",
  "id": 201,
  "method": "tools/call",
  "params": {
    "name": "update_page",
    "arguments": {
      "pageName": "SpecDrivenDevelopment",
      "expectedContentHash": "a4f89d3c2b1e7f60...",
      "content": "---\ntitle: Spec-Driven Development\n...",
      "removeKeys": ["hubs"]
    }
  }
}

Pattern 4: Quality Gate Auditing via verify_pages

# POST /wikantik-admin-mcp
{
  "jsonrpc": "2.0",
  "id": 202,
  "method": "tools/call",
  "params": {
    "name": "verify_pages",
    "arguments": {
      "pageNames": ["SpecDrivenDevelopment", "SkillsVsMcp", "ContextEngineeringForCodingAgents"]
    }
  }
}

7. Recurring Antipatterns and Failure Modes

Antipattern 1: The get_page Void Traversal

Antipattern 2: The Raw Ingestion Flood

Antipattern 3: Credential Misrouting

Antipattern 4: The Graph-as-Search Fallacy

Antipattern 5: Blind Document Overwriting


See Also