API Reference
Complete reference for the MCP tools exposed by Memoria.
Memoria is a tools-only MCP server. It does not expose Resources or Prompts, focusing instead on providing powerful analysis tools that work with any AI workflow.
Available Tools
Memoria exposes two primary tools via the Model Context Protocol:
analyze_file
Analyzes a file using git forensics to reveal hidden dependencies, risk factors, and coupled files. This is the primary tool for understanding code relationships.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
file | string | Yes | Absolute or relative path to the file to analyze |
Returns
A formatted analysis report containing:
- Risk Score — Composite score (0-100) based on volatility, coupling, and drift
- Volatility Analysis — Panic keyword frequency, bus factor, recent bug history
- Coupled Files — Files that change together with coupling percentage
- Stale Dependencies — Coupled files that are out of sync
- Static Imports — Files that explicitly import the target
- Evidence — Actual code diffs showing why files are related
Example Usage
// Ask your AI assistant:
"Analyze src/api/stripe/route.ts before I refactor it"
// The AI will call:
analyze_file({ file: "src/api/stripe/route.ts" })Example Response
MEMORIA ANALYSIS: src/api/stripe/route.ts
═══════════════════════════════════════════
RISK ASSESSMENT
───────────────
Overall Risk: 72/100 (HIGH)
- Volatility: 45% (3 panic commits in last 50)
- Bus Factor: 1 developer (byronwade)
- Drift Risk: 2 stale dependencies detected
COUPLED FILES (>15% correlation)
────────────────────────────────
1. dashboard/billing/page.tsx (85% coupled)
Last changed together: 3 days ago
Evidence: "refactor subscription webhook schema"
2. lib/stripe/client.ts (62% coupled)
Last changed together: 1 week ago
Evidence: "update stripe api version"
STALE DEPENDENCIES
──────────────────
⚠️ components/PricingTable.tsx
Last modified: 14 days ago
Target modified: 2 days ago
→ May need updating
STATIC IMPORTS
──────────────
Found 3 files importing this module:
- app/api/webhooks/stripe/route.ts
- lib/billing/subscription.ts
- tests/stripe.test.ts
RECOMMENDATIONS
───────────────
1. Review dashboard/billing/page.tsx for type compatibility
2. Check if PricingTable.tsx needs corresponding changes
3. Run tests/stripe.test.ts after modificationsask_history
Search git history to understand why code was written. Solves the “Chesterton's Fence” problem — understanding the reason behind code before removing or modifying it.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Natural language question or search term |
file | string | No | Limit search to a specific file's history |
Returns
Relevant commits and changes that answer the query:
- Matching Commits — Commits related to the query
- Code Changes — Relevant diffs from those commits
- Context — Commit messages explaining the changes
- Authors — Who made the changes and when
Example Usage
// Ask your AI assistant:
"Why was the rate limiter added to the API?"
// The AI will call:
ask_history({ query: "rate limiter API" })
// Or for a specific file:
"Why does this function handle null specially?"
ask_history({
query: "null handling",
file: "src/utils/parser.ts"
})Example Response
HISTORY SEARCH: "rate limiter API"
═══════════════════════════════════
RELEVANT COMMITS
────────────────
[a3f21b4] 2024-01-15 - Add rate limiting to prevent abuse
Author: byronwade <byron@example.com>
After the incident on Jan 12th where a misconfigured
client made 50k requests/minute, adding rate limiting
to all public API endpoints.
Limit: 100 requests/minute per IP
Returns: 429 Too Many Requests when exceeded
+ import { rateLimit } from '@/lib/rate-limit'
+
+ const limiter = rateLimit({
+ interval: 60 * 1000,
+ uniqueTokenPerInterval: 500,
+ })
[b7c92e1] 2024-01-12 - HOTFIX: disable public API
Author: byronwade <byron@example.com>
Emergency disable - API being hammered by runaway client.
TODO: Add rate limiting before re-enabling.
SUMMARY
───────
Rate limiting was added after a Jan 12th incident where
a misconfigured client made excessive requests. The limit
is 100 req/min per IP. Consider this context before
modifying rate limit values.Tool Schemas
For MCP client developers, here are the JSON schemas for each tool:
analyze_file Schema
{
"name": "analyze_file",
"description": "Analyze a file using git forensics to reveal hidden dependencies, risk factors, and coupled files.",
"inputSchema": {
"type": "object",
"properties": {
"file": {
"type": "string",
"description": "Path to the file to analyze"
}
},
"required": ["file"]
}
}ask_history Schema
{
"name": "ask_history",
"description": "Search git history to understand why code was written or changed.",
"inputSchema": {
"type": "object",
"properties": {
"query": {
"type": "string",
"description": "Natural language question or search term"
},
"file": {
"type": "string",
"description": "Optional: limit search to a specific file"
}
},
"required": ["query"]
}
}Error Handling
Tools return structured error messages when issues occur:
| Error | Cause | Solution |
|---|---|---|
File not found | The specified file doesn't exist | Check the file path is correct |
Not a git repository | No .git directory in project | Run git init first |
No git history | File has no commits yet | Commit the file first |
Analysis timeout | Repository too large | Add ignore patterns in .memoria.json |
Output Format
Memoria formats output as structured text optimized for LLM consumption. The format includes:
- Clear section headers using ASCII art dividers
- Structured data in lists and tables
- Actionable recommendations for the AI to follow
- Evidence blocks with actual code diffs
This format ensures the AI understands the context and makes informed decisions about code changes.
Token Efficiency
Each analysis uses approximately 600 tokens on average. Results are cached for 5 minutes, making repeat queries nearly instant with minimal token overhead.