-
-
Notifications
You must be signed in to change notification settings - Fork 28
MCP Tools
This document provides a comprehensive reference for the tools exposed by the In Memoria Model Context Protocol (MCP) server. AI agents should use this guide to understand how to interact with the codebase intelligence system.
For optimal performance and context-awareness, AI agents should follow this general workflow when starting a new task:
-
Get Project Overview: Call
get_project_blueprint()to quickly understand the project's structure, technology stack, and key files. This is a low-cost way to get initial bearings. -
Ensure Intelligence is Fresh: Call
auto_learn_if_needed(). This tool will check if the persisted intelligence is stale or missing and will automatically trigger the learning process if necessary. It's a safe and efficient way to ensure you are working with up-to-date information. -
Predict and Search: Use tools like
predict_coding_approach()for high-level implementation guidance andsearch_codebase()to find specific examples or relevant files. -
Contribute Back: As you work, use
contribute_insights()to record important decisions, new patterns, or bug fixes. This enriches the knowledge base for future sessions.
The tools are organized into four categories:
These tools provide direct, real-time analysis of the codebase without relying on the pre-learned intelligence store. They are useful for inspecting the current state of files.
Source: src/mcp-server/tools/core-analysis.ts
Analyzes a directory or a single file to provide a comprehensive overview, including concepts, patterns, and complexity metrics.
Parameters
-
path(string, required): The absolute path to the codebase directory or specific file to analyze. -
includeFileContent(boolean, optional): Iftrueand the path is a file, the full file content will be included in the response. Defaults tofalse.
Returns
A JSON object containing the analysis result. The structure differs depending on whether a file or a directory was analyzed.
-
For a directory:
{ "path": "/path/to/project", "type": "codebase", "languages": ["typescript", "rust"], "frameworks": ["React", "Node.js"], "complexity": { "cyclomatic": 15.2, "cognitive": 25.0, "lines": 12034 }, "topConcepts": [ { "name": "UserSerivce", "type": "class", "confidence": 0.9 } ], "topPatterns": [ { "type": "naming_camelCase", "description": "...", "frequency": 50 } ], "summary": { "totalConcepts": 150, "totalPatterns": 25 } } -
For a file:
{ "type": "file", "path": "/path/to/project/src/index.ts", "language": "typescript", "lineCount": 150, "size": 4500, "concepts": [ { "name": "main", "type": "function", "confidence": 0.8, "line": 10 } ], "patterns": [ { "type": "arrow_function", "description": "..." } ], "complexity": { "cyclomatic": 5, "cognitive": 8, "lines": 150 } }
Performs a powerful search within the codebase using semantic (meaning-based), text (keyword-based), or pattern-based queries.
Parameters
-
query(string, required): The search query. -
type(enum, optional): The type of search. Can besemantic,text, orpattern. Defaults totext. -
language(string, optional): Filters the search to a specific programming language (e.g.,typescript,python). -
limit(number, optional): The maximum number of results to return. Defaults to 20.
Returns
A JSON object containing the search results.
{
"results": [
{
"file": "src/auth/auth.service.ts",
"content": "export class AuthService { ... }",
"score": 0.89,
"context": "> 10: export class AuthService {
11: constructor(private readonly jwtService: JwtService) {}",
"metadata": {
"lineNumber": 10,
"type": "semantic"
}
}
],
"totalFound": 1,
"searchType": "semantic"
}These tools query the persistent knowledge base that In Memoria has built about your project. They provide deep insights, recommendations, and predictions based on learned patterns.
Source: src/mcp-server/tools/intelligence-tools.ts
Triggers the deep learning process to analyze a codebase and build the persistent knowledge base. This is a long-running operation.
Parameters
-
path(string, required): The path to the codebase to learn from. -
force(boolean, optional): Iftrue, forces re-learning even if up-to-date intelligence already exists. Defaults tofalse.
Returns
A JSON object summarizing the learning process.
{
"success": true,
"conceptsLearned": 245,
"patternsLearned": 42,
"insights": [
"🔍 Phase 1: Analyzing codebase structure...",
"🧠 Phase 2: Learning semantic concepts...",
"✅ Extracted 245 semantic concepts",
"⚡ Learning completed in 45231ms"
],
"timeElapsed": 45231
}Provides a quick, token-efficient overview of the project's architecture, tech stack, and key files. This is the ideal first tool to call.
Parameters
-
path(string, optional): The path to the project. Defaults to the current working directory. -
includeFeatureMap(boolean, optional): Iftrue, includes a mapping of features to files. Defaults totrue.
Returns
A JSON object containing the project blueprint.
{
"techStack": ["TypeScript", "React", "Node.js", "Express"],
"entryPoints": {
"web": "src/index.tsx",
"api": "src/server.ts"
},
"keyDirectories": {
"components": "src/components",
"services": "src/services",
"auth": "src/auth"
},
"architecture": "Component-Based (React)",
"featureMap": {
"authentication": ["src/auth/auth.service.ts", "src/auth/Login.tsx"]
},
"learningStatus": {
"hasIntelligence": true,
"isStale": false,
"conceptsStored": 245,
"patternsStored": 42,
"recommendation": "ready",
"message": "Intelligence is ready!"
}
}Retrieves detailed information about the learned semantic concepts and their relationships.
Parameters
-
query(string, optional): A string to filter concepts by name. -
conceptType(string, optional): Filter by type (e.g.,class,function). -
limit(number, optional): Maximum number of insights to return. Defaults to 10.
Returns
{
"insights": [
{
"concept": "UserService",
"relationships": ["implements IUserService", "called_by AuthController"],
"usage": { "frequency": 95, "contexts": ["src/services/user.service.ts"] },
"evolution": { "firstSeen": "...", "lastModified": "...", "changeCount": 5 }
}
],
"totalAvailable": 25
}Gets intelligent coding pattern recommendations based on the current context and problem description.
Parameters
-
problemDescription(string, required): A description of the coding task or problem. -
currentFile(string, optional): The path to the file currently being edited. -
selectedCode(string, optional): The code snippet the user has selected. -
includeRelatedFiles(boolean, optional): Iftrue, suggests other files where similar patterns are used.
Returns
{
"recommendations": [
{
"pattern": "service_layer_pattern",
"description": "Use a service class to encapsulate business logic.",
"confidence": 0.92,
"examples": ["export class UserService { ... }"],
"reasoning": "Based on 12 similar occurrences in your codebase, especially in the services/ directory."
}
],
"reasoning": "Found 3 relevant patterns based on your coding history.",
"relatedFiles": ["src/services/order.service.ts"]
}Predicts the most likely high-level coding approach a developer would take, based on learned patterns.
Parameters
-
problemDescription(string, required): A description of the coding problem. -
context(object, optional): Additional context (e.g.,{ "isApi": true }). -
includeFileRouting(boolean, optional): Iftrue, includes smart routing to target files.
Returns
{
"approach": "Create a new controller and service, following the existing REST API pattern.",
"confidence": 0.88,
"reasoning": "The problem description mentions 'endpoint', and the project consistently uses a service/controller pattern for APIs.",
"suggestedPatterns": ["service_layer", "controller_pattern"],
"estimatedComplexity": "medium",
"fileRouting": {
"intendedFeature": "api",
"targetFiles": ["src/controllers/new.controller.ts", "src/services/new.service.ts"],
"workType": "feature",
"suggestedStartPoint": "src/controllers/new.controller.ts",
"confidence": 0.9
}
}Retrieves the learned profile of the developer, including preferred patterns and coding style.
Parameters
-
includeRecentActivity(boolean, optional): Iftrue, includes recent focus areas. -
includeWorkContext(boolean, optional): Iftrue, includes the current work session context.
Returns
{
"preferredPatterns": [ { "pattern": "async_await", "confidence": 0.98, ... } ],
"codingStyle": {
"namingConventions": { "functions": "camelCase", "classes": "PascalCase" },
"structuralPreferences": ["modular_design"],
"testingApproach": "unit_testing_with_jest"
},
"expertiseAreas": ["typescript", "react", "node.js"],
"recentFocus": ["authentication", "api_design"]
}Allows an AI agent to contribute knowledge back to the database, such as a new bug pattern or an architectural decision.
Parameters
-
type(enum, required): The type of insight. Can bebug_pattern,optimization,refactor_suggestion, orbest_practice. -
content(object, required): The details of the insight. -
confidence(number, required): The agent's confidence in the insight (0.0 to 1.0). -
sourceAgent(string, required): An identifier for the AI agent. -
sessionUpdate(object, optional): An optional update to the current work session.
Returns
{
"success": true,
"insightId": "insight_1678886400000",
"message": "Insight contributed successfully and pending validation."
}These tools help automate the learning and setup process.
Source: src/mcp-server/tools/automation-tools.ts
This is a key tool for seamless agent integration. It checks if the codebase intelligence is missing or stale and automatically triggers the learning process if needed. It can also perform a full project setup.
Parameters
-
path(string, optional): Path to the codebase. Defaults to the current directory. -
force(boolean, optional): Iftrue, forces re-learning even if data is current. Defaults tofalse. -
includeProgress(boolean, optional): Iftrue, streams detailed progress information. Defaults totrue. -
skipLearning(boolean, optional): Iftrue, skips the learning phase. Useful for a quick setup verification. Defaults tofalse. -
includeSetupSteps(boolean, optional): Iftrue, the tool will perform a full setup, including project checks and database initialization, and return detailed step-by-step results. Defaults tofalse.
Returns
A JSON object indicating the action taken.
-
If learning is performed:
{ "action": "learned", "conceptsLearned": 245, "patternsLearned": 42, "filesAnalyzed": 150, "timeElapsed": 45231, "message": "✅ Learning completed!" } -
If learning is skipped:
{ "action": "skipped", "reason": "Intelligence data is up-to-date", "status": { ... } } -
If setup is performed:
{ "success": true, "action": "setup_completed", "steps": [ { "step": "project_check", "status": "completed", ... } ], "message": "✅ Quick setup completed!" }
These tools provide insights into the health and performance of the In Memoria system itself.
Source: src/mcp-server/tools/monitoring-tools.ts
Retrieves a comprehensive status report of the system, including component health and metrics.
Parameters
-
includeMetrics(boolean, optional): Iftrue, includes detailed performance metrics. Defaults totrue. -
includeDiagnostics(boolean, optional): Iftrue, includes system diagnostics. Defaults tofalse.
Returns
{
"success": true,
"status": {
"version": "0.5.4",
"status": "operational",
"components": { "database": { "status": "healthy" } },
"intelligence": { "status": "ready", "conceptCount": 245 },
"performance": { "memory": { "heapUsed": 150 }, ... }
}
}Gets detailed metrics about the contents of the intelligence database.
Parameters
-
includeBreakdown(boolean, optional): Iftrue, includes detailed breakdowns by type and confidence. Defaults totrue.
Returns
{
"success": true,
"metrics": {
"concepts": {
"total": 245,
"breakdown": { "byType": { "function": 150, "class": 50 } }
},
"patterns": {
"total": 42,
"breakdown": { "byType": { "naming": 20, "structural": 10 } }
},
"quality": { "averageConfidence": 0.85 }
}
}Retrieves performance metrics, including memory usage, query times, and an optional benchmark.
Parameters
-
runBenchmark(boolean, optional): Iftrue, runs a quick performance benchmark. Defaults tofalse.
Returns
{
"success": true,
"performance": {
"memory": { "rss": 200, "heapUsed": 150 },
"system": { "nodeVersion": "v18.16.0", "platform": "darwin-arm64" },
"database": { "size": { "mb": 15.5 } },
"benchmark": { "conceptQuery": 50, "patternQuery": 75 }
}
}The following tools were deprecated in version 0.5.x to improve the agent experience. Their functionality has been merged into other tools.
-
get_file_content: Merged intoanalyze_codebase. To get file content, callanalyze_codebasewith a file path and setincludeFileContent: true. -
get_learning_status: Merged intoget_project_blueprint. The blueprint now includes alearningStatusobject. -
quick_setup: Merged intoauto_learn_if_needed. To perform a full setup, callauto_learn_if_neededwithincludeSetupSteps: true.