fix(mcp): resolve the agent resource provider structurally, not nominally - #21
Conversation
…ally #19 moved the plans:// and sessions:// rendering behind AgentResourceProvider and I described the dead endpoints as an interim, waiting on dappcore/agent to depend on this package and implement the interface. That day does not come: agent maintains its own copy of Core\Mcp rather than depending on this package, so it can never name the interface in an implements clause. An interim with no end is a decision that has not been made, so it is made here. The controller now accepts any object bound under the interface name that provides read(). A provider able to name the interface still implements it and is accepted nominally; one that cannot binds and satisfies the method. Both work, neither package imports the other, and two endpoints that would otherwise have stayed dead permanently come back on as soon as agent binds. Half a contract is rejected rather than accepted: an object with neither read() nor the interface returns null, so the controller answers a clean not-found instead of fatalling mid-request. The contract also loses entries(). Nothing in this package ever called it — GET servers/{id}/resources lists a server's own configured resources, which is a different concept — so it was a method an implementer had to satisfy for no consumer. Providers are still free to offer listing for their own transports; agent's registry does, for its stdio server. This package asks only for what it uses. Four tests cover the resolution: a duck-typed binding with no implements clause, a nominal implementation, an object missing read(), and nothing bound at all. Suite: 21 failed, 303 passed, from 21 failed, 299 passed — the four new tests, no change to the existing failures. Co-Authored-By: Virgil <virgil@lethean.io>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe controller now resolves nominal and duck-typed resource providers with a ChangesAgent resource provider resolution
Sequence Diagram(s)sequenceDiagram
participant McpApiController
participant Container
participant ResourceProvider
McpApiController->>Container: Resolve provider binding
Container-->>McpApiController: Return bound value
McpApiController->>ResourceProvider: Check read()
ResourceProvider-->>McpApiController: Provide readable resource
Warning Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Pairs with dAppCore/agent#22, which binds the provider. Together they turn the
plans://andsessions://HTTP endpoints back on.The interim that had no end
#19 moved that rendering behind
AgentResourceProviderand I described the dead endpoints as an interim, waiting ondappcore/agentto depend on this package and implement the interface.That day doesn't come. Agent maintains its own copy of
Core\Mcprather than depending on this package, so it can never name the interface in animplementsclause. An interim with no end is a decision that hasn't been made — so it's made here.Structural resolution
The controller now accepts any object bound under the interface name that provides
read():Both work, neither package imports the other. Half a contract is rejected rather than accepted: an object with neither
read()nor the interface returns null, so the controller answers a clean not-found instead of fatalling mid-request.The contract loses
entries()Nothing in this package ever called it —
GET servers/{id}/resourceslists a server's own configured resources, a different concept. It was a method an implementer had to satisfy for no consumer.Providers remain free to offer listing for their own transports; agent's registry does, for its stdio server. This package asks only for what it uses.
Verification
implements, nominal implementation, object missingread(), nothing boundExisting failures unchanged; the delta is exactly these four tests.
🤖 Generated with Claude Code
Co-Authored-By: Virgil virgil@lethean.io
Summary by CodeRabbit
New Features
read()capability, even without explicitly implementing the provider interface.Bug Fixes
Tests