atabey-mcp 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
File without changes
@@ -26,16 +26,16 @@ export function handleReadFile(projectRoot, args) {
26
26
  Metrics.logUsage(projectRoot, "@mcp", `read_file: ${args.path}`, tokens);
27
27
  return { content: [{ type: "text", text: sliced }] };
28
28
  }
29
- // Default protection limit: 1000 lines
30
- const DEFAULT_MAX_LINES = 1000;
31
- if (lines.length > DEFAULT_MAX_LINES) {
32
- const sliced = lines.slice(0, DEFAULT_MAX_LINES).join("\n");
33
- const tokens = Metrics.estimateTokens(sliced);
34
- Metrics.logUsage(projectRoot, "@mcp", `read_file: ${args.path} (truncated)`, tokens);
29
+ // ENFORCE TOKEN ECONOMY: Hard Limit for large files
30
+ const HARD_LIMIT_LINES = 500;
31
+ if (lines.length > HARD_LIMIT_LINES && (startLine === undefined || endLine === undefined)) {
32
+ const errMsg = `[TOKEN ECONOMY GUARD] File '${args.path}' is too large (${lines.length} lines). To prevent context overflow and token waste, you MUST provide both 'startLine' and 'endLine' parameters to read specific sections of this file.`;
33
+ Metrics.logError(projectRoot, "@mcp", `read_file: ${args.path} (blocked)`, errMsg);
35
34
  return {
35
+ isError: true,
36
36
  content: [{
37
37
  type: "text",
38
- text: `${sliced}\n\n... [TRUNCATED - File is too long (${lines.length} lines). Only the first ${DEFAULT_MAX_LINES} lines are shown. Use startLine and endLine parameters to read other parts of the file.]`
38
+ text: `[ERROR] ${errMsg}`
39
39
  }]
40
40
  };
41
41
  }
@@ -13,6 +13,18 @@ export async function handleWriteFile(projectRoot, args) {
13
13
  }
14
14
  try {
15
15
  const filePath = safePath(projectRoot, args.path);
16
+ // ENFORCE TOKEN ECONOMY: Prevent full-file rewrites of existing files
17
+ if (fs.existsSync(filePath)) {
18
+ const errMsg = `[TOKEN ECONOMY GUARD] The file '${args.path}' already exists. Overwriting entire existing files is FORBIDDEN to save tokens and prevent context drift. You MUST use 'patch_file' or 'replace_text' tools to make surgical edits.`;
19
+ Metrics.logError(projectRoot, "@mcp", `write_file: ${args.path} (blocked)`, errMsg);
20
+ return {
21
+ isError: true,
22
+ content: [{
23
+ type: "text",
24
+ text: `[ERROR] ${errMsg}`
25
+ }]
26
+ };
27
+ }
16
28
  const content = args.content;
17
29
  // ENFORCE PERMISSION MATRIX
18
30
  verifyWritePermission(projectRoot, args.path);
@@ -1,29 +1,17 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import { resolveFrameworkDir } from "../../utils/security.js";
1
+ import { Storage } from "../../utils/storage.js";
4
2
  /**
5
- * Extracts key insights from the project memory to minimize token usage.
3
+ * Extracts key insights from the SQLite database to minimize token usage.
6
4
  * Returns only the active phase, trace, and the last 5 decisions/tasks.
7
5
  */
8
- export function handleGetMemoryInsights(projectRoot, _args) {
6
+ export function handleGetMemoryInsights(_projectRoot, _args) {
9
7
  try {
10
- const frameworkDir = resolveFrameworkDir(projectRoot);
11
- const memoryPath = path.join(projectRoot, frameworkDir, "memory/PROJECT_MEMORY.md");
12
- if (!fs.existsSync(memoryPath)) {
13
- return { content: [{ type: "text", text: "New project: No history available." }] };
14
- }
15
- const content = fs.readFileSync(memoryPath, "utf8");
16
- const lines = content.split("\n");
17
- const activePhase = lines.find(l => l.includes("**Phase:**"))?.split("**Phase:**")[1]?.trim() || "Unknown";
18
- const activeTrace = lines.find(l => l.includes("**Trace ID:**"))?.split("**Trace ID:**")[1]?.trim() || "None";
19
- // Find the last 5 history items (heuristic)
20
- const historyStartIndex = lines.findIndex(l => l.toUpperCase().includes("HISTORY"));
8
+ const activePhase = Storage.getMetadata("phase") || "PHASE_0";
9
+ const activeTrace = Storage.getMetadata("traceId") || "None";
10
+ // Get the last 5 logs from SQLite
11
+ const recentLogs = Storage.getLogs().slice(0, 5);
21
12
  let recentHistory = "No history found.";
22
- if (historyStartIndex !== -1) {
23
- recentHistory = lines.slice(historyStartIndex + 1)
24
- .filter(l => l.trim().startsWith("-"))
25
- .slice(-5)
26
- .join("\n");
13
+ if (recentLogs.length > 0) {
14
+ recentHistory = recentLogs.map(log => `- [${log.agent}] ${log.action}: ${log.summary}`).join("\n");
27
15
  }
28
16
  const insights = `[MEMORY] **Memory Insights**\n- **Phase:** ${activePhase}\n- **Trace:** ${activeTrace}\n\n**Recent Actions:**\n${recentHistory}`;
29
17
  return { content: [{ type: "text", text: insights }] };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atabey-mcp",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Agent Atabey Model Context Protocol (MCP) Server",
5
5
  "author": "Yusuf BEKAR",
6
6
  "license": "MIT",