atabey-mcp 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +125 -89
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,12 +1,21 @@
1
- # [GOV] Atabey MCP — MCP Server for AI Governance & Multi-Agent Platform / Orchestrator
1
+ # [GOV] Atabey MCP — MCP Server for AI Governance & Multi-Agent Orchestration
2
2
 
3
- [![Version](https://img.shields.io/badge/Version-v0.1.0-blue.svg)](https://github.com/ysf-bkr/atabey)
3
+ [![Version](https://img.shields.io/badge/Version-v0.1.2-blue.svg)](https://github.com/ysf-bkr/atabey)
4
4
  [![npm](https://img.shields.io/npm/v/atabey-mcp)](https://www.npmjs.com/package/atabey-mcp)
5
5
  [![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
6
6
  [![MCP](https://img.shields.io/badge/MCP-Compatible-green.svg)](https://modelcontextprotocol.io)
7
7
  [![MCP Tools](https://img.shields.io/badge/MCP%20Tools-40-blue)](https://github.com/ysf-bkr/atabey)
8
8
 
9
- **Atabey MCP** is the MCP (Model Context Protocol) server component of the Atabey framework. It provides 40 MCP tools, a multi-layer governance pipeline (validation, PII masking, discipline, loop detection, token limits, CRUD governance, risk gating, and more), vector memory, risk engine, loop detection, token accounting, auto-rollback, prompt injection protection, and a real-time WebSocket event stream.
9
+ **Atabey MCP** is the MCP (Model Context Protocol) server component of the Atabey framework. It provides **40 MCP tools** and a multi-layer governance pipeline (validation, PII masking, discipline, loop detection, token limits, CRUD governance, risk gating and more), vector memory, risk engine, auto-rollback, prompt-injection protection and a real-time event stream.
10
+
11
+ **Atabey** is a **local AI control plane & discipline layer** that sits between your
12
+ codebase and your local AI coding assistants. It does **not** write code and does **not**
13
+ host an LLM — it **disciplines, bounds and coordinates** the assistant you already use
14
+ through the Model Context Protocol (MCP).
15
+
16
+ > "Order from Chaos" — keeps AI coding assistants focused, blocks destructive actions,
17
+ > rolls back broken edits, prevents runaway token loops, and records an audit trail.
18
+
10
19
 
11
20
  ---
12
21
 
@@ -15,11 +24,11 @@
15
24
  | Capability | Description |
16
25
  |-----------|-------------|
17
26
  | **MCP Tools** | 40 tools across 9 categories: file system, search, messaging, governance, memory, quality, network, orchestration, API catalog |
18
- | **Governance Pipeline** | Multi-layer pre/post execution validation: PII masking, risk gate, discipline, loop detection, token limits, license scan, CRUD governance, and more |
19
- | **Memory** | Vector memory with TF-IDF/OpenAI embeddings, project memory, knowledge base |
20
- | **Observability** | Headless HTTP/SSE server (`/mcp/*`) and a real-time WebSocket event stream (agents, Hermes, token accounting, compliance, loop detection) |
21
- | **Auth** | Bearer token authentication for HTTP/SSE mode |
22
- | **Multi-Transport** | Stdio (per-developer) + HTTP/SSE (team server) |
27
+ | **Governance Pipeline** | Multi-layer pre/post execution validation: PII masking, risk gate, discipline, loop detection, token limits, license scan, CRUD governance |
28
+ | **Memory** | Vector memory (TF-IDF/OpenAI embeddings), project memory, knowledge base |
29
+ | **Observability** | Headless HTTP/SSE server (`/mcp/*`) + real-time WebSocket event stream |
30
+ | **Auth** | Bearer-token authentication for HTTP/SSE mode |
31
+ | **Transport** | Stdio (per-developer) + HTTP/SSE (team server) |
23
32
 
24
33
  ---
25
34
 
@@ -32,12 +41,13 @@ npm install -g atabey-mcp
32
41
  ## Quick Start
33
42
 
34
43
  ```bash
35
- # Start MCP server (stdio mode)
44
+ # Stdio mode (default — spawned by your IDE/CLI)
36
45
  atabey-mcp
37
46
 
38
- # Start unified HTTP/SSE server
47
+ # Unified HTTP/SSE server
39
48
  MCP_TRANSPORT=unified MCP_PORT=5858 atabey-mcp
40
- # API: http://localhost:5858/api WS: ws://localhost:5858/ws
49
+ # MCP SSE: http://localhost:5858/mcp/sse
50
+ # Hermes Bus: ws://localhost:5858/bus
41
51
  ```
42
52
 
43
53
  ---
@@ -47,7 +57,7 @@ MCP_TRANSPORT=unified MCP_PORT=5858 atabey-mcp
47
57
  ### File System (5)
48
58
  | Tool | Description |
49
59
  |------|-------------|
50
- | `read_file` | Read file content with line range support |
60
+ | `read_file` | Read file content with line-range support |
51
61
  | `write_file` | Write content to file, auto-create directories |
52
62
  | `replace_text` | Surgical string replacement |
53
63
  | `batch_surgical_edit` | Multi-file batch surgical edits |
@@ -59,7 +69,7 @@ MCP_TRANSPORT=unified MCP_PORT=5858 atabey-mcp
59
69
  | `list_dir` | List directory contents |
60
70
  | `grep_search` | Recursive regex search |
61
71
  | `get_project_map` | Tree-view project structure |
62
- | `get_project_gaps` | TODO/FIXME/empty function scan |
72
+ | `get_project_gaps` | TODO/FIXME/empty-function scan |
63
73
  | `get_symbol_outline` | AST-lite symbol map with line ranges |
64
74
  | `get_task_context` | Targeted context bundle from the CodeGraph (no repo re-scan) |
65
75
 
@@ -77,33 +87,33 @@ MCP_TRANSPORT=unified MCP_PORT=5858 atabey-mcp
77
87
  | `get_system_health` | CPU/RAM metrics |
78
88
  | `check_active_ports` | Active port scan |
79
89
  | `get_framework_status` | Phase, trace, agent states |
80
- | `read_project_memory` | Read PROJECT_MEMORY.md |
90
+ | `read_project_memory` | Read `PROJECT_MEMORY.md` |
81
91
  | `get_memory_insights` | Memory summary |
82
92
  | `update_project_memory` | Update memory |
83
93
  | `orchestrate_loop` | Process Hermes messages |
84
- | `submit_plan` | Submit DAG plan |
94
+ | `submit_plan` | Submit a DAG plan |
85
95
 
86
96
  ### Control Plane (3)
87
97
  | Tool | Description |
88
98
  |------|-------------|
89
- | `acquire_lock` | Lock shared resource |
90
- | `release_lock` | Release lock |
91
- | `register_agent` | Register agent instance |
99
+ | `acquire_lock` | Lock a shared resource |
100
+ | `release_lock` | Release a lock |
101
+ | `register_agent` | Register an agent instance |
92
102
 
93
103
  ### Memory & Knowledge (4)
94
104
  | Tool | Description |
95
105
  |------|-------------|
96
106
  | `store_knowledge` | Store to vector memory |
97
107
  | `search_knowledge` | Search vector memory |
98
- | `delete_knowledge` | Delete knowledge entry |
108
+ | `delete_knowledge` | Delete a knowledge entry |
99
109
  | `update_contract_hash` | Update contract hash |
100
110
 
101
111
  ### Messaging & Human (3)
102
112
  | Tool | Description |
103
113
  |------|-------------|
104
114
  | `send_agent_message` | Hermes agent-to-agent message |
105
- | `log_agent_action` | Log to framework |
106
- | `ask_human` | Ask developer a question |
115
+ | `log_agent_action` | Log to the framework |
116
+ | `ask_human` | Ask the developer a question |
107
117
 
108
118
  ### Compliance & Quality (4)
109
119
  | Tool | Description |
@@ -116,64 +126,62 @@ MCP_TRANSPORT=unified MCP_PORT=5858 atabey-mcp
116
126
  ### Operations (3)
117
127
  | Tool | Description |
118
128
  |------|-------------|
119
- | `approve_operation` | In-chat risk gate approval |
120
- | `http_proxy_request` | Secure HTTP proxy |
129
+ | `approve_operation` | In-chat risk-gate approval |
130
+ | `http_proxy_request` | Secure HTTP proxy (SSRF-guarded) |
121
131
  | `audit_dependencies` | Unused package audit |
122
132
 
123
- ---
124
-
125
- ## 🔐 Multi-Layer Governance Pipeline
133
+ ## Multi-Layer Governance Pipeline
126
134
 
127
- Every MCP tool call passes through this pipeline:
135
+ Every MCP tool call passes through this **fail-closed** pipeline:
128
136
 
129
137
  ```
130
138
  CallToolRequest
131
139
  ↓
132
- 1. [VALIDATION] Zod schema validation
133
- 2. [GOVERNANCE] validateArgsAgainstRules()
134
- 3. [DISCIPLINE] enforceDiscipline()
135
- 4. [LOOP DETECTION] recordAndCheck() + cooldown
136
- 5. [TOKEN LIMITS] enforceTokenBudgetPreCall() + checkTokenBudget()
137
- 6. [LICENSE] validateLicenseCompliance()
138
- 7. [AUTO-ROLLBACK] prepareWrite() snapshot
139
- 8. [HUMAN-IN-LOOP] RiskEngine.assessTaskRisk() + checkRiskGate()
140
- 9. [PII MASKING] maskToolArgs() → mask before handler
141
- 10. [EXECUTION] Tool handler runs
142
- 11. [POST-VALIDATION] scanFileForViolations() → rollback if needed
143
- 12. [INJECTION PROTECTION] sanitizeResponse()
144
- 13. [PII MASKING] maskToolResult() → mask before returning to AI
140
+ 1. [VALIDATION] Zod schema validation
141
+ 2. [GOVERNANCE] validateArgsAgainstRules()
142
+ 3. [DISCIPLINE] enforceDiscipline()
143
+ 4. [LOOP DETECTION] recordAndCheck() + cooldown
144
+ 5. [TOKEN LIMITS] enforceTokenBudgetPreCall() + checkTokenBudget()
145
+ 6. [LICENSE] validateLicenseCompliance()
146
+ 7. [AUTO-ROLLBACK] prepareWrite() snapshot
147
+ 8. [HUMAN-IN-LOOP] RiskEngine.assessTaskRisk() + checkRiskGate()
148
+ 9. [PII MASKING] maskToolArgs() → mask before handler
149
+ 10. [EXECUTION] Tool handler runs
150
+ 11. [POST-VALIDATION] scanFileForViolations() → rollback if needed
151
+ 12. [INJECTION PROTECTION] sanitizeResponse()
152
+ 13. [PII MASKING] maskToolResult() → mask before returning to AI
145
153
  ↓
146
- Return governed result
154
+ Return governed result
147
155
  ```
148
156
 
157
+ A control that cannot run **denies** the operation rather than passing it silently.
158
+
159
+
149
160
  ### Pipeline Details
150
161
 
151
162
  | Layer | Module | Description |
152
163
  |-------|--------|-------------|
153
164
  | **Validation** | `zod-to-mcp.ts` | All tool inputs validated against Zod schemas |
154
165
  | **Governance** | `rules-engine.ts` | Pre-execution argument validation against governance rules |
155
- | **Discipline** | `discipline.ts` | AI behavior enforcement: rate limiting, file size limits, tool blacklist |
156
- | **Loop Detection** | `loop-detector.ts` | Blocks >10 consecutive same-tool calls, cooldown mechanism |
157
- | **Token Limits** | `context/context-optimizer.ts` | Per-provider token/rate ceilings, cooldowns, smart file truncation |
158
- | **License** | `license-scanner.ts` | Copyleft license detection in write operations |
166
+ | **Discipline** | `discipline.ts` | Rate limiting, file-size limits, tool blacklist |
167
+ | **Loop Detection** | `loop-detector.ts` | Blocks >10 consecutive same-tool calls, cooldown |
168
+ | **Token Limits** | `context/context-optimizer.ts` | Per-provider token/rate ceilings, cooldowns, smart truncation |
159
169
  | **Auto-Rollback** | `auto-rollback.ts` | Pre-write snapshot, post-write governance scan, automatic restore |
160
- | **Human-in-Loop** | `human-in-loop.ts` | Risk score ≥ 60 requires approval via `approve_operation` tool |
170
+ | **Human-in-Loop** | `human-in-loop.ts` | Risk score ≥ 60 requires approval via `approve_operation` |
161
171
  | **PII Masking** | `pii.ts` | 20+ PII patterns masked before/after handler execution |
162
- | **Injection Protection** | `prompt-injection.ts` | OWASP LLM01 compliant: role-playing, override, jailbreak detection |
172
+ | **Injection Protection** | `prompt-injection.ts` | OWASP LLM01: role-play, override, jailbreak detection |
163
173
 
164
174
  ---
165
175
 
166
176
  ## 🧠 Memory & Knowledge
167
177
 
168
178
  ### Vector Memory
169
- ```typescript
179
+ ```
170
180
  store_knowledge(content, category, tags) → generateEmbedding() → VectorStore.addEntry()
171
181
  search_knowledge(query) → generateEmbedding() → VectorStore.search() → cosine similarity sort
172
- delete_knowledge(id) → SQLite DELETE
173
182
  ```
174
-
175
183
  - **Technology**: SQLite + Float32Array vectors
176
- - **Embedding**: OpenAI text-embedding-3-small (1536-dim) or TF-IDF fallback (384-dim)
184
+ - **Embedding**: OpenAI `text-embedding-3-small` (1536-dim) or TF-IDF fallback (384-dim)
177
185
  - **Categories**: ARCHITECTURE, DECISION, CODE_SNIPPET, RULE, TASK_HISTORY
178
186
 
179
187
  ### Knowledge Base
@@ -181,6 +189,23 @@ delete_knowledge(id) → SQLite DELETE
181
189
  - Retrieval via the `search_knowledge` / `read_project_memory` MCP tools
182
190
  - PII masked on all responses
183
191
 
192
+ ## 3-Layer Memory System
193
+
194
+ | Layer | Storage | Technology | Purpose |
195
+ |-------|---------|------------|---------|
196
+ | **Vector Memory** | SQLite | TF-IDF / OpenAI embeddings + cosine similarity | Semantic search across project knowledge |
197
+ | **Project Memory** | Markdown | `PROJECT_MEMORY.md` | Central project state, synchronized every session |
198
+ | **Specialty Memory** | Markdown | `.atabey/memory/specialties/{agent}.md` | Per-agent learned conventions from past tasks |
199
+
200
+ ```
201
+ Task → Evaluation Engine → Score (0-100)
202
+ ├── Success → extractSuccessLesson() → updateSpecialtyMemory()
203
+ └── Failure → compliance/lint/test lesson → updateSpecialtyMemory()
204
+ ↓
205
+ Next session: readLearnedConventions() → injected into agent prompt
206
+ ```
207
+
208
+
184
209
  ---
185
210
 
186
211
  ## 🌐 Unified HTTP/SSE Server
@@ -191,8 +216,6 @@ MCP_TRANSPORT=unified MCP_PORT=5858 atabey-mcp
191
216
  # Hermes Bus: ws://localhost:5858/bus
192
217
  ```
193
218
 
194
- The unified server exposes two network surfaces (no bundled web UI):
195
-
196
219
  | Endpoint | Description |
197
220
  |----------|-------------|
198
221
  | `GET /mcp/health` | Server health + active session count |
@@ -204,61 +227,65 @@ The unified server exposes two network surfaces (no bundled web UI):
204
227
 
205
228
  ## 🔌 MCP Transport Modes
206
229
 
207
- ### Stdio Mode (Default - Per Developer)
230
+ ### Stdio Mode (default — per developer)
208
231
  ```bash
209
232
  atabey-mcp
210
- # Connects via stdin/stdout JSON-RPC
233
+ # Connects via stdin/stdout JSON-RPC (no network exposure)
211
234
  ```
212
235
 
213
- ### HTTP/SSE Mode (Team Server)
236
+ ### HTTP/SSE Mode (team server)
214
237
  ```bash
215
238
  MCP_TRANSPORT=unified MCP_PORT=5858 atabey-mcp
216
239
  ```
217
240
  ```json
218
- // Client mcp.json:
219
241
  {
220
242
  "mcpServers": {
221
- "atabey": {
222
- "url": "http://192.168.1.100:5858/mcp/sse"
223
- }
243
+ "atabey": { "url": "http://192.168.1.100:5858/mcp/sse" }
224
244
  }
225
245
  }
226
246
  ```
227
247
 
228
- ### Authentication (HTTP/SSE Mode)
248
+ ### Authentication (HTTP/SSE mode)
229
249
  ```bash
230
250
  export MCP_AUTH_TOKEN="your-secret-token"
231
251
  export MCP_AUTH_USERS="alice:key1,bob:key2"
232
252
  ```
233
253
 
234
- ---
254
+ ## Security & Compliance
255
+
256
+ ### Deterministic, fail-closed governance
257
+ - AST-based compliance scanning + strict TypeScript (**`any` is forbidden**, no `console.*` in production code)
258
+ - **Fail-closed PolicyGate** + deny-by-default RBAC permission matrix (protected paths: `.env*`, `.git/`, `.ssh/`, `.atabey/*`, keys)
259
+ - **Prompt-injection protection** (OWASP LLM01) on both input and response
260
+ - **Secret-leak redaction** on tool output + AES-256-GCM local secret vault
261
+ - **HMAC-SHA256** tamper-evident audit chain
262
+ - SSRF-guarded HTTP proxy (private IP / metadata / DNS-rebinding protection)
263
+ - **TLS 1.3 + optional mTLS** on the unified HTTP/SSE transport
264
+ - Human-in-the-Loop: risk score ≥ 60 requires approval
265
+
266
+ ### KVKK / GDPR technical alignment
267
+
268
+ | Feature | KVKK | GDPR | Status |
269
+ |---------|------|------|--------|
270
+ | PII Masking (20+ patterns) | Art. 4, 5, 11, 12 | Art. 5, 32 | ✅ |
271
+ | Data Retention (30–730 days, by category) | Art. 5, 7 | Art. 5, 17 | ✅ |
272
+ | Right to Erasure (`atabey audit erase`) | Art. 7 | Art. 17 | ✅ |
273
+ | Audit Trail | Art. 11 | Art. 30 | ✅ |
274
+ | Data Classification | Art. 6 | Art. 9 | ✅ |
275
+
276
+ > Technical compliance tooling — not legal certification. Pair with your DPO / counsel.
277
+
278
+
279
+ ## Token Efficiency
280
+
281
+ Atabey keeps token consumption low at three layers — **there is no monetary budget layer**:
282
+
283
+ 1. **Measurement** — every tool call is counted with the real `cl100k_base` BPE tokenizer (input/output split).
284
+ 2. **Limits** — per-provider context / response / per-minute / per-hour and tool-call rate ceilings (`context-optimizer.ts`). A breach sets a cooldown; hard blocking is opt-in via `ATABEY_TOKEN_BUDGET_ENFORCE=true`.
285
+ 3. **Savings** — `read_file` responses are smart-truncated (imports/types/signatures preserved), `http_proxy` caches + strips HTML, loop detection stops token-burning loops, and `get_task_context` / `get_symbol_outline` / `get_api_catalog` feed the AI pre-indexed context instead of forcing full-repo scans.
286
+
287
+ Tune limits with `MCP_MAX_TOKENS_PER_MINUTE`, `MCP_MAX_TOKENS_PER_HOUR`, `MCP_MAX_CONTEXT_TOKENS`, `MCP_MAX_FILE_READ_SIZE`.
235
288
 
236
- ## 🔒 Security Features
237
-
238
- ### PII Masking (KVKK/GDPR)
239
- | Pattern | Example | Masked |
240
- |---------|---------|--------|
241
- | Email | `user@example.com` | `***@***` |
242
- | Phone | `+90 555 123 45 67` | `***-***-****` |
243
- | TC ID | `12345678901` | `***********` |
244
- | API Key | `sk-abc...xyz` | `***-REDACTED-***` |
245
- | JWT Token | `eyJ...eyJ...` | `***-JWT-REDACTED-***` |
246
- | IP Address | `192.168.1.1` | `***.***.***.***` |
247
- | Credit Card | `4111 1111 1111 1111` | `****-****-****-****` |
248
- | IBAN | `TR33...1326` | `****-IBAN-REDACTED-****` |
249
-
250
- ### AI Discipline Engine
251
- - **Rate Limiting**: Max 60 calls/minute per agent
252
- - **File Size Limits**: Prevents >1MB files
253
- - **Loop Detection**: Blocks >10 consecutive same-tool calls
254
- - **Cooldown**: Automatic when limits exceeded
255
- - **Injection Protection**: OWASP LLM01 compliant
256
-
257
- ### Token Efficiency
258
- - Every tool call is measured with the real `cl100k_base` BPE tokenizer (input/output split)
259
- - Per-provider context/response/per-minute/per-hour + tool-call rate ceilings
260
- - Smart truncation of oversized `read_file` responses (imports/types/signatures preserved)
261
- - Optional hard blocking via `ATABEY_TOKEN_BUDGET_ENFORCE=true` (default: advisory)
262
289
 
263
290
  ---
264
291
 
@@ -299,7 +326,16 @@ packages/atabey-mcp/
299
326
  - **ws**: WebSocket (Hermes WSS bus)
300
327
  - **typescript**: Compiler API for AST compliance scanning
301
328
 
302
- ---
329
+ ## 🔗 Related Packages
330
+
331
+ | Package | Role | Links |
332
+ |---------|------|-------|
333
+ | **atabey** | Core engine — CLI, agents, engines, orchestrator | [npm](https://www.npmjs.com/package/atabey) · [source](https://github.com/ysf-bkr/atabey/tree/main/packages/atabey) |
334
+ | **atabey-mcp** | MCP server — 40 tools & governance pipeline | [npm](https://www.npmjs.com/package/atabey-mcp) · [source](https://github.com/ysf-bkr/atabey/tree/main/packages/atabey-mcp) |
335
+ | **atabey-shared** | Shared utilities — constants, storage, PII, audit, locks | [npm](https://www.npmjs.com/package/atabey-shared) · [source](https://github.com/ysf-bkr/atabey/tree/main/packages/shared) |
336
+
337
+ > Full bilingual documentation (TR + EN): **[github.com/ysf-bkr/atabey](https://github.com/ysf-bkr/atabey#readme)**
338
+
303
339
 
304
340
  ## License
305
341
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "atabey-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Atabey — Local AI Control Plane & Discipline Layer — MCP Server",
5
5
  "author": "Yusuf BEKAR",
6
6
  "license": "AGPL-3.0",
@@ -51,11 +51,11 @@
51
51
  "test:watch": "vitest",
52
52
  "test:coverage": "vitest run --coverage",
53
53
  "lint": "eslint src tests --ext .ts",
54
- "prepublishOnly": "npm run build"
54
+ "prepublishOnly": "node ../../scripts/build-readmes.mjs && npm run build"
55
55
  },
56
56
  "dependencies": {
57
- "atabey": "^0.1.0",
58
- "atabey-shared": "^0.1.0",
57
+ "atabey": "^0.1.2",
58
+ "atabey-shared": "^0.1.2",
59
59
  "@modelcontextprotocol/sdk": "^1.29.0",
60
60
  "better-sqlite3": "^13.0.2",
61
61
  "chalk": "^5.6.2",