Skip to content

feat(context): ctx.minder.call and minder_scopes for AI tools - #58

Merged
Resinder merged 1 commit into
mainfrom
feat/minder-api-capability
Nov 7, 2026
Merged

Resinder merged 1 commit into
mainfrom
feat/minder-api-capability

Conversation

@Resinder

@Resinder Resinder commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary

An AI tool can now call Minder's own API through the platform context, scoped to what it declares.

  • await ctx.minder.call(route, *, method="GET", query=None, json=None): calls a plugin-callable Minder route as the invoking user and returns the parsed JSON answer.

    • Capability minder.api (CAP_MINDER_API, added to HOST_CAPABILITIES).
    • It is granted only while the plugin serves an AI tool call, and only for the tool's approved scopes.
    • New MinderAPI protocol; PlatformContext gains minder.
    • Implemented by the unbound context (CapabilityUnavailable), FakePlatformContext and the T4 CallbackPlatformContext.
    • Wire args: {"route", "method", "query", "body"}. T4 posts them to /v1/plugin-callbacks/minder.api, and minder.api is in REMOTE_CAPABILITIES.
  • Errors use the existing classes, and the reason says which case applies:

    • CapabilityDenied: not a tool call, route not plugin-callable, the token lacks the route's scope, deadline passed, or refused.
    • CapabilityInvalid: Minder rejected the arguments.
    • CapabilityUnavailable: unreachable, or past the deadline mid-call.
  • minder_scopes on AI_TOOLS entries (AIToolSpec): each scope must come from the new context.MINDER_SCOPES list:

    • kb.search
    • kb.read_passage
    • conversation.read_current
    • user.profile.basic
    • ticket.create_internal
    • kb.documents.ingest

    check_plugin fails on a value that is not a list, or on an unknown scope.

  • check_plugin_warnings warns when a tool's action method calls ctx.minder.call without declaring minder_scopes. This is a warning for now and becomes an error in a later release, the same rollout effect had. The check reads the action method's own body only, not the helpers it calls.

  • FakePlatformContext(minder_results={(method, route): value-or-callable}): any other route raises CapabilityDenied. for_plugin grants minder.api when a tool declares minder_scopes.

  • README (tool fields, the ctx table, errors, the fake) and CHANGELOG "Unreleased".

Compatibility

  • Additive for plugins.
  • A host-side PlatformContext implementation must add a minder attribute to keep passing isinstance(ctx, PlatformContext).

Validation

  • black --check src tests examples: clean.
  • flake8 --max-line-length=100 --extend-ignore=E203,W503 src tests examples: clean.
  • mypy src (strict): no issues.
  • pytest tests: 1188 passed.

New tests cover:

  • the unbound context's minder.api call;
  • the T4 callback body for minder.api;
  • minder_scopes validation errors;
  • the warning when ctx.minder.call is used without scopes, and no warning once scopes are declared;
  • the fake's routes and grant.

🤖 Generated with Claude Code

Add the minder.api capability to the platform context: an AI tool can call
a plugin-callable Minder route as the invoking user, for the scopes it
declares in the new AI_TOOLS field minder_scopes (from MINDER_SCOPES).
check_plugin rejects unknown scopes; check_plugin_warnings warns when a
tool's action calls ctx.minder.call without minder_scopes (an error in a
later release). The unbound, fake and T4 callback contexts implement it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Resinder

Resinder commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Driven by session zeynep-portainer from 2026-11-07T03:36:23Z: it is the one session acting on this PR (pushes, reruns, merge). Protocol: minderhq/minder#2342.

@Resinder
Resinder merged commit a9d661a into main Nov 7, 2026
4 checks passed
@Resinder
Resinder deleted the feat/minder-api-capability branch November 7, 2026 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant