Skip to content

🗓️ feat: Let Any Schedule Be Authorized, With or Without an MCP Server - #18486

Draft
danny-avila wants to merge 1 commit into
danny-avila/schedule-grant-all-toolsfrom
danny-avila/schedule-grant-any
Draft

danny-avila wants to merge 1 commit into
danny-avila/schedule-grant-all-toolsfrom
danny-avila/schedule-grant-any

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

A schedule's authorization (#18260, #18465) had to allow at least one MCP tool. A schedule whose agents use no MCP server, or none the operator declared, had nothing to authorize: its dialog said "unsupported", and its code execution, web search and actions ran unattended with no owner decision behind them. A schedule that needed an authorization it did not have (#18274) was refused its MCP calls only; its other tools kept running.

After this change any schedule can be authorized, and one that needs an authorization it lacks is refused every tool until the owner confirms.

  • A grant may allow the agents' other tools and no MCP server at all.
  • The grant stores its own lifetime, since such a grant has no MCP consent to carry one.
  • With no grant, once one is required, each tool call is refused with consent_missing: an MCP call where it is made, any other tool at the run's hook. The run still starts and answers without its tools.

Stacked on #18465. Related to #18274, #13824.

How it works

// Schedule.mcpConsent
consents: Consent[];               // was min(1); may now be empty
tools?: { agentId, tools }[];      // from #18465
grantedAtMs?: number;              // new: the grant's own lifetime, always written from now on
absoluteExpiresAtMs?: number;
revokedAtMs?: number | null;
// valid when: consents or tools is non-empty, and a grant with no consents has its own deadline
grantLifetime(grant)       data-provider   expires = grant's own deadline, else the earliest consent's
                                           revoked = on the grant, or on any consent
  read by                  service.view (state, expiresAtMs), execution (other tools stop at it),
                           storage confirm (an expired grant is not written)
storage revoke             also marks the grant itself revoked

offer    enrollment.ts     other tools are offered even where no MCP server is declared
view     service.ts        an offer exists when there is an MCP tool OR another tool to allow
confirm  service.ts        `allow` may be empty when `tools` is not; nothing at all -> consent_invalid
ready    mcp.ts            a granted run that selects no MCP tool is no longer a binding mismatch
run      run.ts            no grant + needsGrant() -> non-MCP tool refused with consent_missing

needsGrant is the question #18274 already asks at the first MCP call ("does this schedule need a grant it does not have"), now also asked at the first call of any other tool, once per run. A lookup that fails refuses the call with dependency_unavailable.

The tools of a schedule held this way still load, and the refusal happens at the call. That keeps the refusal recorded on the run, so the schedule shows that it needs authorization; dropping the tools at load would leave the owner with worse answers and no explanation.

Type of change

  • Feature

Testing

Tested environments/configuration: WSL2, Node.js 24. Storage tests run against mongodb-memory-server. No external services.

Automated tests:

  • packages/data-provider/src/types/scheduleConsent.spec.ts: a request that allows only other tools; nothing allowed is rejected; a stored grant with no consents needs a tool and its own deadline; grantLifetime for a grant with its own lifetime and for one read from its consents.
  • packages/data-schemas/src/methods/scheduleConsent.spec.ts: a grant with no MCP server is refused without its own deadline, not written once past it, stored and read back, and revoked on the grant itself.
  • packages/api/src/schedules/authorization/service.spec.ts: a schedule with no MCP server is offered, granted, expires and is revoked by the grant's own lifetime; a grant that allows nothing is rejected, and one of either kind is enough.
  • packages/api/src/schedules/authorization/enrollment.spec.ts: other tools are offered where no MCP server is declared; a grant that limits MCP tools only offers nothing there and walks no graph.
  • packages/api/src/schedules/authorization/execution.spec.ts: with no grant and one required, a non-MCP tool is refused with consent_missing, an MCP call and the SDK controls are left to their own checks, the lookup happens once, a failed lookup refuses without leaking the error, and a grant that limits MCP tools only never holds other tools back; a grant with no MCP server loads its other tools until its own deadline.
  • packages/api/src/schedules/authorization/runtime.spec.ts: a granted run that selects no MCP tool has nothing to make ready and connects to nothing.
  • client/src/components/SidePanel/Schedules/__tests__/Consent.spec.tsx: with no MCP server on offer, confirm is disabled until a tool is ticked, and sends allow: {} with the tools.

Eight mutations (the stored lifetime, the offer condition, the nothing-allowed check, the held-run refusal, the undeclared-server offer, the readiness check, the storage revocation and the dialog's count) each fail a test.

npx tsc --noEmit is clean in packages/api, packages/data-schemas, packages/data-provider and client.

Not verified: in a browser, or against a running server.

Performance

A never-authorized scheduled run now asks whether it needs a grant at its first call of any tool, where before it asked only at its first MCP call: one read of the schedule's grant and one resolution of the consent limits, once per run, and not at all for a run that calls no tool. Runs under a grant pay nothing new. Reading the consent view for a deployment with no declared MCP server now walks the agent graph once to list the other tools, where it used to return early. I did not measure latency before and after.

Risk / compatibility

With consent on, an unauthorized schedule that becomes "required" now loses every tool, not only MCP. That happens when its owner edits it, or when the operator's requireAfter date passes. Schedules with no MCP tools were untouched by both before; after this they stop using code execution, web search and actions until the owner authorizes them. Operators who set requireAfter should expect that.

Mixed versions: a grant with no MCP server, or with the new lifetime fields, is unreadable to a replica without this change, which refuses its runs. A grant written by an older replica has no lifetime of its own and is read from its consents.

New schedules are still not authorized at creation. That is the next change.

Schedule consent is off by default.

A grant needed at least one MCP tool, so a schedule whose agents use no MCP server, or
none the operator declared, had nothing to authorize and its other tools were never
gated. A grant can now allow the agents' other tools alone. It has no consent to carry a
deadline, so every grant stores its own lifetime; one made before that is read from its
consents.

A schedule that needs a grant it does not have was refused its MCP calls only. Every
tool call is now refused with the same reason until the owner confirms.

This branch has not been deployed

No deployments
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