Add MCP annotation tools - #309
Merged
johnnygreco merged 1 commit intoJun 17, 2026
Merged
Conversation
This was referenced Jun 17, 2026
johnnygreco
force-pushed
the
issue-304-mcp-annotation-tools
branch
from
June 17, 2026 05:11
06562ce to
4c4f7f9
Compare
Owner
Author
Review RecordFrozen target: Panel:
Accepted findings fixed:
Rejected findings:
Validation after fixes:
Final status: all reviewer findings fixed and rechecked clean on current head; no unresolved blockers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds MCP annotation tools for agents:
create_annotation,update_annotation,list_annotations,get_annotation, anddelete_annotation.This also makes message-level annotations first-class by adding a
messageannotation target type backed byactivity_events.event_uidand validated againstevent_kind = 'message'. Transcript message controls now create message annotations, while non-message transcript blocks remain generic event annotations. MCP uses the current tool surface only; no legacy framing or compatibility shims were added.Closes #304
Validation
make generate-check-> passed after commit06562cemake fmt-check-> passedmake test-> passedmake lint-> passedmake build-> passednpm run test:frontend-> passedgo test ./internal/mcp -run 'TestTool(CreateAnnotationSupportsMessageTarget|ListAnnotationsSessionTargetListsAllSessionAnnotations|UpdateAndDeleteAnnotationVerifyMessageScope|GetAnnotationScopedMissReturnsForbidden|DefinitionsMatchImplementedArguments|DefinitionsAreOpenAIFunctionCompatible)|TestDataBackedToolsReturnDatabaseUnavailableToolErrors'-> passednpm run test:e2e-> passed, 52 testsnpm run test:a11y-> passed, 8 testsgit diff --check-> passedSample MCP Calls
Create message annotation:
{"name":"create_annotation","arguments":{"target_type":"message","message_id":"event:msg-1","session_id":null,"event_id":null,"open_ref":null,"author_id":"agent-1","author_name":"Reviewer Agent","category":"quality","outcome":null,"quality_score":4,"confidence":80,"needs_followup":false,"labels":["dataset:eval"],"note":"Message-level finding.","metadata_json":"{\"rubric\":\"qa\"}","source_name":null,"source_names":null,"runtime":null,"runtimes":null,"project_key":null,"project_keys":null}}List session annotations:
{"name":"list_annotations","arguments":{"target_type":null,"session_id":"session:session-1","message_id":null,"event_id":null,"open_ref":null,"include_deleted":false,"limit":200,"offset":0,"source_name":null,"source_names":null,"runtime":null,"runtimes":null,"project_key":null,"project_keys":null}}Risks
MCP now opens ClickHouse through the writable store path so write tools can insert annotation revisions. That is intentional for this issue and covered by backend-unavailable redaction tests.
Message annotations introduce a new
target_typevalue (message) without a schema migration becausetrace_annotations.target_typeis already a string column. Validation rejects message targets unless the referenced activity event is currently a message event.Reviewer Notes
Focus on target resolution and scope behavior in
internal/mcp/annotation_tools.go, the newmessagemodel/API handling, and the fact that session annotation listing intentionally returns all annotation targets for that session unless a target type is specified. Backward compatibility was explicitly not required and no compatibility work was added.