# feat\(mcp\): update thread metadata · PR \#8690 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/8690)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: merged

Source repository: pingdotgg/t3code

Source branch: agents/mcp-thread-metadata/update

Target branch: t3code/codex-turn-mapping

Head commit: 1d3256bdc9a469fa15a84358873b0a0acad019bb

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/8690)

[Commits](https://git.cafe/pingdotgg/t3code/pull/8690/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/8690/diffs?format=markdown)

## Description

---

## Problem

Provider agents can read thread history but cannot safely rename a thread, regenerate its title, or link and unlink a pull request through the app-owned MCP workflow.

## Change

Add `t3_thread_update` with a provider-compatible object-root schema and typed metadata actions. A focused service keeps updates in the current project, uses V2 commands and idempotent receipts, and returns committed title, title-regeneration, and linked-PR state. Thread list/read expose the corresponding read path; docs and tool presentation cover the user-visible behavior.

## Behavior

`threadId` defaults to the calling thread. Rename requires `title`; link requires repository, number, and URL; regenerate and unlink take no action-specific payload. Branch and workspace mutations remain outside this tool.

## Validation

- Focused contracts, toolkit schema, presentation, and real MCP/V2 integration tests (4 files, 14 tests)
- Targeted lint for changed TypeScript files
- Contracts, shared, and server package typechecks

## Dependency

Depends on #8689, which fixes V2 linked-pull-request persistence. Native stack #8709: #8689 → #8690, rooted at `agents/mcp-controls/base-490318a`. It remains independent from thread organization stack #8708.

Implemented by GPT-5.6-Sol via Codex in T3 Code.


<!-- Macroscope's pull request summary starts here -->
<!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. -->
<!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. -->
> [!NOTE]
> ### Add `t3_thread_update` MCP tool for thread metadata actions
> - Introduces `ThreadMetadataMcpService` and the `t3_thread_update` orchestrator MCP tool supporting four actions: rename, title regeneration, pull-request link, and pull-request unlink
> - Defines validated contracts in [threadMetadataMcp.ts](https://github.com/pingdotgg/t3code/pull/8690/files#diff-f33e572489204f77607cb25bd93b4e4ea5697076434c257f8746b95d51d04bfb) requiring action-specific fields, HTTP(S)-only PR URLs, bounded client request IDs, and non-empty titles up to 512 chars
> - Updates `thread.metadata.update` command handling in [Orchestrator.ts](https://github.com/pingdotgg/t3code/pull/8690/files#diff-8747d8bd671948fc866dd5d05e74fa07e196b1f397fa7895aa5095e3186cd570) to persist or clear a linked pull request field in the resulting event
> - Thread list and detail responses now include nullable linked pull request and title-regeneration state; determinstic command IDs enable idempotent client-request retries
> - Behavioral Change: `OrchestratorMcpThreadListItem` and `OrchestratorMcpThreadDetail` schemas in [orchestratorMcp.ts](https://github.com/pingdotgg/t3code/pull/8690/files#diff-30fbd4867ef75aeb0387d7659bcc37b66ae287fb1356db374bd78ac363599dd3) gain new nullable fields; existing MCP consumers that validate strictly against these schemas must accept the added fields
>
> <!-- Macroscope's review summary starts here -->
>
> <sup><a href="https://app.macroscope.com">Macroscope</a> summarized aeabb89.</sup>
> <!-- Macroscope's review summary ends here -->
>
<!-- Macroscope's pull request summary ends here -->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Introduces a new mutating MCP surface that dispatches durable orchestration commands and links external PR metadata; mistakes in scoping or validation could affect thread metadata across a project.
> 
> **Overview**
> Adds **`t3_thread_update`** so provider agents can mutate thread metadata through the orchestrator MCP toolkit: **rename**, **regenerate title**, **link pull request**, and **unlink pull request**. Workspace/branch changes stay out of scope.
> 
> A new **`ThreadMetadataMcpService`** enforces orchestration capability, resolves the target thread in the calling project (defaulting to the caller), builds stable **`thread.metadata.update`** commands with **`clientRequestId`** idempotency, and returns committed title, **`titleRegeneration`**, and **`linkedPullRequest`** state. **`OrchestratorMcpService`** thread list/detail responses now surface **`linkedPullRequest`** (and in-flight title regeneration on read).
> 
> Contracts live in **`threadMetadataMcp.ts`** with action-specific validation (HTTP(S) PR URLs, title length, surrogate-safe idempotency keys). Docs, UI tool presentation, and integration/unit tests cover the new tool and read path.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit aeabb8905cb9f78653fc8841f269242411a059ed. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->


