Files
alamin-br 585694941f feat(mcp): choose tools per connection and share list_views with Kuma (#6425)
* feat(assistant): add MCP metadata decorator for Kuma tools

* feat(mcp): offer Kuma's read tools over MCP from the same definition

Builder page lookups are now scoped to the chat workspace so a read can't cross workspaces.

* fix(mcp): keep endpoints without an allow-list on today's tools

A null allow-list now means the tools enabled on 2026-10-19, so new tools need an explicit grant. Cross-workspace tests assert the exact exception.

* fix(assistant): treat a workflow in another workspace as missing

A different error for a foreign workflow let a client probe workflow IDs across workspaces.

* feat(mcp): return tool errors as MCP error results

Expected errors reach the client as readable error results without an ERROR log, only unexpected ones are logged.

* chore: add changelog entry for Kuma read tools over MCP

* fix(mcp): keep null grants on legacy tools in the consent screen

A null allowed_tools made the consent screen tick every tool on reconnect.

* chore(mcp): tidy tests and validation error handling

Only argument validation maps pydantic errors to client errors; one raised in a tool body is now an internal error.

* chore(mcp): rewrap get_allowed_tools docstring

* chore(mcp): drop null grant handling from the consent page

The consent API now sends the legacy tool list for a grant with no saved tools, so the page never receives null.

* fix(mcp): keep client errors readable and server errors logged

Row tool errors on develop reached the client verbatim; the new mapping hid some behind "Internal error.".

* fix(mcp): map remaining field errors and document the legacy allow-list

* feat(mcp): keep existing connections on the tools they had

Fill every null allow-list with the legacy tools, so tools added later never reach an existing endpoint. New endpoint keys store their tools explicitly.

* feat(mcp): group tools by area

The consent page lists tools by group and offers presets built from them. It also gets the tools each workspace can't use.

* feat(mcp): read-only and full-access presets on the consent page

The tool list moves into McpToolPicker so Settings can reuse it.

* feat(mcp): change a connection's tools without reconnecting

PATCH on an OAuth connection or an endpoint key replaces its tools, checked against what the endpoint can use, and logs the change in the audit log.

* feat(mcp): edit tools from Settings

Each connected app gets an Edit tools modal and a hint for the tools it has off, since new tools never turn on by themselves.

* chore(mcp): changelog for tool groups and Settings

* test(mcp): point the OAuth e2e test at the tool picker checkboxes

* fix(mcp): keep stored tools on edit and check availability at consent

Sending back a connection's own list failed when one of its tools was unavailable, and
consent stored tools the workspace can't use. Removing tools now needs no permission.

* fix(mcp): keep hidden tools when editing a connection's tools

Ticking any box in Settings dropped granted tools that are only unavailable for now, and a
slow save for one app could close the modal opened for another.

* refactor(mcp): share list_views from core and expose database tools only

Tool definitions live in contrib and know nothing about MCP or Kuma, so the Agent Builder can reuse them. Builder and automation tools ship later with their write tools.

* fix(mcp): reuse REST errors, validate row values and name blocked fields

Bad row values and field-level denials now read like the REST API's errors instead of "Internal error." or a generic denial.

* refactor(mcp): drop tool availability until a tool needs it

No tool overrides is_available since the Kuma tools left this PR. Also loads form field options in one query in list_views and logs stored tool names.
2026-10-21 12:14:33 +02:00

28 lines
874 B
JavaScript

/**
* The tools listed under one of the groups, the only ones the user can pick.
*/
export function listedTools(tools, groups) {
const listed = new Set(groups.map((group) => group.type))
return tools.filter((tool) => listed.has(tool.group))
}
/**
* Names of the tools in `grant`, in the order the API listed the tools.
*/
export function grantedToolNames(tools, grant) {
return tools.map((tool) => tool.name).filter((name) => grant.includes(name))
}
/**
* Names of the tools the "Read only" preset picks: the read-only tools in a
* group with `read_only_preset`, in the listed order.
*/
export function readOnlyToolNames(tools, groups) {
const preset = new Set(
groups.filter((group) => group.read_only_preset).map((group) => group.type)
)
return tools
.filter((tool) => preset.has(tool.group) && tool.read_only)
.map((tool) => tool.name)
}