Skip to content

feat(mcp): add deal management tools to MCP server - #36

Open
anujeet98 wants to merge 6 commits into
mainfrom
feat/mcp-deal-tools
Open

anujeet98 wants to merge 6 commits into
mainfrom
feat/mcp-deal-tools

Conversation

@anujeet98

@anujeet98 anujeet98 commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds list_deals, get_deal, create_deal, and update_deal tools to the OAuth MCP server
  • New deals:read / deals:write scopes in MCP_SCOPES
  • Writes route through DealsService (not prisma-direct) so validation and deal activity-timeline events fire, tagged with a new mcp activity source
  • Docs updated with tool reference and scope table

Changes by layer

  • Backend: mcp-server.ts (new tools), mcp.controller.ts / mcp.module.ts (wire DealsService into the MCP server), sales.module.ts (export DealsService), better-auth/auth.ts (new scopes)
  • Data model / events: deal-events.ts (ACTIVITY_SOURCES.MCP), deal-activity.listener.ts (accept generic ActivitySource instead of hardcoded 'ai')
  • Docs: docs/concepts/mcp-server.mdx — scope table and tool reference for the four new tools

Test plan

  • npx nx test backend passes (mcp-write-tools.spec.ts covers create/update deal)
  • Manually connect a local MCP client (see docs) and exercise list_dealscreate_dealupdate_deal
  • Confirm deal activity timeline shows mcp-sourced events after a create/update via MCP

🤖 Generated with Claude Code

Manual Test screenshot (mcp connector for claude)
image

https://claude.ai/code/session_01Rfj8fStgnMGjHZdLX8YAsj

@anujeet98
anujeet98 force-pushed the feat/mcp-deal-tools branch 2 times, most recently from 310d55f to a3d052d Compare September 15, 2026 12:36
Adds list_deals, get_deal, create_deal, and update_deal tools, gated
behind new deals:read/deals:write scopes. Reads go prisma-direct;
writes route through DealsService so validation and deal
activity-timeline events fire, tagged with a new 'mcp' activity
source.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rfj8fStgnMGjHZdLX8YAsj
Adds list_companies, get_company, create_company, and update_company
tools following the same pattern as the deal tools: reads go
prisma-direct for full control of scoping/ordering, writes route
through CompaniesService so validation and activity-timeline events
match the REST API, tagged with source: 'mcp'.

Adds companies:read/companies:write scopes and exports CompaniesService
from SalesModule for injection into McpController.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
anujeet98 and others added 4 commits September 15, 2026 20:08
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds a full-replace update_company_summary MCP tool for the company
detail page's rich-text summary (Editor.js), routed through
CompaniesService like the other write tools so it's tagged
source: 'mcp'. Block-level operations (edit/append a single block
without resending the whole document) are a planned follow-up.

Also fixes a latent bug in CompaniesService.update's activity-diff
loop: it compared object-valued fields with String(), which always
produces "[object Object]" — so summary (and custom `fields`) edits
never emitted a field_update activity event, via REST or MCP. Replaced
with a new jsonEqual helper (libs/sales/src/lib/utils/json-equal.ts)
that does an order-independent structural compare, since Postgres
jsonb does not preserve object key order on round-trip and a naive
JSON.stringify compare would produce false-positive diffs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
feat(mcp): add company management tools to MCP server
feat(mcp): add update_company_summary tool for Editor.js summaries
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants