Add session management MCP tools (Phase 3)
Implemented 8 new session management tools: - session_start: Initialize session with metadata tracking - session_update: Update session metrics during execution - session_end: Close session with summary and embedding - session_list: List sessions with filtering - session_search: Semantic search across sessions - session_context: Get complete session context (tasks, commits, builds, memories) - build_record: Link builds to sessions and versions - session_commit_link: Link commits to sessions Enhanced existing tools: - memory_add: Added session_id and task_id parameters - Updated all memory queries to use 'memories' table (renamed from session_memories) Implementation: - Created src/tools/sessions.ts with all session operations - Updated src/tools/memories.ts for new schema - Added 8 session tool definitions to src/tools/index.ts - Registered all session tools in src/index.ts switch statement - TypeScript compilation successful Related: CF-167 (Fix shared session-summary.md file conflict)
This commit is contained in:
@@ -559,6 +559,8 @@ export const toolDefinitions = [
|
||||
content: { type: 'string', description: 'The learning/insight to remember' },
|
||||
context: { type: 'string', description: 'When/where this applies (optional)' },
|
||||
project: { type: 'string', description: 'Project this relates to (optional)' },
|
||||
session_id: { type: 'string', description: 'Session ID to link memory to (optional)' },
|
||||
task_id: { type: 'string', description: 'Task ID to link memory to (optional)' },
|
||||
},
|
||||
required: ['category', 'title', 'content'],
|
||||
},
|
||||
@@ -600,4 +602,120 @@ export const toolDefinitions = [
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// Session Management Tools
|
||||
{
|
||||
name: 'session_start',
|
||||
description: 'Start a new session with metadata tracking',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
session_id: { type: 'string', description: 'Session ID (auto-generated if not provided)' },
|
||||
project: { type: 'string', description: 'Project key (e.g., CF, VPN)' },
|
||||
working_directory: { type: 'string', description: 'Current working directory' },
|
||||
git_branch: { type: 'string', description: 'Current git branch' },
|
||||
initial_prompt: { type: 'string', description: 'First user message' },
|
||||
},
|
||||
required: ['project'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'session_update',
|
||||
description: 'Update session metrics (message count, tokens, tools used)',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
session_id: { type: 'string', description: 'Session ID to update' },
|
||||
message_count: { type: 'number', description: 'Number of messages exchanged' },
|
||||
token_count: { type: 'number', description: 'Total tokens used' },
|
||||
tools_used: {
|
||||
type: 'array',
|
||||
items: { type: 'string' },
|
||||
description: 'Array of tool names used',
|
||||
},
|
||||
},
|
||||
required: ['session_id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'session_end',
|
||||
description: 'End session and generate summary with embedding',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
session_id: { type: 'string', description: 'Session ID to end' },
|
||||
summary: { type: 'string', description: 'Session summary text' },
|
||||
status: { type: 'string', enum: ['completed', 'interrupted'], description: 'Session completion status (default: completed)' },
|
||||
},
|
||||
required: ['session_id', 'summary'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'session_list',
|
||||
description: 'List sessions with filtering and pagination',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
project: { type: 'string', description: 'Filter by project key' },
|
||||
status: { type: 'string', enum: ['active', 'completed', 'interrupted'], description: 'Filter by status' },
|
||||
since: { type: 'string', description: 'Show sessions since date (ISO format)' },
|
||||
limit: { type: 'number', description: 'Max results (default: 20)' },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'session_search',
|
||||
description: 'Find similar sessions using vector search',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
query: { type: 'string', description: 'Search query' },
|
||||
project: { type: 'string', description: 'Filter by project (optional)' },
|
||||
limit: { type: 'number', description: 'Max results (default: 5)' },
|
||||
},
|
||||
required: ['query'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'session_context',
|
||||
description: 'Get complete context: tasks, commits, builds, memories',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
session_id: { type: 'string', description: 'Session ID to get context for' },
|
||||
},
|
||||
required: ['session_id'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'build_record',
|
||||
description: 'Record build information linked to session and version',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
session_id: { type: 'string', description: 'Session ID (optional)' },
|
||||
version_id: { type: 'string', description: 'Version ID being built' },
|
||||
build_number: { type: 'number', description: 'Build number' },
|
||||
git_commit_sha: { type: 'string', description: 'Git commit SHA' },
|
||||
status: { type: 'string', description: 'Build status (pending, running, success, failed)' },
|
||||
started_at: { type: 'string', description: 'Build start timestamp (ISO format)' },
|
||||
},
|
||||
required: ['version_id', 'build_number', 'status', 'started_at'],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'session_commit_link',
|
||||
description: 'Link a commit to a session (automatically called when commits are made)',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
session_id: { type: 'string', description: 'Session ID' },
|
||||
commit_sha: { type: 'string', description: 'Git commit SHA' },
|
||||
repo: { type: 'string', description: 'Repository (e.g., christian/ClaudeFramework)' },
|
||||
commit_message: { type: 'string', description: 'Commit message (optional)' },
|
||||
committed_at: { type: 'string', description: 'Commit timestamp (ISO format, optional)' },
|
||||
},
|
||||
required: ['session_id', 'commit_sha', 'repo'],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user