Skip to content

feat(mcp): add lead MCP tools - #42

Merged
anujeet98 merged 1 commit into
mainfrom
feat/mcp-leads-tools
Sep 16, 2026
Merged

anujeet98 merged 1 commit into
mainfrom
feat/mcp-leads-tools

Conversation

@Rishavraaj

Copy link
Copy Markdown
Member

Summary

  • Adds MCP tools for lead management: list_leads, get_lead, create_lead, update_lead, delete_lead, convert_lead, revert_lead — mirrors LeadsController's REST surface
  • Wires leads:read/leads:write OAuth scopes for MCP clients

Changes

MCP server (apps/backend/src/app/mcp/mcp-server.ts)

  • Added the seven lead tools, scoped to the caller's organizations and gated by leads:read/leads:write
  • convert_lead/revert_lead delegate straight to LeadsService, so the same contact/company upsert and deal-cleanup logic the REST API uses applies
  • Extended McpDeps with leads: LeadsService
  • findLists (lead lists grouped by campaign) intentionally left out of MCP for now — add if a client needs it

Wiring

  • leads.module.ts: exports LeadsService (was previously only provided internally)
  • mcp.module.ts: imports LeadsModule
  • mcp.controller.ts: injects LeadsService, passes it into buildMcpServer
  • better-auth/auth.ts: adds leads:read/leads:write to MCP_SCOPES

Tests & docs

  • mcp-write-tools.spec.ts: 15 new tests covering all 7 tools (auth rejection, org resolution, not-found, delegation to LeadsService)
  • docs/concepts/mcp-server.mdx: scopes table rows + full tool reference section

Test plan

  • bun fmt clean
  • tsc --noEmit clean
  • vitest run mcp-write-tools.spec.ts — 77/77 passing (62 existing + 15 new)
  • CI

🤖 Generated with Claude Code

Adds list_leads, get_lead, create_lead, update_lead, delete_lead,
convert_lead, and revert_lead tools mirroring the LeadsController
REST surface, so MCP clients can manage leads alongside deals,
companies, contacts, and ICP profiles. Adds leads:read/leads:write
OAuth scopes, vitest coverage, and docs.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@anujeet98
anujeet98 merged commit ff96294 into main Sep 16, 2026
1 check passed
@anujeet98
anujeet98 deleted the feat/mcp-leads-tools branch September 16, 2026 10:57
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