feat(mcp): add note tool registration adapter
This commit is contained in:
parent
c3831176a6
commit
91559004a8
@ -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<TInput> {
|
||||
description: string;
|
||||
requiredRole: NoteToolRole;
|
||||
readOnly: boolean;
|
||||
inputSchema: { parse(input: unknown): TInput };
|
||||
inputSchema: ZodTypeAny;
|
||||
execute(args: TInput, req: NotesMcpRequest): Promise<unknown>;
|
||||
}
|
||||
|
||||
|
||||
34
backend/src/mcp/register-note-tools.ts
Normal file
34
backend/src/mcp/register-note-tools.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import type { ZodTypeAny } from 'zod';
|
||||
import { NotesExecutableMcpTools } from './note-tools.js';
|
||||
|
||||
export interface RegisterableMcpTool<TInput = unknown> {
|
||||
name: string;
|
||||
description: string;
|
||||
requiredRole: 'viewer' | 'admin' | 'super_admin';
|
||||
inputSchema: ZodTypeAny;
|
||||
execute(args: TInput, req: unknown): Promise<unknown>;
|
||||
}
|
||||
|
||||
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,
|
||||
}));
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user