fix(activities): Add comment MCP tools - #43
Merged
Merged
Conversation
anujeet98
force-pushed
the
feat/mcp-comments-tools
branch
from
September 16, 2026 11:07
db82f92 to
91af346
Compare
… MCP tools Security fix: Activity rows have no organizationId column (only entityType/entityId), and ActivitiesController's routes (list, get, update, delete) plus the four nested per-entity comment/timeline routes only checked AuthGuard. Since Prisma ids are globally unique, any authenticated user could read, comment on, edit, or delete comments/timeline entries for any deal/company/contact/task id, regardless of organization membership. The old (now-dead) libs/agents leave-comment LangChain tool had the same gap. Fixed by adding OrganizationGuard to every activities route and verifying the underlying entity belongs to the caller's active org (via each entity service's existing org-scoped findById / TaskService.getTaskById, which already throw NotFoundException) before touching ActivityService. The generic /activities list endpoint previously allowed omitting entityType/entityId entirely, which can't be scoped safely without a join across four tables and wasn't used by the frontend — now requires both. TaskService is exported from TasksModule and imported into SalesModule so ActivitiesController can reach it alongside the existing Deals/Companies/Contacts services. Also adds four MCP tools mirroring this: add_comment, list_comments, update_comment, delete_comment, generic across task/deal/company/ contact via ActivityService (comments:read/comments:write scopes). Since MCP calls ActivityService directly rather than through the now org-checked REST controllers, each tool independently resolves the entity's org via prisma and checks it against the caller's memberships before proceeding. Unrelated: added .nxignore for apps/ai-agent/.eve/ (local Eve sandbox runtime snapshots were duplicating project names and breaking the Nx project graph for every target). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
anujeet98
force-pushed
the
feat/mcp-comments-tools
branch
from
September 16, 2026 11:50
91af346 to
6f5c90c
Compare
SalesModule owns deals/contacts/companies; importing TasksModule into it just so ActivitiesController could inject TaskService for the org-check muddied that scope, since activities/comments already span tasks too (not just sales entities). Moved the 5 activities controllers into a new ActivitiesModule that imports SalesModule and TasksModule, and reverted SalesModule to its original imports/scope. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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 tools for comments (
add_comment,list_comments,update_comment,delete_comment) covering tasks, deals, companies, and contacts throughActivityService, scoped by newcomments:read/comments:write.While building this, found that the activities REST endpoints (list/get/update/delete + per-entity comment/timeline routes) had no org-membership check — only session auth. Fixed by verifying the underlying entity belongs to the caller's org before touching
ActivityService, and applied the same check inside the new MCP tools (which callActivityServicedirectly, not through the REST controllers).Also extracted
ActivitiesControllerinto its ownActivitiesModule— it now needsTaskServicealongside the existing Deals/Companies/Contacts services, and that didn't belong bolted ontoSalesModule.Changes
add_comment,list_comments,update_comment,delete_commentinmcp-server.ts, newcomments:*scopesOrganizationGuard+ entity-org verification on all 5 activities controllers; genericGET /activitiesnow requiresentityType/entityId(was optional and unscoped — confirmed unused by the frontend without them)ActivitiesModule(importsSalesModule+TasksModule),SalesModuleback to deals/contacts/companies onlydocs/concepts/mcp-server.mdxactivities.controller.spec.ts(org-check coverage), 14 new MCP tool testsTest plan
bun nx run @zuko/backend:test— 279/279 passbun nx run @zuko/backend:build— cleanActivitiesModuleresolves (caught a missingPrismaModuleimport this way)oxfmt/oxlint— no new issuesadd_comment/list_commentsvia Claude, confirm it shows up in the UI🤖 Generated with Claude Code