From 91559004a8e800e6bf322977a0c2d3830b271ae8 Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Tue, 10 Mar 2026 09:15:28 -0700 Subject: [PATCH] feat(mcp): add note tool registration adapter --- backend/src/mcp/note-tools.ts | 3 ++- backend/src/mcp/register-note-tools.ts | 34 ++++++++++++++++++++++++++ docs/ROADMAP.md | 5 ++++ docs/roadmaps/05_MCP_AGENT_ROADMAP.md | 11 +++++++-- 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 backend/src/mcp/register-note-tools.ts diff --git a/backend/src/mcp/note-tools.ts b/backend/src/mcp/note-tools.ts index dd62b82..11a1458 100644 --- a/backend/src/mcp/note-tools.ts +++ b/backend/src/mcp/note-tools.ts @@ -1,4 +1,5 @@ import { randomUUID } from 'node:crypto'; +import type { ZodTypeAny } from 'zod'; import { PRODUCT_ID } from '../lib/product-config.js'; import { createNote, getNote, listNotes } from '../modules/notes/repository.js'; import type { NoteDoc } from '../modules/notes/types.js'; @@ -37,7 +38,7 @@ export interface NotesMcpTool { description: string; requiredRole: NoteToolRole; readOnly: boolean; - inputSchema: { parse(input: unknown): TInput }; + inputSchema: ZodTypeAny; execute(args: TInput, req: NotesMcpRequest): Promise; } diff --git a/backend/src/mcp/register-note-tools.ts b/backend/src/mcp/register-note-tools.ts new file mode 100644 index 0000000..e3c96f6 --- /dev/null +++ b/backend/src/mcp/register-note-tools.ts @@ -0,0 +1,34 @@ +import type { ZodTypeAny } from 'zod'; +import { NotesExecutableMcpTools } from './note-tools.js'; + +export interface RegisterableMcpTool { + name: string; + description: string; + requiredRole: 'viewer' | 'admin' | 'super_admin'; + inputSchema: ZodTypeAny; + execute(args: TInput, req: unknown): Promise; +} + +export type RegisterToolFn = (tool: RegisterableMcpTool) => void; + +export function registerNotesMcpTools(registerTool: RegisterToolFn): void { + for (const tool of NotesExecutableMcpTools) { + registerTool({ + name: tool.name, + description: tool.description, + requiredRole: tool.requiredRole, + inputSchema: tool.inputSchema, + execute: tool.execute, + }); + } +} + +export function getNotesMcpToolsForRegistration(): RegisterableMcpTool[] { + return NotesExecutableMcpTools.map(tool => ({ + name: tool.name, + description: tool.description, + requiredRole: tool.requiredRole, + inputSchema: tool.inputSchema, + execute: tool.execute, + })); +} diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index 00b8e17..e1477d1 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -285,6 +285,11 @@ Detailed implementation plans live under `docs/roadmaps/`. - 2026-03-10 — MCP design work materially advanced: - product-side MCP core tool contracts now exist under `backend/src/mcp/` - namespace, role gating, read-only vs mutating classification, workspace scoping, and dry-run/idempotency/correlation expectations are now encoded for the first core tool set +- 2026-03-10 — MCP execution and registration materially advanced: + - product-side executable note MCP tools now exist for list/get/search/create-draft + - the mutating create-draft path now records a `note-agent-actions` audit/proposal document + - product-side MCP note tools now export through a registration adapter compatible with the shared `mcp-server` tool model + - backend typecheck passes and backend tests pass with MCP execution coverage included - 2026-03-10 — Mobile workstream materially advanced: - `learning_ai_notes/mobile/` was scaffolded from scratch - Expo + TypeScript root config and Expo Router entrypoints now exist diff --git a/docs/roadmaps/05_MCP_AGENT_ROADMAP.md b/docs/roadmaps/05_MCP_AGENT_ROADMAP.md index 91c8a4e..9364747 100644 --- a/docs/roadmaps/05_MCP_AGENT_ROADMAP.md +++ b/docs/roadmaps/05_MCP_AGENT_ROADMAP.md @@ -21,6 +21,7 @@ Parent: `docs/ROADMAP.md` - [x] Workspace-scoped retrieval - [x] Define tool input/output schemas - [x] Add product-side executable tool layer +- [x] Add product-side registration/export adapter # Phase A2 — Agent Workflows @@ -65,6 +66,11 @@ Parent: `docs/ROADMAP.md` - dry-run draft preview behavior - persisted draft creation with `note-agent-actions` audit/proposal record creation - Vitest coverage for executable MCP tools +- 2026-03-10 — Product-side MCP registration/export adapter added under `backend/src/mcp/register-note-tools.ts`. +- Compatibility work now includes: + - an adapter that exports the note tools in a shape compatible with shared `mcp-server` registration + - a clear product-side handoff point for future shared-server wiring + - backend verification still passing after the adapter layer was introduced # Open Questions @@ -74,8 +80,8 @@ Parent: `docs/ROADMAP.md` # Blockers -- `mcp-server` registration and product client execution wiring have not been implemented yet. -- Shared-server registration/auth-boundary review is still pending. +- Shared `mcp-server` registration hookup has not been implemented in the common platform repo yet. +- Shared-server auth-boundary review is still pending. # Deferred @@ -87,5 +93,6 @@ Parent: `docs/ROADMAP.md` # Done When - [x] MCP tools cover core note workflows at the product-backend execution layer +- [x] Product-side MCP tools are exportable in a shared-server-compatible registration shape - [ ] Mutating tool paths are auditable and scoped - [ ] Coding agents have clear contracts for using tools safely