12 KiB
Step 6 Results: Resource-First Discovery and Tool Fallback Contract
This section finalizes Step 6 by defining discovery behavior for clients that can attach MCP resources and the fallback behavior for clients or chat surfaces that must rely on MCP tools.
Step Deliverable
- Update the current
docs/directory with the finalized Step 6 discovery and fallback contract content from this document.
Primary Source Baseline (Repository Docs)
Step 6 is based on the current project contracts in:
docs/architecture.md(resource-first architecture and catalog role)docs/usage.md(operating flows, bounded loading, and fallback sequence)docs/copilot.md(client capability lanes and practical fallback behavior)docs/mcp_layout.md(shared content source and thin-tool fallback position)docs/securing.md(read-only/public-docs security invariant)
Normative conclusions from those sources:
- Discovery stays resource-first.
- Tool fallback is allowed, thin, and read-only.
- Resources and tools must resolve to the same canonical authored markdown.
- Fallback behavior should keep context bounded and deterministic.
FastMCP Source Baseline (Authoritative References)
Step 6 fallback behavior and compatibility-layer expectations align with:
- FastMCP server concepts
- FastMCP resources and resource templates
- FastMCP resources-as-tools transform
- MCP specification: resources
Applied conclusions for this step:
- Resource contracts remain canonical and should be surfaced directly when clients support resource attachment.
- Tool-first compatibility layers should wrap canonical resource reads rather than creating alternate authored-content stores.
- URI-template-backed resource identity remains stable across direct-resource and tool-compatibility access paths.
Client Tool-Naming Research Baseline
Authoritative and client-specific references to verify during implementation:
- MCP specification: tools
- MCP client concepts
- FastMCP tools
- FastMCP resources-as-tools transform
- VS Code MCP servers
- VS Code MCP configuration reference
- Cursor MCP documentation
- Claude Desktop local MCP server setup
Baseline naming conclusions:
- MCP protocol tool identity is the server-advertised
namereturned bytools/listand used intools/call. - FastMCP tool identity should be treated as the canonical server contract unless a tool is intentionally registered with an explicit alternate name.
- Clients and host integrations may display, namespace, or internally route tool names with provider-specific prefixes, but those wrappers are not canonical server tool names.
- Compatibility should be validated by observed
tools/listand successfultools/callbehavior in each target client rather than by assuming one global host naming convention.
Discovery Priority Contract (Normative)
Preferred sequence for skill discovery and loading:
resource://catalog/skills_indexresource://catalog/skills/{skill_id}resource://skills/{skill_id}/documentresource://skills/{skill_id}/references/{ref_id}only when needed
Rules:
- Start from catalog discovery before loading any skill document.
- Do not skip straight to broad document loading when catalog metadata can narrow choices first.
- Use
resource://docs/{path*}only for direct authored-doc access outside skill-specific flows.
Fallback Activation Rule
Fallback is used only when the active client path cannot reliably attach MCP resources (for example, tool-only chat surfaces).
Rules:
- Keep the same discovery order semantics as the resource path.
- If resource attachment is available, prefer resources over tools.
- Tool fallback must never become a second authoritative content source.
Tool Fallback Surface (Normative)
The fallback tool surface includes:
list_resourcesread_resourcesearch_patternsget_pattern_by_idget_skill_document_by_id
Canonical naming rule:
- The server-level tool contract uses the exact registered FastMCP tool names above.
- Clients that expose provider-prefixed names (for example, namespaced wrappers) must map those names to the canonical server tool name before invocation.
catalog_get_skill_document_by_idis not a canonical server tool name for this contract unless an explicit alias is intentionally registered.
Compatibility alias policy:
- Prefer canonical server tool names over aliases.
- Add server-side aliases only when a major client cannot reliably map its wrapper name back to the canonical name.
- Any alias must be read-only, delegate to the same payload builder as the canonical tool, and be documented as compatibility-only.
- If aliases are added, canonical and alias tools must return byte-for-byte equivalent payloads for the same input.
Fallback order:
- call
list_resourcesto inspect canonical static/template resource surfaces - call
read_resourcefor catalog URIs and selected skill URIs - use thin catalog tools only when additional metadata-first narrowing is needed
Tool behavior requirements:
- read-only and idempotent semantics
- deterministic ordering and bounded pagination
- explicit not-found responses (
found: falsestyle) where applicable - payloads remain schema-aligned with catalog resources
- tool invocation examples and Copilot guidance must use canonical server tool names to avoid unknown-tool errors
Major Client Compatibility Plan
Target clients and expected validation:
- GitHub Copilot in VS Code
- primary path: attach MCP resources when
MCP Resources...is available - fallback path: call
list_resources,read_resource, then canonical thin tools only when needed - validation: confirm Copilot-visible tool inventory includes or can invoke
list_resources,read_resource,search_patterns,get_pattern_by_id, andget_skill_document_by_id - compatibility risk: host-generated wrapper names may differ from canonical FastMCP names; document any observed wrapper-to-canonical mapping
- primary path: attach MCP resources when
- Cursor
- primary path: use the client MCP server configuration and resource/tool surfaces supported by the active Cursor version
- fallback path: prefer resource-backed tools first, then canonical thin tools
- validation: capture Cursor
tools/listequivalent behavior and verify the canonical tool names or required host mappings - compatibility risk: Cursor may present MCP tools through its own UI labels or internal routing names
- Claude Desktop
- primary path: configure the local MCP server and inspect advertised tools/resources in Claude Desktop
- fallback path: invoke canonical server tool names exactly as returned by
tools/list - validation: run a local smoke prompt that reads
resource://catalog/skills_indexand loads one skill document throughread_resourceorget_skill_document_by_id - compatibility risk: local server configuration and transport setup may fail before tool-name compatibility is tested
- Generic MCP clients and SDK-based tests
- primary path: protocol-level
resources/list,resources/read,tools/list, andtools/call - fallback path: none beyond the canonical tool contract
- validation: automated smoke tests assert exact tool names returned by
tools/listand successful calls for canonical names - compatibility risk: SDK/client libraries may expose helper names that differ from raw protocol names
- primary path: protocol-level
Implementation checklist:
- Capture each target client's advertised tool names before adding aliases.
- Prefer fixing documentation or client-side mapping when the server already advertises canonical names correctly.
- Add a server-side alias only for a confirmed major-client incompatibility.
- Add regression tests for canonical names, resource-backed tools, and any intentionally supported aliases.
- Keep public examples centered on
list_resources/read_resourceand canonical thin tool names.
Resources-As-Tools Compatibility Layer
Step 6 includes a resources-as-tools compatibility layer for clients that can call tools but not attach resources.
Rules:
- It wraps canonical resource reads rather than re-implementing content transforms.
- It preserves canonical URIs and metadata semantics.
- It does not replace the minimal catalog tools listed above.
- It is interoperability-driven and remains read-only.
Resource/Tool Parity Contract
Resources and fallback tools must agree on identity and routing metadata.
Parity requirements:
skill_idandref_idare identical across both paths.- canonical URIs in payloads match Step 3 URI rules.
- skill metadata (
id,name,description,tags,capabilities,version) remains consistent. - document payload returned by
get_skill_document_by_idresolves to the same canonicalSKILL.mdcontent asresource://skills/{skill_id}/document.
Relevance and Ranking Contract
Baseline matching behavior is metadata-first and deterministic.
Rules:
- Search primarily over normalized skill metadata (id, name, description, tags).
- Keep deterministic ordering and deterministic pagination behavior.
- Keep ranking logic transparent and bounded for predictable client behavior.
Optional extension policy:
- BM25/regex augmentation is allowed only when catalog/tool volume meaningfully harms token efficiency or precision.
- Any augmentation must preserve canonical ids, URIs, and deterministic tie-breaking.
- Any augmentation remains discovery-only and does not create alternate content payloads.
Context-Bounding and Clarification Policy
To prevent context bloat and improve answer quality:
- load only the most relevant skill document by default
- load at most two skill documents in one pass unless the user explicitly asks for more
- if confidence is low after catalog discovery, ask one clarifying question before loading additional skill documents
- fetch references lazily and only when required
Security and Safety Constraints
Fallback tools must preserve the project security invariant.
Rules:
- tool surfaces stay documentation-only and read-only
- no mutation, shell execution, secret access, or private filesystem exposure
- all returned content remains safe to publish publicly
Integration Boundaries
Step 6 integrates with prior steps as follows:
- Step 4 provides the validated in-memory registry.
- Step 5 provides canonical resource registration.
- Step 6 adds fallback discovery/read behavior that reuses the same registry and canonical markdown sources.
Separation-of-concerns rule:
- Catalog/resource contracts remain canonical.
- Fallback tools are interoperability adapters, not a parallel architecture.
Acceptance Criteria for Step 6 Completion
Step 6 is complete when all are true:
- Resource-first discovery remains the documented and implemented default path.
list_resourcesandread_resourceare available for tool-only clients.- Thin catalog tools remain minimal, read-only parity surfaces.
- Fallback tool outputs map to canonical skill identities and URIs.
- Context loading is bounded and clarifying-question behavior is documented for low-confidence cases.
- No second content source is introduced; resources and tools resolve the same authored markdown.
Non-goals for Step 6
- No write or side-effecting tools.
- No alternate authored markdown stores or duplicated skill content pipelines.
- No guarantee that every client session exposes MCP resource attachment UI.
- No packaging/build contract changes (handled in Step 7).
- No CI gate expansion details (handled in later validation/governance steps).