fix(mcp): expose accepted workspace mode values (#3667)

This commit is contained in:
José Almeida
2026-09-14 18:17:38 +02:00
committed by GitHub
parent 01b0dedd6c
commit afeebea2da
10 changed files with 523 additions and 5 deletions
@@ -1,5 +1,5 @@
---
status: draft
status: active
system: tasks
created: 2026-09-11
owners:
@@ -98,11 +98,36 @@ skills and CLI, with no Office task-creation MCP tool.
shall remain indistinguishable. Documentation shall distinguish session MCP,
Office skills/CLI, external MCP, and materialized-workspace policy.
### REQ-TASKS-MCP-WORKSPACE-MODE-004: Discoverable materialization choices
**Intent:** Let MCP callers select a supported materialized-workspace policy
from the advertised contract.
#### Acceptance criteria
- **AC-TASKS-MCP-WORKSPACE-MODE-004.1:** Task and external MCP catalogs shall
advertise optional string `workspace_mode` with exactly the ordered enum
`["inherit_parent", "new_workspace"]` and no schema default.
- **AC-TASKS-MCP-WORKSPACE-MODE-004.2:** The field description shall explain
that omission for a subtask inherits its parent's materialized workspace,
explicit `inherit_parent` requires `parent_id` and reuses that workspace or
worktree, and `new_workspace` requests a separate workspace or worktree.
- **AC-TASKS-MCP-WORKSPACE-MODE-004.3:** Omitted input shall retain existing
parent-dependent defaulting. Both explicit enum values shall reach existing
backend validation, including the parent requirement for `inherit_parent`.
No workspace modes or execution behavior shall be added.
- **AC-TASKS-MCP-WORKSPACE-MODE-004.4:** MCP schema validation shall reject
out-of-enum input before backend dispatch, including `shared`, `shared_group`,
empty strings, whitespace-only strings, and padded mode names. Public caller
guidance shall explain using omission instead of blank input for defaulting.
Backend handling of blank values shall remain unchanged.
## Exclusions
- New Office MCP tools or external assignment fields.
- Office CLI, permission, scheduler, or lifecycle redesign.
- Changes to external creation schemas, launch behavior, or idempotency contracts.
- External creation schema changes beyond materialization enum metadata and its
description; changes to launch behavior or idempotency contracts.
- Workspace conversion, historical migration, rendered UI, or new endpoints.
- Changes to automation/configuration catalogs or their established authority.
@@ -110,3 +135,4 @@ skills and CLI, with no Office task-creation MCP tool.
- [System design](../system-design/mcp-workspace-mode.md)
- [Implementation plan](../../../plans/mcp-workspace-mode/plan.md)
- [Enum discoverability follow-up](../../../plans/mcp-workspace-mode-enum/plan.md)
@@ -1,10 +1,11 @@
---
status: draft
status: current
system: tasks
requirements:
- REQ-TASKS-MCP-WORKSPACE-MODE-001
- REQ-TASKS-MCP-WORKSPACE-MODE-002
- REQ-TASKS-MCP-WORKSPACE-MODE-003
- REQ-TASKS-MCP-WORKSPACE-MODE-004
---
# MCP task workspace mode design
@@ -35,6 +36,7 @@ them.
| REQ-TASKS-MCP-WORKSPACE-MODE-001 | Trusted admission; Destination resolution |
| REQ-TASKS-MCP-WORKSPACE-MODE-002 | Surface contract |
| REQ-TASKS-MCP-WORKSPACE-MODE-003 | External compatibility; Errors |
| REQ-TASKS-MCP-WORKSPACE-MODE-004 | Materialization schema discoverability |
## Surface contract
@@ -140,6 +142,63 @@ No migration, mode column, historical rewrite, new endpoint, or UI is planned.
Update public reference documentation when the gate is implemented.
The earlier proposal for a separate Office MCP creation tool is withdrawn.
## Materialization schema discoverability
The task system owns this addition because the field is a task-creation
contract. Workspace lifecycle, transport discovery guidance, and Office
admission remain with their existing owners.
In `internal/mcp/server/server.go`, `registerCreateTaskTool` adds
`mcp.Enum("inherit_parent", "new_workspace")` to the existing
`mcp.WithString("workspace_mode", ...)` in `registerCreateTaskTool`.
The pinned `mcp-go` v1.0.0-beta.1 supports this property option; existing
`delivery_mode` and profile-session-policy fields use it. Do not add
`mcp.Required()` or a default. Both `ModeTask` (through `registerKanbanTools`)
and `ModeExternal` use this registration.
Field description: "Optional materialized-workspace mode. Omit for
subtasks to inherit the parent's workspace/worktree. inherit_parent requires
parent_id and reuses the parent's materialized workspace/worktree;
new_workspace requests a separate workspace/worktree."
Keep `resolveMCPWorkspacePolicy` in `internal/mcp/handlers/handlers.go`
unchanged. It trims input, defaults blank with a parent to `inherit_parent`,
leaves blank root policy unspecified, rejects explicit inheritance without a
parent, and accepts only the two explicit modes. Do not advertise the broader
service's `shared_group` or an invented `shared` alias.
### Compatibility and schema propagation
`compileToolArgumentSchema` marshals the registered schema and only adds root
`additionalProperties: false`; it preserves enum metadata. Validation runs
before dispatch. `normalizeToolArguments` only handles the legacy prompt alias,
so the enum rejects empty, whitespace-only, and padded strings that
previously reached the trimming handler. This is a real MCP input narrowing,
not merely a description improvement. Callers should omit the key to request
defaulting, or send an exact enum value. Do not introduce normalization or alter
the backend to conceal this effect. This follows the existing
[schema validation decision](../../../decisions/2026-08-01-validate-mcp-tool-arguments.md).
`mcpToolInputSchema` preserves raw schemas or marshals structured schemas for
attachment evidence. `cloneValidMCPInputSchema` in
`internal/agentctl/types/streams/mcp_attachment.go` copies valid JSON unchanged;
size limits can drop a whole schema with a truncation marker, not individual
enum keywords. No enum-stripping transform was found in the inspected MCP
registration, validator, or attachment paths. Regression tests verify serialized
catalog and attachment schemas; this does not prove behavior of arbitrary
external clients.
Schema and wrapped-call tests in `server/create_task_workspace_mode_test.go`
cover task/external registration, exact enum order, optionality, absent default,
description semantics, both accepted values, omission, and rejected
blank/unsupported inputs without dispatch. The direct policy matrix in
`handlers/workspace_policy_test.go` and existing handler tests preserve root,
parent, trimming, and rejection behavior. The public MCP reference and
coordination guide document omission and blank-input compatibility.
No rendered UI changes or browser test are needed.
- [Enum implementation plan](../../../plans/mcp-workspace-mode-enum/plan.md)
## Related contracts
- [Workspace-owned mode](../../../decisions/2026-08-15-office-mode-follows-active-workspace.md)