get_smart_context
Aggregate context from projects, tasks, and documents using natural language queries to find relevant information quickly.
Instructions
Get intelligent context aggregation based on natural language query across projects, tasks, and documents
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Natural language query describing what context you need (e.g., "authentication tasks", "API documentation", "blocked items") | |
| project_id | No | Optional project ID to scope the search | |
| context_types | No | Types of content to include in context | |
| max_results_per_type | No | Maximum results to return per content type | |
| include_related | No | Whether to include related/linked content |
Implementation Reference
- src/tools/context-aggregation.ts:95-148 (handler)The main handler function that executes the get_smart_context tool logic: parses input, analyzes query, fetches relevant projects/tasks/documents/conversations, finds related content, generates insights and a summary, and returns the aggregated context.
export const getSmartContext = requireAuth(async (args: any) => { const { query, project_id, context_types, max_results_per_type, include_related } = GetSmartContextSchema.parse(args) logger.info('Getting smart context', { query, project_id, context_types }) // Analyze query to understand intent and extract keywords const queryAnalysis = analyzeContextQuery(query) const context: any = { query_analysis: queryAnalysis, results: {}, related_content: {}, insights: {} } // Get relevant content for each requested type for (const type of context_types) { try { switch (type) { case 'projects': context.results.projects = await getRelevantProjects(queryAnalysis, project_id, max_results_per_type) break case 'tasks': context.results.tasks = await getRelevantTasks(queryAnalysis, project_id, max_results_per_type) break case 'documents': context.results.documents = await getRelevantDocuments(queryAnalysis, project_id, max_results_per_type) break case 'conversations': context.results.conversations = await getRelevantConversations(queryAnalysis, project_id, max_results_per_type) break } } catch (error) { logger.error(`Error getting ${type} context:`, error) context.results[type] = [] } } // Get related content if requested if (include_related) { context.related_content = await findRelatedContentInternal(context.results, queryAnalysis) } // Generate insights and recommendations context.insights = generateContextInsights(context.results, queryAnalysis) context.summary = generateSmartContextSummary(context, query) logger.info('Smart context generated', { query, total_results: Object.values(context.results).flat().length }) return context }) - Zod schema defining input validation for get_smart_context: query (required string), project_id (optional UUID), context_types (array with defaults), max_results_per_type (number with default 5), include_related (boolean, default true).
const GetSmartContextSchema = z.object({ query: z.string().min(1), project_id: z.string().uuid().optional(), context_types: z.array(z.enum(['projects', 'tasks', 'documents', 'conversations'])).default(['projects', 'tasks', 'documents']), max_results_per_type: z.number().int().positive().max(20).default(5), include_related: z.boolean().default(true) }) - src/tools/context-aggregation.ts:54-93 (registration)MCPTool registration object for get_smart_context: defines the tool name, description, and JSON Schema input schema that gets exposed via the MCP ListTools endpoint.
export const getSmartContextTool: MCPTool = { name: 'get_smart_context', description: 'Get intelligent context aggregation based on natural language query across projects, tasks, and documents', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'Natural language query describing what context you need (e.g., "authentication tasks", "API documentation", "blocked items")' }, project_id: { type: 'string', format: 'uuid', description: 'Optional project ID to scope the search' }, context_types: { type: 'array', items: { type: 'string', enum: ['projects', 'tasks', 'documents', 'conversations'] }, default: ['projects', 'tasks', 'documents'], description: 'Types of content to include in context' }, max_results_per_type: { type: 'number', minimum: 1, maximum: 20, default: 5, description: 'Maximum results to return per content type' }, include_related: { type: 'boolean', default: true, description: 'Whether to include related/linked content' } }, required: ['query'] } } - src/tools/context-aggregation.ts:724-730 (registration)Handler export map that maps the tool name 'get_smart_context' to its handler function, which is then merged in src/index.ts into the allHandlers object used by the CallToolRequest handler.
export const contextAggregationHandlers = { get_smart_context: getSmartContext, get_workspace_overview: getWorkspaceOverview, get_project_insights: getProjectInsights, find_related_content: findRelatedContent, generate_context_summary: generateContextSummary }